All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] leds: add driver for disk leds in synology devices
@ 2026-12-02 15:21 Markus Probst
  2026-12-02 15:21 ` [PATCH 1/2] dt-bindings: leds: Add synology disk led controller Markus Probst
  2026-12-02 15:21 ` [PATCH 2/2] leds: add driver for disk leds in synology devices Markus Probst
  0 siblings, 2 replies; 6+ messages in thread
From: Markus Probst @ 2026-12-02 15:21 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek, Griffin Kroah-Hartman, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Daniel Almeida,
	Tamir Duberstein, Alexandre Courbot, Onur Özkan
  Cc: linux-leds, devicetree, linux-kernel, rust-for-linux,
	Markus Probst

Yet another user for the rust led abstractions.

This adds a driver to control the disk leds on synology devices.

Dependencies:
- LED Rust Abstraction [1]
- Rust I2C SMBus IO backend implementation [2]

[1] https://lore.kernel.org/rust-for-linux/20261113-rust_leds-v28-0-b8cf2f74fa57@posteo.de/
[2]
https://lore.kernel.org/rust-for-linux/20261201165508.39336-1-muchamadcoirulanwar@gmail.com/
(patch 1+2)

Signed-off-by: Markus Probst <markus.probst@posteo.de>
---
Markus Probst (2):
      dt-bindings: leds: Add synology disk led controller
      leds: add driver for disk leds in synology devices

 .../bindings/leds/synology,disk-leds.yaml          | 151 +++++++
 MAINTAINERS                                        |   7 +
 drivers/leds/Kconfig                               |   9 +
 drivers/leds/Makefile                              |   1 +
 drivers/leds/leds_synology_disk.rs                 | 441 +++++++++++++++++++++
 5 files changed, 609 insertions(+)
---
base-commit: c8cbaa094f4f7cc4e4d5a1e3ea7be5dfb362dcbb
change-id: 20261122-synology_disk_leds-182da42b8902
prerequisite-change-id: 20251114-rust_leds-a959f7c2f7f9:v28
prerequisite-patch-id: 432510e001a037b2220f63c4e20d6b7650f6efc4
prerequisite-patch-id: e75e391b393ce7a10fd541e1c8b223c0be0c2817
prerequisite-patch-id: 8149d3294f6b99a672cb468c4992dfd8101e6650
prerequisite-patch-id: 9976190872fe26c2a980c66a4ebc050fd2bcaf71
prerequisite-message-id: 20261201165508.39336-1-muchamadcoirulanwar@gmail.com
prerequisite-patch-id: 8741958d13c628fd7b19b96c3b3dcbbd30ddfb48
prerequisite-patch-id: 13b003555af95fc3e45de60a39e9a0ff8aabd1bd
prerequisite-patch-id: f28d13f870e227b99920bc10f9990d8f713f8c00
prerequisite-patch-id: 5ede68001055ff3faddde5d3173f84ebce2f3e92


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] dt-bindings: leds: Add synology disk led controller
  2026-12-02 15:21 [PATCH 0/2] leds: add driver for disk leds in synology devices Markus Probst
@ 2026-12-02 15:21 ` Markus Probst
  2026-12-02 15:29   ` sashiko-bot
  2026-12-02 15:21 ` [PATCH 2/2] leds: add driver for disk leds in synology devices Markus Probst
  1 sibling, 1 reply; 6+ messages in thread
From: Markus Probst @ 2026-12-02 15:21 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek, Griffin Kroah-Hartman, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Daniel Almeida,
	Tamir Duberstein, Alexandre Courbot, Onur Özkan
  Cc: linux-leds, devicetree, linux-kernel, rust-for-linux,
	Markus Probst

Add devicetree bindings for the synology disk led controller. It uses
the Atmega1608 microcontroller with I2C interface.

The led controller supports up to 24 leds. It is common that multiple leds
in Synology devices share the same slot and thus are grouped as multicolor
led.

Signed-off-by: Markus Probst <markus.probst@posteo.de>
---
 .../bindings/leds/synology,disk-leds.yaml          | 151 +++++++++++++++++++++
 1 file changed, 151 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/synology,disk-leds.yaml b/Documentation/devicetree/bindings/leds/synology,disk-leds.yaml
new file mode 100644
index 000000000000..e9a8df77c8b4
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/synology,disk-leds.yaml
@@ -0,0 +1,151 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/synology,disk-leds.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Synology disk led controller
+
+maintainers:
+  - Markus Probst <markus.probst@posteo.de>
+
+description: |
+  Led controller used for disk leds in Synology devices. It uses the
+  Atmega1608 microcontroller with I2C interface.
+
+properties:
+  compatible:
+    const: synology,disk-leds
+
+  reg:
+    maxItems: 1
+
+patternProperties:
+  "^disk-[0-9]+$":
+    type: object
+    $ref: leds-class-multicolor.yaml#
+    unevaluatedProperties: false
+
+    properties:
+      "#address-cells":
+        const: 1
+
+      "#size-cells":
+        const: 0
+
+    patternProperties:
+      "^led@[0-9]+$":
+        type: object
+        additionalProperties: false
+
+        properties:
+          reg:
+            description: Index of the LED.
+            minimum: 0
+            maximum: 23
+
+          color:
+            description: Color of the LED.
+            $ref: /schemas/types.yaml#/definitions/uint32
+            minimum: 0
+            maximum: 14
+
+        required:
+          - reg
+          - color
+
+    required:
+      - "#address-cells"
+      - "#size-cells"
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/leds/common.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        led-controller@60 {
+            compatible = "synology,disk-leds";
+            reg = <0x60>;
+
+            disk-1 {
+                function = LED_FUNCTION_DISK;
+                function-enumerator = <1>;
+                color = <LED_COLOR_ID_MULTI>;
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                led@0 {
+                    reg = <0>;
+                    color = <LED_COLOR_ID_GREEN>;
+                };
+
+                led@1 {
+                    reg = <1>;
+                    color = <LED_COLOR_ID_AMBER>;
+                };
+            };
+
+            disk-2 {
+                function = LED_FUNCTION_DISK;
+                function-enumerator = <2>;
+                color = <LED_COLOR_ID_MULTI>;
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                led@2 {
+                    reg = <2>;
+                    color = <LED_COLOR_ID_GREEN>;
+                };
+
+                led@3 {
+                    reg = <3>;
+                    color = <LED_COLOR_ID_AMBER>;
+                };
+            };
+
+            disk-3 {
+                function = LED_FUNCTION_DISK;
+                function-enumerator = <3>;
+                color = <LED_COLOR_ID_MULTI>;
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                led@4 {
+                    reg = <4>;
+                    color = <LED_COLOR_ID_GREEN>;
+                };
+
+                led@5 {
+                    reg = <5>;
+                    color = <LED_COLOR_ID_AMBER>;
+                };
+            };
+
+            disk-4 {
+                function = LED_FUNCTION_DISK;
+                function-enumerator = <4>;
+                color = <LED_COLOR_ID_MULTI>;
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                led@6 {
+                    reg = <6>;
+                    color = <LED_COLOR_ID_GREEN>;
+                };
+
+                led@7 {
+                    reg = <7>;
+                    color = <LED_COLOR_ID_AMBER>;
+                };
+            };
+        };
+    };

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] leds: add driver for disk leds in synology devices
  2026-12-02 15:21 [PATCH 0/2] leds: add driver for disk leds in synology devices Markus Probst
  2026-12-02 15:21 ` [PATCH 1/2] dt-bindings: leds: Add synology disk led controller Markus Probst
