[PATCH v2 10/13] staging: comedi: usbduxfast: fix analog input 'maxdata'

Hartley Sweeten HartleyS at visionengravers.com
Mon Aug 24 16:13:14 UTC 2015


On Monday, August 24, 2015 6:36 AM, Ian Abbott wrote:
> On 17/08/15 19:31, H Hartley Sweeten wrote:
>> The analog inputs have 12-bit resoultion. The subdevice 'maxdata' is
>> a mask value for the resolution. Fix the value.
>>
>> Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
>> Cc: Ian Abbott <abbotti at mev.co.uk>
>> Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
>> ---
>>   drivers/staging/comedi/drivers/usbduxfast.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c
>> index 60f1c5e..c8687b0 100644
>> --- a/drivers/staging/comedi/drivers/usbduxfast.c
>> +++ b/drivers/staging/comedi/drivers/usbduxfast.c
>> @@ -865,7 +865,7 @@ static int usbduxfast_attach_common(struct comedi_device *dev)
>>   	s->do_cmdtest	= usbduxfast_ai_cmdtest;
>>   	s->do_cmd	= usbduxfast_ai_cmd;
>>   	s->cancel	= usbduxfast_ai_cancel;
>> -	s->maxdata	= 0x1000;
>> +	s->maxdata	= 0x0fff;
>>   	s->range_table	= &range_usbduxfast_ai_range;
>>
>>   	up(&devpriv->sem);
>>
>
> I've just got confirmation from the driver author Bernd Porr, that the 
> maximum value it can produce is 0x1000, not 0xfff.  This is due to an 
> overflow bit from the ADC.
>
> Probably best not to mess with it for now, as the current comedilib 
> library's 'comedi_to_phys()' function returns NAN by default if the raw 
> value is either 0 or maxdata as that means the value is probably pegged. 
>   However, it does not currently return NAN for raw values above maxdata 
>  (although it probably ought to).

Ian,

Good to know.   Will drop this patch and update the series. I'll also add a
comment about the odd 0x1000 maxdata so that it will not get "fixed" in
the future.

Thanks,
Hartley



More information about the devel mailing list