usb: musb: ux500: use devm_ functions
This patch introduces the use of managed interfaces for clk_get and kzalloc and removes the corresponding free function calls in the probe and remove functions. Signed-off-by: Himangi Saraogi <himangi774@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
parent
c63d2225e7
commit
d7dc5bde6d
@ -246,7 +246,7 @@ static int ux500_probe(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glue = kzalloc(sizeof(*glue), GFP_KERNEL);
|
glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
|
||||||
if (!glue) {
|
if (!glue) {
|
||||||
dev_err(&pdev->dev, "failed to allocate glue context\n");
|
dev_err(&pdev->dev, "failed to allocate glue context\n");
|
||||||
goto err0;
|
goto err0;
|
||||||
@ -255,20 +255,20 @@ static int ux500_probe(struct platform_device *pdev)
|
|||||||
musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
|
musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
|
||||||
if (!musb) {
|
if (!musb) {
|
||||||
dev_err(&pdev->dev, "failed to allocate musb device\n");
|
dev_err(&pdev->dev, "failed to allocate musb device\n");
|
||||||
goto err1;
|
goto err0;
|
||||||
}
|
}
|
||||||
|
|
||||||
clk = clk_get(&pdev->dev, NULL);
|
clk = devm_clk_get(&pdev->dev, NULL);
|
||||||
if (IS_ERR(clk)) {
|
if (IS_ERR(clk)) {
|
||||||
dev_err(&pdev->dev, "failed to get clock\n");
|
dev_err(&pdev->dev, "failed to get clock\n");
|
||||||
ret = PTR_ERR(clk);
|
ret = PTR_ERR(clk);
|
||||||
goto err3;
|
goto err1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = clk_prepare_enable(clk);
|
ret = clk_prepare_enable(clk);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "failed to enable clock\n");
|
dev_err(&pdev->dev, "failed to enable clock\n");
|
||||||
goto err4;
|
goto err1;
|
||||||
}
|
}
|
||||||
|
|
||||||
musb->dev.parent = &pdev->dev;
|
musb->dev.parent = &pdev->dev;
|
||||||
@ -302,34 +302,28 @@ static int ux500_probe(struct platform_device *pdev)
|
|||||||
ARRAY_SIZE(musb_resources));
|
ARRAY_SIZE(musb_resources));
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "failed to add resources\n");
|
dev_err(&pdev->dev, "failed to add resources\n");
|
||||||
goto err5;
|
goto err2;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
|
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "failed to add platform_data\n");
|
dev_err(&pdev->dev, "failed to add platform_data\n");
|
||||||
goto err5;
|
goto err2;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = platform_device_add(musb);
|
ret = platform_device_add(musb);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "failed to register musb device\n");
|
dev_err(&pdev->dev, "failed to register musb device\n");
|
||||||
goto err5;
|
goto err2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err5:
|
err2:
|
||||||
clk_disable_unprepare(clk);
|
clk_disable_unprepare(clk);
|
||||||
|
|
||||||
err4:
|
|
||||||
clk_put(clk);
|
|
||||||
|
|
||||||
err3:
|
|
||||||
platform_device_put(musb);
|
|
||||||
|
|
||||||
err1:
|
err1:
|
||||||
kfree(glue);
|
platform_device_put(musb);
|
||||||
|
|
||||||
err0:
|
err0:
|
||||||
return ret;
|
return ret;
|
||||||
@ -341,8 +335,6 @@ static int ux500_remove(struct platform_device *pdev)
|
|||||||
|
|
||||||
platform_device_unregister(glue->musb);
|
platform_device_unregister(glue->musb);
|
||||||
clk_disable_unprepare(glue->clk);
|
clk_disable_unprepare(glue->clk);
|
||||||
clk_put(glue->clk);
|
|
||||||
kfree(glue);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user