@ 2026-12-02 15:21 ` Markus Probst
  2026-12-02 15:38   ` sashiko-bot
  1 sibling, 1 reply; 6+ messages in thread
From: Markus Probst @ 2026-12-02 15:21 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek, Griffin Kroah-Hartman, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Daniel Almeida,
	Tamir Duberstein, Alexandre Courbot, Onur Özkan
  Cc: linux-leds, devicetree, linux-kernel, rust-for-linux,
	Markus Probst

Synology uses an atmega1608 microcontroller as led controller for disk
leds via the I2C bus on its NAS devices. This adds the driver to control
those leds.

Successfully tested on a Synology DS923+.

Signed-off-by: Markus Probst <markus.probst@posteo.de>
---
 MAINTAINERS                        |   7 +
 drivers/leds/Kconfig               |   9 +
 drivers/leds/Makefile              |   1 +
 drivers/leds/leds_synology_disk.rs | 441 +++++++++++++++++++++++++++++++++++++
 4 files changed, 458 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index d4fc9f48db34..ef1db5f95a37 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -27144,6 +27144,13 @@ F:	drivers/dma-buf/sync_*
 F:	include/linux/sync_file.h
 F:	include/uapi/linux/sync_file.h
 
+SYNOLOGY DISK LED CONTROLLER DRIVER
+M:	Markus Probst <markus.probst@posteo.de>
+L:	linux-leds@vger.kernel.org
+S:	Maintained
+F:	Documentation/devicetree/bindings/leds/synology,disk-leds.yaml
+F:	drivers/leds/leds_synology_disk.rs
+
 SYNOPSYS ARC ARCHITECTURE
 M:	Vineet Gupta <vgupta@kernel.org>
 L:	linux-snps-arc@lists.infradead.org
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 7ec2c8d78542..34cf2a3f0bac 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -332,6 +332,15 @@ config LEDS_WRAP
 	help
 	  This option enables support for the PCEngines WRAP programmable LEDs.
 
+config LEDS_SYNOLOGY_DISK
+	tristate "LED Support for disk leds used in Synology devices"
+	depends on LEDS_CLASS && LEDS_CLASS_MULTICOLOR
+	depends on I2C
+	depends on RUST
+	help
+	  This option enables support for the led controller for disk leds in
+	  synology devices.
+
 config LEDS_COBALT_QUBE
 	tristate "LED Support for the Cobalt Qube series front LED"
 	depends on LEDS_CLASS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 4d4b089156e2..466549f65f9c 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -101,6 +101,7 @@ obj-$(CONFIG_LEDS_UPBOARD)		+= leds-upboard.o
 obj-$(CONFIG_LEDS_WM831X_STATUS)	+= leds-wm831x-status.o
 obj-$(CONFIG_LEDS_WM8350)		+= leds-wm8350.o
 obj-$(CONFIG_LEDS_WRAP)			+= leds-wrap.o
+obj-$(CONFIG_LEDS_SYNOLOGY_DISK)	+= leds_synology_disk.o
 
 # Kinetic ExpressWire Protocol
 obj-$(CONFIG_LEDS_EXPRESSWIRE)		+= leds-expresswire.o
