mfd: omap-usb-tll: Use devm_kzalloc/ioremap and clean up error path
Use devm_ variants of kzalloc() and ioremap(). Simplify the error path. Signed-off-by: Roger Quadros <rogerq@ti.com> Reviewed-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
parent
7e0ff1035c
commit
1a7a8d70cd
1 changed files with 12 additions and 26 deletions
|
@ -215,11 +215,10 @@ static int usbtll_omap_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
dev_dbg(dev, "starting TI HSUSB TLL Controller\n");
|
dev_dbg(dev, "starting TI HSUSB TLL Controller\n");
|
||||||
|
|
||||||
tll = kzalloc(sizeof(struct usbtll_omap), GFP_KERNEL);
|
tll = devm_kzalloc(dev, sizeof(struct usbtll_omap), GFP_KERNEL);
|
||||||
if (!tll) {
|
if (!tll) {
|
||||||
dev_err(dev, "Memory allocation failed\n");
|
dev_err(dev, "Memory allocation failed\n");
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_init(&tll->lock);
|
spin_lock_init(&tll->lock);
|
||||||
|
@ -230,28 +229,22 @@ static int usbtll_omap_probe(struct platform_device *pdev)
|
||||||
if (IS_ERR(tll->usbtll_p1_fck)) {
|
if (IS_ERR(tll->usbtll_p1_fck)) {
|
||||||
ret = PTR_ERR(tll->usbtll_p1_fck);
|
ret = PTR_ERR(tll->usbtll_p1_fck);
|
||||||
dev_err(dev, "usbtll_p1_fck failed error:%d\n", ret);
|
dev_err(dev, "usbtll_p1_fck failed error:%d\n", ret);
|
||||||
goto err_tll;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
tll->usbtll_p2_fck = clk_get(dev, "usb_tll_hs_usb_ch1_clk");
|
tll->usbtll_p2_fck = clk_get(dev, "usb_tll_hs_usb_ch1_clk");
|
||||||
if (IS_ERR(tll->usbtll_p2_fck)) {
|
if (IS_ERR(tll->usbtll_p2_fck)) {
|
||||||
ret = PTR_ERR(tll->usbtll_p2_fck);
|
ret = PTR_ERR(tll->usbtll_p2_fck);
|
||||||
dev_err(dev, "usbtll_p2_fck failed error:%d\n", ret);
|
dev_err(dev, "usbtll_p2_fck failed error:%d\n", ret);
|
||||||
goto err_usbtll_p1_fck;
|
goto err_p2_fck;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
if (!res) {
|
base = devm_request_and_ioremap(dev, res);
|
||||||
dev_err(dev, "usb tll get resource failed\n");
|
|
||||||
ret = -ENODEV;
|
|
||||||
goto err_usbtll_p2_fck;
|
|
||||||
}
|
|
||||||
|
|
||||||
base = ioremap(res->start, resource_size(res));
|
|
||||||
if (!base) {
|
if (!base) {
|
||||||
dev_err(dev, "TLL ioremap failed\n");
|
ret = -EADDRNOTAVAIL;
|
||||||
ret = -ENOMEM;
|
dev_err(dev, "Resource request/ioremap failed:%d\n", ret);
|
||||||
goto err_usbtll_p2_fck;
|
goto err_res;
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_set_drvdata(pdev, tll);
|
platform_set_drvdata(pdev, tll);
|
||||||
|
@ -323,23 +316,17 @@ static int usbtll_omap_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irqrestore(&tll->lock, flags);
|
spin_unlock_irqrestore(&tll->lock, flags);
|
||||||
iounmap(base);
|
|
||||||
pm_runtime_put_sync(dev);
|
pm_runtime_put_sync(dev);
|
||||||
tll_pdev = pdev;
|
tll_pdev = pdev;
|
||||||
if (!ret)
|
|
||||||
goto end;
|
|
||||||
pm_runtime_disable(dev);
|
|
||||||
|
|
||||||
err_usbtll_p2_fck:
|
return 0;
|
||||||
|
|
||||||
|
err_res:
|
||||||
clk_put(tll->usbtll_p2_fck);
|
clk_put(tll->usbtll_p2_fck);
|
||||||
|
|
||||||
err_usbtll_p1_fck:
|
err_p2_fck:
|
||||||
clk_put(tll->usbtll_p1_fck);
|
clk_put(tll->usbtll_p1_fck);
|
||||||
|
|
||||||
err_tll:
|
|
||||||
kfree(tll);
|
|
||||||
|
|
||||||
end:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +343,6 @@ static int usbtll_omap_remove(struct platform_device *pdev)
|
||||||
clk_put(tll->usbtll_p2_fck);
|
clk_put(tll->usbtll_p2_fck);
|
||||||
clk_put(tll->usbtll_p1_fck);
|
clk_put(tll->usbtll_p1_fck);
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(&pdev->dev);
|
||||||
kfree(tll);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue