From d1524ba0b83fa05d80d411a296c7fd90830e0f17 Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Mon, 11 Jun 2018 15:09:29 +0200 Subject: [PATCH] usb_block_drv: don't select alternate interface setting Selecting an alternate interface setting, even if it is the same as the current one, apparently makes the INQUIRY command fail with USB devices like 'SanDisk Ultra Fit' (0781:5583) and 'Corsair Flash Voyager' (1b1c:1a03) when the USB block driver is restarted. Fixes #2860 --- repos/os/src/drivers/usb_block/main.cc | 36 +++++++++++--------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/repos/os/src/drivers/usb_block/main.cc b/repos/os/src/drivers/usb_block/main.cc index 377f43962b..876527c027 100644 --- a/repos/os/src/drivers/usb_block/main.cc +++ b/repos/os/src/drivers/usb_block/main.cc @@ -381,32 +381,26 @@ struct Usb::Block_driver : Usb::Completion, ISUBCLASS_SCSI = 6, IPROTO_BULK_ONLY = 80 }; - try { - Alternate_interface &alt_iface = iface.alternate_interface(0); - iface.set_alternate_interface(alt_iface); - if (alt_iface.iclass != ICLASS_MASS_STORAGE - || alt_iface.isubclass != ISUBCLASS_SCSI - || alt_iface.iprotocol != IPROTO_BULK_ONLY) { - Genode::error("No mass storage SCSI bulk-only device"); - return false; - } + Alternate_interface &alt_iface = iface.current(); - for (int i = 0; i < alt_iface.num_endpoints; i++) { - Endpoint ep = alt_iface.endpoint(i); - if (!ep.is_bulk()) - continue; - if (ep.address & Usb::ENDPOINT_IN) - ep_in = i; - else - ep_out = i; - } - - } catch (Usb::Session::Interface_not_found) { - Genode::error("Interface not found"); + if (alt_iface.iclass != ICLASS_MASS_STORAGE + || alt_iface.isubclass != ISUBCLASS_SCSI + || alt_iface.iprotocol != IPROTO_BULK_ONLY) { + Genode::error("No mass storage SCSI bulk-only device"); return false; } + for (int i = 0; i < alt_iface.num_endpoints; i++) { + Endpoint ep = alt_iface.endpoint(i); + if (!ep.bulk()) + continue; + if (ep.address & Usb::ENDPOINT_IN) + ep_in = i; + else + ep_out = i; + } + try { /*