diff --git a/drivers/leds/leds_synology_disk.rs b/drivers/leds/leds_synology_disk.rs
new file mode 100644
index 000000000000..1f339e2e429e
--- /dev/null
+++ b/drivers/leds/leds_synology_disk.rs
@@ -0,0 +1,441 @@
+// SPDX-License-Identifier: GPL-2.0
+
+//! Led Driver for Synology devices using Atmega1608 as Led Controller.
+//!
+//! Atmega1608 is a microcontroller from Microchip Technology, it is used
+//! as a led controller in synology nas devices for disk leds.
+//!
+//! It can handle a total of 24 leds. Each led has 4 modes:
+//! * OFF - the led is turned off
+//! * ON - the led is turned on at full brightness
+//! * DIM0 - custom brightness and optional hardware accelerated blinking
+//!
+//! there should also be DIM1 (which should do the same as DIM0), but
+//! according to my own testing it doesn't actually work, so it won't be used.
+//!
+//!
+//! # Limitations
+//!
+//! DIM0 (and DIM1) are shared across all leds, meaning if DIM0 is used by
+//! multiple leds, these multiple leds cannot have different brightness
+//! levels. The same does apply for the hardware accelerated blinking.
+//!
+//! In other words, for all 24 leds there can either only be one brightness other
+//! than 0 and 255, or one hardware accelerated blinking delay.
+//!
+//! Furthermore the off and on delay in hardware accelerated blinking cannot
+//! have different values and have to be equal.
+//!
+//! We solve this by only allowing a hardcoded blinking delay of 90 ms.
+//!
+//! While hardware accelerated blinking is on, the led cycles between
+//! the current brightness for the mode and full brightness. Because of this
+//! behaviour, we hardcode the brightness value of 128 for hardware accelerated
+//! blinking.
+//!
+//! Hardware accelerated blinking starts with a delay of 300 - 400 ms.
+//!
+//! # Technical details
+//!
+//! The controller has 6 8-bit i2c registers for led modes. See [`LedAddress`].
+//! Each led has its own 2 bits:
+//!
+//! +=====================================+
+//! | Register  | Leds (2 bits each)      |
+//! +=====================================+
+//! | 0x06      | LED3  LED2  LED1  LED0  |
+//! |-----------+-------------------------+
+//! | 0x07      | LED7  LED6  LED5  LED4  |
+//! |-----------+-------------------------+
+//! | 0x08      | LED11 LED10 LED9  LED8  |
+//! |-----------+-------------------------+
+//! | 0x09      | LED15 LED14 LED13 LED12 |
+//! |-----------+-------------------------+
+//! | 0x0A      | LED19 LED18 LED17 LED16 |
+//! |-----------+-------------------------+
+//! | 0x0B      | LED23 LED22 LED21 LED20 |
+//! |=====================================+
+//!
+//! See [`LedMode`] for the value of each mode.
+//!
+//!
+//! +===============================================+
+//! | Register  | Mode / Meaning                    |
+//! +===============================================+
+//! | 0x01      | turns all leds off if set to 1    |
+//! +-----------------------------------------------+
+//! | 0x02      | blinking delay for Dim0, 1 = 3 ms |
+//! +-----------------------------------------------+
+//! | 0x03      | brightness for Dim0, inverted     |
+//! +-----------------------------------------------+
+//! | 0x04      | blinking delay for Dim1, 1 = 3 ms |
+//! +-----------------------------------------------+
+//! | 0x05      | brightness for Dim1, inverted     |
+//! +===============================================+
+//!
+
+use kernel::{
+    device::{
+        Bound,
+        Core, //
+    },
+    i2c::{
+        self,
+        I2cClient, //
+    },
+    io::Io,
+    led::{self, MultiColorDevice},
+    new_mutex, of,
+    prelude::*,
+    sync::{
+        Arc,
+        Mutex, //
+    },
+};
+
+struct SynologyDiskLedDriver<'bound> {
+    _leds: KVec<Pin<KBox<MultiColorDevice<'bound, Led<'bound>>>>>,
+}
+
+kernel::module_i2c_driver! {
+    type: SynologyDiskLedDriver<'static>,
+    name: "leds_synology_disk",
+    authors: ["Markus Probst <markus.probst@posteo.de>"],
+    description: "Led Driver for disk leds in synology devices",
+    license: "GPL v2",
+}
+
+#[repr(u8)]
+#[derive(Copy, Clone, PartialEq, Eq)]
+enum LedAddress {
+    Ls0 = 0x06,
+    Ls1 = 0x07,
+    Ls2 = 0x08,
+    Ls3 = 0x09,
+    Ls4 = 0x0A,
+    Ls5 = 0x0B,
+}
+
+#[repr(u8)]
+#[derive(Copy, Clone)]
+enum LedId {
+    Sel0 = 0,
+    Sel1 = 1,
+    Sel2 = 2,
+    Sel3 = 3,
+}
+
+#[repr(u8)]
+#[derive(Copy, Clone, PartialEq, Eq, Debug)]
+enum LedMode {
+    Off = 0b00,
+    On = 0b01,
+    Dim0 = 0b10,
+    // Dim1 = 0b11,
+}
+
+#[pin_data]
+struct LedAddressData {
+    addr: LedAddress,
+    #[pin]
+    data: Mutex<u8>,
+}
+
+#[pin_data]
+struct Led<'bound> {
+    client: &'bound I2cClient<Bound>,
+    addr: Arc<Pin<KBox<[LedAddressData]>>>,
+    subleds: KVec<SubLed>,
+    #[pin]
+    blink: Mutex<bool>,
+}
+
+struct SubLed {
+    addr: LedAddress,
+    id: LedId,
+}
+
+kernel::of_device_table! {
+    OF_TABLE,
+    <SynologyDiskLedDriver<'_> as i2c::Driver>::IdInfo,
+    [(of::DeviceId::new(c"synology,disk-leds"), 0)]
+}
+
+impl i2c::Driver for SynologyDiskLedDriver<'_> {
+    type IdInfo = u32;
+    type Data<'bound> = SynologyDiskLedDriver<'bound>;
+
+    const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);
+
+    fn probe<'bound>(
+        idev: &'bound I2cClient<Core<'_>>,
+        _id_info: Option<&'bound Self::IdInfo>,
+    ) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
+        let dev = idev.as_ref();
+
+        let Some(fwnode) = dev.fwnode() else {
+            return Err(EINVAL);
+        };
+
+        idev.smbus_io()
+            .try_write8(30, 0x02)
+            .inspect_err(|err| dev_err!(dev, "unable to set blink delay: {err:?}\n"))?;
+
+        idev.smbus_io()
+            .try_write8(127, 0x03)
+            .inspect_err(|err| dev_err!(dev, "unable to set blink brightness: {err:?}\n"))?;
+
+        let addr = Arc::new(
+            KBox::pin_slice::<_, _, Error, Error>(
+                |index| {
+                    try_pin_init!(LedAddressData {
+                        addr: LedAddress::VALUES[index],
+                        data <- new_mutex!(0u8),
+                    })
+                },
+                LedAddress::VALUES.len(),
+                GFP_KERNEL,
+            )?,
+            GFP_KERNEL,
+        )?;
+        let mut used = [false; LedId::VALUES.len() * LedAddress::VALUES.len()];
+        let mut subleds_classdev = KVec::with_capacity(2, GFP_KERNEL)?;
+        let mut subleds;
+        let mut leds = KVec::new();
+
+        for child in fwnode.children() {
+            subleds_classdev.clear();
+            subleds = KVec::with_capacity(2, GFP_KERNEL)?;
+
+            for (index, color) in child.children().enumerate() {
+                let reg = usize::try_from(color.property_read::<u32>(c"reg").required_by(dev)?)?;
+                if reg >= LedAddress::VALUES.len() * LedId::VALUES.len() {
+                    dev_err!(dev, "{}: property 'reg' is out of bounds\n", *color);
+                    return Err(EINVAL);
+                }
+
+                if used[reg] {
+                    dev_err!(
+                        dev,
+                        "{}: property 'reg' conflicts with a previous entry\n",
+                        *color,
+                    );
+                    return Err(EINVAL);
+                }
+                used[reg] = true;
+
+                let color =
+                    led::Color::try_from(color.property_read::<u32>(c"color").required_by(dev)?)
+                        .map_err(|_err| {
+                            dev_err!(dev, "{}: property 'color' is out of bounds\n", *color);
+                            EINVAL
+                        })?;
+                subleds_classdev.push(
+                    led::MultiColorSubLed::new(color).initial_intensity(if index == 0 {
+                        1
+                    } else {
+                        0
+                    }),
+                    GFP_KERNEL,
+                )?;
+                subleds.push(
+                    SubLed {
+                        addr: LedAddress::VALUES[reg / LedId::VALUES.len()],
+                        id: LedId::VALUES[reg % LedId::VALUES.len()],
+                    },
+                    GFP_KERNEL,
+                )?;
+            }
+            debug_assert_eq!(subleds_classdev.len(), subleds.len());
+            if subleds_classdev.is_empty() {
+                dev_err!(dev, "{}: at least one subled is required\n", *child);
+                return Err(EINVAL);
+            }
+
+            let addr = Arc::clone(&addr);
+            leds.push(
+                KBox::pin_init(
+                    led::DeviceBuilder::new()
+                        .fwnode(Some(child))
+                        .build_multicolor(
+                            dev,
+                            try_pin_init!(Led {
+                                client: idev,
+                                subleds,
+                                addr,
+                                blink <- new_mutex!(false),
+                            }),
+                            &subleds_classdev,
+                        ),
+                    GFP_KERNEL,
+                )?,
+                GFP_KERNEL,
+            )?;
+        }
+
+        idev.smbus_io()
+            .try_write8(0, 0x01)
+            .inspect_err(|err| dev_err!(dev, "unable to remove led mask: {err:?}\n"))?;
+
+        Ok(SynologyDiskLedDriver { _leds: leds })
+    }
+
+    fn unbind<'bound>(dev: &'bound I2cClient<Core<'_>>, _this: Pin<&Self::Data<'bound>>) {
+        let _ = dev
+            .smbus_io()
+            .try_write8(1, 0x01)
+            .inspect_err(|err| dev_err!(dev.as_ref(), "unable to set led mask: {err:?}\n"));
+
+        for addr in LedAddress::VALUES {
+            let _ = dev
+                .smbus_io()
+                .try_write8(0, addr as usize)
+                .inspect_err(|err| {
+                    dev_err!(
+                        dev.as_ref(),
+                        "Unable to turn off leds at address {:#2x}: {err:?}\n",
+                        (addr as u8)
+                    )
+                });
+        }
+    }
+}
+
+impl LedAddress {
+    const VALUES: [Self; 6] = [
+        Self::Ls0,
+        Self::Ls1,
+        Self::Ls2,
+        Self::Ls3,
+        Self::Ls4,
+        Self::Ls5,
+    ];
+}
+
+impl LedId {
+    const VALUES: [Self; 4] = [Self::Sel0, Self::Sel1, Self::Sel2, Self::Sel3];
+
+    const fn mask(self) -> u8 {
+        match self {
+            Self::Sel0 => 0x03,
+            Self::Sel1 => 0x0C,
+            Self::Sel2 => 0x30,
+            Self::Sel3 => 0xC0,
+        }
+    }
+
+    const fn shift(self) -> u8 {
+        match self {
+            Self::Sel0 => 0,
+            Self::Sel1 => 2,
+            Self::Sel2 => 4,
+            Self::Sel3 => 6,
+        }
+    }
+}
+
+#[vtable]
+impl led::LedOps for Led<'_> {
+    type Mode = led::MultiColor;
+    const BLOCKING: bool = true;
+    const MAX_BRIGHTNESS: u32 = 1;
+
+    fn brightness_set<'bound>(
+        self: &led::MultiColorDevice<'bound, Self>,
+        brightness: u32,
+    ) -> Result<()> {
+        let mut blink = self.blink.lock();
+
+        if brightness == 0 {
+            *blink = false;
+        }
+
+        self.update_modes(|subled_info| {
+            if subled_info.brightness() == 0 {
+                LedMode::Off
+            } else if *blink {
+                LedMode::Dim0
+            } else {
+                LedMode::On
+            }
+        })?;
+
+        Ok(())
+    }
+
+    fn blink_set<'bound>(
+        self: &led::MultiColorDevice<'bound, Self>,
+        delay_on: &mut usize,
+        delay_off: &mut usize,
+    ) -> Result<()> {
+        let mut blink = self.blink.lock();
+        if *delay_on == 0 && *delay_off != 0 {
+            *blink = false;
+            self.update_modes(|_subled_info| LedMode::Off)?;
+            return Ok(());
+        }
+        if *delay_off == 0 && *delay_on != 0 {
+            *blink = false;
+            self.update_modes(|subled_info| {
+                if subled_info.intensity() == 0 {
+                    LedMode::Off
+                } else {
+                    LedMode::On
+                }
+            })?;
+            return Ok(());
+        }
+
+        *delay_on = 90;
+        *delay_off = 90;
+
+        self.update_modes(|subled_info| {
+            if subled_info.intensity() == 0 {
+                LedMode::Off
+            } else {
+                LedMode::Dim0
+            }
+        })?;
+        *blink = true;
+
+        Ok(())
+    }
+}
+
+impl Led<'_> {
+    fn update_modes<F: FnMut(&led::MultiColorSubLed) -> LedMode>(
+        self: &led::MultiColorDevice<'_, Self>,
+        mut func: F,
+    ) -> Result<()> {
+        for LedAddressData { addr, data } in &**self.addr {
+            let mut guard = None;
+            for (subled, subled_info) in self.subleds.iter().zip(self.subleds()) {
+                if subled.addr == *addr {
+                    let (goal, _) = guard.get_or_insert_with(|| {
+                        let guard = data.lock();
+                        (*guard, guard)
+                    });
+                    let mode = (func)(subled_info);
+                    *goal = (*goal & !subled.id.mask())
+                        | (((mode as u8) << subled.id.shift()) & subled.id.mask());
+                }
+            }
+            if let Some((goal, mut current)) = guard {
+                if goal != *current {
+                    self.client
+                        .smbus_io()
+                        .try_write8(goal, *addr as usize)
+                        .inspect_err(|err| {
+                            dev_err!(
+                                self.client.as_ref(),
+                                "failed to write {:#2x}: {err:?}\n",
+                                (*addr as u8)
+                            );
+                        })?;
+                    *current = goal;
+                }
+            }
+        }
+        Ok(())
+    }
+}

-- 
2.56.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] dt-bindings: leds: Add synology disk led controller
  2026-12-02 15:21 ` [PATCH 1/2] dt-bindings: leds: Add synology disk led controller Markus Probst
@ 2026-12-02 15:29   ` sashiko-bot
  0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-12-02 15:29 UTC (permalink / raw)
  To: Markus Probst; +Cc: linux-leds, devicetree, robh, conor+dt, lee, ojeda, gary

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] dt-bindings: leds: disk-[0-9]+ node pattern conflicts with
  multicolor schema
- [Medium] dt-bindings: leds: led@[0-9]+ pattern rejects hex unit
  addresses 0xa to 0xf
- [Low] dt-bindings: leds: sub-LED node redefines color instead of
  common.yaml ref
--

commit e8aa6261363feedc9e09aa356cf6da1d57e34dcb
Author: Markus Probst <markus.probst@posteo.de>

dt-bindings: leds: Add synology disk led controller

This commit adds a devicetree binding schema for the I2C-connected Atmega1608
disk LED controller used in Synology devices.

> diff --git a/Documentation/devicetree/bindings/leds/synology,disk-leds.yaml b/Documentation/devicetree/bindings/leds/synology,disk-leds.yaml
> new file mode 100644
> index 0000000000000..e9a8df77c8b42
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/synology,disk-leds.yaml
> @@ -0,0 +1,151 @@

