[U-Boot] [PATCH 12/18] dm: usb: Adjust the USB_DEVICE() macro naming

Simon Glass sjg at chromium.org
Tue Jul 7 00:47:51 CEST 2015


In Linux USB_DEVICE() is used to declare a USB device by vendor/device ID.
We should follow the same convention in U-Boot. Rename the existing
USB_DEVICE() macro to U_BOOT_USB_DEVICE() and bring in the USB_DEVICE()
macro from Linux for use in U-Boot.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 common/usb_hub.c            |  2 +-
 common/usb_kbd.c            |  4 ++--
 common/usb_storage.c        |  2 +-
 drivers/usb/Kconfig         |  4 ++--
 drivers/usb/eth/usb_ether.c |  4 ++--
 include/usb.h               | 18 +++++++++++++++++-
 6 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index be01f4f..f621ddb 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -652,6 +652,6 @@ static const struct usb_device_id hub_id_table[] = {
 	{ }	/* Terminating entry */
 };
 
-USB_DEVICE(usb_generic_hub, hub_id_table);
+U_BOOT_USB_DEVICE(usb_generic_hub, hub_id_table);
 
 #endif
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index e2af67d..0227024 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -540,8 +540,8 @@ int drv_usb_kbd_init(void)
 	debug("%s: Probing for keyboard\n", __func__);
 #ifdef CONFIG_DM_USB
 	/*
-	 * TODO: We should add USB_DEVICE() declarations to each USB ethernet
-	 * driver and then most of this file can be removed.
+	 * TODO: We should add U_BOOT_USB_DEVICE() declarations to each USB
+	 * keyboard driver and then most of this file can be removed.
 	 */
 	struct udevice *bus;
 	struct uclass *uc;
diff --git a/common/usb_storage.c b/common/usb_storage.c
index cc9b3e3..b978430 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -1442,6 +1442,6 @@ static const struct usb_device_id mass_storage_id_table[] = {
 	{ }		/* Terminating entry */
 };
 
-USB_DEVICE(usb_mass_storage, mass_storage_id_table);
+U_BOOT_USB_DEVICE(usb_mass_storage, mass_storage_id_table);
 
 #endif
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 637ef3d..3fa5b2e 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -46,8 +46,8 @@ config DM_USB
 
 	  Much of the code is shared but with this option enabled the USB
 	  uclass takes care of device enumeration. USB devices can be
-	  declared with the USB_DEVICE() macro and will be automatically
-	  probed when found on the bus.
+	  declared with the U_BOOT_USB_DEVICE() macro and will be
+	  automatically probed when found on the bus.
 
 source "drivers/usb/host/Kconfig"
 
diff --git a/drivers/usb/eth/usb_ether.c b/drivers/usb/eth/usb_ether.c
index 07d2309..63785a9 100644
--- a/drivers/usb/eth/usb_ether.c
+++ b/drivers/usb/eth/usb_ether.c
@@ -266,8 +266,8 @@ int usb_host_eth_scan(int mode)
 	usb_max_eth_dev = 0;
 #ifdef CONFIG_DM_USB
 	/*
-	 * TODO: We should add USB_DEVICE() declarations to each USB ethernet
-	 * driver and then most of this file can be removed.
+	 * TODO: We should add U_BOOT_USB_DEVICE() declarations to each USB
+	 * Ethernet driver and then most of this file can be removed.
 	 */
 	struct udevice *bus;
 	struct uclass *uc;
diff --git a/include/usb.h b/include/usb.h
index 1b9140f..83a8964 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -501,7 +501,23 @@ struct usb_driver_entry {
 	const struct usb_device_id *match;
 };
 
-#define USB_DEVICE(__name, __match)					\
+#define USB_DEVICE_ID_MATCH_DEVICE \
+		(USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT)
+
+/**
+ * USB_DEVICE - macro used to describe a specific usb device
+ * @vend: the 16 bit USB Vendor ID
+ * @prod: the 16 bit USB Product ID
+ *
+ * This macro is used to create a struct usb_device_id that matches a
+ * specific device.
+ */
+#define USB_DEVICE(vend, prod) \
+	.match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
+	.idVendor = (vend), \
+	.idProduct = (prod)
+
+#define U_BOOT_USB_DEVICE(__name, __match) \
 	ll_entry_declare(struct usb_driver_entry, __name, usb_driver_entry) = {\
 		.driver = llsym(struct driver, __name, driver), \
 		.match = __match, \
-- 
2.4.3.573.g4eafbef



More information about the U-Boot mailing list