aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-12-11 02:16:33 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-18 19:33:47 -0500
commit806f6e6b92d8f1bf303198a3e78cf1ff99bd5c0e (patch)
tree94023a5542e115bdd3d7a7255d7703c1903ddaa1 /drivers/usb/host
parent63c9b9d3fe3b1b39a235755f724ab4378f21137c (diff)
USB: ehci-orion: Use devm_*() functions
Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Acked-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/ehci-orion.c43
1 files changed, 12 insertions, 31 deletions
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 4ca61203fead..30d35e5e503a 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -184,33 +184,23 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
184 if (err) 184 if (err)
185 goto err1; 185 goto err1;
186 186
187 if (!request_mem_region(res->start, resource_size(res), 187 regs = devm_ioremap_resource(&pdev->dev, res);
188 ehci_orion_hc_driver.description)) { 188 if (IS_ERR(regs)) {
189 dev_dbg(&pdev->dev, "controller already in use\n"); 189 err = PTR_ERR(regs);
190 err = -EBUSY;
191 goto err1; 190 goto err1;
192 } 191 }
193 192
194 regs = ioremap(res->start, resource_size(res));
195 if (regs == NULL) {
196 dev_dbg(&pdev->dev, "error mapping memory\n");
197 err = -EFAULT;
198 goto err2;
199 }
200
201 /* Not all platforms can gate the clock, so it is not 193 /* Not all platforms can gate the clock, so it is not
202 an error if the clock does not exists. */ 194 an error if the clock does not exists. */
203 clk = clk_get(&pdev->dev, NULL); 195 clk = devm_clk_get(&pdev->dev, NULL);
204 if (!IS_ERR(clk)) { 196 if (!IS_ERR(clk))
205 clk_prepare_enable(clk); 197 clk_prepare_enable(clk);
206 clk_put(clk);
207 }
208 198
209 hcd = usb_create_hcd(&ehci_orion_hc_driver, 199 hcd = usb_create_hcd(&ehci_orion_hc_driver,
210 &pdev->dev, dev_name(&pdev->dev)); 200 &pdev->dev, dev_name(&pdev->dev));
211 if (!hcd) { 201 if (!hcd) {
212 err = -ENOMEM; 202 err = -ENOMEM;
213 goto err3; 203 goto err2;
214 } 204 }
215 205
216 hcd->rsrc_start = res->start; 206 hcd->rsrc_start = res->start;
@@ -250,21 +240,16 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
250 240
251 err = usb_add_hcd(hcd, irq, IRQF_SHARED); 241 err = usb_add_hcd(hcd, irq, IRQF_SHARED);
252 if (err) 242 if (err)
253 goto err4; 243 goto err3;
254 244
255 device_wakeup_enable(hcd->self.controller); 245 device_wakeup_enable(hcd->self.controller);
256 return 0; 246 return 0;
257 247
258err4:
259 usb_put_hcd(hcd);
260err3: 248err3:
261 if (!IS_ERR(clk)) { 249 usb_put_hcd(hcd);
262 clk_disable_unprepare(clk);
263 clk_put(clk);
264 }
265 iounmap(regs);
266err2: 250err2:
267 release_mem_region(res->start, resource_size(res)); 251 if (!IS_ERR(clk))
252 clk_disable_unprepare(clk);
268err1: 253err1:
269 dev_err(&pdev->dev, "init %s fail, %d\n", 254 dev_err(&pdev->dev, "init %s fail, %d\n",
270 dev_name(&pdev->dev), err); 255 dev_name(&pdev->dev), err);
@@ -278,15 +263,11 @@ static int ehci_orion_drv_remove(struct platform_device *pdev)
278 struct clk *clk; 263 struct clk *clk;
279 264
280 usb_remove_hcd(hcd); 265 usb_remove_hcd(hcd);
281 iounmap(hcd->regs);
282 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
283 usb_put_hcd(hcd); 266 usb_put_hcd(hcd);
284 267
285 clk = clk_get(&pdev->dev, NULL); 268 clk = devm_clk_get(&pdev->dev, NULL);
286 if (!IS_ERR(clk)) { 269 if (!IS_ERR(clk))
287 clk_disable_unprepare(clk); 270 clk_disable_unprepare(clk);
288 clk_put(clk);
289 }
290 return 0; 271 return 0;
291} 272}
292 273