Skip to content

Commit b0375f7

Browse files
committed
usb-msctest: Be more conservative setting GETMAXLUN quirk
Only set the GETMAXLUN quirk when it causes an error, but don't set it when it returns 0. Since we reset the device when we set any quirk, only set this quirk when it generates an error so umass will avoid it. When the command works, there's no reason for umass to avoid it at all. MFC After: 1 week Sponsored by: Netflix
1 parent b39f500 commit b0375f7

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

sys/dev/usb/usb_msctest.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -741,11 +741,10 @@ usb_iface_is_cdrom(struct usb_device *udev, uint8_t iface_index)
741741
return (is_cdrom);
742742
}
743743

744-
static uint8_t
744+
static int
745745
usb_msc_get_max_lun(struct usb_device *udev, uint8_t iface_index)
746746
{
747747
struct usb_device_request req;
748-
usb_error_t err;
749748
uint8_t buf = 0;
750749

751750
/* The Get Max Lun command is a class-specific request. */
@@ -756,11 +755,7 @@ usb_msc_get_max_lun(struct usb_device *udev, uint8_t iface_index)
756755
req.wIndex[1] = 0;
757756
USETW(req.wLength, 1);
758757

759-
err = usbd_do_request(udev, NULL, &req, &buf);
760-
if (err)
761-
buf = 0;
762-
763-
return (buf);
758+
return usbd_do_request(udev, NULL, &req, &buf);
764759
}
765760

766761
#define USB_ADD_QUIRK(udev, any, which) do { \
@@ -803,8 +798,8 @@ usb_msc_auto_quirk(struct usb_device *udev, uint8_t iface_index,
803798
usb_pause_mtx(NULL, hz);
804799

805800
if (usb_test_quirk(uaa, UQ_MSC_NO_GETMAXLUN) == 0 &&
806-
usb_msc_get_max_lun(udev, iface_index) == 0) {
807-
DPRINTF("Device has only got one LUN.\n");
801+
usb_msc_get_max_lun(udev, iface_index) != 0) {
802+
DPRINTF("Device can't handle GETMAXLUN\n");
808803
USB_ADD_QUIRK(udev, any_quirk, UQ_MSC_NO_GETMAXLUN);
809804
}
810805

0 commit comments

Comments
 (0)