aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorH Hartley Sweeten <hartleys@visionengravers.com>2013-07-01 18:53:02 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-26 16:54:29 -0400
commitaf3f233fd27b6a59cd6ea46a7dc048fff3ef2740 (patch)
tree16a026edba63a96f69b26864abd8e857f70025ca /drivers/usb
parent09ae8e7ead08e403413ceb4ba0f47eb324d03995 (diff)
usb: ohci-ep93xx: tidy up driver (*probe) and (*remove)
Merge the usb_hcd_ep93xx_probe() into ohci_hcd_ep93xx_drv_probe() and the usb_hcd_ep93xx_remove() into ohci_hcd_ep93xx_drv_remove(). As Alan Stern pointed out, there is no reason for them to be separate. Also, as Alan Stern suggested, eliminate the ep93xx_start_hc() and ep93xx_stop_hc() routines and simply call clk_enable() and clk_disable() directly. The extra level of redirection does not add any clarity. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Cc: Lennert Buytenhek <kernel@wantstofly.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/host/ohci-ep93xx.c128
1 files changed, 52 insertions, 76 deletions
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index 28fa6b8b5acd..84a20d5223b9 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -30,74 +30,6 @@
30 30
31static struct clk *usb_host_clock; 31static struct clk *usb_host_clock;
32 32
33static void ep93xx_start_hc(struct device *dev)
34{
35 clk_enable(usb_host_clock);
36}
37
38static void ep93xx_stop_hc(struct device *dev)
39{
40 clk_disable(usb_host_clock);
41}
42
43static int usb_hcd_ep93xx_probe(const struct hc_driver *driver,
44 struct platform_device *pdev)
45{
46 struct usb_hcd *hcd;
47 struct resource *res;
48 int irq;
49 int retval;
50
51 irq = platform_get_irq(pdev, 0);
52 if (irq < 0)
53 return irq;
54
55 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
56 if (!res)
57 return -ENXIO;
58
59 hcd = usb_create_hcd(driver, &pdev->dev, "ep93xx");
60 if (hcd == NULL)
61 return -ENOMEM;
62
63 hcd->rsrc_start = res->start;
64 hcd->rsrc_len = resource_size(res);
65
66 hcd->regs = devm_ioremap_resource(&pdev->dev, res);
67 if (IS_ERR(hcd->regs)) {
68 retval = PTR_ERR(hcd->regs);
69 goto err_put_hcd;
70 }
71
72 usb_host_clock = devm_clk_get(&pdev->dev, NULL);
73 if (IS_ERR(usb_host_clock)) {
74 retval = PTR_ERR(usb_host_clock);
75 goto err_put_hcd;
76 }
77
78 ep93xx_start_hc(&pdev->dev);
79
80 ohci_hcd_init(hcd_to_ohci(hcd));
81
82 retval = usb_add_hcd(hcd, irq, 0);
83 if (retval == 0)
84 return retval;
85
86 ep93xx_stop_hc(&pdev->dev);
87err_put_hcd:
88 usb_put_hcd(hcd);
89
90 return retval;
91}
92
93static void usb_hcd_ep93xx_remove(struct usb_hcd *hcd,
94 struct platform_device *pdev)
95{
96 usb_remove_hcd(hcd);
97 ep93xx_stop_hc(&pdev->dev);
98 usb_put_hcd(hcd);
99}
100
101static int ohci_ep93xx_start(struct usb_hcd *hcd) 33static int ohci_ep93xx_start(struct usb_hcd *hcd)
102{ 34{
103 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 35 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
@@ -138,15 +70,57 @@ static struct hc_driver ohci_ep93xx_hc_driver = {
138 .start_port_reset = ohci_start_port_reset, 70 .start_port_reset = ohci_start_port_reset,
139}; 71};
140 72
141extern int usb_disabled(void);
142
143static int ohci_hcd_ep93xx_drv_probe(struct platform_device *pdev) 73static int ohci_hcd_ep93xx_drv_probe(struct platform_device *pdev)
144{ 74{
75 struct usb_hcd *hcd;
76 struct resource *res;
77 int irq;
145 int ret; 78 int ret;
146 79
147 ret = -ENODEV; 80 if (usb_disabled())
148 if (!usb_disabled()) 81 return -ENODEV;
149 ret = usb_hcd_ep93xx_probe(&ohci_ep93xx_hc_driver, pdev); 82
83 irq = platform_get_irq(pdev, 0);
84 if (irq < 0)
85 return irq;
86
87 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
88 if (!res)
89 return -ENXIO;
90
91 hcd = usb_create_hcd(&ohci_ep93xx_hc_driver, &pdev->dev, "ep93xx");
92 if (!hcd)
93 return -ENOMEM;
94
95 hcd->rsrc_start = res->start;
96 hcd->rsrc_len = resource_size(res);
97
98 hcd->regs = devm_ioremap_resource(&pdev->dev, res);
99 if (IS_ERR(hcd->regs)) {
100 ret = PTR_ERR(hcd->regs);
101 goto err_put_hcd;
102 }
103
104 usb_host_clock = devm_clk_get(&pdev->dev, NULL);
105 if (IS_ERR(usb_host_clock)) {
106 ret = PTR_ERR(usb_host_clock);
107 goto err_put_hcd;
108 }
109
110 clk_enable(usb_host_clock);
111
112 ohci_hcd_init(hcd_to_ohci(hcd));
113
114 ret = usb_add_hcd(hcd, irq, 0);
115 if (ret)
116 goto err_clk_disable;
117
118 return 0;
119
120err_clk_disable:
121 clk_disable(usb_host_clock);
122err_put_hcd:
123 usb_put_hcd(hcd);
150 124
151 return ret; 125 return ret;
152} 126}
@@ -155,7 +129,9 @@ static int ohci_hcd_ep93xx_drv_remove(struct platform_device *pdev)
155{ 129{
156 struct usb_hcd *hcd = platform_get_drvdata(pdev); 130 struct usb_hcd *hcd = platform_get_drvdata(pdev);
157 131
158 usb_hcd_ep93xx_remove(hcd, pdev); 132 usb_remove_hcd(hcd);
133 clk_disable(usb_host_clock);
134 usb_put_hcd(hcd);
159 135
160 return 0; 136 return 0;
161} 137}
@@ -170,7 +146,7 @@ static int ohci_hcd_ep93xx_drv_suspend(struct platform_device *pdev, pm_message_
170 msleep(5); 146 msleep(5);
171 ohci->next_statechange = jiffies; 147 ohci->next_statechange = jiffies;
172 148
173 ep93xx_stop_hc(&pdev->dev); 149 clk_disable(usb_host_clock);
174 return 0; 150 return 0;
175} 151}
176 152
@@ -183,7 +159,7 @@ static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev)
183 msleep(5); 159 msleep(5);
184 ohci->next_statechange = jiffies; 160 ohci->next_statechange = jiffies;
185 161
186 ep93xx_start_hc(&pdev->dev); 162 clk_enable(usb_host_clock);
187 163
188 ohci_resume(hcd, false); 164 ohci_resume(hcd, false);
189 return 0; 165 return 0;