Commit 67ab76f0 authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: ni_tiocmd: pass subdevice to command setup functions

The `ni_tio_input_cmd()`, `ni_tio_output_cmd()` and `ni_tio_cmd_setup()`
functions are called from `ni_tio_cmd()` to set up a comedi command.
They currently get passed two parameters, a pointer to a `struct
ni_gpct` and a pointer to a `struct comedi_async`, but both of those
come from members of a `struct comedi_subdevice` (the former from the
`private` member).  Replace the parameters with a pointer to the `struct
comedi_subdevice`.

The main motive is to make the comedi subdevice more easily available to
the functions for the use of subsequent patches to remove the `struct
comedi_async *` parameters from the comedi buffer handling functions.
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Reviewed-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2fadffc0
...@@ -115,10 +115,12 @@ static int ni_tio_input_inttrig(struct comedi_device *dev, ...@@ -115,10 +115,12 @@ static int ni_tio_input_inttrig(struct comedi_device *dev,
return retval; return retval;
} }
static int ni_tio_input_cmd(struct ni_gpct *counter, struct comedi_async *async) static int ni_tio_input_cmd(struct comedi_subdevice *s)
{ {
struct ni_gpct *counter = s->private;
struct ni_gpct_device *counter_dev = counter->counter_dev; struct ni_gpct_device *counter_dev = counter->counter_dev;
unsigned cidx = counter->counter_index; unsigned cidx = counter->counter_index;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd; struct comedi_cmd *cmd = &async->cmd;
int retval = 0; int retval = 0;
...@@ -164,9 +166,10 @@ static int ni_tio_input_cmd(struct ni_gpct *counter, struct comedi_async *async) ...@@ -164,9 +166,10 @@ static int ni_tio_input_cmd(struct ni_gpct *counter, struct comedi_async *async)
return retval; return retval;
} }
static int ni_tio_output_cmd(struct ni_gpct *counter, static int ni_tio_output_cmd(struct comedi_subdevice *s)
struct comedi_async *async)
{ {
struct ni_gpct *counter = s->private;
dev_err(counter->counter_dev->dev->class_dev, dev_err(counter->counter_dev->dev->class_dev,
"output commands not yet implemented.\n"); "output commands not yet implemented.\n");
return -ENOTSUPP; return -ENOTSUPP;
...@@ -178,9 +181,10 @@ static int ni_tio_output_cmd(struct ni_gpct *counter, ...@@ -178,9 +181,10 @@ static int ni_tio_output_cmd(struct ni_gpct *counter,
return ni_tio_arm(counter, 1, NI_GPCT_ARM_IMMEDIATE); return ni_tio_arm(counter, 1, NI_GPCT_ARM_IMMEDIATE);
} }
static int ni_tio_cmd_setup(struct ni_gpct *counter, struct comedi_async *async) static int ni_tio_cmd_setup(struct comedi_subdevice *s)
{ {
struct comedi_cmd *cmd = &async->cmd; struct comedi_cmd *cmd = &s->async->cmd;
struct ni_gpct *counter = s->private;
unsigned cidx = counter->counter_index; unsigned cidx = counter->counter_index;
int set_gate_source = 0; int set_gate_source = 0;
unsigned gate_source; unsigned gate_source;
...@@ -219,12 +223,12 @@ int ni_tio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -219,12 +223,12 @@ int ni_tio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
"Interrupt-driven commands not yet implemented.\n"); "Interrupt-driven commands not yet implemented.\n");
retval = -EIO; retval = -EIO;
} else { } else {
retval = ni_tio_cmd_setup(counter, async); retval = ni_tio_cmd_setup(s);
if (retval == 0) { if (retval == 0) {
if (cmd->flags & CMDF_WRITE) if (cmd->flags & CMDF_WRITE)
retval = ni_tio_output_cmd(counter, async); retval = ni_tio_output_cmd(s);
else else
retval = ni_tio_input_cmd(counter, async); retval = ni_tio_input_cmd(s);
} }
} }
spin_unlock_irqrestore(&counter->lock, flags); spin_unlock_irqrestore(&counter->lock, flags);
......
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