diff options
author | hselasky <hselasky@FreeBSD.org> | 2011-10-29 12:32:13 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2011-10-29 12:32:13 +0000 |
commit | ca5e2c25d4f63dac76001083afccd6cfd9573962 (patch) | |
tree | 132b503c1e837f3d678f851504e4a91aa284ca33 /sys/dev/usb/usb_msctest.c | |
parent | d014d8bac2b9b64e4778d7d33bed422e5fd2a9c7 (diff) | |
download | FreeBSD-src-ca5e2c25d4f63dac76001083afccd6cfd9573962.zip FreeBSD-src-ca5e2c25d4f63dac76001083afccd6cfd9573962.tar.gz |
Improve USB mass storage quirk auto detection.
MFC after: 3 days
Diffstat (limited to 'sys/dev/usb/usb_msctest.c')
-rw-r--r-- | sys/dev/usb/usb_msctest.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sys/dev/usb/usb_msctest.c b/sys/dev/usb/usb_msctest.c index 0355653..10ba169 100644 --- a/sys/dev/usb/usb_msctest.c +++ b/sys/dev/usb/usb_msctest.c @@ -603,6 +603,29 @@ usb_iface_is_cdrom(struct usb_device *udev, uint8_t iface_index) 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 *udev, uint8_t iface_index) */ 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, |