Message ID | tencent_B5D4CEE5B9DE468871AF5159433E785D9D0A@qq.com |
---|---|
State | New |
Headers | show |
Series | [RFC] phy: freescale: fsl-samsung-hdmi: Use helper function devm_clk_get_enabled() | expand |
On Mon, Jan 13, 2025 at 1:08 AM <xiaopeitux@foxmail.com> wrote: > > From: Pei Xiao <xiaopei01@kylinos.cn> > > Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared > and enabled clocks"), devm_clk_get() and clk_prepare_enable() can now be > replaced by devm_clk_get_enabled() when driver enables the clocks for the > whole lifetime of the device. Moreover, it is no longer necessary to > unprepare and disable the clocks explicitly. > > Fixes: 6ad082bee902 ("phy: freescale: add Samsung HDMI PHY") I would argue that it is not a fix, but an improvement. I don't think anything was technically broken before, but Vinod may have a different opinion. > Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn> Tested-by: Adam Ford <aford173@gmail.com> # imx8mp-beacon > --- > drivers/phy/freescale/phy-fsl-samsung-hdmi.c | 17 ++--------------- > 1 file changed, 2 insertions(+), 15 deletions(-) > > diff --git a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c > index 1a079075de67..170eac317b16 100644 > --- a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c > +++ b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c > @@ -667,7 +667,7 @@ static int fsl_samsung_hdmi_phy_probe(struct platform_device *pdev) > if (IS_ERR(phy->regs)) > return PTR_ERR(phy->regs); > > - phy->apbclk = devm_clk_get(phy->dev, "apb"); > + phy->apbclk = devm_clk_get_enabled(phy->dev, "apb"); > if (IS_ERR(phy->apbclk)) > return dev_err_probe(phy->dev, PTR_ERR(phy->apbclk), > "failed to get apb clk\n"); > @@ -677,29 +677,16 @@ static int fsl_samsung_hdmi_phy_probe(struct platform_device *pdev) > return dev_err_probe(phy->dev, PTR_ERR(phy->refclk), > "failed to get ref clk\n"); > > - ret = clk_prepare_enable(phy->apbclk); > - if (ret) { > - dev_err(phy->dev, "failed to enable apbclk\n"); > - return ret; > - } > - > pm_runtime_get_noresume(phy->dev); > pm_runtime_set_active(phy->dev); > pm_runtime_enable(phy->dev); > > ret = phy_clk_register(phy); > - if (ret) { > + if (ret) > dev_err(&pdev->dev, "register clk failed\n"); > - goto register_clk_failed; > - } > > pm_runtime_put(phy->dev); > > - return 0; > - > -register_clk_failed: > - clk_disable_unprepare(phy->apbclk); > - > return ret; > } > > -- > 2.25.1 >
diff --git a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c index 1a079075de67..170eac317b16 100644 --- a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c +++ b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c @@ -667,7 +667,7 @@ static int fsl_samsung_hdmi_phy_probe(struct platform_device *pdev) if (IS_ERR(phy->regs)) return PTR_ERR(phy->regs); - phy->apbclk = devm_clk_get(phy->dev, "apb"); + phy->apbclk = devm_clk_get_enabled(phy->dev, "apb"); if (IS_ERR(phy->apbclk)) return dev_err_probe(phy->dev, PTR_ERR(phy->apbclk), "failed to get apb clk\n"); @@ -677,29 +677,16 @@ static int fsl_samsung_hdmi_phy_probe(struct platform_device *pdev) return dev_err_probe(phy->dev, PTR_ERR(phy->refclk), "failed to get ref clk\n"); - ret = clk_prepare_enable(phy->apbclk); - if (ret) { - dev_err(phy->dev, "failed to enable apbclk\n"); - return ret; - } - pm_runtime_get_noresume(phy->dev); pm_runtime_set_active(phy->dev); pm_runtime_enable(phy->dev); ret = phy_clk_register(phy); - if (ret) { + if (ret) dev_err(&pdev->dev, "register clk failed\n"); - goto register_clk_failed; - } pm_runtime_put(phy->dev); - return 0; - -register_clk_failed: - clk_disable_unprepare(phy->apbclk); - return ret; }