Skip to content

Commit

Permalink
mfd: omap-usb-host: Use devm_kzalloc() and devm_request_and_ioremap()
Browse files Browse the repository at this point in the history
Use devm_ variants of kzalloc and ioremap. Also clean up error path.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Roger Quadros committed Feb 13, 2013
1 parent a1f0d7a commit 27d4f2c
Showing 1 changed file with 11 additions and 27 deletions.
38 changes: 11 additions & 27 deletions drivers/mfd/omap-usb-host.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,15 +461,20 @@ static int usbhs_omap_probe(struct platform_device *pdev)

if (!pdata) {
dev_err(dev, "Missing platform data\n");
ret = -ENOMEM;
goto end_probe;
return -ENODEV;
}

omap = kzalloc(sizeof(*omap), GFP_KERNEL);
omap = devm_kzalloc(dev, sizeof(*omap), GFP_KERNEL);
if (!omap) {
dev_err(dev, "Memory allocation failed\n");
ret = -ENOMEM;
goto end_probe;
return -ENOMEM;
}

res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "uhh");
omap->uhh_base = devm_request_and_ioremap(dev, res);
if (!omap->uhh_base) {
dev_err(dev, "Resource request/ioremap failed\n");
return -EADDRNOTAVAIL;
}

spin_lock_init(&omap->lock);
Expand Down Expand Up @@ -568,20 +573,6 @@ static int usbhs_omap_probe(struct platform_device *pdev)
"failed error:%d\n", ret);
}

res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "uhh");
if (!res) {
dev_err(dev, "UHH EHCI get resource failed\n");
ret = -ENODEV;
goto err_init_60m_fclk;
}

omap->uhh_base = ioremap(res->start, resource_size(res));
if (!omap->uhh_base) {
dev_err(dev, "UHH ioremap failed\n");
ret = -ENOMEM;
goto err_init_60m_fclk;
}

platform_set_drvdata(pdev, omap);

omap_usbhs_init(dev);
Expand All @@ -591,13 +582,10 @@ static int usbhs_omap_probe(struct platform_device *pdev)
goto err_alloc;
}

goto end_probe;
return 0;

err_alloc:
omap_usbhs_deinit(&pdev->dev);
iounmap(omap->uhh_base);

err_init_60m_fclk:
clk_put(omap->init_60m_fclk);

err_usbhost_p2_fck:
Expand All @@ -621,9 +609,7 @@ static int usbhs_omap_probe(struct platform_device *pdev)
err_end:
clk_put(omap->ehci_logic_fck);
pm_runtime_disable(dev);
kfree(omap);

end_probe:
return ret;
}

Expand All @@ -638,7 +624,6 @@ static int usbhs_omap_remove(struct platform_device *pdev)
struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev);

omap_usbhs_deinit(&pdev->dev);
iounmap(omap->uhh_base);
clk_put(omap->init_60m_fclk);
clk_put(omap->usbhost_p2_fck);
clk_put(omap->usbhost_p1_fck);
Expand All @@ -648,7 +633,6 @@ static int usbhs_omap_remove(struct platform_device *pdev)
clk_put(omap->utmi_p1_fck);
clk_put(omap->ehci_logic_fck);
pm_runtime_disable(&pdev->dev);
kfree(omap);

return 0;
}
Expand Down

0 comments on commit 27d4f2c

Please sign in to comment.