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: <50bbd767-b0e0-4788-975b-f5d9598208e5@chaosfield.at>
Date: Mon, 2 Dec 2024 13:07:51 +0100
From: Jakob Riepler <jakob+lkml@...osfield.at>
To: Pavel Machek <pavel@....cz>, Lee Jones <lee@...nel.org>
Cc: linux-leds@...r.kernel.org, linux-kernel@...r.kernel.org,
 Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
Subject: [PATCH v2] leds: pwm-multicolor: Disable PWM when going to suspend

This fixes suspend on platforms like stm32mp1xx, where the PWM consumer
has to be disabled for the PWM to enter suspend.
Another positive side effect is that active-low LEDs now properly
turn off instead of going back to full brightness when they are set to 0.

Link: https://lore.kernel.org/all/20240417153846.271751-2-u.kleine-koenig@pengutronix.de/
Signed-off-by: Jakob Riepler <jakob+lkml@...osfield.at>
---
Changes in v2:
 - fix wrong line-breaks in patch

 drivers/leds/rgb/leds-pwm-multicolor.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/rgb/leds-pwm-multicolor.c b/drivers/leds/rgb/leds-pwm-multicolor.c
index e1a81e0109e8..f80a06cc31f8 100644
--- a/drivers/leds/rgb/leds-pwm-multicolor.c
+++ b/drivers/leds/rgb/leds-pwm-multicolor.c
@@ -50,7 +50,13 @@ 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;
+        /*
+         * 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.
+         */
+        priv->leds[i].state.enabled = !(cdev->flags & LED_SUSPENDED);
         ret = pwm_apply_might_sleep(priv->leds[i].pwm,
                         &priv->leds[i].state);
         if (ret)
-- 
2.47.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