svn commit: r226903 - head/sys/dev/usb
Hans Petter Selasky
hselasky at FreeBSD.org
Sat Oct 29 12:32:14 UTC 2011
Author: hselasky
Date: Sat Oct 29 12:32:13 2011
New Revision: 226903
URL: http://svn.freebsd.org/changeset/base/226903
Log:
Improve USB mass storage quirk auto detection.
MFC after: 3 days
Modified:
head/sys/dev/usb/usb_device.c
head/sys/dev/usb/usb_msctest.c
Modified: head/sys/dev/usb/usb_device.c
==============================================================================
--- head/sys/dev/usb/usb_device.c Sat Oct 29 08:11:18 2011 (r226902)
+++ head/sys/dev/usb/usb_device.c Sat Oct 29 12:32:13 2011 (r226903)
@@ -1851,7 +1851,8 @@ repeat_set_config:
}
}
if (set_config_failed == 0 && config_index == 0 &&
- usb_test_quirk(&uaa, UQ_MSC_NO_SYNC_CACHE) == 0) {
+ usb_test_quirk(&uaa, UQ_MSC_NO_SYNC_CACHE) == 0 &&
+ usb_test_quirk(&uaa, UQ_MSC_NO_GETMAXLUN) == 0) {
/*
* Try to figure out if there are any MSC quirks we
Modified: head/sys/dev/usb/usb_msctest.c
==============================================================================
--- head/sys/dev/usb/usb_msctest.c Sat Oct 29 08:11:18 2011 (r226902)
+++ head/sys/dev/usb/usb_msctest.c Sat Oct 29 12:32:13 2011 (r226903)
@@ -603,6 +603,29 @@ usb_iface_is_cdrom(struct usb_device *ud
return (is_cdrom);
}
+static uint8_t
+usb_msc_get_max_lun(struct usb_device *udev, uint8_t iface_index)
+{
+ struct usb_device_request req;
+ usb_error_t err;
+ uint8_t buf = 0;
+
+
+ /* The Get Max Lun command is a class-specific request. */
+ req.bmRequestType = UT_READ_CLASS_INTERFACE;
+ req.bRequest = 0xFE; /* GET_MAX_LUN */
+ USETW(req.wValue, 0);
+ req.wIndex[0] = iface_index;
+ req.wIndex[1] = 0;
+ USETW(req.wLength, 1);
+
+ err = usbd_do_request(udev, NULL, &req, &buf);
+ if (err)
+ buf = 0;
+
+ return (buf);
+}
+
usb_error_t
usb_msc_auto_quirk(struct usb_device *udev, uint8_t iface_index)
{
@@ -622,6 +645,11 @@ usb_msc_auto_quirk(struct usb_device *ud
*/
usb_pause_mtx(NULL, hz);
+ if (usb_msc_get_max_lun(udev, iface_index) == 0) {
+ DPRINTF("Device has only got one LUN.\n");
+ usbd_add_dynamic_quirk(udev, UQ_MSC_NO_GETMAXLUN);
+ }
+
is_no_direct = 1;
for (timeout = 4; timeout; timeout--) {
err = bbb_command_start(sc, DIR_IN, 0, sc->buffer,
More information about the svn-src-head
mailing list