Re: [PATCH v3] Introduce Synology x86 NAS LEDs driver
From: Andy Shevchenko
Date: Tue Nov 24 2026 - 13:01:37 EST
On Tue, Nov 24, 2026 at 01:45:46PM +0100, Ondrej Zary wrote:
> Add platform driver for Synology x86-based NAS devices to support HDD LEDs
> controlled by ICH9 GPIO pins.
>
> Only DS411+II is supported for now (DS411+ should be the same except CPU).
>
> Unfortunately, the DMI data in BIOS is not very helpful to identify the
> device as almost all strings are "To be filled by O.E.M.". Match also the
> BIOS date and then check presence of PCI devices (host bridge, LPC bridge,
> onboard SiI3531 SATA controller and i82574L ethernet controller) to avoid
> activation on other systems.
>
> Buttons and other LEDs are not supported by this driver because they're
> controlled by a PIC MCU (connected through serial port).
...
> +struct synology_pci_dev {
> + unsigned int bus;
> + unsigned int devfn;
> + struct pci_device_id id;
> +};
> +
> +/* onboard PCI devices found in DS411+ to confirm the machine type (after DMI match) */
> +static const struct synology_pci_dev ds411plus_pci_devices[] __initconst = {
> + /* 00:00.0 Host bridge: Intel Corporation Atom Processor D4xx/D5xx/N4xx/N5xx DMI Bridge */
> + { 0, PCI_DEVFN(0, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0xa000,
> + PCI_VENDOR_ID_INTEL, 0xa000) } },
> + /* 00:1f.0 ISA bridge: Intel Corporation 82801IR (ICH9R) LPC Interface Controller */
> + { 0, PCI_DEVFN(0x1f, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x2916,
> + PCI_VENDOR_ID_INTEL, 0x2916) } },
> + /* 02:00.0 Mass storage controller: Silicon Image, Inc. SiI 3531 Serial ATA Controller */
> + { 2, PCI_DEVFN(0x00, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_CMD, 0x3531,
> + PCI_VENDOR_ID_CMD, 0x3531) } },
> + /* 03:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection */
> + { 3, PCI_DEVFN(0x00, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x10d3,
> + PCI_VENDOR_ID_INTEL, 0x0000) } },
> + {}
> +};
> +/* check if all PCI devices in the list are present at specified locations */
> +static bool __init synology_pci_devices_present(const struct synology_pci_dev *list)
> +{
> + const struct synology_pci_dev *d;
> +
> + for (d = list; d->id.vendor; d++) {
> + struct pci_dev *pdev = pci_get_domain_bus_and_slot(0, d->bus, d->devfn);
> +
> + if (!pdev)
> + return false;
> + bool matched = d->id.vendor == pdev->vendor &&
> + d->id.device == pdev->device &&
> + d->id.subvendor == pdev->subsystem_vendor &&
> + d->id.subdevice == pdev->subsystem_device;
Don't mix variable definitions with the code (it's exceptionally possible
for a couple of cases, none of which is this one). Can't it use
pci_match_id() approach with driver_data? (If we ever need this check.)
> + pci_dev_put(pdev);
> + if (!matched)
> + return false;
> + }
> +
> + return true;
> +}
Yeah, this becomes an ugly part of the patch...
...
> +static int __init synology_init(void)
> +{
> + struct platform_device_info leds_info = {
> + .name = "leds-gpio",
> + .id = PLATFORM_DEVID_NONE,
> + };
> + int err;
> +
No blank line in the definition block.
> + const struct dmi_system_id *dmi = dmi_first_match(synology_systems);
Split assignment and keep the variables in reversed xmas tree order.
> + if (!dmi)
> + return -ENODEV;
> +
> + /* DS411+ DMI match is too generic, confirm by onboard PCI devices */
> + if (!strcmp(dmi->ident, "DS411+") && !synology_pci_devices_present(ds411plus_pci_devices))
> + return -ENODEV;
> +
> + pr_info("Detected Synology NAS %s\n", dmi->ident);
> +
> + err = software_node_register_node_group(synology_swnodes);
> + if (err) {
> + pr_err("failed to register software nodes: %d\n", err);
> + return err;
> + }
> +
> + leds_info.fwnode = software_node_fwnode(&synology_gpio_leds_node);
> + synology_leds_pdev = platform_device_register_full(&leds_info);
> + err = PTR_ERR_OR_ZERO(synology_leds_pdev);
> + if (err) {
> + pr_err("error registering platform device: %pe\n", synology_leds_pdev);
> + goto err_unregister;
> + }
> +
> + return 0;
> +
> +err_unregister:
> + software_node_unregister_node_group(synology_swnodes);
> + return err;
> +}
--
With Best Regards,
Andy Shevchenko