Improve USB mass storage quirk auto detection.
MFC after: 3 days
This commit is contained in:
parent
7ff80a676a
commit
9157ad4b17
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=226903
@ -1851,7 +1851,8 @@ usb_alloc_device(device_t parent_dev, struct usb_bus *bus,
|
||||
}
|
||||
}
|
||||
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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user