Hello. On 07/14/2014 09:05 PM, Robert Jarzmik wrote:
Use devm_* helpers in the probe function to simplify the error path and the remove path.
Signed-off-by: Robert Jarzmik <robert.jarzmik@xxxxxxx> Cc: Sergei Shtylyov <sergei.shtylyov@xxxxxxxxxxxxxxxxxx>
--- Since V1: Addressed Sergei's comments Since V2: Addressed Sergei's comments on includes --- drivers/usb/gadget/pxa27x_udc.c | 54 +++++++++++------------------------------ 1 file changed, 14 insertions(+), 40 deletions(-)
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index f814795..fed8b2e 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c
[...]
@@ -2500,21 +2502,13 @@ static int pxa_udc_probe(struct platform_device *pdev) return retval; } - 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; @@ -2524,35 +2518,21 @@ 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; + return retval;
You forgot clk_unprepare().
} retval = usb_add_gadget_udc(&pdev->dev, &udc->gadget); if (retval) - goto err_add_udc; + return retval;
Here as well...
pxa_init_debugfs(udc); return 0; - -err_add_udc: - free_irq(udc->irq, udc); -err_irq: - iounmap(udc->regs); -err_map: - clk_unprepare(udc->clk);
You're too fast with this one. It should be kept.
-err_clk_prepare: - clk_put(udc->clk); - udc->clk = NULL; -err_clk: - if (gpio_is_valid(udc->gpio_pullup)) - gpio_free(udc->gpio_pullup); - return retval; }
WBR, Sergei -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html