Note this is done through a usbcore module parameter as the option is needed
by both the uas and usb-storage drivers.

Signed-off-by: Hans de Goede <hdego...@redhat.com>
---
 drivers/usb/core/usb.c           | 12 ++++++++++++
 drivers/usb/storage/uas-detect.h |  3 +++
 include/linux/usb.h              |  1 +
 3 files changed, 16 insertions(+)

diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 4d11449..80e3604 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -48,6 +48,7 @@
 const char *usbcore_name = "usbcore";
 
 static bool nousb;     /* Disable USB when built into kernel image */
+static bool nouas;     /* Disable use of UAS on UAS capable devices */
 
 #ifdef CONFIG_PM_RUNTIME
 static int usb_autosuspend_delay = 2;          /* Default delay value,
@@ -981,6 +982,17 @@ int usb_disabled(void)
 }
 EXPORT_SYMBOL_GPL(usb_disabled);
 
+module_param(nouas, bool, 0644);
+
+/*
+ * for external read access to <nouas>
+ */
+int usb_uas_disabled(void)
+{
+       return nouas;
+}
+EXPORT_SYMBOL_GPL(usb_uas_disabled);
+
 /*
  * Notifications of device and interface registration
  */
diff --git a/drivers/usb/storage/uas-detect.h b/drivers/usb/storage/uas-detect.h
index 02bf5ec..bac33df 100644
--- a/drivers/usb/storage/uas-detect.h
+++ b/drivers/usb/storage/uas-detect.h
@@ -44,6 +44,9 @@ static int uas_use_uas_driver(struct usb_interface *intf,
 {
        unsigned long flags = id->driver_info;
 
+       if (usb_uas_disabled())
+               return 0;
+
        if (flags & US_FL_IGNORE_UAS)
                return 0;
 
diff --git a/include/linux/usb.h b/include/linux/usb.h
index a4c8406..60d5b36 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1166,6 +1166,7 @@ extern void usb_deregister_dev(struct usb_interface *intf,
                               struct usb_class_driver *class_driver);
 
 extern int usb_disabled(void);
+extern int usb_uas_disabled(void);
 
 /* ----------------------------------------------------------------------- */
 
-- 
1.8.4.2

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

Reply via email to