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] [day] [month] [year] [list]
Message-ID: <d08f3202-54f1-4c5a-01bd-70816a917b50@wanadoo.fr>
Date:   Fri, 8 Apr 2022 20:23:22 +0200
From:   Marion & Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     Markuss Broks <markuss.broks@...il.com>,
        linux-kernel@...r.kernel.org
Cc:     phone-devel@...r.kernel.org, ~postmarketos/upstreaming@...ts.sr.ht,
        Pavel Machek <pavel@....cz>, Rob Herring <robh+dt@...nel.org>,
        Linus Walleij <linus.walleij@...aro.org>,
        linux-leds@...r.kernel.org, devicetree@...r.kernel.org
Subject: Re: [PATCH v5 2/2] leds: ktd2692: Make aux-gpios optional


Le 08/04/2022 à 19:59, Markuss Broks a écrit :
> Make the AUX pin optional, since it isn't a core part of functionality,
> and the device is designed to be operational with only one CTRL pin.
>
> Also pick up maintenance for the LED driver and the yaml bindings.
>
> Signed-off-by: Markuss Broks <markuss.broks@...il.com>
> ---
>   MAINTAINERS                       | 6 ++++++
>   drivers/leds/flash/leds-ktd2692.c | 4 ++--
>   2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 2db49ea7ae55..8ef5667a1d98 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -10479,6 +10479,12 @@ S:	Maintained
>   F:	Documentation/devicetree/bindings/leds/backlight/kinetic,ktd253.yaml
>   F:	drivers/video/backlight/ktd253-backlight.c
>   
> +KTD2692 FLASH LED DRIVER
> +M:	Markuss Broks <markuss.broks@...il.com>
> +S:	Maintained
> +F:	Documentation/devicetree/bindings/leds/backlight/kinetic,ktd2692.yaml
> +F:	drivers/leds/flash/leds-ktd2692.yaml
> +
>   KTEST
>   M:	Steven Rostedt <rostedt@...dmis.org>
>   M:	John Hawley <warthog9@...lescrag.net>
> diff --git a/drivers/leds/flash/leds-ktd2692.c b/drivers/leds/flash/leds-ktd2692.c
> index f341da1503a4..fc9c2e441caa 100644
> --- a/drivers/leds/flash/leds-ktd2692.c
> +++ b/drivers/leds/flash/leds-ktd2692.c
> @@ -284,8 +284,8 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
>   		return ret;
>   	}
>   
> -	led->aux_gpio = devm_gpiod_get(dev, "aux", GPIOD_ASIS);
> -	ret = PTR_ERR_OR_ZERO(led->aux_gpio);
> +	led->aux_gpio = devm_gpiod_get_optional(dev, "aux", GPIOD_ASIS);
> +	ret = PTR_ERR(led->aux_gpio);
>   	if (ret) {
>   		dev_err(dev, "cannot get aux-gpios %d\n", ret);
>   		return ret;

Hi,

Sorry if I was unclear. What I was meaning is below.

This v5 is just wrong. If 'led->aux_gpio' is a valid pointer, then 
'PTR_ERR(led->aux_gpio)' will be non-0 and you will bail-out with a 
pointless error value.

PTR_ERR(x) is a valid error value if IS_ERR(x) is true. Otherwise it is 
just 'x' casted as a long. So if 'x' is valid, it can be anything.


What I had in mind was more something like:

@@ -284,10 +284,9 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
  		return ret;
  	}
  
-	led->aux_gpio = devm_gpiod_get(dev, "aux", GPIOD_ASIS);
-	ret = PTR_ERR_OR_ZERO(led->aux_gpio);
-	if (ret) {
-		dev_err(dev, "cannot get aux-gpios %d\n", ret);
+	led->aux_gpio = devm_gpiod_get_optional(dev, "aux", GPIOD_ASIS);
+	if (IS_ERR(led->aux_gpio)) {
+		ret = PTR_ERR(led->aux_gpio);
+		dev_err(dev, "cannot get aux-gpios: %d\n", ret);
  		return ret;
  	}
  


I guess that using PTR_ERR_OR_ZERO() is an option (like in the original 
code) but personally I find it less readable (but it is just a matter of 
taste)

CJ

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