[5/8] ata: sata_rcar: Convert to devm_platform_ioremap_resource()

Message ID 20230706124239.23366-5-frank.li@vivo.com
State New
Headers
Series [1/8] ata: ahci_octeon: Convert to devm_platform_ioremap_resource() |

Commit Message

李扬韬 July 6, 2023, 12:42 p.m. UTC
  Use devm_platform_ioremap_resource() to simplify code.

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

Comments

Geert Uytterhoeven July 6, 2023, 1:05 p.m. UTC | #1
Hi Yangtao,

On Thu, Jul 6, 2023 at 2:44 PM Yangtao Li <frank.li@vivo.com> wrote:
> Use devm_platform_ioremap_resource() to simplify code.
>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>

Thanks for your patch!

> --- a/drivers/ata/sata_rcar.c
> +++ b/drivers/ata/sata_rcar.c
> @@ -861,15 +861,11 @@ static int sata_rcar_probe(struct platform_device *pdev)
>         struct device *dev = &pdev->dev;
>         struct ata_host *host;
>         struct sata_rcar_priv *priv;
> -       struct resource *mem;
> -       int irq;
> -       int ret = 0;
> +       int irq, ret;
>
>         irq = platform_get_irq(pdev, 0);
>         if (irq < 0)
>                 return irq;
> -       if (!irq)
> -               return -EINVAL;

Why this change?
It is not documented in the patch description.

>
>         priv = devm_kzalloc(dev, sizeof(struct sata_rcar_priv), GFP_KERNEL);
>         if (!priv)
> @@ -890,8 +886,7 @@ static int sata_rcar_probe(struct platform_device *pdev)
>
>         host->private_data = priv;
>
> -       mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -       priv->base = devm_ioremap_resource(dev, mem);
> +       priv->base = devm_platform_ioremap_resource(pdev, 0);
>         if (IS_ERR(priv->base)) {
>                 ret = PTR_ERR(priv->base);
>                 goto err_pm_put;

The rest LGTM.

Gr{oetje,eeting}s,

                        Geert
  
Sergey Shtylyov July 6, 2023, 9:10 p.m. UTC | #2
On 7/6/23 3:42 PM, Yangtao Li wrote:

> Use devm_platform_ioremap_resource() to simplify code.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>  drivers/ata/sata_rcar.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c
> index 34790f15c1b8..63f8337c2a98 100644
> --- a/drivers/ata/sata_rcar.c
> +++ b/drivers/ata/sata_rcar.c
> @@ -861,15 +861,11 @@ static int sata_rcar_probe(struct platform_device *pdev)
>  	struct device *dev = &pdev->dev;
>  	struct ata_host *host;
>  	struct sata_rcar_priv *priv;
> -	struct resource *mem;
> -	int irq;
> -	int ret = 0;
> +	int irq, ret;

   This unneeded init of ret should be in a separate patch.

>  
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0)
>  		return irq;
> -	if (!irq)
> -		return -EINVAL;

   This is a separate issue too. I thought I've removed this myself
but apparently not, the commit [1] took shamefully long time to merge... :-(

[...]
> @@ -890,8 +886,7 @@ static int sata_rcar_probe(struct platform_device *pdev)
>  
>  	host->private_data = priv;
>  
> -	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	priv->base = devm_ioremap_resource(dev, mem);
> +	priv->base = devm_platform_ioremap_resource(pdev, 0);
>  	if (IS_ERR(priv->base)) {
>  		ret = PTR_ERR(priv->base);
>  		goto err_pm_put;

   The (documented) change looks OK.


[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ce753ad1549cbe9ccaea4c06a1f5fa47432c8289

MBR, Seregy
  
Damien Le Moal July 6, 2023, 11:37 p.m. UTC | #3
On 7/6/23 21:42, Yangtao Li wrote:
> Use devm_platform_ioremap_resource() to simplify code.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>  drivers/ata/sata_rcar.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c
> index 34790f15c1b8..63f8337c2a98 100644
> --- a/drivers/ata/sata_rcar.c
> +++ b/drivers/ata/sata_rcar.c
> @@ -861,15 +861,11 @@ static int sata_rcar_probe(struct platform_device *pdev)
>  	struct device *dev = &pdev->dev;
>  	struct ata_host *host;
>  	struct sata_rcar_priv *priv;
> -	struct resource *mem;
> -	int irq;
> -	int ret = 0;
> +	int irq, ret;
>  
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0)
>  		return irq;
> -	if (!irq)
> -		return -EINVAL;

Same comment as Geert: this is OK to remove, but make that a different
patch.

>  
>  	priv = devm_kzalloc(dev, sizeof(struct sata_rcar_priv), GFP_KERNEL);
>  	if (!priv)
> @@ -890,8 +886,7 @@ static int sata_rcar_probe(struct platform_device *pdev)
>  
>  	host->private_data = priv;
>  
> -	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	priv->base = devm_ioremap_resource(dev, mem);
> +	priv->base = devm_platform_ioremap_resource(pdev, 0);
>  	if (IS_ERR(priv->base)) {
>  		ret = PTR_ERR(priv->base);
>  		goto err_pm_put;
  

Patch

diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c
index 34790f15c1b8..63f8337c2a98 100644
--- a/drivers/ata/sata_rcar.c
+++ b/drivers/ata/sata_rcar.c
@@ -861,15 +861,11 @@  static int sata_rcar_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct ata_host *host;
 	struct sata_rcar_priv *priv;
-	struct resource *mem;
-	int irq;
-	int ret = 0;
+	int irq, ret;
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
-	if (!irq)
-		return -EINVAL;
 
 	priv = devm_kzalloc(dev, sizeof(struct sata_rcar_priv), GFP_KERNEL);
 	if (!priv)
@@ -890,8 +886,7 @@  static int sata_rcar_probe(struct platform_device *pdev)
 
 	host->private_data = priv;
 
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	priv->base = devm_ioremap_resource(dev, mem);
+	priv->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(priv->base)) {
 		ret = PTR_ERR(priv->base);
 		goto err_pm_put;