Dts aliases label bug?

I'm having issues compiling a dts depending on the label format and I don't know if I am interpreting things wrong and the node label and led label property are different things.

It says in the linux documentation under leds:

label:
description:
The label for this LED. If omitted, the label is taken from the node name
(excluding the unit address). It has to uniquely identify a device, i.e.
no other LED class device can be assigned the same label. This property is
deprecated - use 'function' and 'color' properties instead.
function-enumerator has no effect when this property is present.

https://www.kernel.org/doc/Documentation/devicetree/bindings/leds/common.yaml

if I define it as below it compiles:

aliases {
led-boot = &led_system_red;
};

led_system_red: system-red {
gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>;
color = <LED_COLOR_ID_RED>;
};

If I format it like this, it fails to build:

aliases {
led-boot = &led_system_red;
};

system-red {
label = led_system_red
gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>;
color = <LED_COLOR_ID_RED>;
};

This is my build error:

ERROR (path_references): /aliases: Reference to non-existent node or label "led_system_red"

I guess using the node name for the aliases fixes my issue but is this a bug or not?

I don't really have a clue about DTS. But I think you've just missed the semicolon after label. So it has to look like:

label = "led_system_red";

yep thats likely the issue

sorry that is just my typing error when pasting into the forum the semi colon was present when building the DTS.

I think the led label and node label are formally different properties.

Sorry it's a while ago I've messed around with DTS.

aliases {
      led-boot = &led_system_red;
};

Then you access to it with &.

So it has to look like:

&led_system_red {
      label = "system-red";
      gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>;
      color = <LED_COLOR_ID_RED>;
};

You could also put it into a node like:

leds {
	compatible = "gpio-leds";
	led_system_red: system-red {
	label = "system-red";
	<&tlmm 25 GPIO_ACTIVE_HIGH>;
	};

But don't nail me on that. I don't have a clue if this node approach is outdated already or not. There are others with more clue then me for sure.

The bottom suggestion does not work it is the same format as my code,

I think the & is used as to reference to a node it is often used to point to an include to reference a section in a .dtsi file for example i is why it is used on the alias to reference the node.

I found from my playing around that an alias only likes the format below using the label as a reference I could not get it to notice the node::

[label:] node-name[@unit-address] {
[properties definitions]
[child nodes]
};

aliases {
		serial0 = &blsp1_uart1;
		...

		led-boot = &led_system_blue;
		led-failsafe = &led_status_white;
		led-running = &led_status_white;
		led-upgrade = &led_system_blue;
	};

leds {
		compatible = "gpio-leds";
		pinctrl-0 = <&leds_pins>;
		pinctrl-names = "default";

		led_system_blue: led_system_blue {
			label = "led_system_blue";
			gpio = <&tlmm 24 0>;
			default-state = "on";
		};
		
		led_status_white: led_status_white {
			label = "led_status_white";
			gpio = <&tlmm 23 0>;
			default-state = "off";
		};
	};

&tlmm {
...
leds_pins: leds_pins {
		led_system_blue {
			pins = "gpio24";
			function = "gpio";
			drive-strength = <8>;
			bias-pull-down;
		};
		
		led_status_white {
			pins = "gpio23";
			function = "gpio";
			drive-strength = <8>;
			bias-pull-down;
		};
	};

all relevant led nodes and phandles from a working dts, in which the leds function properly

I don't know if they refer to the label property of the node or the label within the node property's

But that's what I have that compiles and works but it says in the Linux docs it says it is depreciated; I tried the other way and it does not work I'm just a little confused they have called two things label.

I think they mean the property label= is depreciated and instead use function and color to describe the led.

I think they mean this is a bad

		led_status_white: led_status_white {
			label = "led_status_white";

And this is good:

		led_system_red: red {
			color = <LED_COLOR_ID_RED>;
			function = LED_FUNCTION_STATUS;

It seems the aliases does not follow the label = and from my testing it does not follow the node either but I'm not sure I'm interpreting things correct.

All I can say is, I am using this style in my dts and everything compiles and works perfectly building against against kernel 5.10 -> 6.6.56

I agree with @Hostle.

If I look into the document you've linked. I would say that the pointer "label" is deprecated? So why you want to use it then?

label:
description:
The label for this LED. If omitted, the label is taken from the node name
(excluding the unit address). It has to uniquely identify a device, i.e.
no other LED class device can be assigned the same label. This property
is deprecated - use 'function' and 'color' properties instead.
function-enumerator has no effect when this property is present.

Another example (without any use of "label"):

	aliases {
		led-boot = &pwr;
		led-failsafe = &pwr;
	};
...
	leds {
		compatible = "gpio-leds";

		pwr: pwr {
			color = <LED_COLOR_ID_ORANGE>;
			function = LED_FUNCTION_POWER;
			gpios = <&tlmm 28 GPIO_ACTIVE_HIGH>;
		};

		lan  {
			color = <LED_COLOR_ID_BLUE>;
			function = LED_FUNCTION_LAN;
			gpios = <&tlmm 29 GPIO_ACTIVE_HIGH>;
		};

		wlan2g  {
			color = <LED_COLOR_ID_BLUE>;
			function = LED_FUNCTION_WLAN;
			function-enumerator = <0>;
			gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "phy0radio";
		};

		wlan5g  {
			color = <LED_COLOR_ID_BLUE>;
			function = LED_FUNCTION_WLAN;
			function-enumerator = <1>;
			gpios = <&tlmm 31 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "phy1radio";
		};
	};
};

Y, and the error message you've posted is refering to a missing node or label. So either both is wrong or one of them is wrong. You said that label was a copy paste error. So the node is left.

When you use &<name-or-label> then that name or label needs to be defined elsewhere as it's (indeed) a reference.

So in the first example you have a label led_system_red so you can reference it.
In the second example you reference a label which doesn't exist, so it fails.

note that there is no point in having a label with the same value as the name. A label is specifically so you can use a different value then the name, usually something simpler.

1 Like

yip it is just there is two labels a node label and a label property the alias only works with a node label or a node name, documentation is not the best, I have it working now adn have dropped the label property in favour of function and colour and it works as intended.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.