[ ... ]

> +patternProperties:
> +  "^disk-[0-9]+$":
> +    type: object
> +    $ref: leds-class-multicolor.yaml#
> +    unevaluatedProperties: false

[Severity: Medium]
Can a child node satisfy both "^disk-[0-9]+$" and leds-class-multicolor.yaml#?

Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml enforces
$nodename matching "^multi-led(@[0-9a-f]|-[0-9]+)?$".  Because the two
patterns are disjoint, dt_binding_check fails on the disk-1 through disk-4
nodes in the example and rejects any node written against this binding.

> +
> +    properties:
> +      "#address-cells":
> +        const: 1
> +
> +      "#size-cells":
> +        const: 0
> +
> +    patternProperties:
> +      "^led@[0-9]+$":
> +        type: object
> +        additionalProperties: false
> +
> +        properties:
> +          reg:
> +            description: Index of the LED.
> +            minimum: 0
> +            maximum: 23

[Severity: Medium]
Does "^led@[0-9]+$" reject valid hexadecimal unit addresses for LEDs 10
through 15?

Since reg permits indices up to 23 (0x17), sub-LEDs at indices 10 through 15
must use unit addresses led@a through led@f to avoid dtc unit_address_vs_reg
warnings, which this pattern does not allow.  Should this match hex unit
addresses such as "^led@([0-9a-f]|1[0-7])$"?

> +
> +          color:
> +            description: Color of the LED.
> +            $ref: /schemas/types.yaml#/definitions/uint32
> +            minimum: 0
> +            maximum: 14

[Severity: Low]
This isn't a bug, but redefining color here with additionalProperties: false
duplicates common.yaml and prevents sub-LED nodes from using standard
properties such as default-intensity.  Could the sub-LED schema reference
common.yaml# with unevaluatedProperties: false instead?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-synology_disk_leds-v1-0-53249fd3a2ad@posteo.de?part=1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] leds: add driver for disk leds in synology devices
  2026-12-02 15:21 ` [PATCH 2/2] leds: add driver for disk leds in synology devices Markus Probst
@ 2026-12-02 15:38   ` sashiko-bot
  2026-12-02 15:47     ` Markus Probst
  0 siblings, 1 reply; 6+ messages in thread
From: sashiko-bot @ 2026-12-02 15:38 UTC (permalink / raw)
  To: Markus Probst; +Cc: linux-leds, devicetree, robh, conor+dt, lee, ojeda, gary

Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [Medium] leds: synology_disk: missing I2C=y Kconfig dependency breaks
  modular I2C build
- [Medium] leds: synology_disk: uninitialized mode registers desync
  cache in probe()
- [Medium] leds: synology_disk: premature register clear in unbind()
  before LED drop
- [Medium] leds: synology_disk: multi_intensity write cancels hardware
  blink_set()
- [Low] leds: synology_disk: unsorted Makefile entry and non-standard
  commit subject
--

commit 89384e625f4f23cc76bff85dcf0243a699d6bc61
Author: Markus Probst <markus.probst@posteo.de>

leds: add driver for disk leds in synology devices

This commit adds a Rust I2C LED driver for the Atmega1608 disk LED
controller used in Synology NAS devices.

> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> index 7ec2c8d785426..34cf2a3f0baca 100644
> --- a/drivers/leds/Kconfig
> +++ b/drivers/leds/Kconfig
> @@ -332,6 +332,15 @@ config LEDS_WRAP
>  	help
>  	  This option enables support for the PCEngines WRAP programmable LEDs.
>  
> +config LEDS_SYNOLOGY_DISK
> +	tristate "LED Support for disk leds used in Synology devices"
> +	depends on LEDS_CLASS && LEDS_CLASS_MULTICOLOR
> +	depends on I2C

[Severity: Medium]
Should this depend on I2C=y rather than I2C?

The Rust I2C abstractions in rust/kernel/lib.rs are only built when
CONFIG_I2C=y:

rust/kernel/lib.rs {
    ...
#[cfg(CONFIG_I2C = "y")]
pub mod i2c;
    ...
}

When CONFIG_I2C=m and CONFIG_LEDS_SYNOLOGY_DISK=m, compiling this driver
fails with unresolved imports for kernel::i2c and
kernel::module_i2c_driver!.

> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
> index 4d4b089156e24..466549f65f9ca 100644
> --- a/drivers/leds/Makefile
> +++ b/drivers/leds/Makefile
> @@ -101,6 +101,7 @@ obj-$(CONFIG_LEDS_UPBOARD)		+= leds-upboard.o
>  obj-$(CONFIG_LEDS_WM831X_STATUS)	+= leds-wm831x-status.o
>  obj-$(CONFIG_LEDS_WM8350)		+= leds-wm8350.o
>  obj-$(CONFIG_LEDS_WRAP)			+= leds-wrap.o
> +obj-$(CONFIG_LEDS_SYNOLOGY_DISK)	+= leds_synology_disk.o

[Severity: Low]
This isn't a bug, but the LED Platform Drivers section of
drivers/leds/Makefile asks to be kept sorted alphabetically (between
CONFIG_LEDS_SUNFIRE and CONFIG_LEDS_SYSCON).  Also, LED subsystem commit
subjects normally follow the "leds: <driver>: <Capitalized description>"
convention.

> diff --git a/drivers/leds/leds_synology_disk.rs b/drivers/leds/leds_synology_disk.rs
> new file mode 100644
> index 0000000000000..1f339e2e429e5
> --- /dev/null
> +++ b/drivers/leds/leds_synology_disk.rs
[ ... ]
> +    fn probe<'bound>(
> +        idev: &'bound I2cClient<Core<'_>>,
> +        _id_info: Option<&'bound Self::IdInfo>,
> +    ) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
[ ... ]
> +        let addr = Arc::new(
> +            KBox::pin_slice::<_, _, Error, Error>(
> +                |index| {
> +                    try_pin_init!(LedAddressData {
> +                        addr: LedAddress::VALUES[index],
> +                        data <- new_mutex!(0u8),
> +                    })
> +                },
> +                LedAddress::VALUES.len(),
> +                GFP_KERNEL,
> +            )?,
> +            GFP_KERNEL,
> +        )?;
[ ... ]
> +        idev.smbus_io()
> +            .try_write8(0, 0x01)
> +            .inspect_err(|err| dev_err!(dev, "unable to remove led mask: {err:?}\n"))?;
> +
> +        Ok(SynologyDiskLedDriver { _leds: leds })
> +    }

[Severity: Medium]
Can LedAddressData::data start out of sync with the hardware mode
registers 0x06..=0x0B in probe()?

LedAddressData::data is initialized to 0u8, and probe() unmasks register
0x01 without clearing or reading registers 0x06..=0x0B.  If the
bootloader or a previous boot left non-zero mode bits in 0x06..=0x0B,
those physical LEDs turn on or blink as soon as 0x01 is unmasked while
their LED class devices report brightness 0.  Calling brightness_set(0)
then cannot turn them off because update_modes() skips the SMBus write
when goal == *current (0 == 0).

> +
> +    fn unbind<'bound>(dev: &'bound I2cClient<Core<'_>>, _this: Pin<&Self::Data<'bound>>) {
> +        let _ = dev
> +            .smbus_io()
> +            .try_write8(1, 0x01)
> +            .inspect_err(|err| dev_err!(dev.as_ref(), "unable to set led mask: {err:?}\n"));
> +
> +        for addr in LedAddress::VALUES {
> +            let _ = dev
> +                .smbus_io()
> +                .try_write8(0, addr as usize)
> +                .inspect_err(|err| {
> +                    dev_err!(
> +                        dev.as_ref(),
> +                        "Unable to turn off leds at address {:#2x}: {err:?}\n",
> +                        (addr as u8)
> +                    )
> +                });
> +        }
> +    }
> +}

[Severity: Medium]
Does unbind() clear hardware registers before _leds are unregistered?

In the Rust driver lifecycle, i2c::Adapter::remove_callback() runs
unbind() before Registration::post_unbind_callback() drops
SynologyDiskLedDriver and its _leds vector.  While unbind() writes
registers 0x01 and 0x06..=0x0B without locking or updating
LedAddressData::data, active triggers or sysfs writes can still call
update_modes() concurrently.  Then, when post_unbind_callback() drops
each MultiColorDevice, led_classdev_unregister() calls brightness_set(0)
-> update_modes(), which compares against the stale pre-unbind cache in
LedAddressData::data and writes stale non-zero bits of sibling LEDs
sharing a register back to hardware.

[ ... ]

> +#[vtable]
> +impl led::LedOps for Led<'_> {
> +    type Mode = led::MultiColor;
> +    const BLOCKING: bool = true;
> +    const MAX_BRIGHTNESS: u32 = 1;
> +
> +    fn brightness_set<'bound>(
> +        self: &led::MultiColorDevice<'bound, Self>,
> +        brightness: u32,
> +    ) -> Result<()> {
> +        let mut blink = self.blink.lock();
> +
> +        if brightness == 0 {
> +            *blink = false;
> +        }
> +
> +        self.update_modes(|subled_info| {
> +            if subled_info.brightness() == 0 {
> +                LedMode::Off
> +            } else if *blink {
> +                LedMode::Dim0
> +            } else {
> +                LedMode::On
> +            }
> +        })?;
> +
> +        Ok(())
> +    }
> +
> +    fn blink_set<'bound>(
> +        self: &led::MultiColorDevice<'bound, Self>,
> +        delay_on: &mut usize,
> +        delay_off: &mut usize,
> +    ) -> Result<()> {
> +        let mut blink = self.blink.lock();
> +        if *delay_on == 0 && *delay_off != 0 {
> +            *blink = false;
> +            self.update_modes(|_subled_info| LedMode::Off)?;
> +            return Ok(());
> +        }
> +        if *delay_off == 0 && *delay_on != 0 {
> +            *blink = false;
> +            self.update_modes(|subled_info| {
> +                if subled_info.intensity() == 0 {
> +                    LedMode::Off
> +                } else {
> +                    LedMode::On
> +                }
> +            })?;
> +            return Ok(());
> +        }
> +
> +        *delay_on = 90;
> +        *delay_off = 90;
> +
> +        self.update_modes(|subled_info| {
> +            if subled_info.intensity() == 0 {
> +                LedMode::Off
> +            } else {
> +                LedMode::Dim0
> +            }
> +        })?;
> +        *blink = true;
> +
> +        Ok(())
> +    }
> +}

[Severity: Medium]
Does writing to multi_intensity while hardware blinking is active turn
the LED off instead of changing its color?

When blink_set() enables hardware blinking (for example when the timer
trigger is attached), led_blink_setup() does not set LED_BLINK_SW and
leaves led_cdev->brightness at 0.  A later write to multi_intensity runs:

drivers/leds/led-class-multicolor.c:multi_intensity_store() {
    ...
	if (!test_bit(LED_BLINK_SW, &led_cdev->work_flags))
		led_set_brightness(led_cdev, led_cdev->brightness);
    ...
}

Because led_cdev->brightness is 0, this calls Led::brightness_set(0),
which sets *blink = false and turns all sub-LEDs off.  Likewise, handling
*delay_on == 0 or *delay_off == 0 directly in blink_set() instead of
letting led_set_software_blink() update led_cdev->brightness leaves
led_cdev->brightness stale when multi_intensity is written later.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-synology_disk_leds-v1-0-53249fd3a2ad@posteo.de?part=2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] leds: add driver for disk leds in synology devices
  2026-12-02 15:38   ` sashiko-bot
