Commit 7282bdb2 authored by Gerhard Sittig's avatar Gerhard Sittig Committed by Anatolij Gustschin

USB: fsl-mph-dr-of: cleanup clock API use

use devm_get_clk() for automatic put upon device release, check for and
propagate errors when enabling clocks, must prepare clocks before they
can get enabled, unprepare after disable

need to use the _parent_ of the platform device for clock lookup, since
this one is associated with the respective device tree node; this change
remains neutral as long as a "globally" provided "usb%d_clk" item gets
provided by either the PPC_CLOCK implementation or clkdev_register'ed
aliases, using the correct devide and thus referencing the right DT node
becomes essential when clock lookup will become based on device tree
when common clock support will get introduced
Signed-off-by: default avatarGerhard Sittig <gsi@denx.de>
Signed-off-by: default avatarAnatolij Gustschin <agust@denx.de>
parent 2d30ccac
...@@ -260,6 +260,7 @@ int fsl_usb2_mpc5121_init(struct platform_device *pdev) ...@@ -260,6 +260,7 @@ int fsl_usb2_mpc5121_init(struct platform_device *pdev)
{ {
struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
struct clk *clk; struct clk *clk;
int err;
char clk_name[10]; char clk_name[10];
int base, clk_num; int base, clk_num;
...@@ -272,13 +273,16 @@ int fsl_usb2_mpc5121_init(struct platform_device *pdev) ...@@ -272,13 +273,16 @@ int fsl_usb2_mpc5121_init(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
snprintf(clk_name, sizeof(clk_name), "usb%d_clk", clk_num); snprintf(clk_name, sizeof(clk_name), "usb%d_clk", clk_num);
clk = clk_get(&pdev->dev, clk_name); clk = devm_clk_get(pdev->dev.parent, clk_name);
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
dev_err(&pdev->dev, "failed to get clk\n"); dev_err(&pdev->dev, "failed to get clk\n");
return PTR_ERR(clk); return PTR_ERR(clk);
} }
err = clk_prepare_enable(clk);
clk_enable(clk); if (err) {
dev_err(&pdev->dev, "failed to enable clk\n");
return err;
}
pdata->clk = clk; pdata->clk = clk;
if (pdata->phy_mode == FSL_USB2_PHY_UTMI_WIDE) { if (pdata->phy_mode == FSL_USB2_PHY_UTMI_WIDE) {
...@@ -302,10 +306,8 @@ static void fsl_usb2_mpc5121_exit(struct platform_device *pdev) ...@@ -302,10 +306,8 @@ static void fsl_usb2_mpc5121_exit(struct platform_device *pdev)
pdata->regs = NULL; pdata->regs = NULL;
if (pdata->clk) { if (pdata->clk)
clk_disable(pdata->clk); clk_disable_unprepare(pdata->clk);
clk_put(pdata->clk);
}
} }
static struct fsl_usb2_platform_data fsl_usb2_mpc5121_pd = { static struct fsl_usb2_platform_data fsl_usb2_mpc5121_pd = {
......
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