Takashi Iwai 5e8642
From 647a6002cb41d358d9ac5de101a8a6dc74748a59 Mon Sep 17 00:00:00 2001
Takashi Iwai 5e8642
From: Ian Abbott <abbotti@mev.co.uk>
Takashi Iwai 5e8642
Date: Wed, 21 Oct 2020 13:21:42 +0100
Takashi Iwai 5e8642
Subject: [PATCH] staging: comedi: cb_pcidas: Allow 2-channel commands for AO subdevice
Takashi Iwai 5e8642
Git-commit: 647a6002cb41d358d9ac5de101a8a6dc74748a59
Takashi Iwai 5e8642
Patch-mainline: v5.10-rc2
Takashi Iwai 5e8642
References: git-fixes
Takashi Iwai 5e8642
Takashi Iwai 5e8642
The "cb_pcidas" driver supports asynchronous commands on the analog
Takashi Iwai 5e8642
output (AO) subdevice for those boards that have an AO FIFO.  The code
Takashi Iwai 5e8642
(in `cb_pcidas_ao_check_chanlist()` and `cb_pcidas_ao_cmd()`) to
Takashi Iwai 5e8642
validate and set up the command supports output to a single channel or
Takashi Iwai 5e8642
to two channels simultaneously (the boards have two AO channels).
Takashi Iwai 5e8642
However, the code in `cb_pcidas_auto_attach()` that initializes the
Takashi Iwai 5e8642
subdevices neglects to initialize the AO subdevice's `len_chanlist`
Takashi Iwai 5e8642
member, leaving it set to 0, but the Comedi core will "correct" it to 1
Takashi Iwai 5e8642
if the driver neglected to set it.  This limits commands to use a single
Takashi Iwai 5e8642
channel (either channel 0 or 1), but the limit should be two channels.
Takashi Iwai 5e8642
Set the AO subdevice's `len_chanlist` member to be the same value as the
Takashi Iwai 5e8642
`n_chan` member, which will be 2.
Takashi Iwai 5e8642
Takashi Iwai 5e8642
Cc: <stable@vger.kernel.org>
Takashi Iwai 5e8642
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Takashi Iwai 5e8642
Link: https://lore.kernel.org/r/20201021122142.81628-1-abbotti@mev.co.uk
Takashi Iwai 5e8642
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Takashi Iwai 5e8642
Acked-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai 5e8642
Takashi Iwai 5e8642
---
Takashi Iwai 5e8642
 drivers/staging/comedi/drivers/cb_pcidas.c | 1 +
Takashi Iwai 5e8642
 1 file changed, 1 insertion(+)
Takashi Iwai 5e8642
Takashi Iwai 5e8642
diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c
Takashi Iwai 5e8642
index 48ec2ee953dc..d740c4782775 100644
Takashi Iwai 5e8642
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
Takashi Iwai 5e8642
+++ b/drivers/staging/comedi/drivers/cb_pcidas.c
Takashi Iwai 5e8642
@@ -1342,6 +1342,7 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev,
Takashi Iwai 5e8642
 		if (dev->irq && board->has_ao_fifo) {
Takashi Iwai 5e8642
 			dev->write_subdev = s;
Takashi Iwai 5e8642
 			s->subdev_flags	|= SDF_CMD_WRITE;
Takashi Iwai 5e8642
+			s->len_chanlist	= s->n_chan;
Takashi Iwai 5e8642
 			s->do_cmdtest	= cb_pcidas_ao_cmdtest;
Takashi Iwai 5e8642
 			s->do_cmd	= cb_pcidas_ao_cmd;
Takashi Iwai 5e8642
 			s->cancel	= cb_pcidas_ao_cancel;
Takashi Iwai 5e8642
-- 
Takashi Iwai 5e8642
2.16.4
Takashi Iwai 5e8642