[5/6] thermal/drivers/rcar: Convert to devm_platform_ioremap_resource()

Message ID 20230626124334.15100-5-frank.li@vivo.com
State New
Headers
Series [1/6] drivers/thermal/k3: Convert to devm_platform_ioremap_resource() |

Commit Message

李扬韬 June 26, 2023, 12:43 p.m. UTC
  Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/thermal/rcar_thermal.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
  

Comments

Niklas Söderlund June 26, 2023, 4:32 p.m. UTC | #1
Hi Yangtao,

Thanks for your work.

On 2023-06-26 20:43:32 +0800, Yangtao Li wrote:
> Use devm_platform_ioremap_resource() to simplify code.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>  drivers/thermal/rcar_thermal.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> index b8571f7090aa..04a52d82022c 100644
> --- a/drivers/thermal/rcar_thermal.c
> +++ b/drivers/thermal/rcar_thermal.c
> @@ -397,7 +397,6 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>  	struct rcar_thermal_common *common;
>  	struct rcar_thermal_priv *priv;
>  	struct device *dev = &pdev->dev;
> -	struct resource *res;
>  	const struct rcar_thermal_chip *chip = of_device_get_match_data(dev);
>  	int mres = 0;
>  	int i;
> @@ -435,9 +434,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>  			 * Then, driver uses common registers
>  			 * rcar_has_irq_support() will be enabled
>  			 */
> -			res = platform_get_resource(pdev, IORESOURCE_MEM,
> -						    mres++);
> -			common->base = devm_ioremap_resource(dev, res);
> +			common->base = devm_platform_ioremap_resource(pdev, mres++);

This change is fine, please post a separate patch for it.

>  			if (IS_ERR(common->base)) {
>  				ret = PTR_ERR(common->base);
>  				goto error_unregister;
> @@ -459,17 +456,13 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>  	}
>  
>  	for (i = 0;; i++) {
> -		res = platform_get_resource(pdev, IORESOURCE_MEM, mres++);
> -		if (!res)
> -			break;

This change is not OK as it changes the behavior of the driver same as 
in patch 5/6.

Nacked-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> -
>  		priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>  		if (!priv) {
>  			ret = -ENOMEM;
>  			goto error_unregister;
>  		}
>  
> -		priv->base = devm_ioremap_resource(dev, res);
> +		priv->base = devm_platform_ioremap_resource(pdev, mres++);
>  		if (IS_ERR(priv->base)) {
>  			ret = PTR_ERR(priv->base);
>  			goto error_unregister;
> -- 
> 2.39.0
>
  

Patch

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index b8571f7090aa..04a52d82022c 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -397,7 +397,6 @@  static int rcar_thermal_probe(struct platform_device *pdev)
 	struct rcar_thermal_common *common;
 	struct rcar_thermal_priv *priv;
 	struct device *dev = &pdev->dev;
-	struct resource *res;
 	const struct rcar_thermal_chip *chip = of_device_get_match_data(dev);
 	int mres = 0;
 	int i;
@@ -435,9 +434,7 @@  static int rcar_thermal_probe(struct platform_device *pdev)
 			 * Then, driver uses common registers
 			 * rcar_has_irq_support() will be enabled
 			 */
-			res = platform_get_resource(pdev, IORESOURCE_MEM,
-						    mres++);
-			common->base = devm_ioremap_resource(dev, res);
+			common->base = devm_platform_ioremap_resource(pdev, mres++);
 			if (IS_ERR(common->base)) {
 				ret = PTR_ERR(common->base);
 				goto error_unregister;
@@ -459,17 +456,13 @@  static int rcar_thermal_probe(struct platform_device *pdev)
 	}
 
 	for (i = 0;; i++) {
-		res = platform_get_resource(pdev, IORESOURCE_MEM, mres++);
-		if (!res)
-			break;
-
 		priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 		if (!priv) {
 			ret = -ENOMEM;
 			goto error_unregister;
 		}
 
-		priv->base = devm_ioremap_resource(dev, res);
+		priv->base = devm_platform_ioremap_resource(pdev, mres++);
 		if (IS_ERR(priv->base)) {
 			ret = PTR_ERR(priv->base);
 			goto error_unregister;