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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday, March 05, 2014 1:12 AM, Fred Akers wrote:
>
> Refactor this function to remove an extra indent level
>
> Signed-off-by: Fred Akers <knivey@xxxxxxxxxx>
> ---
>  drivers/staging/comedi/range.c | 39 +++++++++++++++++++--------------------
>  1 file changed, 19 insertions(+), 20 deletions(-)

FWIW, I'm ok with this..

Reviewed-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>

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?

Regards,
Hartley



_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux