USB: skip Set-Interface(0) if already in altsetting 0

When a driver unbinds from an interface, usbcore always sends a
Set-Interface request to reinstall altsetting 0.  Unforunately, quite
a few devices have buggy firmware that crashes when it receives this
request.

To avoid such problems, this patch (as1180) arranges to send the
Set-Interface request only when the interface is not already in
altsetting 0.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Alan Stern 2008-12-01 10:24:41 -05:00 коммит произвёл Greg Kroah-Hartman
Родитель 9a9fafb894
Коммит 24c0996a6b
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -279,7 +279,9 @@ static int usb_unbind_interface(struct device *dev)
* altsetting means creating new endpoint device entries).
* When either of these happens, defer the Set-Interface.
*/
if (!error && intf->dev.power.status == DPM_ON)
if (intf->cur_altsetting->desc.bAlternateSetting == 0)
; /* Already in altsetting 0 so skip Set-Interface */
else if (!error && intf->dev.power.status == DPM_ON)
usb_set_interface(udev, intf->altsetting[0].
desc.bInterfaceNumber, 0);
else