Commit 95fcc6a9 authored by Robert Jarzmik's avatar Robert Jarzmik Committed by Felipe Balbi

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: default avatarRobert Jarzmik <robert.jarzmik@free.fr>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 545d64a4
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment