Skip to contentSkip to conversation

leds: pwm-multicolor: fix multicolor PWM LED lights up without any setting

PATCH In review FUKAUMI Naoki 2 participants 11 messages Aug 16, 2024 – Dec 16, 2024 LED

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds: pwm-multicolor: fix multicolor PWM LED lights up without any setting

from drivers/leds/leds-pwm.c:led_pwm_set(),

/*
* Disabling a PWM doesn't guarantee that it emits the inactive level.
* So keep it on. Only for suspending the PWM should be disabled because
* otherwise it refuses to suspend. The possible downside is that the
* LED might stay (or even go) on.
*/

do the same in led_pwm_mc_set().

this fixes LEDs light up without any setting (i.e. brightness is 0) on Radxa E25.

---
 drivers/leds/rgb/leds-pwm-multicolor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/rgb/leds-pwm-multicolor.c +1 -1
index e1a81e0109e8..7155339c075e 100644
@@ -50,7 +50,7 @@ static int led_pwm_mc_set(struct led_classdev *cdev,
 			duty = priv->leds[i].state.period - duty;
 
 		priv->leds[i].state.duty_cycle = duty;
-		priv->leds[i].state.enabled = duty > 0;
+		priv->leds[i].state.enabled = !(cdev->flags & LED_SUSPENDED);
 		ret = pwm_apply_might_sleep(priv->leds[i].pwm,
 					    &priv->leds[i].state);
 		if (ret)
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 9 lines · FUKAUMI Naoki

from drivers/leds/leds-pwm.c:led_pwm_set(),

/*
* Disabling a PWM doesn't guarantee that it emits the inactive level.
* So keep it on. Only for suspending the PWM should be disabled because
* otherwise it refuses to suspend. The possible downside is that the
* LED might stay (or even go) on.
*/

Quoted 4 lines

do the same in led_pwm_mc_set().

this fixes LEDs light up without any setting (i.e. brightness is 0) on Radxa E25.

Please redraft the commit message into proper sentences, complete with correct grammar. All sentences should start with an uppercase char.

Copying comment-blocks into commit messages to save authors from writing one isn't really the done thing.

Quoted 21 lines
---
 drivers/leds/rgb/leds-pwm-multicolor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/rgb/leds-pwm-multicolor.c +1 -1
index e1a81e0109e8..7155339c075e 100644
@@ -50,7 +50,7 @@ static int led_pwm_mc_set(struct led_classdev *cdev,
 			duty = priv->leds[i].state.period - duty;
 
 		priv->leds[i].state.duty_cycle = duty;
-		priv->leds[i].state.enabled = duty > 0;
+		priv->leds[i].state.enabled = !(cdev->flags & LED_SUSPENDED);
 		ret = pwm_apply_might_sleep(priv->leds[i].pwm,
 					    &priv->leds[i].state);
 		if (ret)
Signature · 1 line
2.43.0
Signature · 1 line
Lee Jones [李琼斯]
#2 lore raw

Hi,

Quoted 11 lines · Lee Jones
Quoted 9 lines · FUKAUMI Naoki

from drivers/leds/leds-pwm.c:led_pwm_set(),

/*
* Disabling a PWM doesn't guarantee that it emits the inactive level.
* So keep it on. Only for suspending the PWM should be disabled because
* otherwise it refuses to suspend. The possible downside is that the
* LED might stay (or even go) on.
*/

Quoted 7 lines
Quoted 4 lines

do the same in led_pwm_mc_set().

this fixes LEDs light up without any setting (i.e. brightness is 0) on Radxa E25.

Please redraft the commit message into proper sentences, complete with correct grammar. All sentences should start with an uppercase char.

Thank you for your review!

I'll do it in next ver.

Quoted 2 lines

Copying comment-blocks into commit messages to save authors from writing one isn't really the done thing.

Sorry, I could not understand this part. What should I do for this?

Best regards,

--
FUKAUMI Naoki
Radxa Computer (Shenzhen) Co., Ltd.

Quoted 22 lines
Quoted 21 lines
---
  drivers/leds/rgb/leds-pwm-multicolor.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/rgb/leds-pwm-multicolor.c +1 -1
index e1a81e0109e8..7155339c075e 100644
@@ -50,7 +50,7 @@ static int led_pwm_mc_set(struct led_classdev *cdev,
  			duty = priv->leds[i].state.period - duty;
 
  		priv->leds[i].state.duty_cycle = duty;
-		priv->leds[i].state.enabled = duty > 0;
+		priv->leds[i].state.enabled = !(cdev->flags & LED_SUSPENDED);
  		ret = pwm_apply_might_sleep(priv->leds[i].pwm,
  					    &priv->leds[i].state);
  		if (ret)
Signature · 1 line
2.43.0
#3 lore raw

Hi,

Quoted 22 lines · FUKAUMI Naoki

Hi,

Quoted 11 lines · Lee Jones
Quoted 9 lines · FUKAUMI Naoki

from drivers/leds/leds-pwm.c:led_pwm_set(),

/*
  * Disabling a PWM doesn't guarantee that it emits the inactive level.
  * So keep it on. Only for suspending the PWM should be disabled because
  * otherwise it refuses to suspend. The possible downside is that the
  * LED might stay (or even go) on.
  */

Quoted 7 lines
Quoted 4 lines

do the same in led_pwm_mc_set().

this fixes LEDs light up without any setting (i.e. brightness is 0) on Radxa E25.

Please redraft the commit message into proper sentences, complete with correct grammar.  All sentences should start with an uppercase char.

Quoted 8 lines

Thank you for your review!

I'll do it in next ver.

Quoted 2 lines

Copying comment-blocks into commit messages to save authors from writing one isn't really the done thing.

Sorry, I could not understand this part. What should I do for this?

I (probably) understand what you said. I need to explain detail in my own words and use correct English.

unfortunately my knowledge about electrical circuits and English is not sufficient for now. I need some time to learn some things for writing "why my fix is correct".

then, I will not be able to send v2 so soon. if someone who understand well about this problem and the fix, feel free to reuse my patch (or make better patch).

Best regards

--
FUKAUMI Naoki
Radxa Computer (Shenzhen) Co., Ltd.

Quoted 27 lines

Best regards,

Signature · 2 lines
FUKAUMI Naoki
Radxa Computer (Shenzhen) Co., Ltd.
Quoted 21 lines
Quoted 20 lines

---
  drivers/leds/rgb/leds-pwm-multicolor.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/rgb/leds-pwm-multicolor.c +1 -1
index e1a81e0109e8..7155339c075e 100644
@@ -50,7 +50,7 @@ static int led_pwm_mc_set(struct led_classdev *cdev,
               duty = priv->leds[i].state.period - duty;
           priv->leds[i].state.duty_cycle = duty;
-        priv->leds[i].state.enabled = duty > 0;
+        priv->leds[i].state.enabled = !(cdev->flags & LED_SUSPENDED);
           ret = pwm_apply_might_sleep(priv->leds[i].pwm,
                           &priv->leds[i].state);
           if (ret)
Signature · 1 line
2.43.0
maintainer
#4 lore raw
Quoted 38 lines · FUKAUMI Naoki

Hi,

Quoted 23 lines · FUKAUMI Naoki

Hi,

Quoted 12 lines · Lee Jones
Quoted 10 lines · FUKAUMI Naoki

from drivers/leds/leds-pwm.c:led_pwm_set(),

/*
  * Disabling a PWM doesn't guarantee that it emits the inactive level.
  * So keep it on. Only for suspending the PWM should be disabled because
  * otherwise it refuses to suspend. The possible downside is that the
  * LED might stay (or even go) on.
  */

Quoted 7 lines
Quoted 4 lines

do the same in led_pwm_mc_set().

this fixes LEDs light up without any setting (i.e. brightness is 0) on Radxa E25.

Please redraft the commit message into proper sentences, complete with correct grammar.  All sentences should start with an uppercase char.

Quoted 8 lines

Thank you for your review!

I'll do it in next ver.

Quoted 2 lines

Copying comment-blocks into commit messages to save authors from writing one isn't really the done thing.

Sorry, I could not understand this part. What should I do for this?

I (probably) understand what you said. I need to explain detail in my own words and use correct English.

Quoted 7 lines

unfortunately my knowledge about electrical circuits and English is not sufficient for now.
I need some time to learn some things for writing "why my fix is correct".

then, I will not be able to send v2 so soon. if someone who understand well about this problem and the fix, feel free to reuse my patch (or make better patch).

You understood enough to read the comment and realise that it was related. Simply reword the comment block that you copied and pasted to explain why this is also relevant to your device.

This is the sort of thing that AI might be able to help you with.

Signature · 1 line
Lee Jones [李琼斯]
#5 lore raw
In reply to FUKAUMI Naoki

Hi,

Could you help me(write good commit message), anyone?

Best regards,

--
FUKAUMI Naoki
Radxa Computer (Shenzhen) Co., Ltd.

Quoted 75 lines · FUKAUMI Naoki

Hi,

Quoted 22 lines · FUKAUMI Naoki

Hi,

Quoted 11 lines · Lee Jones
Quoted 9 lines · FUKAUMI Naoki

from drivers/leds/leds-pwm.c:led_pwm_set(),

/*
  * Disabling a PWM doesn't guarantee that it emits the inactive level.
  * So keep it on. Only for suspending the PWM should be disabled because
  * otherwise it refuses to suspend. The possible downside is that the
  * LED might stay (or even go) on.
  */

Quoted 7 lines
Quoted 4 lines

do the same in led_pwm_mc_set().

this fixes LEDs light up without any setting (i.e. brightness is 0) on Radxa E25.

Please redraft the commit message into proper sentences, complete with correct grammar.  All sentences should start with an uppercase char.

Quoted 8 lines

Thank you for your review!

I'll do it in next ver.

Quoted 2 lines

Copying comment-blocks into commit messages to save authors from writing one isn't really the done thing.

Sorry, I could not understand this part. What should I do for this?

I (probably) understand what you said. I need to explain detail in my own words and use correct English.

unfortunately my knowledge about electrical circuits and English is not sufficient for now. I need some time to learn some things for writing "why my fix is correct".

then, I will not be able to send v2 so soon. if someone who understand well about this problem and the fix, feel free to reuse my patch (or make better patch).

Best regards

Signature · 2 lines
FUKAUMI Naoki
Radxa Computer (Shenzhen) Co., Ltd.
Quoted 27 lines

Best regards,

Signature · 2 lines
FUKAUMI Naoki
Radxa Computer (Shenzhen) Co., Ltd.
Quoted 21 lines
Quoted 20 lines

---
  drivers/leds/rgb/leds-pwm-multicolor.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/rgb/leds-pwm-multicolor.c +1 -1
index e1a81e0109e8..7155339c075e 100644
@@ -50,7 +50,7 @@ static int led_pwm_mc_set(struct led_classdev *cdev,
               duty = priv->leds[i].state.period - duty;
           priv->leds[i].state.duty_cycle = duty;
-        priv->leds[i].state.enabled = duty > 0;
+        priv->leds[i].state.enabled = !(cdev->flags & LED_SUSPENDED);
           ret = pwm_apply_might_sleep(priv->leds[i].pwm,
                           &priv->leds[i].state);
           if (ret)
Signature · 1 line
2.43.0
maintainer
#6 lore raw
Quoted 3 lines · FUKAUMI Naoki

Hi,

Could you help me(write good commit message), anyone?

Surely you know what the changes you authored do and why you authored them? Write out a nice description in your first language then use a free online translation tool to convert it into English. It doesn't have to be a novel. Just describe what you're doing and why it's needed.

Signature · 1 line
Lee Jones [李琼斯]
#7 lore raw

Hi,

Quoted 11 lines · Lee Jones
Quoted 3 lines · FUKAUMI Naoki

Hi,

Could you help me(write good commit message), anyone?

Surely you know what the changes you authored do and why you authored them? Write out a nice description in your first language then use a free online translation tool to convert it into English. It doesn't have to be a novel. Just describe what you're doing and why it's needed.

I have no knowledge about electrical circuits...

Best regards,

--
FUKAUMI Naoki
Radxa Computer (Shenzhen) Co., Ltd.

maintainer
#8 lore raw
Quoted 9 lines · FUKAUMI Naoki

Hi,

Quoted 6 lines · Lee Jones
Quoted 3 lines · FUKAUMI Naoki

Hi,

Could you help me(write good commit message), anyone?

Quoted 7 lines
Quoted 5 lines

Surely you know what the changes you authored do and why you authored them? Write out a nice description in your first language then use a free online translation tool to convert it into English. It doesn't have to be a novel. Just describe what you're doing and why it's needed.

I have no knowledge about electrical circuits...

You must know why you made this change?

Signature · 1 line
Lee Jones [李琼斯]
#9 lore raw

Hi Lee,

Quoted 17 lines · Lee Jones
Quoted 15 lines · FUKAUMI Naoki

Hi,

Quoted 11 lines · Lee Jones
Quoted 3 lines · FUKAUMI Naoki

Hi,

Could you help me(write good commit message), anyone?

Surely you know what the changes you authored do and why you authored them? Write out a nice description in your first language then use a free online translation tool to convert it into English. It doesn't have to be a novel. Just describe what you're doing and why it's needed.

Quoted 3 lines
Quoted 1 line

I have no knowledge about electrical circuits...

You must know why you made this change?

I noticed strange behavior on Radxa E25 which have pwm-multicolor.

I compared leds-pwm.c:led_pwm_set() and leds-pwm-multicolor.c:led_pwm_mc_set(), and found difference.

Do the same fixed the problem, so I just thought this is correct fix. No knowledge was required.

Btw, this is enough for me.

https://lore.kernel.org/linux-leds/[email protected]/T/#t

Please ignore my patch. Thank you very much for your help, and sorry for wasting your time.

Best regards,

--
FUKAUMI Naoki
Radxa Computer (Shenzhen) Co., Ltd.

maintainer
#10 lore raw
Quoted 32 lines · FUKAUMI Naoki

Hi Lee,

Quoted 17 lines · Lee Jones
Quoted 15 lines · FUKAUMI Naoki

Hi,

Quoted 11 lines · Lee Jones
Quoted 3 lines · FUKAUMI Naoki

Hi,

Could you help me(write good commit message), anyone?

Surely you know what the changes you authored do and why you authored them? Write out a nice description in your first language then use a free online translation tool to convert it into English. It doesn't have to be a novel. Just describe what you're doing and why it's needed.

Quoted 3 lines
Quoted 1 line

I have no knowledge about electrical circuits...

You must know why you made this change?

I noticed strange behavior on Radxa E25 which have pwm-multicolor.

I compared leds-pwm.c:led_pwm_set() and leds-pwm-multicolor.c:led_pwm_mc_set(), and found difference.

Do the same fixed the problem, so I just thought this is correct fix. No knowledge was required.

Quoted 6 lines

Btw, this is enough for me.

https://lore.kernel.org/linux-leds/[email protected]/T/#t

Please ignore my patch. Thank you very much for your help, and sorry for wasting your time.

You didn't waste my time.

If you see any other issues, please feel free to submit them.

Signature · 1 line
Lee Jones [李琼斯]