aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ehci-mxc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host/ehci-mxc.c')
-rw-r--r--drivers/usb/host/ehci-mxc.c45
1 files changed, 10 insertions, 35 deletions
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index 34201372c85f..959e1a4c3491 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -121,7 +121,7 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
121 if (!hcd) 121 if (!hcd)
122 return -ENOMEM; 122 return -ENOMEM;
123 123
124 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 124 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
125 if (!priv) { 125 if (!priv) {
126 ret = -ENOMEM; 126 ret = -ENOMEM;
127 goto err_alloc; 127 goto err_alloc;
@@ -131,34 +131,28 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
131 if (!res) { 131 if (!res) {
132 dev_err(dev, "Found HC with no register addr. Check setup!\n"); 132 dev_err(dev, "Found HC with no register addr. Check setup!\n");
133 ret = -ENODEV; 133 ret = -ENODEV;
134 goto err_get_resource; 134 goto err_alloc;
135 } 135 }
136 136
137 hcd->rsrc_start = res->start; 137 hcd->rsrc_start = res->start;
138 hcd->rsrc_len = resource_size(res); 138 hcd->rsrc_len = resource_size(res);
139 139
140 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 140 hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
141 dev_dbg(dev, "controller already in use\n");
142 ret = -EBUSY;
143 goto err_request_mem;
144 }
145
146 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
147 if (!hcd->regs) { 141 if (!hcd->regs) {
148 dev_err(dev, "error mapping memory\n"); 142 dev_err(dev, "error mapping memory\n");
149 ret = -EFAULT; 143 ret = -EFAULT;
150 goto err_ioremap; 144 goto err_alloc;
151 } 145 }
152 146
153 /* enable clocks */ 147 /* enable clocks */
154 priv->usbclk = clk_get(dev, "ipg"); 148 priv->usbclk = devm_clk_get(&pdev->dev, "ipg");
155 if (IS_ERR(priv->usbclk)) { 149 if (IS_ERR(priv->usbclk)) {
156 ret = PTR_ERR(priv->usbclk); 150 ret = PTR_ERR(priv->usbclk);
157 goto err_clk; 151 goto err_alloc;
158 } 152 }
159 clk_prepare_enable(priv->usbclk); 153 clk_prepare_enable(priv->usbclk);
160 154
161 priv->ahbclk = clk_get(dev, "ahb"); 155 priv->ahbclk = devm_clk_get(&pdev->dev, "ahb");
162 if (IS_ERR(priv->ahbclk)) { 156 if (IS_ERR(priv->ahbclk)) {
163 ret = PTR_ERR(priv->ahbclk); 157 ret = PTR_ERR(priv->ahbclk);
164 goto err_clk_ahb; 158 goto err_clk_ahb;
@@ -166,7 +160,7 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
166 clk_prepare_enable(priv->ahbclk); 160 clk_prepare_enable(priv->ahbclk);
167 161
168 /* "dr" device has its own clock on i.MX51 */ 162 /* "dr" device has its own clock on i.MX51 */
169 priv->phyclk = clk_get(dev, "phy"); 163 priv->phyclk = devm_clk_get(&pdev->dev, "phy");
170 if (IS_ERR(priv->phyclk)) 164 if (IS_ERR(priv->phyclk))
171 priv->phyclk = NULL; 165 priv->phyclk = NULL;
172 if (priv->phyclk) 166 if (priv->phyclk)
@@ -245,23 +239,12 @@ err_add:
245 if (pdata && pdata->exit) 239 if (pdata && pdata->exit)
246 pdata->exit(pdev); 240 pdata->exit(pdev);
247err_init: 241err_init:
248 if (priv->phyclk) { 242 if (priv->phyclk)
249 clk_disable_unprepare(priv->phyclk); 243 clk_disable_unprepare(priv->phyclk);
250 clk_put(priv->phyclk);
251 }
252 244
253 clk_disable_unprepare(priv->ahbclk); 245 clk_disable_unprepare(priv->ahbclk);
254 clk_put(priv->ahbclk);
255err_clk_ahb: 246err_clk_ahb:
256 clk_disable_unprepare(priv->usbclk); 247 clk_disable_unprepare(priv->usbclk);
257 clk_put(priv->usbclk);
258err_clk:
259 iounmap(hcd->regs);
260err_ioremap:
261 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
262err_request_mem:
263err_get_resource:
264 kfree(priv);
265err_alloc: 248err_alloc:
266 usb_put_hcd(hcd); 249 usb_put_hcd(hcd);
267 return ret; 250 return ret;
@@ -280,22 +263,14 @@ static int __exit ehci_mxc_drv_remove(struct platform_device *pdev)
280 usb_phy_shutdown(pdata->otg); 263 usb_phy_shutdown(pdata->otg);
281 264
282 usb_remove_hcd(hcd); 265 usb_remove_hcd(hcd);
283 iounmap(hcd->regs);
284 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
285 usb_put_hcd(hcd); 266 usb_put_hcd(hcd);
286 platform_set_drvdata(pdev, NULL); 267 platform_set_drvdata(pdev, NULL);
287 268
288 clk_disable_unprepare(priv->usbclk); 269 clk_disable_unprepare(priv->usbclk);
289 clk_put(priv->usbclk);
290 clk_disable_unprepare(priv->ahbclk); 270 clk_disable_unprepare(priv->ahbclk);
291 clk_put(priv->ahbclk);
292 271
293 if (priv->phyclk) { 272 if (priv->phyclk)
294 clk_disable_unprepare(priv->phyclk); 273 clk_disable_unprepare(priv->phyclk);
295 clk_put(priv->phyclk);
296 }
297
298 kfree(priv);
299 274
300 return 0; 275 return 0;
301} 276}