led: unify led trigger tables
Subsystems (2)
PATCH 1/4 led: unify led trigger tables
Currently we have two slightly different led-trigger tables. One in the core module, and the other one in the led-triggers module. The one in the core module, which is used to parse the device-tree triggers, is lacking net-rx and net-tx.
--- drivers/led/core.c | 46 +++++++++++++++++++++++--------------- drivers/led/led-triggers.c | 25 --------------------- 2 files changed, 28 insertions(+), 43 deletions(-)
drivers/led/core.c +28 -18
@@ -256,22 +256,35 @@ void led_unregister(struct led *led)list_del (&led->list); } -struct led_trg { -const char *str; -enum led_trigger trg; +static char *trigger_names[] = { + [LED_TRIGGER_PANIC ] ="panic" , + [LED_TRIGGER_HEARTBEAT ] ="heartbeat" , + [LED_TRIGGER_NET_RX ] ="net-rx" , + [LED_TRIGGER_NET_TX ] ="net-tx" , + [LED_TRIGGER_NET_TXRX ] ="net" , + [LED_TRIGGER_DEFAULT_ON ] ="default-on" , }; -static struct led_trg triggers[] = { - { .str ="heartbeat" ,LED_TRIGGER_HEARTBEAT , }, - { .str ="panic" ,LED_TRIGGER_PANIC , }, - { .str ="net" ,LED_TRIGGER_NET_TXRX , }, - { .str ="default-on" ,LED_TRIGGER_DEFAULT_ON , }, -}; +const char *trigger_name (enum led_trigger trigger) +{ +return trigger_names[trigger]; +} + +enum led_trigger trigger_by_name (const char *name) +{ +int i; + +for (i =0 ; i <LED_TRIGGER_MAX ; i++) +if (!strcmp (name, trigger_names[i])) +return i; + +return LED_TRIGGER_MAX ; +}void led_of_parse_trigger (struct led *led,struct device_node *np) { +enum led_trigger trg;const char *trigger; -int i; trigger =of_get_property (np,"linux,default-trigger" ,NULL );if (!trigger)
@@ -280,13 +293,10 @@ void led_of_parse_trigger(struct led *led, struct device_node *np)if (!trigger)return ; -for (i =0 ; i <ARRAY_SIZE (triggers); i++) { -struct led_trg *trg = &triggers[i]; -if (!strcmp (trg->str, trigger)) { -/* disable LED before installing trigger */ -led_set (led,0 ); -led_set_trigger (trg->trg, led); -return ; - } + trg =trigger_by_name (trigger); +if (trg !=LED_TRIGGER_MAX ) { +/* disable LED before installing trigger */ +led_set (led,0 ); +led_set_trigger (trg, led); } }
drivers/led/led-triggers.c +0 -25
@@ -143,31 +143,6 @@ int led_set_trigger(enum led_trigger trigger, struct led *led)return 0 ; } -static char *trigger_names[] = { - [LED_TRIGGER_PANIC ] ="panic" , - [LED_TRIGGER_HEARTBEAT ] ="heartbeat" , - [LED_TRIGGER_NET_RX ] ="net-rx" , - [LED_TRIGGER_NET_TX ] ="net-tx" , - [LED_TRIGGER_NET_TXRX ] ="net" , - [LED_TRIGGER_DEFAULT_ON ] ="default-on" , -}; - -const char *trigger_name (enum led_trigger trigger) -{ -return trigger_names[trigger]; -} - -enum led_trigger trigger_by_name (const char *name) -{ -int i; - -for (i =0 ; i <LED_TRIGGER_MAX ; i++) -if (!strcmp (name, trigger_names[i])) -return i; - -return LED_TRIGGER_MAX ; -} -/** * led_triggers_show_info - Show information about all registered * triggers
Signature · 7 lines
2.24.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/4 led: add documentation for net-tx and net-rx triggers
--- Documentation/devicetree/bindings/leds/common.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/leds/common.rst +3 -1
@@ -6,7 +6,9 @@ Common leds properties * ``heartbeat`` - LED flashes at a constant rate * ``panic`` - LED turns on when barebox panics - * ``net`` - LED indicates network activity + * ``net`` - LED indicates network activity (tx and rx) + * ``net-rx`` - LED indicates network activity (rx only) + * ``net-tx`` - LED indicates network activity (tx only) * ``label``: The label for this LED. If omitted, the label is taken from the node name (excluding the unit address).
Signature · 7 lines
2.24.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/4 led: check for 'barebox, default-trigger' when 'linux, default-trigger' is not found
In reply to Hubert FeursteinWhen the linux,default-trigger is not found by barebox, then also check if there might be a barebox,default-trigger.
--- drivers/led/core.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/led/core.c +8 -5
@@ -274,6 +274,9 @@ enum led_trigger trigger_by_name(const char *name) {int i; +if (!name) +return LED_TRIGGER_MAX ; +for (i =0 ; i <LED_TRIGGER_MAX ; i++)if (!strcmp (name, trigger_names[i]))return i;
@@ -287,13 +290,13 @@ void led_of_parse_trigger(struct led *led, struct device_node *np)const char *trigger; trigger =of_get_property (np,"linux,default-trigger" ,NULL ); -if (!trigger) - trigger =of_get_property (np,"barebox,default-trigger" ,NULL ); + trg =trigger_by_name (trigger); -if (!trigger) -return ; +if (trg ==LED_TRIGGER_MAX ) { + trigger =of_get_property (np,"barebox,default-trigger" ,NULL ); + trg =trigger_by_name (trigger); + } - trg =trigger_by_name (trigger);if (trg !=LED_TRIGGER_MAX ) {/* disable LED before installing trigger */ led_set (led,0 );
Signature · 7 lines
2.24.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 4/4 led: parse panic-indicator from device-tree
In reply to Hubert Feurstein--- Documentation/devicetree/bindings/leds/common.rst | 3 +++ drivers/led/core.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/leds/common.rst +3 -0
@@ -12,3 +12,6 @@ Common leds properties * ``label``: The label for this LED. If omitted, the label is taken from the node name (excluding the unit address). + +* ``panic-indicator`` - This property specifies that the LED should be used as a + panic indicator.
drivers/led/core.c +8 -3
@@ -286,11 +286,16 @@ enum led_trigger trigger_by_name(const char *name)void led_of_parse_trigger (struct led *led,struct device_node *np) { -enum led_trigger trg; +enum led_trigger trg =LED_TRIGGER_MAX ;const char *trigger; - trigger =of_get_property (np,"linux,default-trigger" ,NULL ); - trg =trigger_by_name (trigger); +if (of_property_read_bool (np,"panic-indicator" )) + trg =LED_TRIGGER_PANIC ; + +if (trg ==LED_TRIGGER_MAX ) { + trigger =of_get_property (np,"linux,default-trigger" ,NULL ); + trg =trigger_by_name (trigger); + }if (trg ==LED_TRIGGER_MAX ) { trigger =of_get_property (np,"barebox,default-trigger" ,NULL );
Signature · 7 lines
2.24.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 10 lines · Hubert Feurstein
Currently we have two slightly different led-trigger tables. One in the core module, and the other one in the led-triggers module. The one in the core module, which is used to parse the device-tree triggers, is lacking net-rx and net-tx.
Signed-off-by Hubert Feurstein <[email protected]>--- drivers/led/core.c | 46 +++++++++++++++++++++++--------------- drivers/led/led-triggers.c | 25 --------------------- 2 files changed, 28 insertions(+), 43 deletions(-)
Applied, thanks
Sascha
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox