diff options
author | Hans de Goede <hdegoede@redhat.com> | 2013-10-21 03:00:58 -0400 |
---|---|---|
committer | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2014-03-04 18:38:12 -0500 |
commit | e1be067b681054e963dfd01346c0d7fc0f8a63aa (patch) | |
tree | 319784dc99999a433e63f57d01e16208aa5f6b79 /drivers/usb/storage | |
parent | d3f7c1560aee57d0ec293253e0c0e79a84ea3016 (diff) |
uas: Add a uas_find_uas_alt_setting helper function
This is a preparation patch for teaching usb-storage to not bind to
uas devices.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Diffstat (limited to 'drivers/usb/storage')
-rw-r--r-- | drivers/usb/storage/uas.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 3f021f2fafdf..54db36541b93 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) | |||
892 | return -ENODEV; | 892 | return -ENODEV; |
893 | } | 893 | } |
894 | 894 | ||
895 | static int uas_switch_interface(struct usb_device *udev, | 895 | static int uas_find_uas_alt_setting(struct usb_interface *intf) |
896 | struct usb_interface *intf) | ||
897 | { | 896 | { |
898 | int i; | 897 | int i; |
898 | struct usb_device *udev = interface_to_usbdev(intf); | ||
899 | int sg_supported = udev->bus->sg_tablesize != 0; | 899 | int sg_supported = udev->bus->sg_tablesize != 0; |
900 | 900 | ||
901 | for (i = 0; i < intf->num_altsetting; i++) { | 901 | for (i = 0; i < intf->num_altsetting; i++) { |
@@ -904,15 +904,26 @@ static int uas_switch_interface(struct usb_device *udev, | |||
904 | if (uas_is_interface(alt)) { | 904 | if (uas_is_interface(alt)) { |
905 | if (!sg_supported) | 905 | if (!sg_supported) |
906 | return uas_isnt_supported(udev); | 906 | return uas_isnt_supported(udev); |
907 | return usb_set_interface(udev, | 907 | return alt->desc.bAlternateSetting; |
908 | alt->desc.bInterfaceNumber, | ||
909 | alt->desc.bAlternateSetting); | ||
910 | } | 908 | } |
911 | } | 909 | } |
912 | 910 | ||
913 | return -ENODEV; | 911 | return -ENODEV; |
914 | } | 912 | } |
915 | 913 | ||
914 | static int uas_switch_interface(struct usb_device *udev, | ||
915 | struct usb_interface *intf) | ||
916 | { | ||
917 | int alt; | ||
918 | |||
919 | alt = uas_find_uas_alt_setting(intf); | ||
920 | if (alt < 0) | ||
921 | return alt; | ||
922 | |||
923 | return usb_set_interface(udev, | ||
924 | intf->altsetting[0].desc.bInterfaceNumber, alt); | ||
925 | } | ||
926 | |||
916 | static void uas_configure_endpoints(struct uas_dev_info *devinfo) | 927 | static void uas_configure_endpoints(struct uas_dev_info *devinfo) |
917 | { | 928 | { |
918 | struct usb_host_endpoint *eps[4] = { }; | 929 | struct usb_host_endpoint *eps[4] = { }; |