Re: CP210x Driver - Issue Enumerating Multiple Interfaces

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

 



> 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?

Thanks,
Blake

On Fri, May 16, 2014 at 2:47 AM, Jidong Xiao <jidong.xiao@xxxxxxxxx> wrote:
> On Thu, May 15, 2014 at 6:53 PM, Miner, Blake <bminer@xxxxxxxxxxxxxxxx> wrote:
>> After debugging further, I figured out what was causing the problem.
>>
>> In the driver for the cp210x, there is a line of code in the `.attach`
>> function that calls `usb_reset_device(serial->dev);`.  See the source
>> code here: https://github.com/torvalds/linux/blob/master/drivers/usb/serial/cp210x.c#L859
>>
>> This call to `usb_reset_device` causes the device to be reset just
>> before the second interface is detected.  For whatever reason, the
>> reset prevents the second interface from being created in `/dev/`.
>>
>> By simply removing this line, both interfaces are properly detected
>> the first time.  Unfortunately, there is a comment above this line
>> that reads "/* cp210x buffers behave strangely unless device is reset
>> */"  Therefore, this reset might actually be necessary in order to
>> clear the buffers of the CP210x.  In this case, when is the
>> appropriate time to perform a device reset so that both interfaces are
>> properly detected?
>>
>> Thanks,
>
> I am not sure about this, but I wonder can we do the reset in
> cp210x_open() instead of in cp210x_startup()?
>
> -Jidong
--
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