clk: tegra: Don't warn three times about failure to unregister
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Sun, 12 Mar 2023 16:14:44 +0000 (17:14 +0100)
committerStephen Boyd <sboyd@kernel.org>
Wed, 29 Mar 2023 02:23:35 +0000 (19:23 -0700)
tegra124_dfll_fcpu_remove() calls tegra_dfll_unregister() and the former
emits an error message if the latter fails. In that case
tegra_dfll_unregister() already printed an error message. Additionally
tegra124_dfll_fcpu_remove() returns an error code which results in yet
another warning emitted by platform_remove().

So drop the error message from tegra124_dfll_fcpu_remove() and let it
return 0. (Retuning 0 has no side effect but suppressing the error
message in platform_remove().)

Also add two comments about exiting early being wrong. This is something
that needs fixing separately.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230312161512.2715500-3-u.kleine-koenig@pengutronix.de
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/tegra/clk-dfll.c
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c

index 4143392..58fa5a5 100644 (file)
@@ -2081,7 +2081,10 @@ struct tegra_dfll_soc_data *tegra_dfll_unregister(struct platform_device *pdev)
 {
        struct tegra_dfll *td = platform_get_drvdata(pdev);
 
-       /* Try to prevent removal while the DFLL is active */
+       /*
+        * Note that exiting early here doesn't prevent unbinding the driver.
+        * Exiting early here only leaks some resources.
+        */
        if (td->mode != DFLL_DISABLED) {
                dev_err(&pdev->dev,
                        "must disable DFLL before removing driver\n");
index 5e339ad..15c5e14 100644 (file)
@@ -616,12 +616,13 @@ static int tegra124_dfll_fcpu_remove(struct platform_device *pdev)
 {
        struct tegra_dfll_soc_data *soc;
 
+       /*
+        * Note that exiting early here is dangerous as after this function
+        * returns *soc is freed.
+        */
        soc = tegra_dfll_unregister(pdev);
-       if (IS_ERR(soc)) {
-               dev_err(&pdev->dev, "failed to unregister DFLL: %ld\n",
-                       PTR_ERR(soc));
-               return PTR_ERR(soc);
-       }
+       if (IS_ERR(soc))
+               return 0;
 
        tegra_cvb_remove_opp_table(soc->dev, soc->cvb, soc->max_freq);