Re: [PATCH 1/7] uas: Add a uas_find_uas_alt_setting helper function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I forgot one important note. This is currently only tested with qemu's
emulated uas device. I'll test it with real hardware when I get back
home this weekend.

Regards,

Hans


On 10/24/2013 06:13 PM, Hans de Goede wrote:
This is a preparation patch for teaching usb-storage to not bind to
uas devices.

Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
---
  drivers/usb/storage/uas.c | 21 ++++++++++++++++-----
  1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 357f14d..b0a96c2 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -892,10 +892,10 @@ static int uas_isnt_supported(struct usb_device *udev)
  	return -ENODEV;
  }

-static int uas_switch_interface(struct usb_device *udev,
-						struct usb_interface *intf)
+static int uas_find_uas_alt_setting(struct usb_interface *intf)
  {
  	int i;
+	struct usb_device *udev = interface_to_usbdev(intf);
  	int sg_supported = udev->bus->sg_tablesize != 0;

  	for (i = 0; i < intf->num_altsetting; i++) {
@@ -904,15 +904,26 @@ static int uas_switch_interface(struct usb_device *udev,
  		if (uas_is_interface(alt)) {
  			if (!sg_supported)
  				return uas_isnt_supported(udev);
-			return usb_set_interface(udev,
-						alt->desc.bInterfaceNumber,
-						alt->desc.bAlternateSetting);
+			return alt->desc.bAlternateSetting;
  		}
  	}

  	return -ENODEV;
  }

+static int uas_switch_interface(struct usb_device *udev,
+				struct usb_interface *intf)
+{
+	int alt;
+
+	alt = uas_find_uas_alt_setting(intf);
+	if (alt < 0)
+		return alt;
+
+	return usb_set_interface(udev,
+			intf->altsetting[0].desc.bInterfaceNumber, alt);
+}
+
  static void uas_configure_endpoints(struct uas_dev_info *devinfo)
  {
  	struct usb_host_endpoint *eps[4] = { };

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux