diff mbox series

[26/31] PM / devfreq: tegra30: convert to use devm_pm_opp_* API

Message ID 20210103035445.23696-1-tiny.windzz@gmail.com (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Yangtao Li Jan. 3, 2021, 3:54 a.m. UTC
Use devm_pm_opp_* API to simplify code, and remove opp_table
from tegra_devfreq.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 drivers/devfreq/tegra30-devfreq.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

Comments

Viresh Kumar Jan. 4, 2021, 7:30 a.m. UTC | #1
On 03-01-21, 03:54, Yangtao Li wrote:
> Use devm_pm_opp_* API to simplify code, and remove opp_table
> from tegra_devfreq.

Patches starting this one didn't appear in the same thread and it is a
nightmare to apply these now. Please send everything properly next
time.
Chanwoo Choi Jan. 5, 2021, 3:47 a.m. UTC | #2
Hi,

On Sun, Jan 3, 2021 at 12:57 PM Yangtao Li <tiny.windzz@gmail.com> wrote:
>
> Use devm_pm_opp_* API to simplify code, and remove opp_table
> from tegra_devfreq.
>
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> ---
>  drivers/devfreq/tegra30-devfreq.c | 21 +++++++--------------
>  1 file changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-devfreq.c
> index 117cad7968ab..4984cb91e9ea 100644
> --- a/drivers/devfreq/tegra30-devfreq.c
> +++ b/drivers/devfreq/tegra30-devfreq.c
> @@ -178,7 +178,6 @@ struct tegra_devfreq_soc_data {
>
>  struct tegra_devfreq {
>         struct devfreq          *devfreq;
> -       struct opp_table        *opp_table;
>
>         struct reset_control    *reset;
>         struct clk              *clock;
> @@ -794,6 +793,7 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
>         struct tegra_devfreq_device *dev;
>         struct tegra_devfreq *tegra;
>         struct devfreq *devfreq;
> +       struct opp_tabl *opp_table;

opp_tabl -> opp_table. It will make the build error. Please do build
test at least.

>         unsigned int i;
>         long rate;
>         int err;
> @@ -841,25 +841,25 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
>                 return err;
>         }
>
> -       tegra->opp_table = dev_pm_opp_set_supported_hw(&pdev->dev,
> -                                                      &hw_version, 1);
> -       err = PTR_ERR_OR_ZERO(tegra->opp_table);
> +       opp_table = devm_pm_opp_set_supported_hw(&pdev->dev,
> +                                                &hw_version, 1);
> +       err = PTR_ERR_OR_ZERO(opp_table);
>         if (err) {
>                 dev_err(&pdev->dev, "Failed to set supported HW: %d\n", err);
>                 return err;
>         }
>
> -       err = dev_pm_opp_of_add_table(&pdev->dev);
> +       err = devm_pm_opp_of_add_table(&pdev->dev);
>         if (err) {
>                 dev_err(&pdev->dev, "Failed to add OPP table: %d\n", err);
> -               goto put_hw;
> +               return err;
>         }
>
>         err = clk_prepare_enable(tegra->clock);
>         if (err) {
>                 dev_err(&pdev->dev,
>                         "Failed to prepare and enable ACTMON clock\n");
> -               goto remove_table;
> +               return err;
>         }
>
>         err = reset_control_reset(tegra->reset);
> @@ -917,10 +917,6 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
>         reset_control_reset(tegra->reset);
>  disable_clk:
>         clk_disable_unprepare(tegra->clock);
> -remove_table:
> -       dev_pm_opp_of_remove_table(&pdev->dev);
> -put_hw:
> -       dev_pm_opp_put_supported_hw(tegra->opp_table);

You might remove the 'devm_pm_opp_remove_all_dynamic(&pdev->dev)
under ' remove_opp' goto statement.kkkk


(snip)
Dmitry Osipenko Jan. 6, 2021, 6:17 p.m. UTC | #3
05.01.2021 06:47, Chanwoo Choi пишет:
> You might remove the 'devm_pm_opp_remove_all_dynamic(&pdev->dev)
> under ' remove_opp' goto statement.kkkk

Good catch, thank you.
diff mbox series

Patch

diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-devfreq.c
index 117cad7968ab..4984cb91e9ea 100644
--- a/drivers/devfreq/tegra30-devfreq.c
+++ b/drivers/devfreq/tegra30-devfreq.c
@@ -178,7 +178,6 @@  struct tegra_devfreq_soc_data {
 
 struct tegra_devfreq {
 	struct devfreq		*devfreq;
-	struct opp_table	*opp_table;
 
 	struct reset_control	*reset;
 	struct clk		*clock;
@@ -794,6 +793,7 @@  static int tegra_devfreq_probe(struct platform_device *pdev)
 	struct tegra_devfreq_device *dev;
 	struct tegra_devfreq *tegra;
 	struct devfreq *devfreq;
+	struct opp_tabl	*opp_table;
 	unsigned int i;
 	long rate;
 	int err;
@@ -841,25 +841,25 @@  static int tegra_devfreq_probe(struct platform_device *pdev)
 		return err;
 	}
 
-	tegra->opp_table = dev_pm_opp_set_supported_hw(&pdev->dev,
-						       &hw_version, 1);
-	err = PTR_ERR_OR_ZERO(tegra->opp_table);
+	opp_table = devm_pm_opp_set_supported_hw(&pdev->dev,
+						 &hw_version, 1);
+	err = PTR_ERR_OR_ZERO(opp_table);
 	if (err) {
 		dev_err(&pdev->dev, "Failed to set supported HW: %d\n", err);
 		return err;
 	}
 
-	err = dev_pm_opp_of_add_table(&pdev->dev);
+	err = devm_pm_opp_of_add_table(&pdev->dev);
 	if (err) {
 		dev_err(&pdev->dev, "Failed to add OPP table: %d\n", err);
-		goto put_hw;
+		return err;
 	}
 
 	err = clk_prepare_enable(tegra->clock);
 	if (err) {
 		dev_err(&pdev->dev,
 			"Failed to prepare and enable ACTMON clock\n");
-		goto remove_table;
+		return err;
 	}
 
 	err = reset_control_reset(tegra->reset);
@@ -917,10 +917,6 @@  static int tegra_devfreq_probe(struct platform_device *pdev)
 	reset_control_reset(tegra->reset);
 disable_clk:
 	clk_disable_unprepare(tegra->clock);
-remove_table:
-	dev_pm_opp_of_remove_table(&pdev->dev);
-put_hw:
-	dev_pm_opp_put_supported_hw(tegra->opp_table);
 
 	return err;
 }
@@ -935,9 +931,6 @@  static int tegra_devfreq_remove(struct platform_device *pdev)
 	reset_control_reset(tegra->reset);
 	clk_disable_unprepare(tegra->clock);
 
-	dev_pm_opp_of_remove_table(&pdev->dev);
-	dev_pm_opp_put_supported_hw(tegra->opp_table);
-
 	return 0;
 }