<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/leds/led-core.c, branch v6.12.80</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.12.80</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.12.80'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2025-04-10T12:39:21+00:00</updated>
<entry>
<title>leds: Fix LED_OFF brightness race</title>
<updated>2025-04-10T12:39:21+00:00</updated>
<author>
<name>Remi Pommarel</name>
<email>repk@triplefau.lt</email>
</author>
<published>2025-02-20T11:23:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=c2ddf2f5760b54533dc9080f0546e4c42a29c756'/>
<id>urn:sha1:c2ddf2f5760b54533dc9080f0546e4c42a29c756</id>
<content type='text'>
[ Upstream commit 2c70953b6f535f7698ccbf22c1f5ba26cb6c2816 ]

While commit fa15d8c69238 ("leds: Fix set_brightness_delayed() race")
successfully forces led_set_brightness() to be called with LED_OFF at
least once when switching from blinking to LED on state so that
hw-blinking can be disabled, another race remains. Indeed in
led_set_brightness(LED_OFF) followed by led_set_brightness(any)
scenario the following CPU scheduling can happen:

    CPU0                                     CPU1
    ----                                     ----
 set_brightness_delayed() {
   test_and_clear_bit(BRIGHTNESS_OFF)
                                         led_set_brightness(LED_OFF) {
                                           set_bit(BRIGHTNESS_OFF)
					   queue_work()
                                         }
                                         led_set_brightness(any) {
                                           set_bit(BRIGHTNESS)
					   queue_work() //already queued
                                         }
   test_and_clear_bit(BRIGHTNESS)
     /* LED set with brightness any */
 }

 /* From previous CPU1 queue_work() */
 set_brightness_delayed() {
   test_and_clear_bit(BRIGHTNESS_OFF)
     /* LED turned off */
   test_and_clear_bit(BRIGHTNESS)
     /* Clear from previous run, LED remains off */

In that case the led_set_brightness(LED_OFF)/led_set_brightness(any)
sequence will be effectively executed in reverse order and LED will
remain off.

With the introduction of commit 32360bf6a5d4 ("leds: Introduce ordered
workqueue for LEDs events instead of system_wq") the race is easier to
trigger as sysfs brightness configuration does not wait for
set_brightness_delayed() work to finish (flush_work() removal).

Use delayed_set_value to optionnally re-configure brightness after a
LED_OFF. That way a LED state could be configured more that once but
final state will always be as expected. Ensure that delayed_set_value
modification is seen before set_bit() using smp_mb__before_atomic().

Fixes: fa15d8c69238 ("leds: Fix set_brightness_delayed() race")
Signed-off-by: Remi Pommarel &lt;repk@triplefau.lt&gt;
Reviewed-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Link: https://lore.kernel.org/r/19c81177059dab7b656c42063958011a8e4d1a66.1740050412.git.repk@triplefau.lt
Signed-off-by: Lee Jones &lt;lee@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>leds: core: Omit set_brightness error message for a LED supporting hw trigger only</title>
<updated>2024-06-26T15:55:44+00:00</updated>
<author>
<name>Lee Jones</name>
<email>lee@kernel.org</email>
</author>
<published>2024-06-12T15:36:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d33d1214a1ddf9e7e4d14c62637518252927f0be'/>
<id>urn:sha1:d33d1214a1ddf9e7e4d14c62637518252927f0be</id>
<content type='text'>
If both set_brightness functions return -ENOTSUPP, then the LED doesn't
support setting a fixed brightness value, and the error message isn't
helpful. This can be the case e.g. for LEDs supporting a specific hw
trigger only.

Pinched the subject line and commit message from Heiner:
Link: https://lore.kernel.org/all/44177e37-9512-4044-8991-bb23b184bf37@gmail.com/

Reworked the function to provide Heiner's required semantics whilst
simultaneously increasing readability and flow.

Cc: Pavel Machek &lt;pavel@ucw.cz&gt;
Cc: linux-leds@vger.kernel.org
Suggested-by: Heiner Kallweit &lt;hkallweit1@gmail.com&gt;
Reviewed-by: Heiner Kallweit &lt;hkallweit1@gmail.com&gt;
Signed-off-by: Lee Jones &lt;lee@kernel.org&gt;
</content>
</entry>
<entry>
<title>Merge branches 'ib-leds-mfd-6.11', 'ib-leds-platform-power-6.11' and 'ib-mfd-leds-platform-6.11' into ibs-for-leds-merged</title>
<updated>2024-06-21T10:54:35+00:00</updated>
<author>
<name>Lee Jones</name>
<email>lee@kernel.org</email>
</author>
<published>2024-06-21T10:54:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=59561ccd90b8fca31f15d7505c73cc22ffd04c06'/>
<id>urn:sha1:59561ccd90b8fca31f15d7505c73cc22ffd04c06</id>
<content type='text'>
</content>
</entry>
<entry>
<title>leds: core: Unexport led_colors[] array</title>
<updated>2024-06-21T10:41:39+00:00</updated>
<author>
<name>Thomas Weißschuh</name>
<email>linux@weissschuh.net</email>
</author>
<published>2024-06-13T14:48:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=493179e692dbb70cac1e54828d0e04bda386f13d'/>
<id>urn:sha1:493179e692dbb70cac1e54828d0e04bda386f13d</id>
<content type='text'>
There are no external users left, make the array static.

Signed-off-by: Thomas Weißschuh &lt;linux@weissschuh.net&gt;
Link: https://lore.kernel.org/r/20240613-cros_ec-led-v3-3-500b50f41e0f@weissschuh.net
Signed-off-by: Lee Jones &lt;lee@kernel.org&gt;
</content>
</entry>
<entry>
<title>leds: core: Introduce led_get_color_name() function</title>
<updated>2024-06-21T10:41:32+00:00</updated>
<author>
<name>Thomas Weißschuh</name>
<email>linux@weissschuh.net</email>
</author>
<published>2024-06-13T14:48:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=5f2e950755c76c6fc20fc4ebd8355671fbbd7ac0'/>
<id>urn:sha1:5f2e950755c76c6fc20fc4ebd8355671fbbd7ac0</id>
<content type='text'>
This is similar to the existing led_colors[] array but is safer to use and
usable by everyone.

Getting string representations of color ids is useful for drivers
which are handling color IDs anyways, for example for the multicolor API.

Signed-off-by: Thomas Weißschuh &lt;linux@weissschuh.net&gt;
Link: https://lore.kernel.org/r/20240613-cros_ec-led-v3-1-500b50f41e0f@weissschuh.net
Signed-off-by: Lee Jones &lt;lee@kernel.org&gt;
</content>
</entry>
<entry>
<title>leds: core: Add led_mc_set_brightness() function</title>
<updated>2024-05-31T11:57:41+00:00</updated>
<author>
<name>Hans de Goede</name>
<email>hdegoede@redhat.com</email>
</author>
<published>2024-05-31T11:41:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=5607ca92e6274dfb85d0ff7c4e91e6c4ddb6d25c'/>
<id>urn:sha1:5607ca92e6274dfb85d0ff7c4e91e6c4ddb6d25c</id>
<content type='text'>
Add a new led_mc_set_brightness() function for in kernel color/brightness
changing of multi-color LEDs.

led-class-multicolor can be build as a module and led_mc_set_brightness()
will have the builtin callers, so put led_mc_set_brightness() inside
led-core instead, just like how led_set_brightness() is part of the core
and not of the led-class object.

This also adds a new LED_MULTI_COLOR led_classdev flag to allow
led_mc_set_brightness() to verify that it is operating on a multi-color
LED classdev, avoiding casting the passed in LED classdev to a multi-color
LED classdev, when it actually is not a multi-color LED.

Signed-off-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Reviewed-by: Jacek Anaszewski &lt;jacek.anaszewski@gmail.com&gt;
Reviewed-by: Andy Shevchenko &lt;andy@kernel.org&gt;
Link: https://lore.kernel.org/r/20240531114124.45346-5-hdegoede@redhat.com
Signed-off-by: Lee Jones &lt;lee@kernel.org&gt;
</content>
</entry>
<entry>
<title>Merge tag 'leds-next-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds</title>
<updated>2023-11-03T00:53:19+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2023-11-03T00:53:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=431f1051884e38d2a5751e4731d69b2ff289ee56'/>
<id>urn:sha1:431f1051884e38d2a5751e4731d69b2ff289ee56</id>
<content type='text'>
Pull LED updates from Lee Jones:
 "Core Frameworks:
   - Add support for a bunch more colours

  New Drivers:
   - Add support for Kinetic KTD2026/7 RGB/White LEDs

  New Functionality:
   - Add support for device to enter HW Controlled Mode to Turris Omnia
     LEDs
   - Add support for HW Gamma Correction to Turris Omnia LEDs

  Fix-ups:
   - Apply new __counted_by() annotation to several data structures
     containing flexible arrays
   - Rid the return value from Platform's .remove() operation
   - Use *_cansleep() variants for instances were threads can sleep
   - Improve the semantics when setting the brightness
   - Generic clean-ups; code reduction, coding style, standard patterns
   - Replace strncpy() with strscpy()
   - Fix-up / add various documentation
   - Re-author the GPIO associated Trigger to use trigger-sources
   - Move to using standard APIs and helpers
   - Improve error checking
   - Stop using static GPIO bases

  Bug Fixes:
   - Fix Pointer to Enum casing warnings
   - Do not pretend that I2C backed device supports SMBUS
   - Ensure PWM LEDs are extinguished when disabled, rather than held in
     a state
   - Fix 'output may be truncated' warnings"

* tag 'leds-next-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds: (43 commits)
  leds: lp5521: Add an error check in lp5521_post_init_device
  leds: gpio: Update headers
  leds: gpio: Remove unneeded assignment
  leds: gpio: Move temporary variable for struct device to gpio_led_probe()
  leds: gpio: Refactor code to use devm_gpiod_get_index_optional()
  leds: gpio: Utilise PTR_ERR_OR_ZERO()
  leds: gpio: Keep driver firmware interface agnostic
  leds: core: Refactor led_update_brightness() to use standard pattern
  leds: turris-omnia: Fix brightness setting and trigger activating
  leds: sc27xx: Move mutex_init() down
  leds: trigger: netdev: Move size check in set_device_name
  leds: Add ktd202x driver
  dt-bindings: leds: Add Kinetic KTD2026/2027 LED
  leds: core: Add more colors from DT bindings to led_colors
  dt-bindings: leds: Last color ID is now 14 (LED_COLOR_ID_LIME)
  leds: tca6507: Don't use fixed GPIO base
  leds: lp3952: Convert to use maple tree register cache
  leds: lm392x: Convert to use maple tree register cache
  leds: aw200xx: Convert to use maple tree register cache
  leds: lm3601x: Convert to use maple tree register cache
  ...
</content>
</entry>
<entry>
<title>leds: core: Refactor led_update_brightness() to use standard pattern</title>
<updated>2023-11-01T11:29:18+00:00</updated>
<author>
<name>Andy Shevchenko</name>
<email>andriy.shevchenko@linux.intel.com</email>
</author>
<published>2023-10-16T15:30:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=49e50aad22aebaaca3ff7abbdd462deaf16c5f35'/>
<id>urn:sha1:49e50aad22aebaaca3ff7abbdd462deaf16c5f35</id>
<content type='text'>
The standard conditional pattern is to check for errors first and
bail out if any. Refactor led_update_brightness() accordingly.

While at it, drop unneeded assignment and return 0 unconditionally
on success.

Signed-off-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Acked-by: Denis Osterland-Heim &lt;denis.osterland@diehl.com&gt;
Reviewed-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Link: https://lore.kernel.org/r/20231016153051.1409074-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones &lt;lee@kernel.org&gt;
</content>
</entry>
<entry>
<title>leds: core: Add more colors from DT bindings to led_colors</title>
<updated>2023-11-01T11:29:06+00:00</updated>
<author>
<name>Ondrej Jirman</name>
<email>megi@xff.cz</email>
</author>
<published>2023-10-08T14:40:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=a067943129b4ec6b835e02cfd5fbef01093c1471'/>
<id>urn:sha1:a067943129b4ec6b835e02cfd5fbef01093c1471</id>
<content type='text'>
The colors are already part of DT bindings. Make sure the kernel is
able to convert them to strings.

Signed-off-by: Ondrej Jirman &lt;megi@xff.cz&gt;
Link: https://lore.kernel.org/r/20231008144014.1180334-1-megi@xff.cz
Signed-off-by: Lee Jones &lt;lee@kernel.org&gt;
</content>
</entry>
<entry>
<title>leds: Drop BUG_ON check for LED_COLOR_ID_MULTI</title>
<updated>2023-09-19T14:16:23+00:00</updated>
<author>
<name>Marek Behún</name>
<email>kabel@kernel.org</email>
</author>
<published>2023-09-18T14:07:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=9dc1664fab2246bc2c3e9bf2cf21518a857f9b5b'/>
<id>urn:sha1:9dc1664fab2246bc2c3e9bf2cf21518a857f9b5b</id>
<content type='text'>
Commit c3f853184bed ("leds: Fix BUG_ON check for LED_COLOR_ID_MULTI that
is always false") fixed a no-op BUG_ON. This turned out to cause a
regression, since some in-tree device-tree files already use
LED_COLOR_ID_MULTI.

Drop the BUG_ON altogether.

Fixes: c3f853184bed ("leds: Fix BUG_ON check for LED_COLOR_ID_MULTI that is always false")
Reported-by: Da Xue &lt;da@libre.computer&gt;
Closes: https://lore.kernel.org/linux-leds/ZQLelWcNjjp2xndY@duo.ucw.cz/T/
Signed-off-by: Marek Behún &lt;kabel@kernel.org&gt;
Link: https://lore.kernel.org/r/20230918140724.18634-1-kabel@kernel.org
Signed-off-by: Lee Jones &lt;lee@kernel.org&gt;
</content>
</entry>
</feed>
