[RFT,3/3] gpio: eic-sprd: use devm_platform_ioremap_resource()

Message ID 20230912094519.22769-3-brgl@bgdev.pl
State New
Headers
Series [RFT,1/3] gpio: eic-sprd: unregister from the irq notifier on remove() |

Commit Message

Bartosz Golaszewski Sept. 12, 2023, 9:45 a.m. UTC
  From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Make two calls into one by using devm_platform_ioremap_resource().

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-eic-sprd.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
  

Comments

Baolin Wang Sept. 12, 2023, 10:05 a.m. UTC | #1
On 9/12/2023 5:45 PM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Make two calls into one by using devm_platform_ioremap_resource().
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Please don't do this. See the previous commit: 
4ed7d7dd4890bb8120a3e77c16191a695fdfcc5a ("Revert "gpio: eic-sprd: Use 
devm_platform_ioremap_resource()"")

> ---
>   drivers/gpio/gpio-eic-sprd.c | 7 +------
>   1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c
> index be7f2fa5aa7b..1e548e4e4cb8 100644
> --- a/drivers/gpio/gpio-eic-sprd.c
> +++ b/drivers/gpio/gpio-eic-sprd.c
> @@ -594,7 +594,6 @@ static int sprd_eic_probe(struct platform_device *pdev)
>   	struct device *dev = &pdev->dev;
>   	struct gpio_irq_chip *irq;
>   	struct sprd_eic *sprd_eic;
> -	struct resource *res;
>   	int ret, i;
>   
>   	pdata = of_device_get_match_data(dev);
> @@ -621,11 +620,7 @@ static int sprd_eic_probe(struct platform_device *pdev)
>   		 * have one bank EIC, thus base[1] and base[2] can be
>   		 * optional.
>   		 */
> -		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
> -		if (!res)
> -			break;
> -
> -		sprd_eic->base[i] = devm_ioremap_resource(dev, res);
> +		sprd_eic->base[i] = devm_platform_ioremap_resource(pdev, i);
>   		if (IS_ERR(sprd_eic->base[i]))
>   			return PTR_ERR(sprd_eic->base[i]);
>   	}
  
Bartosz Golaszewski Sept. 12, 2023, 10:09 a.m. UTC | #2
On Tue, Sep 12, 2023 at 12:05 PM Baolin Wang
<baolin.wang@linux.alibaba.com> wrote:
>
>
>
> On 9/12/2023 5:45 PM, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > Make two calls into one by using devm_platform_ioremap_resource().
> >
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Please don't do this. See the previous commit:
> 4ed7d7dd4890bb8120a3e77c16191a695fdfcc5a ("Revert "gpio: eic-sprd: Use
> devm_platform_ioremap_resource()"")
>

Ah, I see. Dropped. Could use a comment describing the problem though.

Bart

> > ---
> >   drivers/gpio/gpio-eic-sprd.c | 7 +------
> >   1 file changed, 1 insertion(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c
> > index be7f2fa5aa7b..1e548e4e4cb8 100644
> > --- a/drivers/gpio/gpio-eic-sprd.c
> > +++ b/drivers/gpio/gpio-eic-sprd.c
> > @@ -594,7 +594,6 @@ static int sprd_eic_probe(struct platform_device *pdev)
> >       struct device *dev = &pdev->dev;
> >       struct gpio_irq_chip *irq;
> >       struct sprd_eic *sprd_eic;
> > -     struct resource *res;
> >       int ret, i;
> >
> >       pdata = of_device_get_match_data(dev);
> > @@ -621,11 +620,7 @@ static int sprd_eic_probe(struct platform_device *pdev)
> >                * have one bank EIC, thus base[1] and base[2] can be
> >                * optional.
> >                */
> > -             res = platform_get_resource(pdev, IORESOURCE_MEM, i);
> > -             if (!res)
> > -                     break;
> > -
> > -             sprd_eic->base[i] = devm_ioremap_resource(dev, res);
> > +             sprd_eic->base[i] = devm_platform_ioremap_resource(pdev, i);
> >               if (IS_ERR(sprd_eic->base[i]))
> >                       return PTR_ERR(sprd_eic->base[i]);
> >       }
  
andy@kernel.org Sept. 12, 2023, 10:37 a.m. UTC | #3
On Tue, Sep 12, 2023 at 11:45:19AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Make two calls into one by using devm_platform_ioremap_resource().

...

> -		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
> -		if (!res)
> -			break;
> -
> -		sprd_eic->base[i] = devm_ioremap_resource(dev, res);
> +		sprd_eic->base[i] = devm_platform_ioremap_resource(pdev, i);
>  		if (IS_ERR(sprd_eic->base[i]))
>  			return PTR_ERR(sprd_eic->base[i]);

break != return
  
Baolin Wang Sept. 12, 2023, 11:07 a.m. UTC | #4
On 9/12/2023 6:09 PM, Bartosz Golaszewski wrote:
> On Tue, Sep 12, 2023 at 12:05 PM Baolin Wang
> <baolin.wang@linux.alibaba.com> wrote:
>>
>>
>>
>> On 9/12/2023 5:45 PM, Bartosz Golaszewski wrote:
>>> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>>>
>>> Make two calls into one by using devm_platform_ioremap_resource().
>>>
>>> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>>
>> Please don't do this. See the previous commit:
>> 4ed7d7dd4890bb8120a3e77c16191a695fdfcc5a ("Revert "gpio: eic-sprd: Use
>> devm_platform_ioremap_resource()"")
>>
> 
> Ah, I see. Dropped. Could use a comment describing the problem though.

Yes, I think so, in case someone does the same thing in the future.

>>> ---
>>>    drivers/gpio/gpio-eic-sprd.c | 7 +------
>>>    1 file changed, 1 insertion(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c
>>> index be7f2fa5aa7b..1e548e4e4cb8 100644
>>> --- a/drivers/gpio/gpio-eic-sprd.c
>>> +++ b/drivers/gpio/gpio-eic-sprd.c
>>> @@ -594,7 +594,6 @@ static int sprd_eic_probe(struct platform_device *pdev)
>>>        struct device *dev = &pdev->dev;
>>>        struct gpio_irq_chip *irq;
>>>        struct sprd_eic *sprd_eic;
>>> -     struct resource *res;
>>>        int ret, i;
>>>
>>>        pdata = of_device_get_match_data(dev);
>>> @@ -621,11 +620,7 @@ static int sprd_eic_probe(struct platform_device *pdev)
>>>                 * have one bank EIC, thus base[1] and base[2] can be
>>>                 * optional.
>>>                 */
>>> -             res = platform_get_resource(pdev, IORESOURCE_MEM, i);
>>> -             if (!res)
>>> -                     break;
>>> -
>>> -             sprd_eic->base[i] = devm_ioremap_resource(dev, res);
>>> +             sprd_eic->base[i] = devm_platform_ioremap_resource(pdev, i);
>>>                if (IS_ERR(sprd_eic->base[i]))
>>>                        return PTR_ERR(sprd_eic->base[i]);
>>>        }
  

Patch

diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c
index be7f2fa5aa7b..1e548e4e4cb8 100644
--- a/drivers/gpio/gpio-eic-sprd.c
+++ b/drivers/gpio/gpio-eic-sprd.c
@@ -594,7 +594,6 @@  static int sprd_eic_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct gpio_irq_chip *irq;
 	struct sprd_eic *sprd_eic;
-	struct resource *res;
 	int ret, i;
 
 	pdata = of_device_get_match_data(dev);
@@ -621,11 +620,7 @@  static int sprd_eic_probe(struct platform_device *pdev)
 		 * have one bank EIC, thus base[1] and base[2] can be
 		 * optional.
 		 */
-		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
-		if (!res)
-			break;
-
-		sprd_eic->base[i] = devm_ioremap_resource(dev, res);
+		sprd_eic->base[i] = devm_platform_ioremap_resource(pdev, i);
 		if (IS_ERR(sprd_eic->base[i]))
 			return PTR_ERR(sprd_eic->base[i]);
 	}