Re: CP210x Driver - Issue Enumerating Multiple Interfaces

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

 



On Fri, 16 May 2014, Miner, Blake wrote:

> > I am not sure about this, but I wonder can we do the reset in
> > cp210x_open() instead of in cp210x_startup()?
> 
> Possibly, but I'd rather perform the reset just once, right when the
> device is detected and bound to the driver.  After doing some more
> reading, I've found that calling `usb_lock_device_for_reset` just
> before `usb_reset_device` seems to work.  Here's a possible patch:
> 
> --- cp210x.c
> +++ cp210x.c.new.c
> @@ -856,7 +856,8 @@
>   struct cp210x_serial_private *spriv;
> 
>   /* cp210x buffers behave strangely unless device is reset */
> - usb_reset_device(serial->dev);
> + if(usb_lock_device_for_reset(serial->dev, NULL) == 0)
> + usb_reset_device(serial->dev);
> 
>   spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
>   if (!spriv)
> 
> The downside here is that the reset takes a few hundred extra
> milliseconds, and the reset is issued for each interface.  But, at
> least both interfaces are properly detected the first time.  :)  Any
> thoughts?

If you lock a device, you have to unlock it later.  Read the kerneldoc 
in the definition of usb_lock_device_for_reset() to see how it works.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux