USB: OTG: rename product list of devices
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Jun 2020 09:43:00 +0000 (11:43 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 19 Jun 2020 06:58:55 +0000 (08:58 +0200)
Rename the list of specific devices that an OTG device could support to
make it more obvious as to what this list is for and what it is doing.
Also rename the configuration option to make it more obvious as well.

Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Burton <paulburton@kernel.org>
Cc: "Diego Elio Pettenò" <flameeyes@flameeyes.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Eugeniu Rosca <erosca@de.adit-jv.com>
Cc: Qi Zhou <atmgnd@outlook.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Hardik Gajjar <hgajjar@de.adit-jv.com>
Cc: Harry Pan <harry.pan@intel.com>
Cc: David Heinzelmann <heinzelmann.david@gmail.com>
Cc: Nishad Kamdar <nishadkamdar@gmail.com>
Link: https://lore.kernel.org/r/20200618094300.1887727-9-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/mips/configs/fuloong2e_defconfig
arch/mips/configs/lemote2f_defconfig
drivers/usb/core/Kconfig
drivers/usb/core/hub.c
drivers/usb/core/otg_productlist.h [new file with mode: 0644]
drivers/usb/core/otg_whitelist.h [deleted file]

index 6466e83067b4f087f49296683705c5ffea90ed2e..023b4e644b1cd32f66a3a8ccbaaccf5a52cb396d 100644 (file)
@@ -159,7 +159,7 @@ CONFIG_USB_KBD=y
 CONFIG_USB_MOUSE=y
 CONFIG_USB=y
 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
-CONFIG_USB_OTG_WHITELIST=y
+CONFIG_USB_OTG_PRODUCTLIST=y
 CONFIG_USB_WUSB_CBAF=m
 CONFIG_USB_C67X00_HCD=m
 CONFIG_USB_EHCI_HCD=y
index 8254d7d1396f301d8dcb44010985407a949ebf59..3a9a453b126419978b421c8348c2b2a5e7b2aad0 100644 (file)
@@ -207,7 +207,7 @@ CONFIG_ZEROPLUS_FF=y
 CONFIG_USB_HIDDEV=y
 CONFIG_USB=y
 CONFIG_USB_DYNAMIC_MINORS=y
-CONFIG_USB_OTG_WHITELIST=y
+CONFIG_USB_OTG_PRODUCTLIST=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_ROOT_HUB_TT=y
index 06bae55860e458c8cf7f872acfa97a7cc7a9b306..dfacc478a8fc20673e5ecdd90d3bfa2fa316c2bf 100644 (file)
@@ -55,12 +55,12 @@ config USB_OTG
          Select this only if your board has Mini-AB/Micro-AB
          connector.
 
-config USB_OTG_WHITELIST
+config USB_OTG_PRODUCTLIST
        bool "Rely on OTG and EH Targeted Peripherals List"
        depends on USB
        help
-         If you say Y here, the "otg_whitelist.h" file will be used as a
-         product whitelist, so USB peripherals not listed there will be
+         If you say Y here, the "otg_productlist.h" file will be used as a
+         product list, so USB peripherals not listed there will be
          rejected during enumeration.  This behavior is required by the
          USB OTG and EH specification for all devices not on your product's
          "Targeted Peripherals List".  "Embedded Hosts" are likewise
index ab26ac0147f76ae8c3183288d41197438c9fe304..71bbd2eed7c6c8f260f393dfce95e6ae41f1356a 100644 (file)
@@ -35,7 +35,7 @@
 #include <asm/byteorder.h>
 
 #include "hub.h"
-#include "otg_whitelist.h"
+#include "otg_productlist.h"
 
 #define USB_VENDOR_GENESYS_LOGIC               0x05e3
 #define USB_VENDOR_SMSC                                0x0424
@@ -2403,7 +2403,7 @@ static int usb_enumerate_device(struct usb_device *udev)
        if (err < 0)
                return err;
 
-       if (IS_ENABLED(CONFIG_USB_OTG_WHITELIST) && hcd->tpl_support &&
+       if (IS_ENABLED(CONFIG_USB_OTG_PRODUCTLIST) && hcd->tpl_support &&
                !is_targeted(udev)) {
                /* Maybe it can talk to us, though we can't talk to it.
                 * (Includes HNP test device.)
diff --git a/drivers/usb/core/otg_productlist.h b/drivers/usb/core/otg_productlist.h
new file mode 100644 (file)
index 0000000..db67df2
--- /dev/null
@@ -0,0 +1,102 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/* Copyright (C) 2004 Texas Instruments */
+
+/*
+ * This OTG and Embedded Host list is "Targeted Peripheral List".
+ * It should mostly use of USB_DEVICE() or USB_DEVICE_VER() entries..
+ *
+ * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING!
+ */
+
+static struct usb_device_id productlist_table[] = {
+
+/* hubs are optional in OTG, but very handy ... */
+{ USB_DEVICE_INFO(USB_CLASS_HUB, 0, 0), },
+{ USB_DEVICE_INFO(USB_CLASS_HUB, 0, 1), },
+
+#ifdef CONFIG_USB_PRINTER              /* ignoring nonstatic linkage! */
+/* FIXME actually, printers are NOT supposed to use device classes;
+ * they're supposed to use interface classes...
+ */
+{ USB_DEVICE_INFO(7, 1, 1) },
+{ USB_DEVICE_INFO(7, 1, 2) },
+{ USB_DEVICE_INFO(7, 1, 3) },
+#endif
+
+#ifdef CONFIG_USB_NET_CDCETHER
+/* Linux-USB CDC Ethernet gadget */
+{ USB_DEVICE(0x0525, 0xa4a1), },
+/* Linux-USB CDC Ethernet + RNDIS gadget */
+{ USB_DEVICE(0x0525, 0xa4a2), },
+#endif
+
+#if    IS_ENABLED(CONFIG_USB_TEST)
+/* gadget zero, for testing */
+{ USB_DEVICE(0x0525, 0xa4a0), },
+#endif
+
+{ }    /* Terminating entry */
+};
+
+static int is_targeted(struct usb_device *dev)
+{
+       struct usb_device_id    *id = productlist_table;
+
+       /* HNP test device is _never_ targeted (see OTG spec 6.6.6) */
+       if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
+            le16_to_cpu(dev->descriptor.idProduct) == 0xbadd))
+               return 0;
+
+       /* OTG PET device is always targeted (see OTG 2.0 ECN 6.4.2) */
+       if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
+            le16_to_cpu(dev->descriptor.idProduct) == 0x0200))
+               return 1;
+
+       /* NOTE: can't use usb_match_id() since interface caches
+        * aren't set up yet. this is cut/paste from that code.
+        */
+       for (id = productlist_table; id->match_flags; id++) {
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
+                   id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
+                       continue;
+
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
+                   id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
+                       continue;
+
+               /* No need to test id->bcdDevice_lo != 0, since 0 is never
+                  greater than any unsigned number. */
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
+                   (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
+                       continue;
+
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
+                   (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
+                       continue;
+
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
+                   (id->bDeviceClass != dev->descriptor.bDeviceClass))
+                       continue;
+
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
+                   (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass))
+                       continue;
+
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
+                   (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
+                       continue;
+
+               return 1;
+       }
+
+       /* add other match criteria here ... */
+
+
+       /* OTG MESSAGE: report errors here, customize to match your product */
+       dev_err(&dev->dev, "device v%04x p%04x is not supported\n",
+               le16_to_cpu(dev->descriptor.idVendor),
+               le16_to_cpu(dev->descriptor.idProduct));
+
+       return 0;
+}
+
diff --git a/drivers/usb/core/otg_whitelist.h b/drivers/usb/core/otg_whitelist.h
deleted file mode 100644 (file)
index fdd4897..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * drivers/usb/core/otg_whitelist.h
- *
- * Copyright (C) 2004 Texas Instruments
- */
-
-/*
- * This OTG and Embedded Host Whitelist is "Targeted Peripheral List".
- * It should mostly use of USB_DEVICE() or USB_DEVICE_VER() entries..
- *
- * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING!
- */
-
-static struct usb_device_id whitelist_table[] = {
-
-/* hubs are optional in OTG, but very handy ... */
-{ USB_DEVICE_INFO(USB_CLASS_HUB, 0, 0), },
-{ USB_DEVICE_INFO(USB_CLASS_HUB, 0, 1), },
-
-#ifdef CONFIG_USB_PRINTER              /* ignoring nonstatic linkage! */
-/* FIXME actually, printers are NOT supposed to use device classes;
- * they're supposed to use interface classes...
- */
-{ USB_DEVICE_INFO(7, 1, 1) },
-{ USB_DEVICE_INFO(7, 1, 2) },
-{ USB_DEVICE_INFO(7, 1, 3) },
-#endif
-
-#ifdef CONFIG_USB_NET_CDCETHER
-/* Linux-USB CDC Ethernet gadget */
-{ USB_DEVICE(0x0525, 0xa4a1), },
-/* Linux-USB CDC Ethernet + RNDIS gadget */
-{ USB_DEVICE(0x0525, 0xa4a2), },
-#endif
-
-#if    IS_ENABLED(CONFIG_USB_TEST)
-/* gadget zero, for testing */
-{ USB_DEVICE(0x0525, 0xa4a0), },
-#endif
-
-{ }    /* Terminating entry */
-};
-
-static int is_targeted(struct usb_device *dev)
-{
-       struct usb_device_id    *id = whitelist_table;
-
-       /* HNP test device is _never_ targeted (see OTG spec 6.6.6) */
-       if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
-            le16_to_cpu(dev->descriptor.idProduct) == 0xbadd))
-               return 0;
-
-       /* OTG PET device is always targeted (see OTG 2.0 ECN 6.4.2) */
-       if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
-            le16_to_cpu(dev->descriptor.idProduct) == 0x0200))
-               return 1;
-
-       /* NOTE: can't use usb_match_id() since interface caches
-        * aren't set up yet. this is cut/paste from that code.
-        */
-       for (id = whitelist_table; id->match_flags; id++) {
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
-                   id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
-                       continue;
-
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
-                   id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
-                       continue;
-
-               /* No need to test id->bcdDevice_lo != 0, since 0 is never
-                  greater than any unsigned number. */
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
-                   (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
-                       continue;
-
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
-                   (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
-                       continue;
-
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
-                   (id->bDeviceClass != dev->descriptor.bDeviceClass))
-                       continue;
-
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
-                   (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass))
-                       continue;
-
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
-                   (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
-                       continue;
-
-               return 1;
-       }
-
-       /* add other match criteria here ... */
-
-
-       /* OTG MESSAGE: report errors here, customize to match your product */
-       dev_err(&dev->dev, "device v%04x p%04x is not supported\n",
-               le16_to_cpu(dev->descriptor.idVendor),
-               le16_to_cpu(dev->descriptor.idProduct));
-
-       return 0;
-}
-