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