aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <[email protected]>2015-08-05 10:44:43 -0700
committerGreg Kroah-Hartman <[email protected]>2015-08-07 15:03:27 -0700
commit4ec85dadb7c7bb6cf84f18b7207f60efe0095d72 (patch)
treed6085245ac7981ed84784d62db722d5c515dab51
parent1a02387063fbd32f51c98540499b90acc8b4317f (diff)
staging: comedi: me4000: remove 'board' from me4000_ai_check_chanlist()
The maximum differential channel is half the subdevice 'n_chan'. Use that instead and remove the need for the 'board' variable. Also, the comedi core does no validate the aref flags. Add a check to ensure that the subdevice actually supports the AREF_DIFF mode. Signed-off-by: H Hartley Sweeten <[email protected]> Reviewed-by: Ian Abbott <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r--drivers/staging/comedi/drivers/me4000.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c
index 335fafc73a94..008929e8d3fe 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -568,8 +568,6 @@ static int me4000_ai_check_chanlist(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
- const struct me4000_board *board = dev->board_ptr;
- unsigned int max_diff_chan = board->ai_diff_nchan;
unsigned int aref0 = CR_AREF(cmd->chanlist[0]);
int i;
@@ -585,7 +583,13 @@ static int me4000_ai_check_chanlist(struct comedi_device *dev,
}
if (aref == AREF_DIFF) {
- if (chan >= max_diff_chan) {
+ if (!(s->subdev_flags && SDF_DIFF)) {
+ dev_err(dev->class_dev,
+ "Differential inputs are not available\n");
+ return -EINVAL;
+ }
+
+ if (chan >= (s->n_chan / 2)) {
dev_dbg(dev->class_dev,
"Channel number to high\n");
return -EINVAL;