public inbox for linux-leds@vger.kernel.org
 help / color / mirror / Atom feed
From: Andriy Shevencho <andriy.shevchenko@linux.intel.com>
To: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: Jonathan Brophy <professorjonny98@gmail.com>,
	lee Jones <lee@kernel.org>, Pavel Machek <pavel@kernel.org>,
	Jonathan Brophy <professor_jonny@hotmail.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Radoslav Tsvetkov <rtsvetkov@gradotech.eu>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-leds@vger.kernel.org
Subject: Re: [RFC PATCH 0/2] leds: Add optional instance identifier for deterministic naming
Date: Mon, 29 Dec 2025 16:45:00 +0200	[thread overview]
Message-ID: <aVKT7PsPTzRFCuOu@smile.fi.intel.com> (raw)
In-Reply-To: <44ffa209-48b8-439e-a1ce-f9eb2aeb2f26@gmail.com>

On Mon, Dec 29, 2025 at 03:28:20PM +0100, Jacek Anaszewski wrote:
> On 12/29/25 13:30, Andriy Shevencho wrote:
> > On Mon, Dec 29, 2025 at 12:16:17PM +0100, Jacek Anaszewski wrote:
> > > On 12/28/25 19:22, Jonathan Brophy wrote:
> > 
> > > > This patch series introduces an optional "led-instance" device tree property
> > > > to address non-deterministic LED naming when multiple LEDs share the same
> > > > function and color.
> > > > 
> > > > Currently, the LED core appends numerical suffixes (_1, _2, etc.) based on
> > > > registration order when duplicate function:color combinations exist. This
> > > > creates several problems:
> > > > 
> > > > 1. **Non-deterministic naming**: Registration order determines suffix values,
> > > >      which can change across boots due to probe ordering, async initialization,
> > > >      or module load order.
> > > > 
> > > > 2. **Non-semantic identifiers**: Names like "lan:green_23" provide no
> > > >      indication of which physical LED or subsystem they represent.
> > > > 
> > > > 3. **Breaks userspace automation**: Network management tools, LED control
> > > >      daemons, and hardware monitoring cannot reliably identify LEDs.
> > > > 
> > > > 4. **Ambiguous numbering**: "lan:green_23" could be mistaken for LAN port 23
> > > >      when it may actually be the 23rd registered LED of any port.
> > > > 
> > > > 5. **Namespace pollution**: The alternative of adding vendor-specific function
> > > >      names (LED_FUNCTION_LAN_PORT0, LED_FUNCTION_LAN_PORT1...) pollutes the
> > > >      function namespace. The instance identifier keeps standard functions clean
> > > >      while allowing contextual differentiation.
> > > > 
> > > > 6. **Breaks naming convention**: The _1, _2 suffix was intended only as a
> > > >      collision avoidance workaround, but has become the de facto standard for
> > > >      hardware with multiple identical LEDs.
> > > > 
> > > > **Example: 48-port network switch**
> > > > 
> > > > Current behavior (non-deterministic):
> > > >     /sys/class/leds/lan:green      ← Port 0? Unknown
> > > >     /sys/class/leds/lan:green_1    ← Could be any port
> > > >     /sys/class/leds/lan:green_2    ← Could be any port
> > > >     ...
> > > >     /sys/class/leds/lan:green_47   ← Could be port 1 due to probe order
> > > > 
> > > > Proposed behavior (deterministic):
> > > >     /sys/class/leds/lan:green:port0   ← Always port 0
> > > >     /sys/class/leds/lan:green:port1   ← Always port 1
> > > >     /sys/class/leds/lan:green:port2   ← Always port 2
> > > >     ...
> > > >     /sys/class/leds/lan:green:port47  ← Always port 47
> > > > 
> > > > **Example: Multi-domain power indicators**
> > > > 
> > > > Current behavior (non-deterministic):
> > > >     /sys/class/leds/power:red      ← Which power source?
> > > >     /sys/class/leds/power:red_1    ← Which power source?
> > > >     /sys/class/leds/power:red_2    ← Which power source?
> > > > 
> > > > Proposed behavior (deterministic):
> > > >     /sys/class/leds/power:red:mains    ← Mains power indicator
> > > >     /sys/class/leds/power:red:battery  ← Battery power indicator
> > > >     /sys/class/leds/power:red:usb      ← USB power indicator
> > > > 
> > > > **Design principles:**
> > > > 
> > > > - Backward compatible: Instance identifier is optional
> > > > - Extends existing convention: function:color becomes function:color:instance
> > > > - Follows kernel precedent: Similar to eth0/eth1, gpio0/gpio1 naming patterns
> > > > - Ignored with deprecated "label" property: Avoids conflicts with legacy code
> > > > 
> > > > **Alternative solutions considered:**
> > > > 
> > > > 1. function-enumerator: Only supports numbers (0, 1, 2), producing names like
> > > >      "lan:green-0" which are still non-semantic. The 48-port switch needs "port0"
> > > >      to match physical port labels.
> > > 
> > > I think that we have currently everything in place to address the issue
> > > you're trying to solve with this patch. Just introduce dedicated
> > > function like LAN_PORT, and exploit function-enumerator.
> > 
> > The problem as I understood not exactly in this. The reporter wants
> > deterministic way of the mapping between HW numbered LEDs and their respective
> > names. It seems it was already mentioned that current code depends on the
> > arbitrary probe ordering. Saying this, I now think that perhaps GPIO led driver
> > should somehow allocate a range of the LEDs and then enumerate them in
> > accordance with the DT description?
> 
> function-enumerator DT property enables deterministic enumeration.

Ah, that's nice!

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-12-29 14:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-28 18:22 [RFC PATCH 0/2] leds: Add optional instance identifier for deterministic naming Jonathan Brophy
2025-12-28 18:22 ` [RFC PATCH 1/2] leds: core: Add support for led-instance property Jonathan Brophy
2025-12-28 18:35   ` Andriy Shevencho
2025-12-28 18:43     ` Jonathan Brophy
2025-12-28 19:56       ` Andriy Shevencho
2025-12-28 18:22 ` [RFC PATCH 2/2] dt-bindings: leds: common: Add " Jonathan Brophy
2025-12-30 18:28   ` Rob Herring (Arm)
2026-01-02 10:12   ` Krzysztof Kozlowski
2025-12-28 18:31 ` [RFC PATCH 0/2] leds: Add optional instance identifier for deterministic naming Andriy Shevencho
2025-12-28 19:14   ` Jonathan Brophy
2025-12-28 19:59     ` Andriy Shevencho
2025-12-28 20:03     ` Andriy Shevencho
2025-12-29 11:16 ` Jacek Anaszewski
2025-12-29 12:30   ` Andriy Shevencho
2025-12-29 14:28     ` Jacek Anaszewski
2025-12-29 14:45       ` Andriy Shevencho [this message]
2025-12-29 23:59       ` Jonathan Brophy
2025-12-30 16:35         ` Jacek Anaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aVKT7PsPTzRFCuOu@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jacek.anaszewski@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=professor_jonny@hotmail.com \
    --cc=professorjonny98@gmail.com \
    --cc=robh@kernel.org \
    --cc=rtsvetkov@gradotech.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox