Skip to contentSkip to conversation

leds: syscon: Add tristate option

PATCH In review Bevan Weiss 2 participants 5 messages Mar 8 – Apr 6 LED

lore
Share & tools
lore
#0 lore raw

v2 cover leds: syscon: Add tristate option

Quoted 1 line

My first submission to a linux-kernel list, so apologies for any errors.

Apologies, that didn't age well, I should have looked at the file history. It looks like the module=>builtin was done before, so this change reverts that.

It also adds MODULE_DESCRIPTION and MODULE_LICENSE along with the tristate Kconfig.

In OpenWrt, this allows leds-syscon to be .config'd as a module in subtargets, and then included / excluded from rootfs filesystems as required for specific boards. Without this, every board would need to have leds-syscon compiled as builtin just to provide it for one specific board. And OpenWrt devices are often space-constrained, where this is a significant concern.

Bevan Weiss (1):
leds: syscon: Add tristate option

 drivers/leds/Kconfig       |  4 ++--
 drivers/leds/leds-syscon.c | 20 +++++++++++++++++---
 2 files changed, 19 insertions(+), 5 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/1 leds: syscon: Add tristate option

This reverts commit f7d98a65d031 ("leds: syscon: Make the driver explicitly non-modular").

OpenWrt builds with a single .config for a given subtarget, whilst boards below that subtarget may not want to carry the disk usage of all options. So there is a preference to have all functionality not required on all boards as modules that can simply not be included in a given board rootfs to reduce disk usage.

Additional changes:
- (int)(struct platform_device *pdev) => void return
- Add MODULE_DESCRIPTION and MODULE_LICENSE macros
- Add tristate option to Kconfig

---
 drivers/leds/Kconfig       |  4 ++--
 drivers/leds/leds-syscon.c | 20 +++++++++++++++++---
 2 files changed, 19 insertions(+), 5 deletions(-)
drivers/leds/Kconfig +2 -2
index 597d7a79c988..ea3afc76a9c6 100644
@@ -903,8 +903,8 @@ config LEDS_POWERNV
 	  will be called leds-powernv.
 
 config LEDS_SYSCON
-	bool "LED support for LEDs on system controllers"
-	depends on LEDS_CLASS=y
+	tristate "LED support for LEDs on system controllers"
+	depends on LEDS_CLASS
 	depends on MFD_SYSCON
 	depends on OF
 	help
drivers/leds/leds-syscon.c +17 -3
index d633ad519d0c..bc968e8a326d 100644
@@ -6,7 +6,7 @@
  * Author: Linus Walleij <[email protected]>
  */
 #include <linux/io.h>
-#include <linux/init.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/stat.h>
@@ -121,17 +121,31 @@ static int syscon_led_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static void syscon_led_remove(struct platform_device *pdev)
+{
+	struct syscon_led *sled = platform_get_drvdata(pdev);
+
+	led_classdev_unregister(&sled->cdev);
+	/* Turn it off */
+	regmap_update_bits(sled->map, sled->offset, sled->mask, 0);
+}
+
 static const struct of_device_id of_syscon_leds_match[] = {
 	{ .compatible = "register-bit-led", },
 	{},
 };
 
+MODULE_DEVICE_TABLE(of, of_syscon_leds_match);
+
 static struct platform_driver syscon_led_driver = {
 	.probe		= syscon_led_probe,
+	.remove		= syscon_led_remove,
 	.driver		= {
 		.name	= "leds-syscon",
 		.of_match_table = of_syscon_leds_match,
-		.suppress_bind_attrs = true,
 	},
 };
-builtin_platform_driver(syscon_led_driver);
+module_platform_driver(syscon_led_driver);
+
+MODULE_DESCRIPTION("SYSCON LED driver");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.43.0
maintainer
#2 lore raw
Quoted 11 lines · Bevan Weiss

This reverts commit f7d98a65d031 ("leds: syscon: Make the driver explicitly non-modular").

OpenWrt builds with a single .config for a given subtarget, whilst boards below that subtarget may not want to carry the disk usage of all options. So there is a preference to have all functionality not required on all boards as modules that can simply not be included in a given board rootfs to reduce disk usage.

Additional changes:
- (int)(struct platform_device *pdev) => void return

Please rephrase into a human parseable sentence.

Quoted 38 lines

- Add MODULE_DESCRIPTION and MODULE_LICENSE macros
- Add tristate option to Kconfig

---
 drivers/leds/Kconfig       |  4 ++--
 drivers/leds/leds-syscon.c | 20 +++++++++++++++++---
 2 files changed, 19 insertions(+), 5 deletions(-)
drivers/leds/Kconfig +2 -2
index 597d7a79c988..ea3afc76a9c6 100644
@@ -903,8 +903,8 @@ config LEDS_POWERNV
 	  will be called leds-powernv.
 
 config LEDS_SYSCON
-	bool "LED support for LEDs on system controllers"
-	depends on LEDS_CLASS=y
+	tristate "LED support for LEDs on system controllers"
+	depends on LEDS_CLASS
 	depends on MFD_SYSCON
 	depends on OF
 	help
drivers/leds/leds-syscon.c +1 -1
index d633ad519d0c..bc968e8a326d 100644
@@ -6,7 +6,7 @@
  * Author: Linus Walleij <[email protected]>
  */
 #include <linux/io.h>
-#include <linux/init.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/stat.h>

drivers/leds/leds-syscon.c static int syscon_led_probe(struct platform_device *pdev) · line 128

Quoted 8 lines
drivers/leds/leds-syscon.c +5 -0
@@ -121,17 +121,31 @@ static int syscon_led_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static void syscon_led_remove(struct platform_device *pdev)
+{
+	struct syscon_led *sled = platform_get_drvdata(pdev);
+
+	led_classdev_unregister(&sled->cdev);

The driver uses devm_led_classdev_register() in probe, which automatically handles unregistering the LED class device when the driver is detached. Calling it here manually will result in a double-unregister.

drivers/leds/leds-syscon.c static int syscon_led_probe(struct platform_device *pdev) · line 129

Quoted 1 line
drivers/leds/leds-syscon.c +1 -0
+	/* Turn it off */

Turn what off?

drivers/leds/leds-syscon.c static int syscon_led_probe(struct platform_device *pdev) · line 130

Quoted 1 line
drivers/leds/leds-syscon.c +1 -0
+	regmap_update_bits(sled->map, sled->offset, sled->mask, 0);

If 0 was defined, as it should be, then you can drop the comment.

Quoted 13 lines
drivers/leds/leds-syscon.c +5 -0
+}
+
 static const struct of_device_id of_syscon_leds_match[] = {
 	{ .compatible = "register-bit-led", },
 	{},
 };
 
+MODULE_DEVICE_TABLE(of, of_syscon_leds_match);
+
 static struct platform_driver syscon_led_driver = {
 	.probe		= syscon_led_probe,
+	.remove		= syscon_led_remove,
 	.driver		= {

drivers/leds/leds-syscon.c static int syscon_led_probe(struct platform_device *pdev) · line 151

Quoted 10 lines
drivers/leds/leds-syscon.c +4 -2
 		.name	= "leds-syscon",
 		.of_match_table = of_syscon_leds_match,
-		.suppress_bind_attrs = true,
 	},
 };
-builtin_platform_driver(syscon_led_driver);
+module_platform_driver(syscon_led_driver);
+
+MODULE_DESCRIPTION("SYSCON LED driver");
+MODULE_LICENSE("GPL");

The MODULE_LICENSE() string should match the SPDX identifier at the top of the file.

Signature · 1 line
Lee Jones [李琼斯]
#3 lore raw
Quoted 4 lines · On Thu, 19 Mar 2026 10:13:27 +0000 Lee Jones <[email protected]> wrote:
Quoted 2 lines

Additional changes:
- (int)(struct platform_device *pdev) => void return

Please rephrase into a human parseable sentence.

Thanks, will do.

Quoted 6 lines

drivers/leds/leds-syscon.c static int syscon_led_probe(struct platform_device *pdev) · line 128

Quoted 1 line
drivers/leds/leds-syscon.c +1 -0
+	led_classdev_unregister(&sled->cdev);  

The driver uses devm_led_classdev_register() in probe, which automatically handles unregistering the LED class device when the driver is detached. Calling it here manually will result in a double-unregister.

My oversight, will fix.

Quoted 8 lines

drivers/leds/leds-syscon.c static int syscon_led_probe(struct platform_device *pdev) · line 129

Quoted 1 line
drivers/leds/leds-syscon.c +1 -0
+	/* Turn it off */  

Turn what off?

Quoted 2 lines
(quoted diff) +1 -0
+	regmap_update_bits(sled->map, sled->offset, sled->mask,

0);

If 0 was defined, as it should be, then you can drop the comment.

This is carry over from the original source, when it was originally modularised. I'll update the comment to explicitly mention that it's the LED which is turned off on module remove.

Quoted 5 lines
Quoted 1 line

+MODULE_LICENSE("GPL");

The MODULE_LICENSE() string should match the SPDX identifier at the top of the file.

Sorry, I'm not quite understanding this in the context of other files. Most modules within the led subsystem seem to have 'GPL-2.0-or-later' as the SPDX identifier, and MODULE_LICENSE("GPL"), as I currently have here.
Is there a different subtlety I'm missing?
e.g. leds-adp5520.c, leds-as3668.c, leds-blinkm.c
Perhaps MODULE_LICENSE("GPL v2+")? although I don't see similar anywhere in the kernel.
I'd expect MODULE_LICENSE("GPL v2") to be for 'GPL-2.0-only' licenses.

Thanks and regards,
Bevan Weiss

#4 lore raw
Quoted 6 lines · Bevan Weiss
Quoted 5 lines
Quoted 1 line

+MODULE_LICENSE("GPL");

The MODULE_LICENSE() string should match the SPDX identifier at the top of the file.

Quoted 10 lines

Sorry, I'm not quite understanding this in the context of other files. Most modules within the led subsystem seem to have 'GPL-2.0-or-later' as the SPDX identifier, and MODULE_LICENSE("GPL"), as I currently have here.
Is there a different subtlety I'm missing?
e.g. leds-adp5520.c, leds-as3668.c, leds-blinkm.c
Perhaps MODULE_LICENSE("GPL v2+")? although I don't see similar anywhere in the kernel.
I'd expect MODULE_LICENSE("GPL v2") to be for 'GPL-2.0-only' licenses.

I've got a v3 mostly ready to send, but was hoping for resolution of the MODULE_LICENSE query before submitting. Can I proceed with MODULE_LICENSE("GPL")?
If not, what value should be here?

Regards,
Bevan Weiss