All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arvind Yadav <arvind.yadav.cs@gmail.com>
To: Johan Hovold <johan@kernel.org>
Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org, greybus-dev@lists.linaro.org
Subject: Re: [PATCH v2] staging: greybus: Use gpio_is_valid()
Date: Wed, 2 May 2018 15:15:05 +0530	[thread overview]
Message-ID: <2aa263ef-1bbc-69fc-c007-303e59517081@gmail.com> (raw)
In-Reply-To: <20180502084308.GF2285@localhost>



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

  reply	other threads:[~2018-05-02  9:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2018-05-02  9:57     ` Johan Hovold
2018-05-02 10:50       ` Arvind Yadav

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2aa263ef-1bbc-69fc-c007-303e59517081@gmail.com \
    --to=arvind.yadav.cs@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.