[PATCH 10/10] staging: comedi: usbdux: use attach_usb() hook

Bernd Porr berndporr at f2s.com
Mon Apr 2 02:42:37 PDT 2012


Hi,

sure. We can just get rid of it.

/Bernd

Ian Abbott wrote:
> On 2012-03-30 19:03, Dan Carpenter wrote:
>> On Fri, Mar 30, 2012 at 05:15:05PM +0100, Ian Abbott wrote:
>>> Change the usbdux driver to use the new attach_usb() hook in struct
>>> comedi_driver to auto-configure probed USB devices after the firmware is
>>> loaded.
>>>
>>> Signed-off-by: Ian Abbott<abbotti at mev.co.uk>
>>> ---
>>>   drivers/staging/comedi/drivers/usbdux.c |  110 
>>> +++++++++++++++++++++----------
>>>   1 files changed, 76 insertions(+), 34 deletions(-)
>>>
>>> diff --git a/drivers/staging/comedi/drivers/usbdux.c 
>>> b/drivers/staging/comedi/drivers/usbdux.c
>>> index 781da44..c3f928f 100644
>>> --- a/drivers/staging/comedi/drivers/usbdux.c
>>> +++ b/drivers/staging/comedi/drivers/usbdux.c
>>> @@ -2617,46 +2617,22 @@ static void usbduxsub_disconnect(struct 
>>> usb_interface *intf)
>>>       dev_dbg(&intf->dev, "comedi_: disconnected from the usb\n");
>>>   }
>>>
>>> -/* is called when comedi-config is called */
>>> -static int usbdux_attach(struct comedi_device *dev, struct 
>>> comedi_devconfig *it)
>>> +/* common part of attach and attach_usb */
>>> +static int usbdux_attach_common(struct comedi_device *dev,
>>> +                struct usbduxsub *udev,
>>> +                void *aux_data, int aux_len)
>>>   {
>>>       int ret;
>>> -    int index;
>>> -    int i;
>>> -    struct usbduxsub *udev;
>>> -
>>> +    int index = (int)(udev - usbduxsub);
>>                      ^^^^^^^^^^^^^^^^^^^^^^^
>> This is a sort of ugly.  It should be documented in front of the
>> function that udev has to be a pointer to an element from the
>> usbduxsub[] array.  We only use "index" for a printk.  I'd be
>> tempted to just remove the printk().  The other cleaner way would
>> be to pass the index directly but that would be more work.
> 
> The main reason I didn't bother passing it as a parameter is that it was 
> only used in that dev_info/printk.  I'd also be tempted to remove it. 
> There is a later dev_info in the same function that says the device has 
> been attached, without mentioning the index, and no other messages refer 
> to the index, so the single message that does mention the index doesn't 
> seem very useful.
> 
> I'd just like Bernd's opinion on the matter first.
> 

-- 
www:    http://www.berndporr.me.uk/
         http://www.linux-usb-daq.co.uk/
	http://www.imdb.com/name/nm3293421/
Mobile: +44 (0)7840 340069
Work:   +44 (0)141 330 5237
         University of Glasgow
         School of Engineering
         72 Oakfield Avenue (Rankine Building for deliveries)
         Glasgow, G12 8LT


More information about the devel mailing list