Introduce Synology Microp driver
Subsystems (4)
v13 cover Introduce Synology Microp driver
Synology uses a microcontroller in their NAS devices connected to a serial port to control certain LEDs, fan speeds, a beeper, to handle proper shutdown and restart, buttons and fan failures.
This patch series depends on the rust led abstraction [1] and the rust serdev abstraction [2].
This is only a initial version of the driver able to control LEDs. The following rust abstractions would be required, to implement the remaining features:
- hwmon (include/linux/hwmon.h)
- input (include/linux/input.h)
- sysoff handler (include/linux/reboot.h)
[1] https://lore.kernel.org/rust-for-linux/[email protected]/
[2] https://lore.kernel.org/rust-for-linux/[email protected]/
---
Changes in v13:
- adapted to driver-lifetime v5 patch series.
- set blink = false as initial power led state, as set_blink hasn't been
called yet (even though the led is blinking at startup)
- Link to v12: https://patch.msgid.link/[email protected]
Changes in v12:
- adapted to driver-lifetime patch series. The driver can't take
advantage of it, until class devices like led also make use of it.
- Link to v11: https://patch.msgid.link/[email protected]
Changes in v11:
- rebased on top of 7.1-rc1
- add "synology" as devicename to led, like it is done in existing dts
files in the kernel
- fix color for led being orange instead of amber. I personally can't
clearly tell them apart, but apparently its amber.
- replaced MCU with EC in Kconfig help
- Link to v10: https://patch.msgid.link/[email protected]
Changes in v10:
- resolved issues reported by Sashiko Bot:
- removed unneeded include from device tree
- fix typo in of device table
- fix blink not set to false, if delay_off or delay_on is 0
- Link to v9: https://patch.msgid.link/[email protected]
Changes in v9:
- separate fallback and front compatibles in dt schema
- remove front compatibles from of id table, if all functionality is
by covered by the fallback
- remove TODO file
- add [email protected] to Maintainers file entry
- use Delta type in BLINK_DELAY const
- Link to v8: https://patch.msgid.link/[email protected]
Changes in v8:
- removed unnecessary Copy and Clone derive
- added BLINK_DELAY constant
- added compatible id fallbacks
- moved dt schema patch before the driver
- added ds411p
- Link to v7: https://lore.kernel.org/r/[email protected]
Changes in v7:
- remove list of compatible ids from commit msg
- explain what makes the different models not compatible in the commit msg
- remove unnecessary examples
- Link to v6: https://lore.kernel.org/r/[email protected]
Changes in v6:
- moved devicetree bindings patch at the end of the set
- remove several patches
- move of id table from model.rs to synology_microp.rs
- remove the model! macro
- use if blocks in devicetree schema to narrow down the
fan-failure-gpios property
- add multiple devicetree examples to test if blocks
- Link to v5: https://lore.kernel.org/r/[email protected]
Changes in v5:
- add esata led support
- use different compatible for each model
- add visibility modifier to of_device_table macro
- fix match data missing when using PRP0001
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- convert to monolithic driver and moved it into drivers/platform
- removed mfd rust abstraction
- moved dt-bindings to embedded-controller
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- remove default n from Kconfig entry, as n is the default already.
- select RUST_SERIAL_DEV_BUS_ABSTRACTIONS in Kconfig
- add mfd rust abstraction
- split core and led parts into their own driver. It should now be considered a
MFD device.
- split led part of dt binding into its own file
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- fix missing tabs in MAINTAINERS file
- remove word binding from patch subject
- add missing signed-off-by
- add missing help entry in Kconfig
- add missing spdx license headers
- remove no-check{,-cpu}-fan properties from the dt-bindings and replace
them with the check_fan module parameter
- use patternProperties for leds in dt-bindings
- license dt-binding as GPL-2.0-only OR BSD-2-Clause
- move driver from staging tree into mfd tree and mark it as work in
progress inside Kconfig
- only register alert and usb led if fwnode is present
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Markus Probst (2):
dt-bindings: embedded-controller: Add synology microp devices
platform: Add initial synology microp driver
.../synology,ds918p-microp.yaml | 100 +++++++ MAINTAINERS | 7 + drivers/platform/Kconfig | 2 + drivers/platform/Makefile | 1 + drivers/platform/synology_microp/Kconfig | 13 + drivers/platform/synology_microp/Makefile | 3 + drivers/platform/synology_microp/command.rs | 54 ++++ drivers/platform/synology_microp/led.rs | 287 +++++++++++++++++++++ drivers/platform/synology_microp/model.rs | 49 ++++ .../platform/synology_microp/synology_microp.rs | 91 +++++++ 10 files changed, 607 insertions(+)
---
base-commit: 9e171fc1d7d7ab847a750c03571c87ac3c17bd84
change-id: 20260306-synology_microp_initial-0f7dac7b7496
prerequisite-message-id: [email protected]
prerequisite-patch-id: d2aebf69b153c039bbed1d0ed26906708fd22534
prerequisite-patch-id: 84b28da2f5de20fc1785095c647b2ffc35d969a5
prerequisite-patch-id: 67318671a5eed5fb4ad23a450f1cf0e442bf8ca2
prerequisite-message-id: [email protected]
prerequisite-patch-id: b84db329d4372a175cb8d49e4e88c3eecf7eb228
prerequisite-patch-id: 2c30303f409cc8288cc87e241920219f5ddd8390
prerequisite-patch-id: 4e4f0ad370d763ad00b0f75b91fa216f2cc95953
prerequisite-patch-id: 5bcd6b37f3498feebda275dfef78136eba34004e
prerequisite-patch-id: 872b0982f3e5e7d1698d9df3b325e4cd27b27789
prerequisite-patch-id: 3a3c7749e017d9335f58497404d1350e96caf471
prerequisite-patch-id: 3526c9154f581497a11465b936d83ef61a875454
prerequisite-patch-id: 65d8c757b52475c2acc7d22ddc92cd3f0152b55d
prerequisite-patch-id: 4bd31f1414d5248dc080884caadf5f21684a8427
prerequisite-patch-id: 7beadbb0da3e589ed86d12f512d1c83427dd82b4
prerequisite-patch-id: 12cd0f67ffd27347f90c065db491945908206b7f
prerequisite-patch-id: 4642e31f66331f6c3b579377111ea733dbb3a11c
prerequisite-patch-id: 52d67b40b4396c741e2222d6a5bc7927abcb77aa
prerequisite-patch-id: 74ca82ff26cf9c7a993757c87db8be62006e820f
prerequisite-patch-id: 466fb9fa7febbffd8ef51b311c7d9893c11fc0f0
prerequisite-patch-id: e515cd98b06e26721cbbe6a4fbacd251d0073b63
prerequisite-patch-id: 8dc8e75d9f6499a554ef7e474bbacdbf3660a9f2
prerequisite-patch-id: 5fdb9f71dca2f44dd293760a60db125b770f1f55
prerequisite-patch-id: c766a24c2d5064f5ec09daada0b8e8fba862d3aa
prerequisite-patch-id: b768f6456d35fa7a80c015e34bbdba6082dbd593
prerequisite-patch-id: 6a8b17234f12f7084e6e2ce843a7031b0a891ce4
prerequisite-patch-id: 98b2deb9e60c1f28f90c5ee34fd608aaa9fd9420
prerequisite-patch-id: 774b29be66e641ee50cedb4704cf49d8b9fabf50
prerequisite-patch-id: cf95dc936cfc4b3a7a363435a51a48d9009645b3
prerequisite-change-id: 20251217-rust_serdev-ee5481e9085c:v8
prerequisite-patch-id: 45128665162dd9f51a0764deb3815a338948b291
prerequisite-patch-id: b84db329d4372a175cb8d49e4e88c3eecf7eb228
prerequisite-patch-id: 2c30303f409cc8288cc87e241920219f5ddd8390
prerequisite-patch-id: 4e4f0ad370d763ad00b0f75b91fa216f2cc95953
prerequisite-patch-id: 5bcd6b37f3498feebda275dfef78136eba34004e
prerequisite-patch-id: 872b0982f3e5e7d1698d9df3b325e4cd27b27789
prerequisite-patch-id: 3a3c7749e017d9335f58497404d1350e96caf471
prerequisite-patch-id: 3526c9154f581497a11465b936d83ef61a875454
prerequisite-patch-id: 65d8c757b52475c2acc7d22ddc92cd3f0152b55d
prerequisite-patch-id: 4bd31f1414d5248dc080884caadf5f21684a8427
prerequisite-patch-id: 7beadbb0da3e589ed86d12f512d1c83427dd82b4
prerequisite-patch-id: 12cd0f67ffd27347f90c065db491945908206b7f
prerequisite-patch-id: 4642e31f66331f6c3b579377111ea733dbb3a11c
prerequisite-patch-id: 52d67b40b4396c741e2222d6a5bc7927abcb77aa
prerequisite-patch-id: 74ca82ff26cf9c7a993757c87db8be62006e820f
prerequisite-patch-id: 466fb9fa7febbffd8ef51b311c7d9893c11fc0f0
prerequisite-patch-id: e515cd98b06e26721cbbe6a4fbacd251d0073b63
prerequisite-patch-id: 8dc8e75d9f6499a554ef7e474bbacdbf3660a9f2
prerequisite-patch-id: 5fdb9f71dca2f44dd293760a60db125b770f1f55
prerequisite-patch-id: c766a24c2d5064f5ec09daada0b8e8fba862d3aa
prerequisite-patch-id: b768f6456d35fa7a80c015e34bbdba6082dbd593
prerequisite-patch-id: 6a8b17234f12f7084e6e2ce843a7031b0a891ce4
prerequisite-patch-id: 98b2deb9e60c1f28f90c5ee34fd608aaa9fd9420
prerequisite-patch-id: 774b29be66e641ee50cedb4704cf49d8b9fabf50
prerequisite-patch-id: cf95dc936cfc4b3a7a363435a51a48d9009645b3
prerequisite-patch-id: 52b17274481cc770c257d8f95335293eca32a2c5
prerequisite-patch-id: 6ab09768759461c6bea5d4a0833d50e3e41067f1
prerequisite-patch-id: c8506718a0433ffc4b3c686c1261509159a54d31
prerequisite-patch-id: 19eb53ce0c653c1406f8f192f6ad158fb4bd8d8f
prerequisite-patch-id: 55d6a70baf3be7f4da36b82cf02a5a7d59457520
prerequisite-change-id: 20251114-rust_leds-a959f7c2f7f9:v17
prerequisite-patch-id: 45128665162dd9f51a0764deb3815a338948b291
prerequisite-patch-id: b84db329d4372a175cb8d49e4e88c3eecf7eb228
prerequisite-patch-id: 2c30303f409cc8288cc87e241920219f5ddd8390
prerequisite-patch-id: 4e4f0ad370d763ad00b0f75b91fa216f2cc95953
prerequisite-patch-id: 5bcd6b37f3498feebda275dfef78136eba34004e
prerequisite-patch-id: 872b0982f3e5e7d1698d9df3b325e4cd27b27789
prerequisite-patch-id: 3a3c7749e017d9335f58497404d1350e96caf471
prerequisite-patch-id: 3526c9154f581497a11465b936d83ef61a875454
prerequisite-patch-id: 65d8c757b52475c2acc7d22ddc92cd3f0152b55d
prerequisite-patch-id: 4bd31f1414d5248dc080884caadf5f21684a8427
prerequisite-patch-id: 7beadbb0da3e589ed86d12f512d1c83427dd82b4
prerequisite-patch-id: 12cd0f67ffd27347f90c065db491945908206b7f
prerequisite-patch-id: 4642e31f66331f6c3b579377111ea733dbb3a11c
prerequisite-patch-id: 52d67b40b4396c741e2222d6a5bc7927abcb77aa
prerequisite-patch-id: 74ca82ff26cf9c7a993757c87db8be62006e820f
prerequisite-patch-id: 466fb9fa7febbffd8ef51b311c7d9893c11fc0f0
prerequisite-patch-id: e515cd98b06e26721cbbe6a4fbacd251d0073b63
prerequisite-patch-id: 8dc8e75d9f6499a554ef7e474bbacdbf3660a9f2
prerequisite-patch-id: 5fdb9f71dca2f44dd293760a60db125b770f1f55
prerequisite-patch-id: c766a24c2d5064f5ec09daada0b8e8fba862d3aa
prerequisite-patch-id: b768f6456d35fa7a80c015e34bbdba6082dbd593
prerequisite-patch-id: 6a8b17234f12f7084e6e2ce843a7031b0a891ce4
prerequisite-patch-id: 98b2deb9e60c1f28f90c5ee34fd608aaa9fd9420
prerequisite-patch-id: 774b29be66e641ee50cedb4704cf49d8b9fabf50
prerequisite-patch-id: cf95dc936cfc4b3a7a363435a51a48d9009645b3
prerequisite-patch-id: ea861073f29519d3aa4e6e13b6cdf22e6882c093
prerequisite-patch-id: 72e3f69ddcb244e8871f63086c416d485d807901
prerequisite-patch-id: e8dab3c76da6795163eabb6799188856431134b7
PATCH v13 1/2 dt-bindings: embedded-controller: Add synology microp devices
Add the Synology Microp devicetree bindings. Those devices are microcontrollers found on Synology NAS devices. They are connected to a serial port on the host device.
Those devices are used to control certain LEDs, fan speeds, a beeper, to handle buttons, fan failures and to properly shutdown and reboot the device.
The device has a different feature set depending on the Synology NAS model, like having different number of fans, buttons and leds. Depending on the architecture of the model, they also need a different system shutdown behaviour.
--- .../synology,ds918p-microp.yaml | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+)
Documentation/devicetree/bindings/embedded-controller/synology,ds918p-microp.yaml new file +100 -0
@@ -0,0 +1,100 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/embedded-controller/synology,ds918p-microp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Synology NAS on-board Microcontroller + +maintainers: + - Markus Probst <[email protected]> + +description: | + Synology Microp is a microcontroller found in Synology NAS devices. + It is connected to a serial port on the host device. + + It is necessary to properly shutdown and reboot the NAS device and + provides additional functionality such as led control, fan speed control, + a beeper and buttons on the NAS device. + +properties: + compatible: + oneOf: + - items: + - enum: + - synology,ds1221rpp-microp + - synology,rs822p-microp + - synology,rs422p-microp + - const: synology,rs1221p-microp + + - items: + - const: synology,ds1825p-microp + - const: synology,ds1823xsp-microp + + - items: + - enum: + - synology,ds725p-microp + - synology,ds225p-microp + - synology,ds723p-microp + - synology,ds710p-microp + - const: synology,ds214play-microp + + - items: + - enum: + - synology,ds425p-microp + - synology,ds1525p-microp + - synology,ds925p-microp + - synology,ds923p-microp + - synology,ds1522p-microp + - synology,ds1010p-microp + - synology,ds411p-microp + - const: synology,ds918p-microp + + - items: + - enum: + - synology,ds124-microp + - synology,ds223j-microp + - synology,ds223-microp + - const: synology,ds118-microp + + - enum: + - synology,ds118-microp + - synology,ds1823xsp-microp + - synology,rs1221p-microp + - synology,ds918p-microp + - synology,ds214play-microp + + fan-failure-gpios: + description: GPIOs needed to determine which fans stopped working on a fan failure event. + minItems: 2 + maxItems: 3 + +required: + - compatible + +allOf: + - if: + properties: + compatible: + contains: + enum: + - synology,ds918p-microp + - synology,rs422p-microp + then: + required: + - fan-failure-gpios + else: + properties: + fan-failure-gpios: false + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + embedded-controller { + compatible = "synology,ds923p-microp", "synology,ds918p-microp"; + + fan-failure-gpios = <&gpio 68 GPIO_ACTIVE_HIGH>, <&gpio 69 GPIO_ACTIVE_HIGH>; + };
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v13 1/2] dt-bindings: embedded-controller: Add synology microp devices
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] Chronological fallback inversions for older models in DT bindings - [Medium] Model prefix typo…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Chronological fallback inversions for older models in DT bindings
- [Medium] Model prefix typo (DS vs RS) for synology,ds1221rpp-microp
--
commit 420a38b2f09dfb652dcda0d1d821575521540bff
Author: Markus Probst <[email protected]>
dt-bindings: embedded-controller: Add synology microp devices
This commit adds device tree bindings for Synology Microcontrollers (Microp). These devices manage LEDs, fans, beepers, and handle power events via a serial connection on Synology NAS devices.
Quoted 5 lines
Documentation/devicetree/bindings/embedded-controller/synology,ds918p-microp.yaml new file +0
-0
[ ... ]
Documentation/devicetree/bindings/embedded-controller/synology,ds918p-microp.yaml line 25
Quoted 6 lines
Documentation/devicetree/bindings/embedded-controller/synology,ds918p-microp.yaml new file +6
-0+properties: + compatible: + oneOf: + - items: + - enum: + - synology,ds1221rpp-microp
[Severity: Medium]
Is synology,ds1221rpp-microp a typo? Synology models with redundant power supplies are typically RackStations (RS) rather than DiskStations (DS), and this falls back to synology,rs1221p-microp.
Should this be synology,rs1221rpp-microp instead to avoid establishing a typo in the permanent device tree ABI?
Quoted 5 lines
Documentation/devicetree/bindings/embedded-controller/synology,ds918p-microp.yaml new file +5
-0+ - synology,rs822p-microp + - synology,rs422p-microp + - const: synology,rs1221p-microp + + - items:
Documentation/devicetree/bindings/embedded-controller/synology,ds918p-microp.yaml line 40
Quoted 10 lines
Documentation/devicetree/bindings/embedded-controller/synology,ds918p-microp.yaml new file +10
-0+ - const: synology,ds1825p-microp + - const: synology,ds1823xsp-microp + + - items: + - enum: + - synology,ds725p-microp + - synology,ds225p-microp + - synology,ds723p-microp + - synology,ds710p-microp + - const: synology,ds214play-microp
[Severity: Medium]
Is it correct for the older 2010 model synology,ds710p-microp to fall back to the newer 2014 model synology,ds214play-microp?
In Device Tree schemas, newer hardware variants typically fall back to older established base models if they are backward compatible, rather than the other way around.
Documentation/devicetree/bindings/embedded-controller/synology,ds918p-microp.yaml line 51
Quoted 11 lines
Documentation/devicetree/bindings/embedded-controller/synology,ds918p-microp.yaml new file +11
-0+ + - items: + - enum: + - synology,ds425p-microp + - synology,ds1525p-microp + - synology,ds925p-microp + - synology,ds923p-microp + - synology,ds1522p-microp + - synology,ds1010p-microp + - synology,ds411p-microp + - const: synology,ds918p-microp
[Severity: Medium]
Does this correctly map the hardware relationships? The 2010 and 2011 models (synology,ds1010p-microp and synology,ds411p-microp) are configured to fall back to the 2018 model synology,ds918p-microp.
Since synology,ds918p-microp enforces fan-failure-gpios as a required property in the conditional block further down in the file, this inverted fallback forces the older hardware to satisfy constraints defined for newer hardware. This will cause validation failures for correct older device trees.
Should these older models be listed as their own base models or fall back to an older base instead?
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v13 2/2 platform: Add initial synology microp driver
In reply to Markus ProbstAdd a initial synology microp driver, written in Rust.
The driver targets a microcontroller found in Synology NAS devices. It currently only supports controlling of the power led, status led, alert led and usb led. Other components such as fan control or handling on-device buttons will be added once the required rust abstractions are there.
This driver can be used both on arm and x86, thus it goes into the root directory of drivers/platform.
Tested successfully on a Synology DS923+.
--- MAINTAINERS | 7 + drivers/platform/Kconfig | 2 + drivers/platform/Makefile | 1 + drivers/platform/synology_microp/Kconfig | 13 + drivers/platform/synology_microp/Makefile | 3 + drivers/platform/synology_microp/command.rs | 54 ++++ drivers/platform/synology_microp/led.rs | 287 +++++++++++++++++++++ drivers/platform/synology_microp/model.rs | 49 ++++ .../platform/synology_microp/synology_microp.rs | 91 +++++++ 9 files changed, 507 insertions(+)
MAINTAINERS +7 -0
@@ -25838,6 +25838,13 @@ F: drivers/dma-buf/sync_* F: include/linux/sync_file.h F: include/uapi/linux/sync_file.h +SYNOLOGY MICROP DRIVER +M: Markus Probst <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/embedded-controller/synology,ds918p-microp.yaml +F: drivers/platform/synology_microp/ + SYNOPSYS ARC ARCHITECTURE M: Vineet Gupta <[email protected]> L: [email protected]
drivers/platform/Kconfig +2 -0
@@ -22,3 +22,5 @@ source "drivers/platform/arm64/Kconfig" source "drivers/platform/raspberrypi/Kconfig" source "drivers/platform/wmi/Kconfig" + +source "drivers/platform/synology_microp/Kconfig"
drivers/platform/Makefile +1 -0
@@ -15,3 +15,4 @@ obj-$(CONFIG_SURFACE_PLATFORMS) += surface/ obj-$(CONFIG_ARM64_PLATFORM_DEVICES) += arm64/ obj-$(CONFIG_BCM2835_VCHIQ) += raspberrypi/ obj-$(CONFIG_ACPI_WMI) += wmi/ +obj-$(CONFIG_SYNOLOGY_MICROP) += synology_microp/
drivers/platform/synology_microp/Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0 + +config SYNOLOGY_MICROP + tristate "Synology Microp driver" + depends on LEDS_CLASS && LEDS_CLASS_MULTICOLOR + depends on RUST_SERIAL_DEV_BUS_ABSTRACTIONS + help + Enable support for the EC found in Synology NAS devices. + + This is needed to properly shutdown and reboot the device, as well as + additional functionality like fan and LED control. + + This driver is work in progress and may not be fully functional.
drivers/platform/synology_microp/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-y += synology_microp.o
drivers/platform/synology_microp/command.rs new file +54 -0
54 lines not on this page · raw message
drivers/platform/synology_microp/led.rs new file +287 -0
287 lines not on this page · raw message
drivers/platform/synology_microp/model.rs new file +49 -0
49 lines not on this page · raw message
drivers/platform/synology_microp/synology_microp.rs new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v13 2/2] platform: Add initial synology microp driver
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [Critical] The dynamically allocated name for the conditionally registered alert LED is dropped…
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Critical] The dynamically allocated name for the conditionally registered alert LED is dropped prematurely, leaving a dangling pointer in the LED subsystem.
- [Medium] Concurrent LED operations can interleave serial commands, corrupting the communication protocol with the microcontroller.
- [Medium] Setting an LED's brightness to a non-zero value fails to override and disable hardware blinking.
- [Low] The config SYNOLOGY_MICROP depends on a non-existent symbol RUST_SERIAL_DEV_BUS_ABSTRACTIONS.
--
commit 1779a8eccc4d1fbf66dab42036dc8b8505625855
Author: Markus Probst <[email protected]>
platform: Add initial synology microp driver
Add an initial synology microp driver, written in Rust. The driver targets a microcontroller found in Synology NAS devices to support controlling of the power led, status led, alert led and usb led.
drivers/platform/synology_microp/Kconfig line 6
Quoted 11 lines
drivers/platform/synology_microp/Kconfig new file +6
-0@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0 + +config SYNOLOGY_MICROP + tristate "Synology Microp driver" + depends on LEDS_CLASS && LEDS_CLASS_MULTICOLOR + depends on RUST_SERIAL_DEV_BUS_ABSTRACTIONS
[Severity: Low]
Does RUST_SERIAL_DEV_BUS_ABSTRACTIONS exist in the kernel tree?
Kconfig guidelines state that all dependencies must correspond to a valid config definition.
Could this missing symbol cause silent build failures by preventing the driver from ever being enabled?
[ ... ]
Quoted 4 lines
drivers/platform/synology_microp/command.rs new file +0
-0
[ ... ]
Quoted 4 lines
drivers/platform/synology_microp/command.rs new file +4
-0+impl Command { +pub (crate )fn write (self, dev: &serdev::Device <Bound >) ->Result { + dev.write_all( + match self {
[ ... ]
drivers/platform/synology_microp/command.rs line 54
Quoted 8 lines
drivers/platform/synology_microp/command.rs new file +8
-0+ Self::EsataLed(led::State::Off) => &[0x4C, 0x45, 0x33], + }, + serdev::Timeout::Max, + )?; + dev.wait_until_sent (serdev::Timeout ::Max ); +Ok (()) + } +}
[Severity: Medium]
Since multiple LEDs share the same serdev bus, can their operations (like brightness_set and blink_set) be called concurrently from different sysfs contexts?
Without a driver-wide lock protecting the dev.write_all() and dev.wait_until_sent() sequence here, could concurrent calls interleave bytes in the UART transmit buffer and corrupt the communication protocol with the microcontroller?
[ ... ]
Quoted 4 lines
drivers/platform/synology_microp/led.rs new file +0
-0
[ ... ]
drivers/platform/synology_microp/led.rs line 48
Quoted 12 lines
drivers/platform/synology_microp/led.rs new file +12
-0+impl Data { + pub(super) fn register<'a>( + dev: &'a serdev::Device<Bound>, + model: &'a Model, + ) -> impl PinInit<Self, Error> + 'a { + pin_init_scope(move || { + if let Some(color) = model.led_alert { + let name = + CString::try_from_fmt(fmt!("synology:{}:alarm", color.as_c_str().to_str()?))?; + devres::register( + dev.as_ref(), + led::DeviceBuilder::new().color(color).name(&name).build(
[Severity: Critical]
Since the name variable is a local CString scoped to the if let block, won't it be dropped at the end of the block?
The LED core doesn't copy the string, so could passing the reference &name leave a dangling pointer that triggers a use-after-free when sysfs, tracepoints, or triggers access it later?
Quoted 9 lines
drivers/platform/synology_microp/led.rs new file +9
-0+ dev, +try_pin_init! (LedHandler { + blink <-new_mutex! (false ), + command:Command ::AlertLed , + }), + ), +GFP_KERNEL , + )?; + }
[ ... ]
Quoted 5 lines
drivers/platform/synology_microp/led.rs new file +5
-0+fn brightness_set ( + &self, + dev: &Self ::Bus , + _classdev: &led::Device <Self >, + brightness: u32,
drivers/platform/synology_microp/led.rs line 169
Quoted 10 lines
drivers/platform/synology_microp/led.rs new file +10
-0+ ) -> Result<()> { +let mut blink = self.blink.lock (); + (self.command)(if brightness ==0 { + *blink =false ; +State ::Off + }else if *blink { +State ::Blink + }else { +State ::On + })
[Severity: Medium]
The LED subsystem API semantics normally dictate that writing a non-zero value to the brightness sysfs file must stop any active hardware blinking and turn the LED solid on.
By preserving State::Blink here when brightness is greater than 0, does this force users to explicitly write 0 to brightness to stop the blinking before they can turn it solid on?
Quoted 4 lines
drivers/platform/synology_microp/led.rs new file +4
-0+ .write(dev)?; + +Ok (()) + }
[ ... ]
Quoted 6 lines
drivers/platform/synology_microp/led.rs new file +6
-0+fn brightness_set ( + &self, + dev: &Self ::Bus , + classdev: &led::MultiColorDevice <Self >, + brightness:u32 , + ) ->Result <()> {
[ ... ]
drivers/platform/synology_microp/led.rs line 249
Quoted 10 lines
drivers/platform/synology_microp/led.rs new file +10
-0+Command ::StatusLed ( + color, +if subled_brightness ==0 { +State ::Off + }else if *blink { +State ::Blink + }else { +State ::On + }, + )
[Severity: Medium]
Similarly to the standard LedHandler, does preserving State::Blink here when setting a non-zero brightness break the LED subsystem expectation that brightness > 0 overrides and stops blinking?
Quoted 2 lines
drivers/platform/synology_microp/led.rs new file +2
-0+ .write(dev) + }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2