* RE: [PATCH] comedi: Change error return code for if statement in the function,cb_pcimdas_ai_rinsn
[not found] <1424837601-23401-1-git-send-email-xerofoify@gmail.com>
@ 2015-02-25 18:03 ` Hartley Sweeten
[not found] ` <03715F59-83C8-45E2-9BB8-6C617979F147@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Hartley Sweeten @ 2015-02-25 18:03 UTC (permalink / raw)
To: Nicholas Krause, abbotti@mev.co.uk
Cc: gregkh@linuxfoundation.org, ravi23ganiga@gmail.com,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
On Tuesday, February 24, 2015 9:13 PM, Nicholas Krause wrote:
> This changes us using the incorrect error,-ETIMEOUT when checking if
> the channel we are allocating to on the device structure pointer passed
> to this function is greater then the maximum available channels for this
> device to the correct error for a channel being out of range,-ECHRNG.
>
> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
> ---
> drivers/staging/comedi/drivers/cb_pcimdas.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c
> index 70dd2c9..d91a6f3 100644
> --- a/drivers/staging/comedi/drivers/cb_pcimdas.c
> +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
> @@ -121,7 +121,7 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
> maxchans = s->n_chan;
>
> if (chan > (maxchans - 1))
> - return -ETIMEDOUT; /* *** Wrong error code. Fixme. */
> + return -ECHRNG;
>
> /* configure for sw initiated read */
> d = inb(devpriv->BADR3 + 5);
Hmm... This isn't quite right...
The 16 single-ended / 8 differential analog input channels on this board is
set with a switch on the PCB. The state of the switch should be read when
the driver is attached and the subdevice initialized with the correct number
of channels. The core will then validate the "chan" number before calling
the (*insn_read) operation.
Regards,
Hartley
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] comedi: Change error return code for if statement in the function,cb_pcimdas_ai_rinsn
[not found] ` <03715F59-83C8-45E2-9BB8-6C617979F147@gmail.com>
@ 2015-02-26 11:09 ` Ian Abbott
0 siblings, 0 replies; 2+ messages in thread
From: Ian Abbott @ 2015-02-26 11:09 UTC (permalink / raw)
To: Nicholas Krause, Hartley Sweeten
Cc: gregkh@linuxfoundation.org, ravi23ganiga@gmail.com,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
On 25/02/15 21:37, Nicholas Krause wrote:
>
>
> On February 25, 2015 1:03:14 PM EST, Hartley Sweeten <HartleyS@visionengravers.com> wrote:
>> On Tuesday, February 24, 2015 9:13 PM, Nicholas Krause wrote:
>>> This changes us using the incorrect error,-ETIMEOUT when checking if
>>> the channel we are allocating to on the device structure pointer
>> passed
>>> to this function is greater then the maximum available channels for
>> this
>>> device to the correct error for a channel being out of range,-ECHRNG.
>>>
>>> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
>>> ---
>>> drivers/staging/comedi/drivers/cb_pcimdas.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c
>> b/drivers/staging/comedi/drivers/cb_pcimdas.c
>>> index 70dd2c9..d91a6f3 100644
>>> --- a/drivers/staging/comedi/drivers/cb_pcimdas.c
>>> +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
>>> @@ -121,7 +121,7 @@ static int cb_pcimdas_ai_rinsn(struct
>> comedi_device *dev,
>>> maxchans = s->n_chan;
>>>
>>> if (chan > (maxchans - 1))
>>> - return -ETIMEDOUT; /* *** Wrong error code. Fixme. */
>>> + return -ECHRNG;
>>>
>>> /* configure for sw initiated read */
>>> d = inb(devpriv->BADR3 + 5);
>>
>> Hmm... This isn't quite right...
>>
>> The 16 single-ended / 8 differential analog input channels on this
>> board is
>> set with a switch on the PCB. The state of the switch should be read
>> when
>> the driver is attached and the subdevice initialized with the correct
>> number
>> of channels. The core will then validate the "chan" number before
>> calling
>> the (*insn_read) operation.
>>
>> Regards,
>> Hartley
> Hartley,
> If that is the case then why is the check for max channels here. I can send in a v2 removing this check as it seems unneeded based on my understanding and your response to this patch.
> Nick
>
The patch is fine, but now superceded by Hartley's series of patches
which has more extensive changes to the driver:
http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2015-February/065754.html
That set of patches assumes the switches remain in the same state
through the lifetime of the device instance, which seems reasonable for
a PCI card.
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Web: http://www.mev.co.uk/ )=-
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-26 11:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1424837601-23401-1-git-send-email-xerofoify@gmail.com>
2015-02-25 18:03 ` [PATCH] comedi: Change error return code for if statement in the function,cb_pcimdas_ai_rinsn Hartley Sweeten
[not found] ` <03715F59-83C8-45E2-9BB8-6C617979F147@gmail.com>
2015-02-26 11:09 ` Ian Abbott
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.