[PATCH] Staging: comedi: range: tidy up comedi_check_chanlist()

Ian Abbott abbotti at mev.co.uk
Wed Mar 5 18:32:32 UTC 2014


On 2014-03-05 16:50, Hartley Sweeten wrote:
> But, it appears that this sanity check is really unnecessary:
>
>> +	if (!s->range_table && !s->range_table_list) {
>> 		dev_err(dev->class_dev, "(bug) no range type list!\n");
>>   		return -EINVAL;
>>   	}
>
> The comedi_check_chanlist() function appears to only get called by code paths
> that occur after a driver has been successfully attached to the comedi subsystem.
> The attach will either be manually thru comedi_device_attach() or automatically
> thru comedi_auto_config(). The last step for both attach methods it to call
> comedi_device_postconfig().
>
> comedi_device_postconfig() does some final cleanup of all the subdevices. This
> cleanup initializes some of the subdevice members to default values if the driver
> did not do it. One of these defaults is:
>
> 		if (!s->range_table && !s->range_table_list)
> 			s->range_table = &range_unknown;
>
> So, any driver that does not initialize the 'range_table' or 'range_table_list' for
> a subdevice will automatically get the 'range_table' initialized to 'range_unkown'
> which is:
>
> const struct comedi_lrange range_unknown = { 1, {{0, 1000000, UNIT_none} } };
>
> So the sanity check above will always pass.
>
> Ian, do you agree that this sanity check can be removed? If so, Fred do you want
> to submit a follow up patch that removes it?

Yes, the sanity check can be removed.

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti at mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-


More information about the devel mailing list