Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Oct 2011 08:51:15 +0200
From:      Hans Petter Selasky <hselasky@c2i.net>
To:        Gustau =?iso-8859-1?q?P=E9rez?= <gperez@entel.upc.edu>
Cc:        Pawel Jakub Dawidek <pjd@freebsd.org>, freebsd-usb@freebsd.org
Subject:   Re: Quirk for a USB mass storage device
Message-ID:  <201110290851.15130.hselasky@c2i.net>
In-Reply-To: <4EAAC562.3000201@entel.upc.edu>
References:  <4EA9127E.80504@entel.upc.edu> <201110281549.15561.hselasky@c2i.net> <4EAAC562.3000201@entel.upc.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
--Boundary-00=_jJ6qOcgvAd4Xy7t
Content-Type: Text/Plain;
  charset="iso-8859-15"
Content-Transfer-Encoding: quoted-printable

On Friday 28 October 2011 17:08:18 Gustau P=E9rez wrote:
> >>   Do you want the patch? I can generate it in a second if you wish.
> >=20
> > Yes, please do.
>=20
>    This one applies over both current and 9.0RC1.
>=20
>    Gus

Hi Pawel and Gustau,

Can you both clean out your own patches and try the attached one?

=2D-HPS

--Boundary-00=_jJ6qOcgvAd4Xy7t
Content-Type: text/x-patch; charset="iso-8859-15"; name="no_get_max_lun.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
	filename="no_get_max_lun.diff"

=== sys/dev/usb/usb_device.c
==================================================================
--- sys/dev/usb/usb_device.c	(revision 226805)
+++ sys/dev/usb/usb_device.c	(local)
@@ -1851,7 +1851,8 @@
 		}
 	}
 	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
=== sys/dev/usb/usb_msctest.c
==================================================================
--- sys/dev/usb/usb_msctest.c	(revision 226805)
+++ sys/dev/usb/usb_msctest.c	(local)
@@ -603,6 +603,29 @@
 	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_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,

--Boundary-00=_jJ6qOcgvAd4Xy7t--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110290851.15130.hselasky>