Commit 1c13b0f01abf717dee7e2637fea78b971f867e85

Authored by Ahmed S. Darwish
Committed by Greg Kroah-Hartman
1 parent 40b50e09ad

can: kvaser_usb: Retry the first bulk transfer on -ETIMEDOUT

commit 14c10c2a1dd8eb8e00b750b521753260befa2789 upstream.

On some x86 laptops, plugging a Kvaser device again after an
unplug makes the firmware always ignore the very first command.
For such a case, provide some room for retries instead of
completely exiting the driver init code.

Signed-off-by: Ahmed S. Darwish <ahmed.darwish@valeo.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 10 additions and 2 deletions Side-by-side Diff

drivers/net/can/usb/kvaser_usb.c
... ... @@ -1588,7 +1588,7 @@
1588 1588 {
1589 1589 struct kvaser_usb *dev;
1590 1590 int err = -ENOMEM;
1591   - int i;
  1591 + int i, retry = 3;
1592 1592  
1593 1593 dev = devm_kzalloc(&intf->dev, sizeof(*dev), GFP_KERNEL);
1594 1594 if (!dev)
... ... @@ -1606,7 +1606,15 @@
1606 1606  
1607 1607 usb_set_intfdata(intf, dev);
1608 1608  
1609   - err = kvaser_usb_get_software_info(dev);
  1609 + /* On some x86 laptops, plugging a Kvaser device again after
  1610 + * an unplug makes the firmware always ignore the very first
  1611 + * command. For such a case, provide some room for retries
  1612 + * instead of completely exiting the driver.
  1613 + */
  1614 + do {
  1615 + err = kvaser_usb_get_software_info(dev);
  1616 + } while (--retry && err == -ETIMEDOUT);
  1617 +
1610 1618 if (err) {
1611 1619 dev_err(&intf->dev,
1612 1620 "Cannot get software infos, error %d\n", err);