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