summaryrefslogtreecommitdiffstats
path: root/target/linux/octeon/patches-3.10/0004-fix_hcd.patch
blob: 318e59cb3eb70e13a5bd869781b3ba1a5c3e2336 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
--- a/drivers/staging/octeon-usb/octeon-hcd.c
+++ b/drivers/staging/octeon-usb/octeon-hcd.c
@@ -673,8 +673,9 @@ static const struct hc_driver octeon_hc_
 };
 
 
-static int octeon_usb_driver_probe(struct device *dev)
+static int octeon_usb_driver_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	int status;
 	int usb_num = to_platform_device(dev)->id;
 	int irq = platform_get_irq(to_platform_device(dev), 0);
@@ -728,8 +729,9 @@ static int octeon_usb_driver_probe(struc
 	return 0;
 }
 
-static int octeon_usb_driver_remove(struct device *dev)
+static int octeon_usb_driver_remove(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	int status;
 	struct usb_hcd *hcd = dev_get_drvdata(dev);
 	struct octeon_hcd *priv = hcd_to_octeon(hcd);
@@ -748,30 +750,35 @@ static int octeon_usb_driver_remove(stru
 	return 0;
 }
 
-static struct device_driver octeon_usb_driver = {
-	.name	= "OcteonUSB",
-	.bus	= &platform_bus_type,
+static struct platform_driver octeon_usb_driver = {
+	.driver = {
+		.name	= "OcteonUSB",
+		.owner  = THIS_MODULE,
+	},
 	.probe	= octeon_usb_driver_probe,
 	.remove	= octeon_usb_driver_remove,
 };
 
+static struct resource octeon_usb_resources = {
+	.start	= OCTEON_IRQ_USB0,
+	.end	= OCTEON_IRQ_USB0,
+	.flags	= IORESOURCE_IRQ,
+};
+
+static struct platform_device octeon_usb_device = {
+	.name		= "OcteonUSB",
+	.id		= 0,
+	.resource	= &octeon_usb_resources,
+	.num_resources	= 1,
+};
 
-#define MAX_USB_PORTS   10
-static struct platform_device *pdev_glob[MAX_USB_PORTS];
-static int octeon_usb_registered;
 static int __init octeon_usb_module_init(void)
 {
 	int num_devices = cvmx_usb_get_num_ports();
-	int device;
 
 	if (usb_disabled() || num_devices == 0)
 		return -ENODEV;
 
-	if (driver_register(&octeon_usb_driver))
-		return -ENOMEM;
-
-	octeon_usb_registered = 1;
-
 	/*
 	 * Only cn52XX and cn56XX have DWC_OTG USB hardware and the
 	 * IOB priority registers.  Under heavy network load USB
@@ -792,37 +799,14 @@ static int __init octeon_usb_module_init
 		cvmx_write_csr(CVMX_IOB_N2C_L2C_PRI_CNT, pri_cnt.u64);
 	}
 
-	for (device = 0; device < num_devices; device++) {
-		struct resource irq_resource;
-		struct platform_device *pdev;
-		memset(&irq_resource, 0, sizeof(irq_resource));
-		irq_resource.start = (device == 0) ? OCTEON_IRQ_USB0 : OCTEON_IRQ_USB1;
-		irq_resource.end = irq_resource.start;
-		irq_resource.flags = IORESOURCE_IRQ;
-		pdev = platform_device_register_simple((char *)octeon_usb_driver.  name, device, &irq_resource, 1);
-		if (IS_ERR(pdev)) {
-			driver_unregister(&octeon_usb_driver);
-			octeon_usb_registered = 0;
-			return PTR_ERR(pdev);
-		}
-		if (device < MAX_USB_PORTS)
-			pdev_glob[device] = pdev;
+	platform_device_register(&octeon_usb_device);
 
-	}
-	return 0;
+	return platform_driver_register(&octeon_usb_driver);
 }
 
 static void __exit octeon_usb_module_cleanup(void)
 {
-	int i;
-
-	for (i = 0; i < MAX_USB_PORTS; i++)
-		if (pdev_glob[i]) {
-			platform_device_unregister(pdev_glob[i]);
-			pdev_glob[i] = NULL;
-		}
-	if (octeon_usb_registered)
-		driver_unregister(&octeon_usb_driver);
+	platform_driver_unregister(&octeon_usb_driver);
 }
 
 MODULE_LICENSE("GPL");