lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180502084308.GF2285@localhost>
Date:   Wed, 2 May 2018 10:43:08 +0200
From:   Johan Hovold <johan@...nel.org>
To:     Arvind Yadav <arvind.yadav.cs@...il.com>
Cc:     hvaibhav.linux@...il.com, johan@...nel.org, elder@...nel.org,
        gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
        greybus-dev@...ts.linaro.org, devel@...verdev.osuosl.org
Subject: Re: [PATCH v2] staging: greybus: Use gpio_is_valid()

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@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