@ 2026-12-02 15:47     ` Markus Probst
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Probst @ 2026-12-02 15:47 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: linux-leds, devicetree, robh, conor+dt, lee, ojeda, gary

[-- Attachment #1: Type: text/plain, Size: 9123 bytes --]

On Wed, 2026-12-02 at 15:38 +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 5 potential
> issues to consider:
> - [Medium] leds: synology_disk: missing I2C=y Kconfig dependency breaks
>   modular I2C build
> - [Medium] leds: synology_disk: uninitialized mode registers desync
>   cache in probe()
> - [Medium] leds: synology_disk: premature register clear in unbind()
>   before LED drop
> - [Medium] leds: synology_disk: multi_intensity write cancels hardware
>   blink_set()
> - [Low] leds: synology_disk: unsorted Makefile entry and non-standard
>   commit subject
> --
> 
> commit 89384e625f4f23cc76bff85dcf0243a699d6bc61
> Author: Markus Probst <markus.probst@posteo.de>
> 
> leds: add driver for disk leds in synology devices
> 
> This commit adds a Rust I2C LED driver for the Atmega1608 disk LED
> controller used in Synology NAS devices.
> 
> > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> > index 7ec2c8d785426..34cf2a3f0baca 100644
> > --- a/drivers/leds/Kconfig
> > +++ b/drivers/leds/Kconfig
> > @@ -332,6 +332,15 @@ config LEDS_WRAP
> >  	help
> >  	  This option enables support for the PCEngines WRAP programmable LEDs.
> >  
> > +config LEDS_SYNOLOGY_DISK
> > +	tristate "LED Support for disk leds used in Synology devices"
> > +	depends on LEDS_CLASS && LEDS_CLASS_MULTICOLOR
> > +	depends on I2C
> 
> [Severity: Medium]
> Should this depend on I2C=y rather than I2C?
> 
> The Rust I2C abstractions in rust/kernel/lib.rs are only built when
> CONFIG_I2C=y:
> 
> rust/kernel/lib.rs {
>     ...
> #[cfg(CONFIG_I2C = "y")]
> pub mod i2c;
>     ...
> }
> 
> When CONFIG_I2C=m and CONFIG_LEDS_SYNOLOGY_DISK=m, compiling this driver
> fails with unresolved imports for kernel::i2c and
> kernel::module_i2c_driver!.
> 
> > diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
> > index 4d4b089156e24..466549f65f9ca 100644
> > --- a/drivers/leds/Makefile
> > +++ b/drivers/leds/Makefile
> > @@ -101,6 +101,7 @@ obj-$(CONFIG_LEDS_UPBOARD)		+= leds-upboard.o
> >  obj-$(CONFIG_LEDS_WM831X_STATUS)	+= leds-wm831x-status.o
> >  obj-$(CONFIG_LEDS_WM8350)		+= leds-wm8350.o
> >  obj-$(CONFIG_LEDS_WRAP)			+= leds-wrap.o
> > +obj-$(CONFIG_LEDS_SYNOLOGY_DISK)	+= leds_synology_disk.o
> 
> [Severity: Low]
> This isn't a bug, but the LED Platform Drivers section of
> drivers/leds/Makefile asks to be kept sorted alphabetically (between
> CONFIG_LEDS_SUNFIRE and CONFIG_LEDS_SYSCON).  Also, LED subsystem commit
> subjects normally follow the "leds: <driver>: <Capitalized description>"
> convention.
> 
> > diff --git a/drivers/leds/leds_synology_disk.rs b/drivers/leds/leds_synology_disk.rs
> > new file mode 100644
> > index 0000000000000..1f339e2e429e5
> > --- /dev/null
> > +++ b/drivers/leds/leds_synology_disk.rs
> [ ... ]
> > +    fn probe<'bound>(
> > +        idev: &'bound I2cClient<Core<'_>>,
> > +        _id_info: Option<&'bound Self::IdInfo>,
> > +    ) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
> [ ... ]
> > +        let addr = Arc::new(
> > +            KBox::pin_slice::<_, _, Error, Error>(
> > +                |index| {
> > +                    try_pin_init!(LedAddressData {
> > +                        addr: LedAddress::VALUES[index],
> > +                        data <- new_mutex!(0u8),
> > +                    })
> > +                },
> > +                LedAddress::VALUES.len(),
> > +                GFP_KERNEL,
> > +            )?,
> > +            GFP_KERNEL,
> > +        )?;
> [ ... ]
> > +        idev.smbus_io()
> > +            .try_write8(0, 0x01)
> > +            .inspect_err(|err| dev_err!(dev, "unable to remove led mask: {err:?}\n"))?;
> > +
> > +        Ok(SynologyDiskLedDriver { _leds: leds })
> > +    }
> 
> [Severity: Medium]
> Can LedAddressData::data start out of sync with the hardware mode
> registers 0x06..=0x0B in probe()?
> 
> LedAddressData::data is initialized to 0u8, and probe() unmasks register
> 0x01 without clearing or reading registers 0x06..=0x0B.  If the
> bootloader or a previous boot left non-zero mode bits in 0x06..=0x0B,
> those physical LEDs turn on or blink as soon as 0x01 is unmasked while
> their LED class devices report brightness 0.  Calling brightness_set(0)
> then cannot turn them off because update_modes() skips the SMBus write
> when goal == *current (0 == 0).
> 
> > +
> > +    fn unbind<'bound>(dev: &'bound I2cClient<Core<'_>>, _this: Pin<&Self::Data<'bound>>) {
> > +        let _ = dev
> > +            .smbus_io()
> > +            .try_write8(1, 0x01)
> > +            .inspect_err(|err| dev_err!(dev.as_ref(), "unable to set led mask: {err:?}\n"));
> > +
> > +        for addr in LedAddress::VALUES {
> > +            let _ = dev
> > +                .smbus_io()
> > +                .try_write8(0, addr as usize)
> > +                .inspect_err(|err| {
> > +                    dev_err!(
> > +                        dev.as_ref(),
> > +                        "Unable to turn off leds at address {:#2x}: {err:?}\n",
> > +                        (addr as u8)
> > +                    )
> > +                });
> > +        }
> > +    }
> > +}
> 
> [Severity: Medium]
> Does unbind() clear hardware registers before _leds are unregistered?
> 
> In the Rust driver lifecycle, i2c::Adapter::remove_callback() runs
> unbind() before Registration::post_unbind_callback() drops
> SynologyDiskLedDriver and its _leds vector.  While unbind() writes
> registers 0x01 and 0x06..=0x0B without locking or updating
> LedAddressData::data, active triggers or sysfs writes can still call
> update_modes() concurrently.  Then, when post_unbind_callback() drops
> each MultiColorDevice, led_classdev_unregister() calls brightness_set(0)
> -> update_modes(), which compares against the stale pre-unbind cache in
> LedAddressData::data and writes stale non-zero bits of sibling LEDs
> sharing a register back to hardware.
> 
> [ ... ]
> 
> > +#[vtable]
> > +impl led::LedOps for Led<'_> {
> > +    type Mode = led::MultiColor;
> > +    const BLOCKING: bool = true;
> > +    const MAX_BRIGHTNESS: u32 = 1;
> > +
> > +    fn brightness_set<'bound>(
> > +        self: &led::MultiColorDevice<'bound, Self>,
> > +        brightness: u32,
> > +    ) -> Result<()> {
> > +        let mut blink = self.blink.lock();
> > +
> > +        if brightness == 0 {
> > +            *blink = false;
> > +        }
> > +
> > +        self.update_modes(|subled_info| {
> > +            if subled_info.brightness() == 0 {
> > +                LedMode::Off
> > +            } else if *blink {
> > +                LedMode::Dim0
> > +            } else {
> > +                LedMode::On
> > +            }
> > +        })?;
> > +
> > +        Ok(())
> > +    }
> > +
> > +    fn blink_set<'bound>(
> > +        self: &led::MultiColorDevice<'bound, Self>,
> > +        delay_on: &mut usize,
> > +        delay_off: &mut usize,
> > +    ) -> Result<()> {
> > +        let mut blink = self.blink.lock();
> > +        if *delay_on == 0 && *delay_off != 0 {
> > +            *blink = false;
> > +            self.update_modes(|_subled_info| LedMode::Off)?;
> > +            return Ok(());
> > +        }
> > +        if *delay_off == 0 && *delay_on != 0 {
> > +            *blink = false;
> > +            self.update_modes(|subled_info| {
> > +                if subled_info.intensity() == 0 {
> > +                    LedMode::Off
> > +                } else {
> > +                    LedMode::On
> > +                }
> > +            })?;
> > +            return Ok(());
> > +        }
> > +
> > +        *delay_on = 90;
> > +        *delay_off = 90;
> > +
> > +        self.update_modes(|subled_info| {
> > +            if subled_info.intensity() == 0 {
> > +                LedMode::Off
> > +            } else {
> > +                LedMode::Dim0
> > +            }
> > +        })?;
> > +        *blink = true;
> > +
> > +        Ok(())
> > +    }
> > +}
> 
> [Severity: Medium]
> Does writing to multi_intensity while hardware blinking is active turn
> the LED off instead of changing its color?
> 
> When blink_set() enables hardware blinking (for example when the timer
> trigger is attached), led_blink_setup() does not set LED_BLINK_SW and
> leaves led_cdev->brightness at 0.  A later write to multi_intensity runs:
> 
> drivers/leds/led-class-multicolor.c:multi_intensity_store() {
>     ...
> 	if (!test_bit(LED_BLINK_SW, &led_cdev->work_flags))
> 		led_set_brightness(led_cdev, led_cdev->brightness);
>     ...
> }
> 
> Because led_cdev->brightness is 0, this calls Led::brightness_set(0),
> which sets *blink = false and turns all sub-LEDs off.  Likewise, handling
> *delay_on == 0 or *delay_off == 0 directly in blink_set() instead of
> letting led_set_software_blink() update led_cdev->brightness leaves
> led_cdev->brightness stale when multi_intensity is written later.

Everything except the last is a true positive.


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 870 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-12-02 15:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 15:21 [PATCH 0/2] leds: add driver for disk leds in synology devices Markus Probst
2026-12-02 15:21 ` [PATCH 1/2] dt-bindings: leds: Add synology disk led controller Markus Probst
2026-12-02 15:29   ` sashiko-bot
2026-12-02 15:21 ` [PATCH 2/2] leds: add driver for disk leds in synology devices Markus Probst
2026-12-02 15:38   ` sashiko-bot
2026-12-02 15:47     ` Markus Probst

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.