diff mbox series

[1/2] drm/panfrost: missing remove opp table in case of failure

Message ID 20200411200632.4045-1-peron.clem@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/panfrost: missing remove opp table in case of failure | expand

Commit Message

Clément Péron April 11, 2020, 8:06 p.m. UTC
In case of failure we need to remove OPP table.

Use Linux classic error handling with goto usage.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
---
 drivers/gpu/drm/panfrost/panfrost_devfreq.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Comments

Steven Price April 13, 2020, 1:07 p.m. UTC | #1
On 11/04/2020 21:06, Clément Péron wrote:
> In case of failure we need to remove OPP table.
> 
> Use Linux classic error handling with goto usage.
> 
> Signed-off-by: Clément Péron <peron.clem@gmail.com>

Reviewed-by: Steven Price <steven.price@arm.com>

> ---
>   drivers/gpu/drm/panfrost/panfrost_devfreq.c | 16 ++++++++++++----
>   1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> index 413987038fbf..62541f4edd81 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> @@ -90,8 +90,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
>   	cur_freq = clk_get_rate(pfdev->clock);
>   
>   	opp = devfreq_recommended_opp(dev, &cur_freq, 0);
> -	if (IS_ERR(opp))
> -		return PTR_ERR(opp);
> +	if (IS_ERR(opp)) {
> +		DRM_DEV_ERROR(dev, "Failed to set recommended OPP\n");
> +		ret = PTR_ERR(opp);
> +		goto err_opp;
> +	}
>   
>   	panfrost_devfreq_profile.initial_freq = cur_freq;
>   	dev_pm_opp_put(opp);
> @@ -100,8 +103,8 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
>   					  DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);
>   	if (IS_ERR(devfreq)) {
>   		DRM_DEV_ERROR(dev, "Couldn't initialize GPU devfreq\n");
> -		dev_pm_opp_of_remove_table(dev);
> -		return PTR_ERR(devfreq);
> +		ret = PTR_ERR(devfreq);
> +		goto err_opp;
>   	}
>   	pfdev->devfreq.devfreq = devfreq;
>   
> @@ -112,6 +115,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
>   		pfdev->devfreq.cooling = cooling;
>   
>   	return 0;
> +
> +err_opp:
> +	dev_pm_opp_of_remove_table(dev);
> +
> +	return ret;
>   }
>   
>   void panfrost_devfreq_fini(struct panfrost_device *pfdev)
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
index 413987038fbf..62541f4edd81 100644
--- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
+++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
@@ -90,8 +90,11 @@  int panfrost_devfreq_init(struct panfrost_device *pfdev)
 	cur_freq = clk_get_rate(pfdev->clock);
 
 	opp = devfreq_recommended_opp(dev, &cur_freq, 0);
-	if (IS_ERR(opp))
-		return PTR_ERR(opp);
+	if (IS_ERR(opp)) {
+		DRM_DEV_ERROR(dev, "Failed to set recommended OPP\n");
+		ret = PTR_ERR(opp);
+		goto err_opp;
+	}
 
 	panfrost_devfreq_profile.initial_freq = cur_freq;
 	dev_pm_opp_put(opp);
@@ -100,8 +103,8 @@  int panfrost_devfreq_init(struct panfrost_device *pfdev)
 					  DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);
 	if (IS_ERR(devfreq)) {
 		DRM_DEV_ERROR(dev, "Couldn't initialize GPU devfreq\n");
-		dev_pm_opp_of_remove_table(dev);
-		return PTR_ERR(devfreq);
+		ret = PTR_ERR(devfreq);
+		goto err_opp;
 	}
 	pfdev->devfreq.devfreq = devfreq;
 
@@ -112,6 +115,11 @@  int panfrost_devfreq_init(struct panfrost_device *pfdev)
 		pfdev->devfreq.cooling = cooling;
 
 	return 0;
+
+err_opp:
+	dev_pm_opp_of_remove_table(dev);
+
+	return ret;
 }
 
 void panfrost_devfreq_fini(struct panfrost_device *pfdev)