[linux-yocto] [PATCH 05/87] usb/ehci-ci13612: use the of match method to probe the hcd

Paul Butler butler.paul at gmail.com
Mon May 27 09:55:36 PDT 2013


From: Kevin Hao <kexin.hao at windriver.com>

The of platform has already registered ehci host controller
as a platform device. We can probe this device correctly by
just adding the corresponding of match table. Also move the
codes which check whether the ehci is enabled to the ci13612
specific file.

Signed-off-by: Kevin Hao <kexin.hao at windriver.com>
---
 drivers/usb/host/ehci-ci13612.c | 16 ++++++++++++++++
 drivers/usb/host/ehci-hcd.c     | 39 ---------------------------------------
 2 files changed, 16 insertions(+), 39 deletions(-)

diff --git a/drivers/usb/host/ehci-ci13612.c b/drivers/usb/host/ehci-ci13612.c
index 09fd1c3..76919aa 100644
--- a/drivers/usb/host/ehci-ci13612.c
+++ b/drivers/usb/host/ehci-ci13612.c
@@ -23,6 +23,7 @@
 
 #include <linux/platform_device.h>
 #include <linux/irq.h>
+#include <linux/of_platform.h>
 #include "ehci-ci13612.h"
 
 
@@ -145,8 +146,14 @@ static int ci13612_ehci_probe(struct platform_device *pdev)
 	void __iomem *gpreg_base = (void __iomem *) 0xF000C000;
 	int irq;
 	int retval;
+	struct device_node *np = pdev->dev.of_node;
+	const int *enabled;
 
 
+	enabled = of_get_property(np, "enabled", NULL);
+	if (!enabled || !*enabled)
+		return -ENODEV;
+
 	if (usb_disabled())
 		return -ENODEV;
 
@@ -204,10 +211,19 @@ static int ci13612_ehci_remove(struct platform_device *pdev)
 
 MODULE_ALIAS("platform:ci13612-ehci");
 
+static struct of_device_id ci13612_match[] = {
+	{
+		.type	= "usb",
+		.compatible = "acp-usb",
+	},
+	{},
+};
+
 static struct platform_driver ci13612_ehci_driver = {
 	.probe = ci13612_ehci_probe,
 	.remove = ci13612_ehci_remove,
 	.driver = {
 		.name = "ci13612-ehci",
+		.of_match_table = ci13612_match,
 	},
 };
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index c05a245..6bdfc8d 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1396,42 +1396,10 @@ MODULE_LICENSE ("GPL");
 #error "missing bus glue for ehci-hcd"
 #endif
 
-static void ci13612_device_release(struct device *dev)
-{
-}
-
-static struct platform_device ci13612_device = {
-	.name		= "ci13612-ehci",
-	.id		= -1,
-	.dev		= {
-		.release = ci13612_device_release,
-       },
-};
-
 static int __init ehci_hcd_init(void)
 {
 	int retval = 0;
 
-#ifdef CONFIG_ACP
-
-	struct device_node *np = NULL;
-	int *enabled;
-
-	np = of_find_node_by_type(np, "usb");
-
-	while (np && !of_device_is_compatible(np, "acp-usb"))
-		np = of_find_node_by_type(np, "usb");
-
-	if (np)
-		enabled = of_get_property(np, "enabled", NULL);
-	else
-		return -ENODEV;
-
-	if ((NULL == *enabled) || (0 == *enabled))
-		return -ENODEV;
-
-#endif
-
 	if (usb_disabled())
 		return -ENODEV;
 
@@ -1479,10 +1447,6 @@ static int __init ehci_hcd_init(void)
 		goto clean3;
 #endif
 
-	retval = platform_device_register(&ci13612_device);
-	if (retval < 0)
-	goto err_device_register;
-
 #ifdef XILINX_OF_PLATFORM_DRIVER
 	retval = platform_driver_register(&XILINX_OF_PLATFORM_DRIVER);
 	if (retval < 0)
@@ -1490,7 +1454,6 @@ static int __init ehci_hcd_init(void)
 #endif
 	return retval;
 
-err_device_register:
 #ifdef XILINX_OF_PLATFORM_DRIVER
 	/* platform_driver_unregister(&XILINX_OF_PLATFORM_DRIVER); */
 clean4:
@@ -1524,8 +1487,6 @@ module_init(ehci_hcd_init);
 static void __exit ehci_hcd_cleanup(void)
 {
 
-platform_device_unregister(&ci13612_device);
-
 #ifdef XILINX_OF_PLATFORM_DRIVER
 	platform_driver_unregister(&XILINX_OF_PLATFORM_DRIVER);
 #endif
-- 
1.8.3




More information about the linux-yocto mailing list