mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-09 07:14:48 +08:00
usb: gadget: pxa27x_udc: use devm_* helpers
Use devm_* helpers in the probe function to simplify the error path and the remove path. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
parent
545d64a46c
commit
95fcc6a901
@ -2438,8 +2438,9 @@ static int pxa_udc_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!regs)
|
||||
return -ENXIO;
|
||||
udc->regs = devm_ioremap_resource(&pdev->dev, regs);
|
||||
if (IS_ERR(udc->regs))
|
||||
return PTR_ERR(udc->regs);
|
||||
udc->irq = platform_get_irq(pdev, 0);
|
||||
if (udc->irq < 0)
|
||||
return udc->irq;
|
||||
@ -2455,21 +2456,13 @@ static int pxa_udc_probe(struct platform_device *pdev)
|
||||
if (udc->gpiod)
|
||||
gpiod_direction_output(udc->gpiod, 0);
|
||||
|
||||
udc->clk = clk_get(&pdev->dev, NULL);
|
||||
if (IS_ERR(udc->clk)) {
|
||||
retval = PTR_ERR(udc->clk);
|
||||
goto err_clk;
|
||||
}
|
||||
udc->clk = devm_clk_get(&pdev->dev, NULL);
|
||||
if (IS_ERR(udc->clk))
|
||||
return PTR_ERR(udc->clk);
|
||||
|
||||
retval = clk_prepare(udc->clk);
|
||||
if (retval)
|
||||
goto err_clk_prepare;
|
||||
|
||||
retval = -ENOMEM;
|
||||
udc->regs = ioremap(regs->start, resource_size(regs));
|
||||
if (!udc->regs) {
|
||||
dev_err(&pdev->dev, "Unable to map UDC I/O memory\n");
|
||||
goto err_map;
|
||||
}
|
||||
return retval;
|
||||
|
||||
udc->vbus_sensed = 0;
|
||||
|
||||
@ -2479,32 +2472,23 @@ static int pxa_udc_probe(struct platform_device *pdev)
|
||||
pxa_eps_setup(udc);
|
||||
|
||||
/* irq setup after old hardware state is cleaned up */
|
||||
retval = request_irq(udc->irq, pxa_udc_irq,
|
||||
IRQF_SHARED, driver_name, udc);
|
||||
retval = devm_request_irq(&pdev->dev, udc->irq, pxa_udc_irq,
|
||||
IRQF_SHARED, driver_name, udc);
|
||||
if (retval != 0) {
|
||||
dev_err(udc->dev, "%s: can't get irq %i, err %d\n",
|
||||
driver_name, udc->irq, retval);
|
||||
goto err_irq;
|
||||
goto err;
|
||||
}
|
||||
|
||||
retval = usb_add_gadget_udc(&pdev->dev, &udc->gadget);
|
||||
if (retval)
|
||||
goto err_add_udc;
|
||||
goto err;
|
||||
|
||||
pxa_init_debugfs(udc);
|
||||
|
||||
return 0;
|
||||
|
||||
err_add_udc:
|
||||
free_irq(udc->irq, udc);
|
||||
err_irq:
|
||||
iounmap(udc->regs);
|
||||
err_map:
|
||||
err:
|
||||
clk_unprepare(udc->clk);
|
||||
err_clk_prepare:
|
||||
clk_put(udc->clk);
|
||||
udc->clk = NULL;
|
||||
err_clk:
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -2518,7 +2502,6 @@ static int pxa_udc_remove(struct platform_device *_dev)
|
||||
|
||||
usb_del_gadget_udc(&udc->gadget);
|
||||
usb_gadget_unregister_driver(udc->driver);
|
||||
free_irq(udc->irq, udc);
|
||||
pxa_cleanup_debugfs(udc);
|
||||
|
||||
usb_put_phy(udc->transceiver);
|
||||
@ -2526,8 +2509,6 @@ static int pxa_udc_remove(struct platform_device *_dev)
|
||||
udc->transceiver = NULL;
|
||||
the_controller = NULL;
|
||||
clk_unprepare(udc->clk);
|
||||
clk_put(udc->clk);
|
||||
iounmap(udc->regs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user