diff mbox

[1/2] thermal: rcar_thermal: remove redundant operation

Message ID 87egfylia4.wl%kuninori.morimoto.gx@renesas.com (mailing list archive)
State Accepted
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Kuninori Morimoto Nov. 10, 2015, 2:12 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Probe error operation and remove operation are same.
Let's use same function.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/thermal/rcar_thermal.c | 49 ++++++++++++++++++------------------------
 1 file changed, 21 insertions(+), 28 deletions(-)

Comments

Ulf Hansson Nov. 13, 2015, 2:50 p.m. UTC | #1
On 10 November 2015 at 03:12, Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>
> Probe error operation and remove operation are same.

Currently they are, but that's because the error handling in ->probe() is wrong.

In some error cases the pm_runtime_put|disable() should have been
called but they aren't. Perhaps it's better to fix that first.

Kind regards
Uffe

> Let's use same function.
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  drivers/thermal/rcar_thermal.c | 49 ++++++++++++++++++------------------------
>  1 file changed, 21 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> index 5d4ae7d..13d01ed 100644
> --- a/drivers/thermal/rcar_thermal.c
> +++ b/drivers/thermal/rcar_thermal.c
> @@ -361,6 +361,24 @@ static irqreturn_t rcar_thermal_irq(int irq, void *data)
>  /*
>   *             platform functions
>   */
> +static int rcar_thermal_remove(struct platform_device *pdev)
> +{
> +       struct rcar_thermal_common *common = platform_get_drvdata(pdev);
> +       struct device *dev = &pdev->dev;
> +       struct rcar_thermal_priv *priv;
> +
> +       rcar_thermal_for_each_priv(priv, common) {
> +               if (rcar_has_irq_support(priv))
> +                       rcar_thermal_irq_disable(priv);
> +               thermal_zone_device_unregister(priv->zone);
> +       }
> +
> +       pm_runtime_put(dev);
> +       pm_runtime_disable(dev);
> +
> +       return 0;
> +}
> +
>  static int rcar_thermal_probe(struct platform_device *pdev)
>  {
>         struct rcar_thermal_common *common;
> @@ -377,6 +395,8 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>         if (!common)
>                 return -ENOMEM;
>
> +       platform_set_drvdata(pdev, common);
> +
>         INIT_LIST_HEAD(&common->head);
>         spin_lock_init(&common->lock);
>         common->dev = dev;
> @@ -454,43 +474,16 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>                 rcar_thermal_common_write(common, ENR, enr_bits);
>         }
>
> -       platform_set_drvdata(pdev, common);
> -
>         dev_info(dev, "%d sensor probed\n", i);
>
>         return 0;
>
>  error_unregister:
> -       rcar_thermal_for_each_priv(priv, common) {
> -               if (rcar_has_irq_support(priv))
> -                       rcar_thermal_irq_disable(priv);
> -               thermal_zone_device_unregister(priv->zone);
> -       }
> -
> -       pm_runtime_put(dev);
> -       pm_runtime_disable(dev);
> +       rcar_thermal_remove(pdev);
>
>         return ret;
>  }
>
> -static int rcar_thermal_remove(struct platform_device *pdev)
> -{
> -       struct rcar_thermal_common *common = platform_get_drvdata(pdev);
> -       struct device *dev = &pdev->dev;
> -       struct rcar_thermal_priv *priv;
> -
> -       rcar_thermal_for_each_priv(priv, common) {
> -               if (rcar_has_irq_support(priv))
> -                       rcar_thermal_irq_disable(priv);
> -               thermal_zone_device_unregister(priv->zone);
> -       }
> -
> -       pm_runtime_put(dev);
> -       pm_runtime_disable(dev);
> -
> -       return 0;
> -}
> -
>  static const struct of_device_id rcar_thermal_dt_ids[] = {
>         { .compatible = "renesas,rcar-thermal", },
>         {},
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eduardo Valentin Nov. 16, 2015, 6:42 p.m. UTC | #2
On Tue, Nov 10, 2015 at 02:12:06AM +0000, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> Probe error operation and remove operation are same.
> Let's use same function.

I am picking this one and sending for next rc cycle. The second  patch
is still under discussion and the issue may be solved differently,
so for now I wont get that. 

BR,

> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  drivers/thermal/rcar_thermal.c | 49 ++++++++++++++++++------------------------
>  1 file changed, 21 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> index 5d4ae7d..13d01ed 100644
> --- a/drivers/thermal/rcar_thermal.c
> +++ b/drivers/thermal/rcar_thermal.c
> @@ -361,6 +361,24 @@ static irqreturn_t rcar_thermal_irq(int irq, void *data)
>  /*
>   *		platform functions
>   */
> +static int rcar_thermal_remove(struct platform_device *pdev)
> +{
> +	struct rcar_thermal_common *common = platform_get_drvdata(pdev);
> +	struct device *dev = &pdev->dev;
> +	struct rcar_thermal_priv *priv;
> +
> +	rcar_thermal_for_each_priv(priv, common) {
> +		if (rcar_has_irq_support(priv))
> +			rcar_thermal_irq_disable(priv);
> +		thermal_zone_device_unregister(priv->zone);
> +	}
> +
> +	pm_runtime_put(dev);
> +	pm_runtime_disable(dev);
> +
> +	return 0;
> +}
> +
>  static int rcar_thermal_probe(struct platform_device *pdev)
>  {
>  	struct rcar_thermal_common *common;
> @@ -377,6 +395,8 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>  	if (!common)
>  		return -ENOMEM;
>  
> +	platform_set_drvdata(pdev, common);
> +
>  	INIT_LIST_HEAD(&common->head);
>  	spin_lock_init(&common->lock);
>  	common->dev = dev;
> @@ -454,43 +474,16 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>  		rcar_thermal_common_write(common, ENR, enr_bits);
>  	}
>  
> -	platform_set_drvdata(pdev, common);
> -
>  	dev_info(dev, "%d sensor probed\n", i);
>  
>  	return 0;
>  
>  error_unregister:
> -	rcar_thermal_for_each_priv(priv, common) {
> -		if (rcar_has_irq_support(priv))
> -			rcar_thermal_irq_disable(priv);
> -		thermal_zone_device_unregister(priv->zone);
> -	}
> -
> -	pm_runtime_put(dev);
> -	pm_runtime_disable(dev);
> +	rcar_thermal_remove(pdev);
>  
>  	return ret;
>  }
>  
> -static int rcar_thermal_remove(struct platform_device *pdev)
> -{
> -	struct rcar_thermal_common *common = platform_get_drvdata(pdev);
> -	struct device *dev = &pdev->dev;
> -	struct rcar_thermal_priv *priv;
> -
> -	rcar_thermal_for_each_priv(priv, common) {
> -		if (rcar_has_irq_support(priv))
> -			rcar_thermal_irq_disable(priv);
> -		thermal_zone_device_unregister(priv->zone);
> -	}
> -
> -	pm_runtime_put(dev);
> -	pm_runtime_disable(dev);
> -
> -	return 0;
> -}
> -
>  static const struct of_device_id rcar_thermal_dt_ids[] = {
>  	{ .compatible = "renesas,rcar-thermal", },
>  	{},
> -- 
> 1.9.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 5d4ae7d..13d01ed 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -361,6 +361,24 @@  static irqreturn_t rcar_thermal_irq(int irq, void *data)
 /*
  *		platform functions
  */
+static int rcar_thermal_remove(struct platform_device *pdev)
+{
+	struct rcar_thermal_common *common = platform_get_drvdata(pdev);
+	struct device *dev = &pdev->dev;
+	struct rcar_thermal_priv *priv;
+
+	rcar_thermal_for_each_priv(priv, common) {
+		if (rcar_has_irq_support(priv))
+			rcar_thermal_irq_disable(priv);
+		thermal_zone_device_unregister(priv->zone);
+	}
+
+	pm_runtime_put(dev);
+	pm_runtime_disable(dev);
+
+	return 0;
+}
+
 static int rcar_thermal_probe(struct platform_device *pdev)
 {
 	struct rcar_thermal_common *common;
@@ -377,6 +395,8 @@  static int rcar_thermal_probe(struct platform_device *pdev)
 	if (!common)
 		return -ENOMEM;
 
+	platform_set_drvdata(pdev, common);
+
 	INIT_LIST_HEAD(&common->head);
 	spin_lock_init(&common->lock);
 	common->dev = dev;
@@ -454,43 +474,16 @@  static int rcar_thermal_probe(struct platform_device *pdev)
 		rcar_thermal_common_write(common, ENR, enr_bits);
 	}
 
-	platform_set_drvdata(pdev, common);
-
 	dev_info(dev, "%d sensor probed\n", i);
 
 	return 0;
 
 error_unregister:
-	rcar_thermal_for_each_priv(priv, common) {
-		if (rcar_has_irq_support(priv))
-			rcar_thermal_irq_disable(priv);
-		thermal_zone_device_unregister(priv->zone);
-	}
-
-	pm_runtime_put(dev);
-	pm_runtime_disable(dev);
+	rcar_thermal_remove(pdev);
 
 	return ret;
 }
 
-static int rcar_thermal_remove(struct platform_device *pdev)
-{
-	struct rcar_thermal_common *common = platform_get_drvdata(pdev);
-	struct device *dev = &pdev->dev;
-	struct rcar_thermal_priv *priv;
-
-	rcar_thermal_for_each_priv(priv, common) {
-		if (rcar_has_irq_support(priv))
-			rcar_thermal_irq_disable(priv);
-		thermal_zone_device_unregister(priv->zone);
-	}
-
-	pm_runtime_put(dev);
-	pm_runtime_disable(dev);
-
-	return 0;
-}
-
 static const struct of_device_id rcar_thermal_dt_ids[] = {
 	{ .compatible = "renesas,rcar-thermal", },
 	{},