All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: "Pali Rohár" <pali@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Linus Walleij <linus.walleij@linaro.org>,
	soc@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND 2/8] leds: syscon: Implement support for active-low property
Date: Thu, 23 Feb 2023 14:25:45 +0000	[thread overview]
Message-ID: <Y/d3aS4pQP1xhSBo@google.com> (raw)
In-Reply-To: <20221226123630.6515-3-pali@kernel.org>

On Mon, 26 Dec 2022, Pali Rohár wrote:

> This new active-low property specify that LED has inverted logic
> (0 - enable LED, 1 - disable LED).
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/leds/leds-syscon.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)

Reviewed-by: Lee Jones <lee@kernel.org>

> diff --git a/drivers/leds/leds-syscon.c b/drivers/leds/leds-syscon.c
> index 7eddb8ecb44e..5e605d8438e9 100644
> --- a/drivers/leds/leds-syscon.c
> +++ b/drivers/leds/leds-syscon.c
> @@ -29,6 +29,7 @@ struct syscon_led {
>  	struct regmap *map;
>  	u32 offset;
>  	u32 mask;
> +	bool active_low;
>  	bool state;
>  };
>  
> @@ -41,10 +42,10 @@ static void syscon_led_set(struct led_classdev *led_cdev,
>  	int ret;
>  
>  	if (value == LED_OFF) {
> -		val = 0;
> +		val = sled->active_low ? sled->mask : 0;
>  		sled->state = false;
>  	} else {
> -		val = sled->mask;
> +		val = sled->active_low ? 0 : sled->mask;
>  		sled->state = true;
>  	}
>  
> @@ -85,6 +86,8 @@ static int syscon_led_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	if (of_property_read_u32(np, "mask", &sled->mask))
>  		return -EINVAL;
> +	if (of_find_property(np, "active-low", NULL))
> +		sled->active_low = true;
>  
>  	state = of_get_property(np, "default-state", NULL);
>  	if (state) {
> @@ -95,17 +98,20 @@ static int syscon_led_probe(struct platform_device *pdev)
>  			if (ret < 0)
>  				return ret;
>  			sled->state = !!(val & sled->mask);
> +			if (sled->active_low)
> +				sled->state = !sled->state;
>  		} else if (!strcmp(state, "on")) {
>  			sled->state = true;
>  			ret = regmap_update_bits(map, sled->offset,
>  						 sled->mask,
> -						 sled->mask);
> +						 sled->active_low ? 0 : sled->mask);
>  			if (ret < 0)
>  				return ret;
>  		} else {
>  			sled->state = false;
>  			ret = regmap_update_bits(map, sled->offset,
> -						 sled->mask, 0);
> +						 sled->mask,
> +						 sled->active_low ? sled->mask : 0);
>  			if (ret < 0)
>  				return ret;
>  		}
> -- 
> 2.20.1
> 

-- 
Lee Jones [李琼斯]

  reply	other threads:[~2023-02-23 14:25 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-26 12:36 [PATCH RESEND 0/8] Resend LED patches Pali Rohár
2022-12-26 12:36 ` [PATCH RESEND 1/8] dt-bindings: leds: register-bit-led: Add active-low property Pali Rohár
2023-01-27 11:16   ` Lee Jones
2023-02-23 14:22     ` Lee Jones
2023-02-23 16:48       ` Pali Rohár
2023-02-23 20:59         ` Linus Walleij
2023-02-24  8:42           ` Krzysztof Kozlowski
2022-12-26 12:36 ` [PATCH RESEND 2/8] leds: syscon: Implement support for " Pali Rohár
2023-02-23 14:25   ` Lee Jones [this message]
2022-12-26 12:36 ` [PATCH RESEND 3/8] powerpc/85xx: DTS: Add CPLD definitions for P1021RDB Combo Board CPL Design Pali Rohár
2022-12-26 12:36 ` [PATCH RESEND 4/8] dt-bindings: leds: Add cznic,turris1x-leds.yaml binding Pali Rohár
2023-01-27 11:16   ` Lee Jones
2023-02-24  9:15     ` Krzysztof Kozlowski
2023-02-24  9:38       ` Lee Jones
2023-03-09 20:42         ` Pali Rohár
2023-03-11 11:47           ` Krzysztof Kozlowski
2023-02-24  9:13   ` Krzysztof Kozlowski
2022-12-26 12:36 ` [PATCH RESEND 5/8] leds: Add support for Turris 1.x LEDs Pali Rohár
2023-01-27 11:20   ` Lee Jones
2023-02-02 23:46     ` Pali Rohár
2023-02-24  9:25     ` Krzysztof Kozlowski
2023-02-24  9:37       ` Lee Jones
2023-02-24  9:22   ` Krzysztof Kozlowski
2023-02-24  9:28   ` Lee Jones
2023-03-09 20:35     ` Pali Rohár
2022-12-26 12:36 ` [PATCH RESEND 6/8] leds: turris-omnia: support HW controlled mode via private trigger Pali Rohár
2023-02-24  9:32   ` Lee Jones
2022-12-26 12:36 ` [PATCH RESEND 7/8] leds: turris-omnia: initialize multi-intensity to full Pali Rohár
2023-02-24  9:33   ` Lee Jones
2022-12-26 12:36 ` [PATCH RESEND 8/8] leds: turris-omnia: change max brightness from 255 to 1 Pali Rohár
2023-02-24  9:34   ` Lee Jones
2023-03-09 20:07     ` Pali Rohár
2023-01-20 16:41 ` [PATCH RESEND 0/8] Resend LED patches Arnd Bergmann
2023-01-20 16:41   ` Arnd Bergmann
2023-01-20 17:15   ` Lee Jones
2023-01-20 17:15     ` Lee Jones
2023-01-20 17:47     ` Arnd Bergmann
2023-01-20 17:47       ` Arnd Bergmann
2023-01-20 20:02       ` Lee Jones
2023-01-20 20:02         ` Lee Jones
2023-01-26 20:07     ` Linus Walleij
2023-01-26 20:07       ` Linus Walleij

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=Y/d3aS4pQP1xhSBo@google.com \
    --to=lee@kernel.org \
    --cc=arnd@arndb.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pali@kernel.org \
    --cc=soc@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.