leds: trigger: Introduce a NETDEV trigger
Subsystems (3)
PATCH v3 1/1 leds: trigger: Introduce a NETDEV trigger
From: Ben Whitten <[email protected]>
This commit introduces a NETDEV trigger for named device activity. Available triggers are link, rx, and tx.
---
Changes in v3:
Cancel the software blink prior to a oneshot re-queue Changes in v2:
Sort includes and redate documentation
Correct licence
Remove macro and replace with generic function using enums Convert blink logic in stats work to use led_blink_oneshot Uses configured brightness instead of FULL
--- .../ABI/testing/sysfs-class-led-trigger-netdev | 45 ++ drivers/leds/trigger/Kconfig | 7 + drivers/leds/trigger/Makefile | 1 + drivers/leds/trigger/ledtrig-netdev.c | 503 +++++++++++++++++++++ 4 files changed, 556 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-led-trigger-netdev create mode 100644 drivers/leds/trigger/ledtrig-netdev.c
Documentation/ABI/testing/sysfs-class-led-trigger-netdev new file +45 -0
@@ -0,0 +1,45 @@ +What: /sys/class/leds/<led>/device_name +Date: Dec 2017 +KernelVersion: 4.16 +Contact: [email protected] +Description: + Specifies the network device name to monitor. + +What: /sys/class/leds/<led>/interval +Date: Dec 2017 +KernelVersion: 4.16 +Contact: [email protected] +Description: + Specifies the duration of the LED blink in milliseconds. + Defaults to 50 ms. + +What: /sys/class/leds/<led>/link +Date: Dec 2017 +KernelVersion: 4.16 +Contact: [email protected] +Description: + Signal the link state of the named network device. + If set to 0 (default), the LED's normal state is off. + If set to 1, the LED's normal state reflects the link state + of the named network device. + Setting this value also immediately changes the LED state. + +What: /sys/class/leds/<led>/tx +Date: Dec 2017 +KernelVersion: 4.16 +Contact: [email protected] +Description: + Signal transmission of data on the named network device. + If set to 0 (default), the LED will not blink on transmission. + If set to 1, the LED will blink for the milliseconds specified + in interval to signal transmission. + +What: /sys/class/leds/<led>/rx +Date: Dec 2017 +KernelVersion: 4.16 +Contact: [email protected] +Description: + Signal reception of data on the named network device. + If set to 0 (default), the LED will not blink on reception. + If set to 1, the LED will blink for the milliseconds specified + in interval to signal reception.
drivers/leds/trigger/Kconfig +7 -0
@@ -126,4 +126,11 @@ config LEDS_TRIGGER_PANIC a different trigger. If unsure, say Y. +config LEDS_TRIGGER_NETDEV + tristate "LED Netdev Trigger" + depends on NET && LEDS_TRIGGERS + help + This allows LEDs to be controlled by network device activity. + If unsure, say Y. + endif # LEDS_TRIGGERS
drivers/leds/trigger/Makefile +1 -0
@@ -11,3 +11,4 @@ obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT) += ledtrig-transient.o obj-$(CONFIG_LEDS_TRIGGER_CAMERA) += ledtrig-camera.o obj-$(CONFIG_LEDS_TRIGGER_PANIC) += ledtrig-panic.o +obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += ledtrig-netdev.o
drivers/leds/trigger/ledtrig-netdev.c new file +503 -0
503 lines not on this page · raw message
Signature · 1 line
2.7.4
Ben,
Quoted 6 lines · Ben Whitten
From: Ben Whitten <[email protected]>
This commit introduces a NETDEV trigger for named device activity. Available triggers are link, rx, and tx.
Signed-off-by Ben Whitten <[email protected]>
[]
Quoted 11 lines
drivers/leds/trigger/ledtrig-netdev.c new file +8
-0@@ -0,0 +1,503 @@ +/* +* LED Kernel Netdev Trigger +* +* Toggles the LED to reflect the link and traffic state of a named net device +* +* Copyright 2017 Ben Whitten <[email protected]> +* +* Copyright 2007 Oliver Jowett <[email protected]>
drivers/leds/trigger/ledtrig-netdev.c line 18
Quoted 10 lines
drivers/leds/trigger/ledtrig-netdev.c new file +10
-0+* +* Derived from ledtrig-timer.c which is: +* Copyright 2005-2006 Openedhand Ltd. +* Author: Richard Purdie <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +*/
Have you considered using the new SPDX id instead ? See Thomas doc patches and Greg and Linus comments on the topic
Here this would likely come out this way (yes, using a C++ comment at the top):
Quoted 5 lines
drivers/leds/trigger/ledtrig-netdev.c new file +5
-0+// SPDX-License-Identifier: GPL-2.0 +/* +* LED Kernel Netdev Trigger +* +* Toggles the LED to reflect the link and traffic state of a named net device
drivers/leds/trigger/ledtrig-netdev.c line 18
Quoted 10 lines
drivers/leds/trigger/ledtrig-netdev.c new file +10
-0+* +* Copyright 2017 Ben Whitten <[email protected]> +* +* Copyright 2007 Oliver Jowett <[email protected]> +* +* Derived from ledtrig-timer.c which is: +* Copyright 2005-2006 Openedhand Ltd. +* Author: Richard Purdie <[email protected]> +* +*/
This is cleaner and simpler, don't you think?
Signature · 2 lines
Cordially Philippe Ombredanne
Philippe,
Quoted 46 lines · Philippe Ombredanne
Ben,
Quoted 6 lines · Ben Whitten
From: Ben Whitten <[email protected]>
This commit introduces a NETDEV trigger for named device activity. Available triggers are link, rx, and tx.
Signed-off-by Ben Whitten <[email protected]>[]
Quoted 11 lines
drivers/leds/trigger/ledtrig-netdev.c new file +8
-0@@ -0,0 +1,503 @@ +/* +* LED Kernel Netdev Trigger +* +* Toggles the LED to reflect the link and traffic state of a named net device +* +* Copyright 2017 Ben Whitten <[email protected]> +* +* Copyright 2007 Oliver Jowett <[email protected]> drivers/leds/trigger/ledtrig-netdev.c line 18
Quoted 10 lines
drivers/leds/trigger/ledtrig-netdev.c new file +10
-0+* +* Derived from ledtrig-timer.c which is: +* Copyright 2005-2006 Openedhand Ltd. +* Author: Richard Purdie <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +*/ Have you considered using the new SPDX id instead ? See Thomas doc patches and Greg and Linus comments on the topic
Here this would likely come out this way (yes, using a C++ comment at the top):Quoted 10 lines
drivers/leds/trigger/ledtrig-netdev.c new file +10
-0+// SPDX-License-Identifier: GPL-2.0 +/* +* LED Kernel Netdev Trigger +* +* Toggles the LED to reflect the link and traffic state of a named net device +* +* Copyright 2017 Ben Whitten <[email protected]> +* +* Copyright 2007 Oliver Jowett <[email protected]> +*
Quoted 8 lines
drivers/leds/trigger/ledtrig-netdev.c line 18
Quoted 5 lines
drivers/leds/trigger/ledtrig-netdev.c new file +5
-0+* Derived from ledtrig-timer.c which is: +* Copyright 2005-2006 Openedhand Ltd. +* Author: Richard Purdie <[email protected]> +* +*/ This is cleaner and simpler, don't you think?
Much cleaner. Thank you for the suggestion, I was unaware of this.
Kind regards,
Ben Whitten
Quoted 46 lines · Philippe Ombredanne
Ben,
Quoted 6 lines · Ben Whitten
From: Ben Whitten <[email protected]>
This commit introduces a NETDEV trigger for named device activity. Available triggers are link, rx, and tx.
Signed-off-by Ben Whitten <[email protected]>[]
Quoted 11 lines
drivers/leds/trigger/ledtrig-netdev.c new file +8
-0@@ -0,0 +1,503 @@ +/* +* LED Kernel Netdev Trigger +* +* Toggles the LED to reflect the link and traffic state of a named net device +* +* Copyright 2017 Ben Whitten <[email protected]> +* +* Copyright 2007 Oliver Jowett <[email protected]> drivers/leds/trigger/ledtrig-netdev.c line 18
Quoted 10 lines
drivers/leds/trigger/ledtrig-netdev.c new file +10
-0+* +* Derived from ledtrig-timer.c which is: +* Copyright 2005-2006 Openedhand Ltd. +* Author: Richard Purdie <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +*/ Have you considered using the new SPDX id instead ? See Thomas doc patches and Greg and Linus comments on the topic
Here this would likely come out this way (yes, using a C++ comment at the top):Quoted 10 lines
drivers/leds/trigger/ledtrig-netdev.c new file +10
-0+// SPDX-License-Identifier: GPL-2.0 +/* +* LED Kernel Netdev Trigger +* +* Toggles the LED to reflect the link and traffic state of a named net device +* +* Copyright 2017 Ben Whitten <[email protected]> +* +* Copyright 2007 Oliver Jowett <[email protected]> +*
Quoted 8 lines
drivers/leds/trigger/ledtrig-netdev.c line 18
Quoted 5 lines
drivers/leds/trigger/ledtrig-netdev.c new file +5
-0+* Derived from ledtrig-timer.c which is: +* Copyright 2005-2006 Openedhand Ltd. +* Author: Richard Purdie <[email protected]> +* +*/ This is cleaner and simpler, don't you think?
Please consider putting SPDX where it logically belongs -- near the copyright.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Pavel,
Quoted 56 lines · Pavel Machek
Quoted 46 lines · Philippe Ombredanne
Ben,
Quoted 6 lines · Ben Whitten
From: Ben Whitten <[email protected]>
This commit introduces a NETDEV trigger for named device activity. Available triggers are link, rx, and tx.
Signed-off-by Ben Whitten <[email protected]>[]
Quoted 11 lines
drivers/leds/trigger/ledtrig-netdev.c new file +8
-0@@ -0,0 +1,503 @@ +/* +* LED Kernel Netdev Trigger +* +* Toggles the LED to reflect the link and traffic state of a named net device +* +* Copyright 2017 Ben Whitten <[email protected]> +* +* Copyright 2007 Oliver Jowett <[email protected]> drivers/leds/trigger/ledtrig-netdev.c line 18
Quoted 10 lines
drivers/leds/trigger/ledtrig-netdev.c new file +10
-0+* +* Derived from ledtrig-timer.c which is: +* Copyright 2005-2006 Openedhand Ltd. +* Author: Richard Purdie <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +*/ Have you considered using the new SPDX id instead ? See Thomas doc patches and Greg and Linus comments on the topic
Here this would likely come out this way (yes, using a C++ comment at the top):Quoted 10 lines
drivers/leds/trigger/ledtrig-netdev.c new file +10
-0+// SPDX-License-Identifier: GPL-2.0 +/* +* LED Kernel Netdev Trigger +* +* Toggles the LED to reflect the link and traffic state of a named net device +* +* Copyright 2017 Ben Whitten <[email protected]> +* +* Copyright 2007 Oliver Jowett <[email protected]> +* Quoted 8 lines
drivers/leds/trigger/ledtrig-netdev.c line 18
Quoted 5 lines
drivers/leds/trigger/ledtrig-netdev.c new file +5
-0+* Derived from ledtrig-timer.c which is: +* Copyright 2005-2006 Openedhand Ltd. +* Author: Richard Purdie <[email protected]> +* +*/ This is cleaner and simpler, don't you think?
Quoted 2 lines
Please consider putting SPDX where it logically belongs -- near the copyright.
Linus wants it on the first line. So you could write this way alright:
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/leds/trigger/ledtrig-netdev.c new file +5
-0+// SPDX-License-Identifier: GPL-2.0 +// Copyright 2017 Ben Whitten <[email protected]> +// Copyright 2007 Oliver Jowett <[email protected]> +/* +* LED Kernel Netdev Trigger
Quoted 8 lines
Quoted 8 lines
drivers/leds/trigger/ledtrig-netdev.c line 18
Quoted 8 lines
drivers/leds/trigger/ledtrig-netdev.c new file +8
-0+* +* Toggles the LED to reflect the link and traffic state of a named net device +* +* Derived from ledtrig-timer.c which is: +* Copyright 2005-2006 Openedhand Ltd. +* Author: Richard Purdie <[email protected]> +* +*/
For reference please check Linus [1][2][3], Thomas [4] and Greg [5] comments on the topic of C++ style // comments and first line placement.
Jonathan also wrote a nice background article on the SPDXification topic at LWN [6]
[1] https://lkml.org/lkml/2017/11/2/715
[2] https://lkml.org/lkml/2017/11/25/125
[3] https://lkml.org/lkml/2017/11/25/133
[4] https://lkml.org/lkml/2017/11/2/805
[5] https://lkml.org/lkml/2017/10/19/165
[6] https://lwn.net/Articles/739183/
Signature · 2 lines
Cordially Philippe Ombredanne