Commit a21eacfe authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: ni_mio_common: use cfc_handle_events()

The ni_event() function in this file is an open coded version of
cfc_handle_events() where instead of calling the subdevice (*cancel)
function a switch is used to call the function based on the subdevice
'index'.

Use the comedi_fc helper function to simplify the code.

This also allows removing a couple of the forward declarations.

Fix the #ifdef/#endif for the ni_gpct_cancel() foward declaration and
around the function. This function is now only referenced by code that
is blocked with #ifdef PCIDMA.

This source file is included by the ni_atmio, ni_mio_cs, and ni_pcimio
drivers. In the Kconfig, the config options for these drivers already
select COMEDI_FC.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e5bdf512
...@@ -256,7 +256,6 @@ static int ni_rtsi_insn_config(struct comedi_device *dev, ...@@ -256,7 +256,6 @@ static int ni_rtsi_insn_config(struct comedi_device *dev,
static void caldac_setup(struct comedi_device *dev, struct comedi_subdevice *s); static void caldac_setup(struct comedi_device *dev, struct comedi_subdevice *s);
static int ni_read_eeprom(struct comedi_device *dev, int addr); static int ni_read_eeprom(struct comedi_device *dev, int addr);
static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s);
#ifndef PCIDMA #ifndef PCIDMA
static void ni_handle_fifo_half_full(struct comedi_device *dev); static void ni_handle_fifo_half_full(struct comedi_device *dev);
static int ni_ao_fifo_half_empty(struct comedi_device *dev, static int ni_ao_fifo_half_empty(struct comedi_device *dev,
...@@ -272,15 +271,12 @@ static void shutdown_ai_command(struct comedi_device *dev); ...@@ -272,15 +271,12 @@ static void shutdown_ai_command(struct comedi_device *dev);
static int ni_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, static int ni_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int trignum); unsigned int trignum);
static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s);
static int ni_8255_callback(int dir, int port, int data, unsigned long arg); static int ni_8255_callback(int dir, int port, int data, unsigned long arg);
#ifdef PCIDMA #ifdef PCIDMA
static int ni_gpct_cmd(struct comedi_device *dev, struct comedi_subdevice *s); static int ni_gpct_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
static int ni_gpct_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
#endif #endif
static int ni_gpct_cancel(struct comedi_device *dev,
struct comedi_subdevice *s);
static void handle_gpct_interrupt(struct comedi_device *dev, static void handle_gpct_interrupt(struct comedi_device *dev,
unsigned short counter_index); unsigned short counter_index);
...@@ -947,32 +943,6 @@ static void shutdown_ai_command(struct comedi_device *dev) ...@@ -947,32 +943,6 @@ static void shutdown_ai_command(struct comedi_device *dev)
s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_EOA;
} }
static void ni_event(struct comedi_device *dev, struct comedi_subdevice *s)
{
if (s->
async->events & (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW |
COMEDI_CB_EOA)) {
switch (s->index) {
case NI_AI_SUBDEV:
ni_ai_reset(dev, s);
break;
case NI_AO_SUBDEV:
ni_ao_reset(dev, s);
break;
case NI_GPCT0_SUBDEV:
case NI_GPCT1_SUBDEV:
ni_gpct_cancel(dev, s);
break;
case NI_DIO_SUBDEV:
ni_cdio_cancel(dev, s);
break;
default:
break;
}
}
comedi_event(dev, s);
}
static void handle_gpct_interrupt(struct comedi_device *dev, static void handle_gpct_interrupt(struct comedi_device *dev,
unsigned short counter_index) unsigned short counter_index)
{ {
...@@ -984,8 +954,7 @@ static void handle_gpct_interrupt(struct comedi_device *dev, ...@@ -984,8 +954,7 @@ static void handle_gpct_interrupt(struct comedi_device *dev,
ni_tio_handle_interrupt(&devpriv->counter_dev->counters[counter_index], ni_tio_handle_interrupt(&devpriv->counter_dev->counters[counter_index],
s); s);
if (s->async->events) cfc_handle_events(dev, s);
ni_event(dev, s);
#endif #endif
} }
...@@ -1043,7 +1012,7 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status, ...@@ -1043,7 +1012,7 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
if (comedi_is_subdevice_running(s)) { if (comedi_is_subdevice_running(s)) {
s->async->events |= s->async->events |=
COMEDI_CB_ERROR | COMEDI_CB_EOA; COMEDI_CB_ERROR | COMEDI_CB_EOA;
ni_event(dev, s); cfc_handle_events(dev, s);
} }
return; return;
} }
...@@ -1058,8 +1027,7 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status, ...@@ -1058,8 +1027,7 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
if (status & (AI_Overrun_St | AI_Overflow_St)) if (status & (AI_Overrun_St | AI_Overflow_St))
s->async->events |= COMEDI_CB_OVERFLOW; s->async->events |= COMEDI_CB_OVERFLOW;
ni_event(dev, s); cfc_handle_events(dev, s);
return; return;
} }
if (status & AI_SC_TC_St) { if (status & AI_SC_TC_St) {
...@@ -1086,7 +1054,7 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status, ...@@ -1086,7 +1054,7 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
if ((status & AI_STOP_St)) if ((status & AI_STOP_St))
ni_handle_eos(dev, s); ni_handle_eos(dev, s);
ni_event(dev, s); cfc_handle_events(dev, s);
} }
static void ack_b_interrupt(struct comedi_device *dev, unsigned short b_status) static void ack_b_interrupt(struct comedi_device *dev, unsigned short b_status)
...@@ -1161,7 +1129,7 @@ static void handle_b_interrupt(struct comedi_device *dev, ...@@ -1161,7 +1129,7 @@ static void handle_b_interrupt(struct comedi_device *dev,
} }
#endif #endif
ni_event(dev, s); cfc_handle_events(dev, s);
} }
#ifndef PCIDMA #ifndef PCIDMA
...@@ -3672,7 +3640,7 @@ static void handle_cdio_interrupt(struct comedi_device *dev) ...@@ -3672,7 +3640,7 @@ static void handle_cdio_interrupt(struct comedi_device *dev)
M_Offset_CDIO_Command); M_Offset_CDIO_Command);
/* s->async->events |= COMEDI_CB_EOA; */ /* s->async->events |= COMEDI_CB_EOA; */
} }
ni_event(dev, s); cfc_handle_events(dev, s);
} }
static int ni_serial_insn_config(struct comedi_device *dev, static int ni_serial_insn_config(struct comedi_device *dev,
...@@ -5008,9 +4976,9 @@ static int ni_gpct_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -5008,9 +4976,9 @@ static int ni_gpct_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
} }
#endif #endif
#ifdef PCIDMA
static int ni_gpct_cancel(struct comedi_device *dev, struct comedi_subdevice *s) static int ni_gpct_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{ {
#ifdef PCIDMA
struct ni_gpct *counter = s->private; struct ni_gpct *counter = s->private;
int retval; int retval;
...@@ -5018,10 +4986,8 @@ static int ni_gpct_cancel(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -5018,10 +4986,8 @@ static int ni_gpct_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
ni_e_series_enable_second_irq(dev, counter->counter_index, 0); ni_e_series_enable_second_irq(dev, counter->counter_index, 0);
ni_release_gpct_mite_channel(dev, counter->counter_index); ni_release_gpct_mite_channel(dev, counter->counter_index);
return retval; return retval;
#else
return 0;
#endif
} }
#endif
/* /*
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment