LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2] staging: greybus: Use gpio_is_valid()
@ 2018-04-28  4:35 Arvind Yadav
  2018-04-28 19:58 ` [greybus-dev] " Alex Elder
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Arvind Yadav @ 2018-04-28  4:35 UTC (permalink / raw)
  To: hvaibhav.linux, johan, elder, gregkh; +Cc: devel, greybus-dev, linux-kernel

Replace the manual validity checks for the GPIO with the
gpio_is_valid().

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
---
chnage in v2 :
             Returning invalid gpio as error instead of -ENODEV.

 drivers/staging/greybus/arche-platform.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
index 83254a7..c3a7da5 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -448,7 +448,7 @@ static int arche_platform_probe(struct platform_device *pdev)
 	arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
 							"svc,reset-gpio",
 							0);
-	if (arche_pdata->svc_reset_gpio < 0) {
+	if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
 		dev_err(dev, "failed to get reset-gpio\n");
 		return arche_pdata->svc_reset_gpio;
 	}
@@ -468,7 +468,7 @@ static int arche_platform_probe(struct platform_device *pdev)
 	arche_pdata->svc_sysboot_gpio = of_get_named_gpio(np,
 							  "svc,sysboot-gpio",
 							  0);
-	if (arche_pdata->svc_sysboot_gpio < 0) {
+	if (!gpio_is_valid(arche_pdata->svc_sysboot_gpio)) {
 		dev_err(dev, "failed to get sysboot gpio\n");
 		return arche_pdata->svc_sysboot_gpio;
 	}
@@ -487,7 +487,7 @@ static int arche_platform_probe(struct platform_device *pdev)
 	arche_pdata->svc_refclk_req = of_get_named_gpio(np,
 							"svc,refclk-req-gpio",
 							0);
-	if (arche_pdata->svc_refclk_req < 0) {
+	if (!gpio_is_valid(arche_pdata->svc_refclk_req)) {
 		dev_err(dev, "failed to get svc clock-req gpio\n");
 		return arche_pdata->svc_refclk_req;
 	}
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [greybus-dev] [PATCH v2] staging: greybus: Use gpio_is_valid()
  2018-04-28  4:35 [PATCH v2] staging: greybus: Use gpio_is_valid() Arvind Yadav
@ 2018-04-28 19:58 ` Alex Elder
  2018-05-02  5:44 ` Viresh Kumar
  2018-05-02  8:43 ` Johan Hovold
  2 siblings, 0 replies; 7+ messages in thread
From: Alex Elder @ 2018-04-28 19:58 UTC (permalink / raw)
  To: Arvind Yadav, hvaibhav.linux, johan, elder, gregkh
  Cc: devel, greybus-dev, linux-kernel

On 04/27/2018 11:35 PM, Arvind Yadav wrote:
> Replace the manual validity checks for the GPIO with the
> gpio_is_valid().
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>

Looks good.

Reviewed-by: Alex Elder <elder@linaro.org>

> ---
> chnage in v2 :
>              Returning invalid gpio as error instead of -ENODEV.
> 
>  drivers/staging/greybus/arche-platform.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
> index 83254a7..c3a7da5 100644
> --- a/drivers/staging/greybus/arche-platform.c
> +++ b/drivers/staging/greybus/arche-platform.c
> @@ -448,7 +448,7 @@ static int arche_platform_probe(struct platform_device *pdev)
>  	arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
>  							"svc,reset-gpio",
>  							0);
> -	if (arche_pdata->svc_reset_gpio < 0) {
> +	if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
>  		dev_err(dev, "failed to get reset-gpio\n");
>  		return arche_pdata->svc_reset_gpio;
>  	}
> @@ -468,7 +468,7 @@ static int arche_platform_probe(struct platform_device *pdev)
>  	arche_pdata->svc_sysboot_gpio = of_get_named_gpio(np,
>  							  "svc,sysboot-gpio",
>  							  0);
> -	if (arche_pdata->svc_sysboot_gpio < 0) {
> +	if (!gpio_is_valid(arche_pdata->svc_sysboot_gpio)) {
>  		dev_err(dev, "failed to get sysboot gpio\n");
>  		return arche_pdata->svc_sysboot_gpio;
>  	}
> @@ -487,7 +487,7 @@ static int arche_platform_probe(struct platform_device *pdev)
>  	arche_pdata->svc_refclk_req = of_get_named_gpio(np,
>  							"svc,refclk-req-gpio",
>  							0);
> -	if (arche_pdata->svc_refclk_req < 0) {
> +	if (!gpio_is_valid(arche_pdata->svc_refclk_req)) {
>  		dev_err(dev, "failed to get svc clock-req gpio\n");
>  		return arche_pdata->svc_refclk_req;
>  	}
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [greybus-dev] [PATCH v2] staging: greybus: Use gpio_is_valid()
  2018-04-28  4:35 [PATCH v2] staging: greybus: Use gpio_is_valid() Arvind Yadav
  2018-04-28 19:58 ` [greybus-dev] " Alex Elder
@ 2018-05-02  5:44 ` Viresh Kumar
  2018-05-02  8:43 ` Johan Hovold
  2 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2018-05-02  5:44 UTC (permalink / raw)
  To: Arvind Yadav
  Cc: hvaibhav.linux, johan, elder, gregkh, devel, greybus-dev, linux-kernel

On 28-04-18, 10:05, Arvind Yadav wrote:
> Replace the manual validity checks for the GPIO with the
> gpio_is_valid().
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
> chnage in v2 :
>              Returning invalid gpio as error instead of -ENODEV.
> 
>  drivers/staging/greybus/arche-platform.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
> index 83254a7..c3a7da5 100644
> --- a/drivers/staging/greybus/arche-platform.c
> +++ b/drivers/staging/greybus/arche-platform.c
> @@ -448,7 +448,7 @@ static int arche_platform_probe(struct platform_device *pdev)
>  	arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
>  							"svc,reset-gpio",
>  							0);
> -	if (arche_pdata->svc_reset_gpio < 0) {
> +	if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
>  		dev_err(dev, "failed to get reset-gpio\n");
>  		return arche_pdata->svc_reset_gpio;
>  	}
> @@ -468,7 +468,7 @@ static int arche_platform_probe(struct platform_device *pdev)
>  	arche_pdata->svc_sysboot_gpio = of_get_named_gpio(np,
>  							  "svc,sysboot-gpio",
>  							  0);
> -	if (arche_pdata->svc_sysboot_gpio < 0) {
> +	if (!gpio_is_valid(arche_pdata->svc_sysboot_gpio)) {
>  		dev_err(dev, "failed to get sysboot gpio\n");
>  		return arche_pdata->svc_sysboot_gpio;
>  	}
> @@ -487,7 +487,7 @@ static int arche_platform_probe(struct platform_device *pdev)
>  	arche_pdata->svc_refclk_req = of_get_named_gpio(np,
>  							"svc,refclk-req-gpio",
>  							0);
> -	if (arche_pdata->svc_refclk_req < 0) {
> +	if (!gpio_is_valid(arche_pdata->svc_refclk_req)) {
>  		dev_err(dev, "failed to get svc clock-req gpio\n");
>  		return arche_pdata->svc_refclk_req;
>  	}

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] staging: greybus: Use gpio_is_valid()
  2018-04-28  4:35 [PATCH v2] staging: greybus: Use gpio_is_valid() Arvind Yadav
  2018-04-28 19:58 ` [greybus-dev] " Alex Elder
  2018-05-02  5:44 ` Viresh Kumar
@ 2018-05-02  8:43 ` Johan Hovold
  2018-05-02  9:45   ` Arvind Yadav
  2 siblings, 1 reply; 7+ messages in thread
From: Johan Hovold @ 2018-05-02  8:43 UTC (permalink / raw)
  To: Arvind Yadav; +Cc: devel, gregkh, johan, linux-kernel, greybus-dev

On Sat, Apr 28, 2018 at 10:05:39AM +0530, Arvind Yadav wrote:
> Replace the manual validity checks for the GPIO with the
> gpio_is_valid().
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
> chnage in v2 :
>              Returning invalid gpio as error instead of -ENODEV.
> 
>  drivers/staging/greybus/arche-platform.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
> index 83254a7..c3a7da5 100644
> --- a/drivers/staging/greybus/arche-platform.c
> +++ b/drivers/staging/greybus/arche-platform.c
> @@ -448,7 +448,7 @@ static int arche_platform_probe(struct platform_device *pdev)
>  	arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
>  							"svc,reset-gpio",
>  							0);
> -	if (arche_pdata->svc_reset_gpio < 0) {
> +	if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
>  		dev_err(dev, "failed to get reset-gpio\n");
>  		return arche_pdata->svc_reset_gpio;

I'm sorry, but I don't this change is desirable. of_get_named_gpio()
returns a valid gpio number or a negative errno, so there's no need to
use the legacy gpio_is_valid() helper here.

If you grep for of_get_named_gpio() you'll find that some drivers indeed
use that helper this way, but they are in a clear minority.

And ultimately, we want to move to using gpio descriptors anyway.

>  	}
> @@ -468,7 +468,7 @@ static int arche_platform_probe(struct platform_device *pdev)
>  	arche_pdata->svc_sysboot_gpio = of_get_named_gpio(np,
>  							  "svc,sysboot-gpio",
>  							  0);
> -	if (arche_pdata->svc_sysboot_gpio < 0) {
> +	if (!gpio_is_valid(arche_pdata->svc_sysboot_gpio)) {
>  		dev_err(dev, "failed to get sysboot gpio\n");
>  		return arche_pdata->svc_sysboot_gpio;
>  	}
> @@ -487,7 +487,7 @@ static int arche_platform_probe(struct platform_device *pdev)
>  	arche_pdata->svc_refclk_req = of_get_named_gpio(np,
>  							"svc,refclk-req-gpio",
>  							0);
> -	if (arche_pdata->svc_refclk_req < 0) {
> +	if (!gpio_is_valid(arche_pdata->svc_refclk_req)) {
>  		dev_err(dev, "failed to get svc clock-req gpio\n");
>  		return arche_pdata->svc_refclk_req;
>  	}

But if this were to be changed, you'd need to update also the fourth
call to of_get_named_gpio() in this function.

Thanks,
Johan
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] staging: greybus: Use gpio_is_valid()
  2018-05-02  8:43 ` Johan Hovold
@ 2018-05-02  9:45   ` Arvind Yadav
  2018-05-02  9:57     ` Johan Hovold
  0 siblings, 1 reply; 7+ messages in thread
From: Arvind Yadav @ 2018-05-02  9:45 UTC (permalink / raw)
  To: Johan Hovold; +Cc: devel, gregkh, linux-kernel, greybus-dev



On Wednesday 02 May 2018 02:13 PM, Johan Hovold wrote:
> On Sat, Apr 28, 2018 at 10:05:39AM +0530, Arvind Yadav wrote:
>> Replace the manual validity checks for the GPIO with the
>> gpio_is_valid().
>>
>> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
>> ---
>> chnage in v2 :
>>               Returning invalid gpio as error instead of -ENODEV.
>>
>>   drivers/staging/greybus/arche-platform.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
>> index 83254a7..c3a7da5 100644
>> --- a/drivers/staging/greybus/arche-platform.c
>> +++ b/drivers/staging/greybus/arche-platform.c
>> @@ -448,7 +448,7 @@ static int arche_platform_probe(struct platform_device *pdev)
>>   	arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
>>   							"svc,reset-gpio",
>>   							0);
>> -	if (arche_pdata->svc_reset_gpio < 0) {
>> +	if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
>>   		dev_err(dev, "failed to get reset-gpio\n");
>>   		return arche_pdata->svc_reset_gpio;
> I'm sorry, but I don't this change is desirable. of_get_named_gpio()
> returns a valid gpio number or a negative errno, so there's no need to
> use the legacy gpio_is_valid() helper here.
>
> If you grep for of_get_named_gpio() you'll find that some drivers indeed
> use that helper this way, but they are in a clear minority.
>
> And ultimately, we want to move to using gpio descriptors anyway.

We need to check gpio validity. If we are using of_get_named_gpio() or not.
of_get_name_gpio() will read a device node and fetch the value. But 
it'll not
check that gpio is valid or not valid.
>
>>   	}
>> @@ -468,7 +468,7 @@ static int arche_platform_probe(struct platform_device *pdev)
>>   	arche_pdata->svc_sysboot_gpio = of_get_named_gpio(np,
>>   							  "svc,sysboot-gpio",
>>   							  0);
>> -	if (arche_pdata->svc_sysboot_gpio < 0) {
>> +	if (!gpio_is_valid(arche_pdata->svc_sysboot_gpio)) {
>>   		dev_err(dev, "failed to get sysboot gpio\n");
>>   		return arche_pdata->svc_sysboot_gpio;
>>   	}
>> @@ -487,7 +487,7 @@ static int arche_platform_probe(struct platform_device *pdev)
>>   	arche_pdata->svc_refclk_req = of_get_named_gpio(np,
>>   							"svc,refclk-req-gpio",
>>   							0);
>> -	if (arche_pdata->svc_refclk_req < 0) {
>> +	if (!gpio_is_valid(arche_pdata->svc_refclk_req)) {
>>   		dev_err(dev, "failed to get svc clock-req gpio\n");
>>   		return arche_pdata->svc_refclk_req;
>>   	}
> But if this were to be changed, you'd need to update also the fourth
> call to of_get_named_gpio() in this function.

Sorry, I missed it. Thanks for point out. I will add check for this.

~arvind
>
> Thanks,
> Johan

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] staging: greybus: Use gpio_is_valid()
  2018-05-02  9:45   ` Arvind Yadav
@ 2018-05-02  9:57     ` Johan Hovold
  2018-05-02 10:50       ` Arvind Yadav
  0 siblings, 1 reply; 7+ messages in thread
From: Johan Hovold @ 2018-05-02  9:57 UTC (permalink / raw)
  To: Arvind Yadav; +Cc: devel, gregkh, Johan Hovold, linux-kernel, greybus-dev

On Wed, May 02, 2018 at 03:15:05PM +0530, Arvind Yadav wrote:

> On Wednesday 02 May 2018 02:13 PM, Johan Hovold wrote:
> > On Sat, Apr 28, 2018 at 10:05:39AM +0530, Arvind Yadav wrote:
> >> Replace the manual validity checks for the GPIO with the
> >> gpio_is_valid().
> >>
> >> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> >> ---
> >> chnage in v2 :
> >>               Returning invalid gpio as error instead of -ENODEV.
> >>
> >>   drivers/staging/greybus/arche-platform.c | 6 +++---
> >>   1 file changed, 3 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
> >> index 83254a7..c3a7da5 100644
> >> --- a/drivers/staging/greybus/arche-platform.c
> >> +++ b/drivers/staging/greybus/arche-platform.c
> >> @@ -448,7 +448,7 @@ static int arche_platform_probe(struct platform_device *pdev)
> >>   	arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
> >>   							"svc,reset-gpio",
> >>   							0);
> >> -	if (arche_pdata->svc_reset_gpio < 0) {
> >> +	if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
> >>   		dev_err(dev, "failed to get reset-gpio\n");
> >>   		return arche_pdata->svc_reset_gpio;
> >
> > I'm sorry, but I don't this change is desirable. of_get_named_gpio()
> > returns a valid gpio number or a negative errno, so there's no need to
> > use the legacy gpio_is_valid() helper here.
> >
> > If you grep for of_get_named_gpio() you'll find that some drivers indeed
> > use that helper this way, but they are in a clear minority.
> >
> > And ultimately, we want to move to using gpio descriptors anyway.
> 
> We need to check gpio validity. If we are using of_get_named_gpio() or
> not.  of_get_name_gpio() will read a device node and fetch the value.
> But it'll not check that gpio is valid or not valid.

No, I believe you're mistaken here. of_get_named_gpio() does not return
an arbitrary gpio number, unlike what you could possibly find in
legacy board files and for which the gpio_is_valid() helper made sense.

Johan
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] staging: greybus: Use gpio_is_valid()
  2018-05-02  9:57     ` Johan Hovold
@ 2018-05-02 10:50       ` Arvind Yadav
  0 siblings, 0 replies; 7+ messages in thread
From: Arvind Yadav @ 2018-05-02 10:50 UTC (permalink / raw)
  To: Johan Hovold; +Cc: devel, gregkh, linux-kernel, greybus-dev



On Wednesday 02 May 2018 03:27 PM, Johan Hovold wrote:
> On Wed, May 02, 2018 at 03:15:05PM +0530, Arvind Yadav wrote:
>
>> On Wednesday 02 May 2018 02:13 PM, Johan Hovold wrote:
>>> On Sat, Apr 28, 2018 at 10:05:39AM +0530, Arvind Yadav wrote:
>>>> Replace the manual validity checks for the GPIO with the
>>>> gpio_is_valid().
>>>>
>>>> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
>>>> ---
>>>> chnage in v2 :
>>>>                Returning invalid gpio as error instead of -ENODEV.
>>>>
>>>>    drivers/staging/greybus/arche-platform.c | 6 +++---
>>>>    1 file changed, 3 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
>>>> index 83254a7..c3a7da5 100644
>>>> --- a/drivers/staging/greybus/arche-platform.c
>>>> +++ b/drivers/staging/greybus/arche-platform.c
>>>> @@ -448,7 +448,7 @@ static int arche_platform_probe(struct platform_device *pdev)
>>>>    	arche_pdata->svc_reset_gpio = of_get_named_gpio(np,
>>>>    							"svc,reset-gpio",
>>>>    							0);
>>>> -	if (arche_pdata->svc_reset_gpio < 0) {
>>>> +	if (!gpio_is_valid(arche_pdata->svc_reset_gpio)) {
>>>>    		dev_err(dev, "failed to get reset-gpio\n");
>>>>    		return arche_pdata->svc_reset_gpio;
>>> I'm sorry, but I don't this change is desirable. of_get_named_gpio()
>>> returns a valid gpio number or a negative errno, so there's no need to
>>> use the legacy gpio_is_valid() helper here.
>>>
>>> If you grep for of_get_named_gpio() you'll find that some drivers indeed
>>> use that helper this way, but they are in a clear minority.
>>>
>>> And ultimately, we want to move to using gpio descriptors anyway.
>> We need to check gpio validity. If we are using of_get_named_gpio() or
>> not.  of_get_name_gpio() will read a device node and fetch the value.
>> But it'll not check that gpio is valid or not valid.
> No, I believe you're mistaken here. of_get_named_gpio() does not return
> an arbitrary gpio number, unlike what you could possibly find in
> legacy board files and for which the gpio_is_valid() helper made sense.
>
> Johan
Yes, You are coorect. It'll read gpio form gpio device node. Which means
it'll read from device tree node. without finding a valid entry. It'll 
return
an error.

~arvind

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-05-02 10:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-28  4:35 [PATCH v2] staging: greybus: Use gpio_is_valid() Arvind Yadav
2018-04-28 19:58 ` [greybus-dev] " Alex Elder
2018-05-02  5:44 ` Viresh Kumar
2018-05-02  8:43 ` Johan Hovold
2018-05-02  9:45   ` Arvind Yadav
2018-05-02  9:57     ` Johan Hovold
2018-05-02 10:50       ` Arvind Yadav

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).