dt-bindings: leds: leds-gpio: fix & extend node regex
Subsystems (2)
PATCH 1/1 dt-bindings: leds: leds-gpio: fix & extend node regex
From: Rafał Miłecki <[email protected]>
The old regex allowed only 1 character to follow the "led-" prefix which was most likely just an overlook. Fix it and while at it allow dashes in node names. It allows more meaningful names and it helpful e.g. when having the same function name with 2 different colors. For example:
1. led-power-white
2. led-power-blue
--- Documentation/devicetree/bindings/leds/leds-gpio.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/leds/leds-gpio.yaml +1 -1
@@ -21,7 +21,7 @@ properties: patternProperties: # The first form is preferred, but fall back to just 'led' anywhere in the # node name to at least catch some child nodes. - "(^led-[0-9a-f]$|led)": + "(^led-[0-9a-f][0-9a-f-]*$|led)": type: object $ref: common.yaml#
Signature · 1 line
2.26.2
Quoted 19 lines · On Wed, 10 Mar 2021 08:00:25 +0100 Rafał Miłecki <[email protected]> wrote:
From: Rafał Miłecki <[email protected]>
The old regex allowed only 1 character to follow the "led-" prefix which was most likely just an overlook. Fix it and while at it allow dashes in node names. It allows more meaningful names and it helpful e.g. when having the same function name with 2 different colors. For example:
1. led-power-white
2. led-power-blueSigned-off-by Rafał Miłecki <[email protected]>--- Documentation/devicetree/bindings/leds/leds-gpio.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/devicetree/bindings/leds/leds-gpio.yaml +0
-0
Documentation/devicetree/bindings/leds/leds-gpio.yaml properties: · line 24
Quoted 5 lines
Documentation/devicetree/bindings/leds/leds-gpio.yaml +1
-1@@ -21,7 +21,7 @@ properties: patternProperties: # The first form is preferred, but fall back to just 'led' anywhere in the # node name to at least catch some child nodes. - "(^led-[0-9a-f]$|led)": + "(^led-[0-9a-f][0-9a-f-]*$|led)":
Why not use +, like everywhere else?
"(^led-[0-9a-f]+$|led)"
Quoted 17 lines · Marek Behun
Quoted 14 lines · On Wed, 10 Mar 2021 08:00:25 +0100 Rafał Miłecki <[email protected]> wrote:
From: Rafał Miłecki <[email protected]>
The old regex allowed only 1 character to follow the "led-" prefix which was most likely just an overlook. Fix it and while at it allow dashes in node names. It allows more meaningful names and it helpful e.g. when having the same function name with 2 different colors. For example:
1. led-power-white
2. led-power-blueSigned-off-by Rafał Miłecki <[email protected]>--- Documentation/devicetree/bindings/leds/leds-gpio.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
Documentation/devicetree/bindings/leds/leds-gpio.yaml properties: · line 24
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-gpio.yaml +1
-1@@ -21,7 +21,7 @@ properties: patternProperties: # The first form is preferred, but fall back to just 'led' anywhere in the # node name to at least catch some child nodes. - "(^led-[0-9a-f]$|led)": + "(^led-[0-9a-f][0-9a-f-]*$|led)":Why not use +, like everywhere else?
"(^led-[0-9a-f]+$|led)"
1. Your regex doesn't allow dashes. I described that in commit message.
2. If I use one range and +, that will allow unwanted names like "led--power"
Quoted 32 lines · On Fri, 12 Mar 2021 08:52:16 +0100 Rafał Miłecki <[email protected]> wrote:
Quoted 17 lines · Marek Behun
Quoted 14 lines · On Wed, 10 Mar 2021 08:00:25 +0100 Rafał Miłecki <[email protected]> wrote:
From: Rafał Miłecki <[email protected]>
The old regex allowed only 1 character to follow the "led-" prefix which was most likely just an overlook. Fix it and while at it allow dashes in node names. It allows more meaningful names and it helpful e.g. when having the same function name with 2 different colors. For example:
1. led-power-white
2. led-power-blueSigned-off-by Rafał Miłecki <[email protected]>--- Documentation/devicetree/bindings/leds/leds-gpio.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 13 lines
Documentation/devicetree/bindings/leds/leds-gpio.yaml properties: · line 24
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-gpio.yaml +1
-1@@ -21,7 +21,7 @@ properties: patternProperties: # The first form is preferred, but fall back to just 'led' anywhere in the # node name to at least catch some child nodes. - "(^led-[0-9a-f]$|led)": + "(^led-[0-9a-f][0-9a-f-]*$|led)":Why not use +, like everywhere else?
"(^led-[0-9a-f]+$|led)"
Quoted 1 line
1. Your regex doesn't allow dashes. I described that in commit message.
Ah, I confess I did not read the commit message. My fault.
Quoted 1 line
2. If I use one range and +, that will allow unwanted names like "led--power"
But this can happen anyway. Your regex will match for example "led-deaf------beef".
Moreover you give as an example names
led-power-white
led-power-blue
but the regex only allows hexadecimal characters, ie
led-dead-beef
led-1f-3
The idea is that the string after "led-" is a hexadecimal address. Names like
led-power-white
shouldn't be used, as far as I understand.
Marek
Quoted 35 lines · Marek Behun
Quoted 32 lines · On Fri, 12 Mar 2021 08:52:16 +0100 Rafał Miłecki <[email protected]> wrote:
Quoted 30 lines · Marek Behun
Quoted 19 lines · On Wed, 10 Mar 2021 08:00:25 +0100 Rafał Miłecki <[email protected]> wrote:
From: Rafał Miłecki <[email protected]>
The old regex allowed only 1 character to follow the "led-" prefix which was most likely just an overlook. Fix it and while at it allow dashes in node names. It allows more meaningful names and it helpful e.g. when having the same function name with 2 different colors. For example:
1. led-power-white
2. led-power-blueSigned-off-by Rafał Miłecki <[email protected]>--- Documentation/devicetree/bindings/leds/leds-gpio.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/devicetree/bindings/leds/leds-gpio.yaml +0
-0Documentation/devicetree/bindings/leds/leds-gpio.yaml properties: · line 24
Quoted 5 lines
Documentation/devicetree/bindings/leds/leds-gpio.yaml +1
-1@@ -21,7 +21,7 @@ properties: patternProperties: # The first form is preferred, but fall back to just 'led' anywhere in the # node name to at least catch some child nodes. - "(^led-[0-9a-f]$|led)": + "(^led-[0-9a-f][0-9a-f-]*$|led)":Why not use +, like everywhere else?
"(^led-[0-9a-f]+$|led)"
Quoted 8 lines
Quoted 1 line
1. Your regex doesn't allow dashes. I described that in commit message.
Ah, I confess I did not read the commit message. My fault.
Quoted 1 line
2. If I use one range and +, that will allow unwanted names like "led--power"
But this can happen anyway. Your regex will match for example "led-deaf------beef".
You're right. I probably was overthinking that ;)
Quoted 11 lines
Moreover you give as an example names
led-power-white
led-power-blue
but the regex only allows hexadecimal characters, ie
led-dead-beef
led-1f-3The idea is that the string after "led-" is a hexadecimal address. Names like
led-power-white
shouldn't be used, as far as I understand.
Oops!
1. My regex was meant to be [0-9][a-z-][0-9][a-z-]+
2. I totally missed that nodename should contain hex num and not a name
My patch is based on bad binding understanding.
So as I understand it now, the point of led hex number is to enumerate nodes. That way we avoid:
ERROR (duplicate_node_names): /leds/led: Duplicate node name
I'm just wondering if there is some cleaner solution than using those led-0, led-1, led-2, led-3, led-4 (...) names.
Would that be acceptable to use address with GPIO number? Example:
leds {
compatible = "gpio-leds";
led@6 {
gpios = <&mpc8572 6 GPIO_ACTIVE_HIGH>;
color = <LED_COLOR_ID_RED>;
};
led@7 {
gpios = <&mpc8572 7 GPIO_ACTIVE_HIGH>;
color = <LED_COLOR_ID_GREEN>;
};
};Quoted 77 lines · On Fri, 12 Mar 2021 10:12:26 +0100 Rafał Miłecki <[email protected]> wrote:
Quoted 35 lines · Marek Behun
Quoted 32 lines · On Fri, 12 Mar 2021 08:52:16 +0100 Rafał Miłecki <[email protected]> wrote:
Quoted 30 lines · Marek Behun
Quoted 19 lines · On Wed, 10 Mar 2021 08:00:25 +0100 Rafał Miłecki <[email protected]> wrote:
From: Rafał Miłecki <[email protected]>
The old regex allowed only 1 character to follow the "led-" prefix which was most likely just an overlook. Fix it and while at it allow dashes in node names. It allows more meaningful names and it helpful e.g. when having the same function name with 2 different colors. For example:
1. led-power-white
2. led-power-blueSigned-off-by Rafał Miłecki <[email protected]>--- Documentation/devicetree/bindings/leds/leds-gpio.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/devicetree/bindings/leds/leds-gpio.yaml +0
-0Documentation/devicetree/bindings/leds/leds-gpio.yaml properties: · line 24
Quoted 5 lines
Documentation/devicetree/bindings/leds/leds-gpio.yaml +1
-1@@ -21,7 +21,7 @@ properties: patternProperties: # The first form is preferred, but fall back to just 'led' anywhere in the # node name to at least catch some child nodes. - "(^led-[0-9a-f]$|led)": + "(^led-[0-9a-f][0-9a-f-]*$|led)":Why not use +, like everywhere else?
"(^led-[0-9a-f]+$|led)"Quoted 8 lines
Quoted 1 line
1. Your regex doesn't allow dashes. I described that in commit message.
Ah, I confess I did not read the commit message. My fault.
Quoted 1 line
2. If I use one range and +, that will allow unwanted names like "led--power"
But this can happen anyway. Your regex will match for example "led-deaf------beef".
You're right. I probably was overthinking that ;)
Quoted 11 lines
Moreover you give as an example names
led-power-white
led-power-blue
but the regex only allows hexadecimal characters, ie
led-dead-beef
led-1f-3The idea is that the string after "led-" is a hexadecimal address. Names like
led-power-white
shouldn't be used, as far as I understand.Oops!
1. My regex was meant to be [0-9][a-z-][0-9][a-z-]+
2. I totally missed that nodename should contain hex num and not a nameMy patch is based on bad binding understanding.
So as I understand it now, the point of led hex number is to enumerate nodes. That way we avoid:
ERROR (duplicate_node_names): /leds/led: Duplicate node nameI'm just wondering if there is some cleaner solution than using those led-0, led-1, led-2, led-3, led-4 (...) names.
Would that be acceptable to use address with GPIO number? Example:
Quoted 11 lines
leds {
compatible = "gpio-leds";
led@6 {
gpios = <&mpc8572 6 GPIO_ACTIVE_HIGH>;
color = <LED_COLOR_ID_RED>;
};
led@7 {
gpios = <&mpc8572 7 GPIO_ACTIVE_HIGH>;
color = <LED_COLOR_ID_GREEN>;
};
};I don't know. This is a question for Rob Herring. But why is led-0, led-1, led-2 not good enough? You can still define function via the function property:
led-7 {
gpios = <&mpc8572 7 GPIO_ACTIVE_HIGH>;
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_POWER;
};
[Rob: please kindly comment on nodes numbering]
Quoted 92 lines · Marek Behun
Quoted 77 lines · On Fri, 12 Mar 2021 10:12:26 +0100 Rafał Miłecki <[email protected]> wrote:
Quoted 35 lines · Marek Behun
Quoted 32 lines · On Fri, 12 Mar 2021 08:52:16 +0100 Rafał Miłecki <[email protected]> wrote:
Quoted 30 lines · Marek Behun
Quoted 19 lines · On Wed, 10 Mar 2021 08:00:25 +0100 Rafał Miłecki <[email protected]> wrote:
From: Rafał Miłecki <[email protected]>
The old regex allowed only 1 character to follow the "led-" prefix which was most likely just an overlook. Fix it and while at it allow dashes in node names. It allows more meaningful names and it helpful e.g. when having the same function name with 2 different colors. For example:
1. led-power-white
2. led-power-blueSigned-off-by Rafał Miłecki <[email protected]>--- Documentation/devicetree/bindings/leds/leds-gpio.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/devicetree/bindings/leds/leds-gpio.yaml +0
-0Documentation/devicetree/bindings/leds/leds-gpio.yaml properties: · line 24
Quoted 5 lines
Documentation/devicetree/bindings/leds/leds-gpio.yaml +1
-1@@ -21,7 +21,7 @@ properties: patternProperties: # The first form is preferred, but fall back to just 'led' anywhere in the # node name to at least catch some child nodes. - "(^led-[0-9a-f]$|led)": + "(^led-[0-9a-f][0-9a-f-]*$|led)":Why not use +, like everywhere else?
"(^led-[0-9a-f]+$|led)"Quoted 8 lines
Quoted 1 line
1. Your regex doesn't allow dashes. I described that in commit message.
Ah, I confess I did not read the commit message. My fault.
Quoted 1 line
2. If I use one range and +, that will allow unwanted names like "led--power"
But this can happen anyway. Your regex will match for example "led-deaf------beef".
You're right. I probably was overthinking that ;)
Quoted 11 lines
Moreover you give as an example names
led-power-white
led-power-blue
but the regex only allows hexadecimal characters, ieled-dead-beef led-1f-3The idea is that the string after "led-" is a hexadecimal address. Names like
led-power-white
shouldn't be used, as far as I understand.Oops!
1. My regex was meant to be [0-9][a-z-][0-9][a-z-]+
2. I totally missed that nodename should contain hex num and not a nameMy patch is based on bad binding understanding.
So as I understand it now, the point of led hex number is to enumerate nodes. That way we avoid:
ERROR (duplicate_node_names): /leds/led: Duplicate node nameI'm just wondering if there is some cleaner solution than using those led-0, led-1, led-2, led-3, led-4 (...) names.
Would that be acceptable to use address with GPIO number? Example:
Quoted 11 lines
leds { compatible = "gpio-leds"; led@6 { gpios = <&mpc8572 6 GPIO_ACTIVE_HIGH>; color = <LED_COLOR_ID_RED>; }; led@7 { gpios = <&mpc8572 7 GPIO_ACTIVE_HIGH>; color = <LED_COLOR_ID_GREEN>; }; };
Quoted 8 lines
I don't know. This is a question for Rob Herring. But why is led-0, led-1, led-2 not good enough? You can still define function via the function property:
led-7 { gpios = <&mpc8572 7 GPIO_ACTIVE_HIGH>; color = <LED_COLOR_ID_GREEN>; function = LED_FUNCTION_POWER;};
1. I found is a bit unnatural
2. Inserting/removing single LED may result in renaming nodes
Nothing really serious, I'm just wondering if that could be slightly improved.
Rob Herring
maintainerQuoted 4 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
The old regex allowed only 1 character to follow the "led-" prefix which was most likely just an overlook.
Indeed.
Quoted 5 lines
Fix it and while at it allow dashes in
node names. It allows more meaningful names and it helpful e.g. when having the same function name with 2 different colors. For example:
1. led-power-white
2. led-power-blue
No, node names are supposed to be generic and reflect the class of device.
Quoted 22 lines
Signed-off-by Rafał Miłecki <[email protected]>--- Documentation/devicetree/bindings/leds/leds-gpio.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/devicetree/bindings/leds/leds-gpio.yaml +1
-1@@ -21,7 +21,7 @@ properties: patternProperties: # The first form is preferred, but fall back to just 'led' anywhere in the # node name to at least catch some child nodes. - "(^led-[0-9a-f]$|led)": + "(^led-[0-9a-f][0-9a-f-]*$|led)": type: object $ref: common.yaml#Signature · 1 line
2.26.2
Quoted 8 lines · Rob Herring
Quoted 4 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
The old regex allowed only 1 character to follow the "led-" prefix which was most likely just an overlook.
Indeed.
Quoted 8 lines
Quoted 5 lines
Fix it and while at it allow dashes in
node names. It allows more meaningful names and it helpful e.g. when having the same function name with 2 different colors. For example:
1. led-power-white
2. led-power-blueNo, node names are supposed to be generic and reflect the class of device.
There was some extra discussion on this patch that has ended up with a question about numbering nodes.
Current binding assumes that nodes should be numbered with independent suffix numbers like:
led-0 { };
led-1 { };
led-2 { };
Do you think this could / should be improved somehow?
One option I was thinking about was using:
led@0 { };
led@5 { };
where numbers ("0", "5") should match GPIO numbers.
Is that a valid solution and does it improve things to make it worth it?
Rob Herring
maintainerQuoted 19 lines · Rafał Miłecki
Quoted 8 lines · Rob Herring
Quoted 4 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
The old regex allowed only 1 character to follow the "led-" prefix which was most likely just an overlook.
Indeed.
Quoted 8 lines
Quoted 5 lines
Fix it and while at it allow dashes in
node names. It allows more meaningful names and it helpful e.g. when having the same function name with 2 different colors. For example:
1. led-power-white
2. led-power-blueNo, node names are supposed to be generic and reflect the class of device.
Quoted 8 lines
There was some extra discussion on this patch that has ended up with a question about numbering nodes.
Current binding assumes that nodes should be numbered with independent suffix numbers like:
led-0 { };
led-1 { };
led-2 { };Do you think this could / should be improved somehow?
No, we have other ways for meaningful names (label, color, function, etc.).
Quoted 6 lines
One option I was thinking about was using:
led@0 { };
led@5 { };
where numbers ("0", "5") should match GPIO numbers.Is that a valid solution and does it improve things to make it worth it?
What if you have <gpioa 1> and <gpiob 1>?
The cells in a consumer for a provider are opaque to the consumer.
Rob
Quoted 36 lines · Rob Herring
Quoted 19 lines · Rafał Miłecki
Quoted 8 lines · Rob Herring
Quoted 4 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
The old regex allowed only 1 character to follow the "led-" prefix which was most likely just an overlook.
Indeed.
Quoted 8 lines
Quoted 5 lines
Fix it and while at it allow dashes in
node names. It allows more meaningful names and it helpful e.g. when having the same function name with 2 different colors. For example:
1. led-power-white
2. led-power-blueNo, node names are supposed to be generic and reflect the class of device.
Quoted 8 lines
There was some extra discussion on this patch that has ended up with a question about numbering nodes.
Current binding assumes that nodes should be numbered with independent suffix numbers like:
led-0 { };
led-1 { };
led-2 { };Do you think this could / should be improved somehow?
No, we have other ways for meaningful names (label, color, function, etc.).
Quoted 5 lines
One option I was thinking about was using:
led@0 { };
led@5 { };
where numbers ("0", "5") should match GPIO numbers.
Quoted 5 lines
Quoted 1 line
Is that a valid solution and does it improve things to make it worth it?
What if you have <gpioa 1> and <gpiob 1>?
The cells in a consumer for a provider are opaque to the consumer.
Thanks a lot for helping me understand that, it make sense ofc.