leds: Add driver for MAX8907 LED cell
Subsystems (2)
PATCH v4 1/1 leds: Add driver for MAX8907 LED cell
Add a small driver to control the LED cell provided by the MAX8907 PMIC. The LED does not require any specific configuration and is folded into the PMIC's node.
---
Changes in v2:
- rebased so patch is now applicable to linux/next
Changes in v3:
- added check if led is off for get callback
- added dedicated MAX8907_REG_WLED_MODE_ON mask
- switched to devm_led_classdev_register_ext
Changes in v4:
- platform_set_drvdata dropped
- init_data.devicename dropped
- added MODULE_ALIAS
--- drivers/leds/Kconfig | 7 +++ drivers/leds/Makefile | 1 + drivers/leds/leds-max8907.c | 90 +++++++++++++++++++++++++++++++++++++ drivers/mfd/max8907.c | 1 + include/linux/mfd/max8907.h | 2 +- 5 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 drivers/leds/leds-max8907.c
drivers/leds/Kconfig +7 -0
@@ -813,6 +813,13 @@ config LEDS_MAX77705 help LED driver for MAX77705 PMIC from Maxim Integrated. +config LEDS_MAX8907 + tristate "LED support for MAX8907 PMIC" + depends on LEDS_CLASS && MFD_MAX8907 + help + This option enables support for on-chip LED drivers on + MAXIM MAX8907 PMIC. + config LEDS_MAX8997 tristate "LED support for MAX8997 PMIC" depends on LEDS_CLASS && MFD_MAX8997
drivers/leds/Makefile +1 -0
@@ -67,6 +67,7 @@ obj-$(CONFIG_LEDS_LTC3220) += leds-ltc3220.o obj-$(CONFIG_LEDS_MAX5970) += leds-max5970.o obj-$(CONFIG_LEDS_MAX77650) += leds-max77650.o obj-$(CONFIG_LEDS_MAX77705) += leds-max77705.o +obj-$(CONFIG_LEDS_MAX8907) += leds-max8907.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o
drivers/leds/leds-max8907.c new file +90 -0
90 lines not on this page · raw message
drivers/mfd/max8907.c +1 -0
@@ -20,6 +20,7 @@#include <linux/slab.h> static const struct mfd_cell max8907_cells[] = { + { .name ="max8907-leds" , }, { .name ="max8907-regulator" , }, { .name ="max8907-rtc" , }, };
include/linux/mfd/max8907.h +1 -1
@@ -112,7 +112,7 @@#define MAX8907_REG_CHG_IRQ2_MASK 0x81#define MAX8907_REG_CHG_STAT 0x82#define MAX8907_REG_WLED_MODE_CNTL 0x84 -#define MAX8907_REG_ILED_CNTL 0x84 +#define MAX8907_REG_WLED_CNTL 0x85#define MAX8907_REG_II1RR 0x8E#define MAX8907_REG_II2RR 0x8F#define MAX8907_REG_LDOCTL20 0x9C
Signature · 1 line
2.53.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 5 lines
Add a small driver to control the LED cell provided by the MAX8907 PMIC. The LED does not require any specific configuration and is folded into the PMIC's node.
Signed-off-by Svyatoslav Ryhel <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Lee Jones
maintainer--- checkpatch.pl (1 issue) ---
Line 38: WARNING: please write a help paragraph that fully describes the config symbol with at least 4 lines
----------------------------------
Quoted 32 lines · Svyatoslav Ryhel
Add a small driver to control the LED cell provided by the MAX8907 PMIC. The LED does not require any specific configuration and is folded into the PMIC's node.
Signed-off-by Svyatoslav Ryhel <[email protected]>---
Changes in v2:
- rebased so patch is now applicable to linux/nextChanges in v3:
- added check if led is off for get callback
- added dedicatedMAX8907_REG_WLED_MODE_ONmask
- switched todevm_led_classdev_register_extChanges in v4:
-platform_set_drvdatadropped
- init_data.devicename dropped
- addedMODULE_ALIAS--- drivers/leds/Kconfig | 7 +++ drivers/leds/Makefile | 1 + drivers/leds/leds-max8907.c | 90 +++++++++++++++++++++++++++++++++++++ drivers/mfd/max8907.c | 1 + include/linux/mfd/max8907.h | 2 +- 5 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 drivers/leds/leds-max8907.cdrivers/leds/Kconfig +0
-0
drivers/leds/Kconfig config LEDS_MAX77705 · line 821
Quoted 9 lines
drivers/leds/Kconfig +6
-0@@ -813,6 +813,13 @@ config LEDS_MAX77705 help LED driver for MAX77705 PMIC from Maxim Integrated. +config LEDS_MAX8907 + tristate "LED support for MAX8907 PMIC" + depends on LEDS_CLASS && MFD_MAX8907 + help + This option enables support for on-chip LED drivers on + MAXIM MAX8907 PMIC.
As requested on v3, please expand this help text to at least 4 lines to satisfy 'checkpatch.pl'.
Quoted 26 lines
drivers/leds/Kconfig +1
-0+ config LEDS_MAX8997 tristate "LED support for MAX8997 PMIC" depends on LEDS_CLASS && MFD_MAX8997drivers/leds/Makefile +1
-0@@ -67,6 +67,7 @@ obj-$(CONFIG_LEDS_LTC3220) += leds-ltc3220.o obj-$(CONFIG_LEDS_MAX5970) += leds-max5970.o obj-$(CONFIG_LEDS_MAX77650) += leds-max77650.o obj-$(CONFIG_LEDS_MAX77705) += leds-max77705.o +obj-$(CONFIG_LEDS_MAX8907) += leds-max8907.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.odrivers/leds/leds-max8907.c new file +4
-0@@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/err.h> +#include <linux/leds.h>
drivers/leds/leds-max8907.c line 14
Quoted 10 lines
drivers/leds/leds-max8907.c new file +10
-0+#include <linux/mfd/max8907.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regmap.h> + +#define MAX8907_REG_WLED_MODE_ON BIT(0) + +struct max8907_led_data { +struct max8907 *max8907;
As asked on v3, what is 'max8907' used for?
Quoted 45 lines
drivers/leds/leds-max8907.c new file +45
-0+struct regmap *regmap; +struct led_classdev cdev; +}; + +static enum led_brightness max8907_led_get_brightness (struct led_classdev *cdev) +{ + struct max8907_led_data *ddata = container_of(cdev, struct max8907_led_data, cdev); +unsigned int brightness_lvl; +int ret; + + ret =regmap_read (ddata->regmap,MAX8907_REG_WLED_MODE_CNTL , &brightness_lvl); +if (ret || !(brightness_lvl &MAX8907_REG_WLED_MODE_ON )) +return LED_OFF ; + + ret =regmap_read (ddata->regmap,MAX8907_REG_WLED_CNTL , &brightness_lvl); +if (ret) +return LED_OFF ; + +return brightness_lvl; +} + +static int max8907_led_set_brightness (struct led_classdev *cdev, +enum led_brightness brightness) +{ + struct max8907_led_data *ddata = container_of(cdev, struct max8907_led_data, cdev); +int brightness_lvl, ret; + + brightness_lvl =clamp (brightness,LED_OFF ,LED_FULL ); + +if (brightness_lvl) { + ret =regmap_write (ddata->regmap,MAX8907_REG_WLED_CNTL , brightness_lvl); +if (ret) +return ret; + } + +return regmap_update_bits (ddata->regmap,MAX8907_REG_WLED_MODE_CNTL , +MAX8907_REG_WLED_MODE_ON , + brightness_lvl ?MAX8907_REG_WLED_MODE_ON :0 ); +} + +static int max8907_led_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct max8907 *max8907 =dev_get_drvdata (dev->parent); +struct led_init_data init_data = { };
drivers/leds/leds-max8907.c line 69
Quoted 10 lines
drivers/leds/leds-max8907.c new file +10
-0+struct max8907_led_data *ddata; + + ddata =devm_kzalloc (dev,sizeof (*ddata),GFP_KERNEL ); +if (!ddata) +return -ENOMEM ; + + ddata->max8907 = max8907; + ddata->regmap = max8907->regmap_gen; + + init_data.fwnode =dev_fwnode (dev->parent);
This will evaluate to 'pmic'. The sysfs attribute will be incorrect.
Since there is no child node, why not set 'ddata->cdev.name' directly and use 'devm_led_classdev_register()'?
drivers/leds/leds-max8907.c line 82
Quoted 13 lines
drivers/leds/leds-max8907.c new file +13
-0+ + ddata->cdev.brightness =LED_OFF ; + ddata->cdev.flags =LED_CORE_SUSPENDRESUME ; + ddata->cdev.max_brightness =LED_FULL ; + + ddata->cdev.brightness_get = max8907_led_get_brightness; + ddata->cdev.brightness_set_blocking = max8907_led_set_brightness; + +return devm_led_classdev_register_ext (dev, &ddata->cdev, &init_data); +} + +static struct platform_driver max8907_led_driver = { + .driver.name ="max8907-leds" ,
Cute. But please expand.
drivers/leds/leds-max8907.c line 88
Quoted 6 lines
drivers/leds/leds-max8907.c new file +6
-0+ .probe = max8907_led_probe, +}; +module_platform_driver (max8907_led_driver); + +MODULE_ALIAS ("platform:max8907-leds" ); +MODULE_AUTHOR ("Svyatolsav Ryhel <[email protected]>" );
Your name is misspelt here.
drivers/mfd/max8907.c line 23
Quoted 11 lines
drivers/leds/leds-max8907.c new file +2
-0+MODULE_DESCRIPTION ("MAX8907 LED driver" ); +MODULE_LICENSE ("GPL" );drivers/mfd/max8907.c +1
-0@@ -20,6 +20,7 @@#include <linux/slab.h> static const struct mfd_cell max8907_cells[] = { + { .name ="max8907-leds" , },
Separate patch.
Quoted 20 lines
drivers/mfd/max8907.c +0
-0{ .name = "max8907-regulator", }, { .name = "max8907-rtc", }, };include/linux/mfd/max8907.h +1
-1@@ -112,7 +112,7 @@#define MAX8907_REG_CHG_IRQ2_MASK 0x81#define MAX8907_REG_CHG_STAT 0x82#define MAX8907_REG_WLED_MODE_CNTL 0x84 -#define MAX8907_REG_ILED_CNTL 0x84 +#define MAX8907_REG_WLED_CNTL 0x85#define MAX8907_REG_II1RR 0x8E#define MAX8907_REG_II2RR 0x8F#define MAX8907_REG_LDOCTL20 0x9CSignature · 1 line
2.53.0
Signature · 1 line
Lee Jones
ср, 4 лист. 2026 р. о 17:16 Lee Jones <[email protected]> пише:
Quoted 186 lines
--- checkpatch.pl (1 issue) ---
Line 38: WARNING: please write a help paragraph that fully describes the config symbol with at least 4 lines
----------------------------------Quoted 32 lines · Svyatoslav Ryhel
Add a small driver to control the LED cell provided by the MAX8907 PMIC. The LED does not require any specific configuration and is folded into the PMIC's node.
Signed-off-by Svyatoslav Ryhel <[email protected]>---
Changes in v2:
- rebased so patch is now applicable to linux/nextChanges in v3:
- added check if led is off for get callback
- added dedicatedMAX8907_REG_WLED_MODE_ONmask
- switched todevm_led_classdev_register_extChanges in v4:
-platform_set_drvdatadropped
- init_data.devicename dropped
- addedMODULE_ALIAS--- drivers/leds/Kconfig | 7 +++ drivers/leds/Makefile | 1 + drivers/leds/leds-max8907.c | 90 +++++++++++++++++++++++++++++++++++++ drivers/mfd/max8907.c | 1 + include/linux/mfd/max8907.h | 2 +- 5 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 drivers/leds/leds-max8907.cdrivers/leds/Kconfig +0
-0drivers/leds/Kconfig config LEDS_MAX77705 · line 821
Quoted 9 lines
drivers/leds/Kconfig +6
-0@@ -813,6 +813,13 @@ config LEDS_MAX77705 help LED driver for MAX77705 PMIC from Maxim Integrated. +config LEDS_MAX8907 + tristate "LED support for MAX8907 PMIC" + depends on LEDS_CLASS && MFD_MAX8907 + help + This option enables support for on-chip LED drivers on + MAXIM MAX8907 PMIC.As requested on v3, please expand this help text to at least 4 lines to satisfy 'checkpatch.pl'.
Quoted 26 lines
drivers/leds/Kconfig +1
-0+ config LEDS_MAX8997 tristate "LED support for MAX8997 PMIC" depends on LEDS_CLASS && MFD_MAX8997drivers/leds/Makefile +1
-0@@ -67,6 +67,7 @@ obj-$(CONFIG_LEDS_LTC3220) += leds-ltc3220.o obj-$(CONFIG_LEDS_MAX5970) += leds-max5970.o obj-$(CONFIG_LEDS_MAX77650) += leds-max77650.o obj-$(CONFIG_LEDS_MAX77705) += leds-max77705.o +obj-$(CONFIG_LEDS_MAX8907) += leds-max8907.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.odrivers/leds/leds-max8907.c new file +4
-0@@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/err.h> +#include <linux/leds.h> drivers/leds/leds-max8907.c line 14
Quoted 10 lines
drivers/leds/leds-max8907.c new file +10
-0+#include <linux/mfd/max8907.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regmap.h> + +#define MAX8907_REG_WLED_MODE_ON BIT(0) + +struct max8907_led_data { +struct max8907 *max8907;As asked on v3, what is 'max8907' used for?
Quoted 45 lines
drivers/leds/leds-max8907.c new file +45
-0+struct regmap *regmap; +struct led_classdev cdev; +}; + +static enum led_brightness max8907_led_get_brightness (struct led_classdev *cdev) +{ + struct max8907_led_data *ddata = container_of(cdev, struct max8907_led_data, cdev); +unsigned int brightness_lvl; +int ret; + + ret =regmap_read (ddata->regmap,MAX8907_REG_WLED_MODE_CNTL , &brightness_lvl); +if (ret || !(brightness_lvl &MAX8907_REG_WLED_MODE_ON )) +return LED_OFF ; + + ret =regmap_read (ddata->regmap,MAX8907_REG_WLED_CNTL , &brightness_lvl); +if (ret) +return LED_OFF ; + +return brightness_lvl; +} + +static int max8907_led_set_brightness (struct led_classdev *cdev, +enum led_brightness brightness) +{ + struct max8907_led_data *ddata = container_of(cdev, struct max8907_led_data, cdev); +int brightness_lvl, ret; + + brightness_lvl =clamp (brightness,LED_OFF ,LED_FULL ); + +if (brightness_lvl) { + ret =regmap_write (ddata->regmap,MAX8907_REG_WLED_CNTL , brightness_lvl); +if (ret) +return ret; + } + +return regmap_update_bits (ddata->regmap,MAX8907_REG_WLED_MODE_CNTL , +MAX8907_REG_WLED_MODE_ON , + brightness_lvl ?MAX8907_REG_WLED_MODE_ON :0 ); +} + +static int max8907_led_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct max8907 *max8907 =dev_get_drvdata (dev->parent); +struct led_init_data init_data = { };drivers/leds/leds-max8907.c line 69
Quoted 10 lines
drivers/leds/leds-max8907.c new file +10
-0+struct max8907_led_data *ddata; + + ddata =devm_kzalloc (dev,sizeof (*ddata),GFP_KERNEL ); +if (!ddata) +return -ENOMEM ; + + ddata->max8907 = max8907; + ddata->regmap = max8907->regmap_gen; + + init_data.fwnode =dev_fwnode (dev->parent);This will evaluate to 'pmic'. The sysfs attribute will be incorrect.
Since there is no child node, why not set '
ddata->cdev.name' directly and use 'devm_led_classdev_register()'?drivers/leds/leds-max8907.c line 82
Quoted 13 lines
drivers/leds/leds-max8907.c new file +13
-0+ + ddata->cdev.brightness =LED_OFF ; + ddata->cdev.flags =LED_CORE_SUSPENDRESUME ; + ddata->cdev.max_brightness =LED_FULL ; + + ddata->cdev.brightness_get = max8907_led_get_brightness; + ddata->cdev.brightness_set_blocking = max8907_led_set_brightness; + +return devm_led_classdev_register_ext (dev, &ddata->cdev, &init_data); +} + +static struct platform_driver max8907_led_driver = { + .driver.name ="max8907-leds" ,Cute. But please expand.
drivers/leds/leds-max8907.c line 88
Quoted 6 lines
drivers/leds/leds-max8907.c new file +6
-0+ .probe = max8907_led_probe, +}; +module_platform_driver (max8907_led_driver); + +MODULE_ALIAS ("platform:max8907-leds" ); +MODULE_AUTHOR ("Svyatolsav Ryhel <[email protected]>" );Your name is misspelt here.
Quoted 9 lines
drivers/leds/leds-max8907.c new file +2
-0+MODULE_DESCRIPTION ("MAX8907 LED driver" ); +MODULE_LICENSE ("GPL" );drivers/mfd/max8907.c +0
-0@@ -20,6 +20,7 @@#include <linux/slab.h>
Quoted 5 lines
drivers/mfd/max8907.c line 23
Quoted 2 lines
drivers/mfd/max8907.c +1
-0static const struct mfd_cell max8907_cells[] = { + { .name ="max8907-leds" , },Separate patch.
All valid, but way adding led requires a separate patch? Just to know.
The max8907.h change can be left with leds change? It changes reg name used by led cell.
Quoted 23 lines
Quoted 17 lines
drivers/mfd/max8907.c +0
-0{ .name = "max8907-regulator", }, { .name = "max8907-rtc", }, };include/linux/mfd/max8907.h +1
-2@@ -112,7 +112,7 @@#define MAX8907_REG_CHG_IRQ2_MASK 0x81#define MAX8907_REG_CHG_STAT 0x82#define MAX8907_REG_WLED_MODE_CNTL 0x84 -#define MAX8907_REG_ILED_CNTL 0x84 +#define MAX8907_REG_WLED_CNTL 0x85#define MAX8907_REG_II1RR 0x8E#define MAX8907_REG_II2RR 0x8F#define MAX8907_REG_LDOCTL20 0x9C --Quoted 3 lines
2.53.0
--
Lee Jones
Lee Jones
maintainerQuoted 187 lines · Svyatoslav Ryhel
ср, 4 лист. 2026 р. о 17:16 Lee Jones <[email protected]> пише:
Quoted 186 lines
--- checkpatch.pl (1 issue) ---
Line 38: WARNING: please write a help paragraph that fully describes the config symbol with at least 4 lines
----------------------------------Quoted 32 lines · Svyatoslav Ryhel
Add a small driver to control the LED cell provided by the MAX8907 PMIC. The LED does not require any specific configuration and is folded into the PMIC's node.
Signed-off-by Svyatoslav Ryhel <[email protected]>---
Changes in v2:
- rebased so patch is now applicable to linux/nextChanges in v3:
- added check if led is off for get callback
- added dedicatedMAX8907_REG_WLED_MODE_ONmask
- switched todevm_led_classdev_register_extChanges in v4:
-platform_set_drvdatadropped
- init_data.devicename dropped
- addedMODULE_ALIAS--- drivers/leds/Kconfig | 7 +++ drivers/leds/Makefile | 1 + drivers/leds/leds-max8907.c | 90 +++++++++++++++++++++++++++++++++++++ drivers/mfd/max8907.c | 1 + include/linux/mfd/max8907.h | 2 +- 5 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 drivers/leds/leds-max8907.cdrivers/leds/Kconfig +0
-0drivers/leds/Kconfig config LEDS_MAX77705 · line 821
Quoted 9 lines
drivers/leds/Kconfig +6
-0@@ -813,6 +813,13 @@ config LEDS_MAX77705 help LED driver for MAX77705 PMIC from Maxim Integrated. +config LEDS_MAX8907 + tristate "LED support for MAX8907 PMIC" + depends on LEDS_CLASS && MFD_MAX8907 + help + This option enables support for on-chip LED drivers on + MAXIM MAX8907 PMIC.As requested on v3, please expand this help text to at least 4 lines to satisfy 'checkpatch.pl'.
Quoted 26 lines
drivers/leds/Kconfig +1
-0+ config LEDS_MAX8997 tristate "LED support for MAX8997 PMIC" depends on LEDS_CLASS && MFD_MAX8997drivers/leds/Makefile +1
-0@@ -67,6 +67,7 @@ obj-$(CONFIG_LEDS_LTC3220) += leds-ltc3220.o obj-$(CONFIG_LEDS_MAX5970) += leds-max5970.o obj-$(CONFIG_LEDS_MAX77650) += leds-max77650.o obj-$(CONFIG_LEDS_MAX77705) += leds-max77705.o +obj-$(CONFIG_LEDS_MAX8907) += leds-max8907.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.odrivers/leds/leds-max8907.c new file +4
-0@@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/err.h> +#include <linux/leds.h> drivers/leds/leds-max8907.c line 14
Quoted 10 lines
drivers/leds/leds-max8907.c new file +10
-0+#include <linux/mfd/max8907.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regmap.h> + +#define MAX8907_REG_WLED_MODE_ON BIT(0) + +struct max8907_led_data { +struct max8907 *max8907;As asked on v3, what is 'max8907' used for?
Quoted 45 lines
drivers/leds/leds-max8907.c new file +45
-0+struct regmap *regmap; +struct led_classdev cdev; +}; + +static enum led_brightness max8907_led_get_brightness (struct led_classdev *cdev) +{ + struct max8907_led_data *ddata = container_of(cdev, struct max8907_led_data, cdev); +unsigned int brightness_lvl; +int ret; + + ret =regmap_read (ddata->regmap,MAX8907_REG_WLED_MODE_CNTL , &brightness_lvl); +if (ret || !(brightness_lvl &MAX8907_REG_WLED_MODE_ON )) +return LED_OFF ; + + ret =regmap_read (ddata->regmap,MAX8907_REG_WLED_CNTL , &brightness_lvl); +if (ret) +return LED_OFF ; + +return brightness_lvl; +} + +static int max8907_led_set_brightness (struct led_classdev *cdev, +enum led_brightness brightness) +{ + struct max8907_led_data *ddata = container_of(cdev, struct max8907_led_data, cdev); +int brightness_lvl, ret; + + brightness_lvl =clamp (brightness,LED_OFF ,LED_FULL ); + +if (brightness_lvl) { + ret =regmap_write (ddata->regmap,MAX8907_REG_WLED_CNTL , brightness_lvl); +if (ret) +return ret; + } + +return regmap_update_bits (ddata->regmap,MAX8907_REG_WLED_MODE_CNTL , +MAX8907_REG_WLED_MODE_ON , + brightness_lvl ?MAX8907_REG_WLED_MODE_ON :0 ); +} + +static int max8907_led_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct max8907 *max8907 =dev_get_drvdata (dev->parent); +struct led_init_data init_data = { };drivers/leds/leds-max8907.c line 69
Quoted 10 lines
drivers/leds/leds-max8907.c new file +10
-0+struct max8907_led_data *ddata; + + ddata =devm_kzalloc (dev,sizeof (*ddata),GFP_KERNEL ); +if (!ddata) +return -ENOMEM ; + + ddata->max8907 = max8907; + ddata->regmap = max8907->regmap_gen; + + init_data.fwnode =dev_fwnode (dev->parent);This will evaluate to 'pmic'. The sysfs attribute will be incorrect.
Since there is no child node, why not set '
ddata->cdev.name' directly and use 'devm_led_classdev_register()'?drivers/leds/leds-max8907.c line 82
Quoted 13 lines
drivers/leds/leds-max8907.c new file +13
-0+ + ddata->cdev.brightness =LED_OFF ; + ddata->cdev.flags =LED_CORE_SUSPENDRESUME ; + ddata->cdev.max_brightness =LED_FULL ; + + ddata->cdev.brightness_get = max8907_led_get_brightness; + ddata->cdev.brightness_set_blocking = max8907_led_set_brightness; + +return devm_led_classdev_register_ext (dev, &ddata->cdev, &init_data); +} + +static struct platform_driver max8907_led_driver = { + .driver.name ="max8907-leds" ,Cute. But please expand.
drivers/leds/leds-max8907.c line 88
Quoted 6 lines
drivers/leds/leds-max8907.c new file +6
-0+ .probe = max8907_led_probe, +}; +module_platform_driver (max8907_led_driver); + +MODULE_ALIAS ("platform:max8907-leds" ); +MODULE_AUTHOR ("Svyatolsav Ryhel <[email protected]>" );Your name is misspelt here.
Quoted 9 lines
drivers/leds/leds-max8907.c new file +2
-0+MODULE_DESCRIPTION ("MAX8907 LED driver" ); +MODULE_LICENSE ("GPL" );drivers/mfd/max8907.c +0
-0@@ -20,6 +20,7 @@#include <linux/slab.h>
Quoted 7 lines
Quoted 5 lines
drivers/mfd/max8907.c line 23
Quoted 2 lines
drivers/mfd/max8907.c +1
-0static const struct mfd_cell max8907_cells[] = { + { .name ="max8907-leds" , },Separate patch.
All valid, but way adding led requires a separate patch? Just to know.
Build-deps only.
Quoted 2 lines
The
max8907.hchange can be left with leds change? It changes reg name used by led cell.
Yes. That's a build-dep.
Quoted 23 lines
Quoted 23 lines
Quoted 17 lines
drivers/mfd/max8907.c +0
-0{ .name = "max8907-regulator", }, { .name = "max8907-rtc", }, };include/linux/mfd/max8907.h +1
-2@@ -112,7 +112,7 @@#define MAX8907_REG_CHG_IRQ2_MASK 0x81#define MAX8907_REG_CHG_STAT 0x82#define MAX8907_REG_WLED_MODE_CNTL 0x84 -#define MAX8907_REG_ILED_CNTL 0x84 +#define MAX8907_REG_WLED_CNTL 0x85#define MAX8907_REG_II1RR 0x8E#define MAX8907_REG_II2RR 0x8F#define MAX8907_REG_LDOCTL20 0x9C --Quoted 3 lines
2.53.0
--
Lee Jones
Signature · 1 line
Lee Jones
ср, 4 лист. 2026 р. о 17:16 Lee Jones <[email protected]> пише:
Quoted 149 lines
--- checkpatch.pl (1 issue) ---
Line 38: WARNING: please write a help paragraph that fully describes the config symbol with at least 4 lines
----------------------------------Quoted 32 lines · Svyatoslav Ryhel
Add a small driver to control the LED cell provided by the MAX8907 PMIC. The LED does not require any specific configuration and is folded into the PMIC's node.
Signed-off-by Svyatoslav Ryhel <[email protected]>---
Changes in v2:
- rebased so patch is now applicable to linux/nextChanges in v3:
- added check if led is off for get callback
- added dedicatedMAX8907_REG_WLED_MODE_ONmask
- switched todevm_led_classdev_register_extChanges in v4:
-platform_set_drvdatadropped
- init_data.devicename dropped
- addedMODULE_ALIAS--- drivers/leds/Kconfig | 7 +++ drivers/leds/Makefile | 1 + drivers/leds/leds-max8907.c | 90 +++++++++++++++++++++++++++++++++++++ drivers/mfd/max8907.c | 1 + include/linux/mfd/max8907.h | 2 +- 5 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 drivers/leds/leds-max8907.cdrivers/leds/Kconfig +0
-0drivers/leds/Kconfig config LEDS_MAX77705 · line 821
Quoted 9 lines
drivers/leds/Kconfig +6
-0@@ -813,6 +813,13 @@ config LEDS_MAX77705 help LED driver for MAX77705 PMIC from Maxim Integrated. +config LEDS_MAX8907 + tristate "LED support for MAX8907 PMIC" + depends on LEDS_CLASS && MFD_MAX8907 + help + This option enables support for on-chip LED drivers on + MAXIM MAX8907 PMIC.As requested on v3, please expand this help text to at least 4 lines to satisfy 'checkpatch.pl'.
Quoted 26 lines
drivers/leds/Kconfig +1
-0+ config LEDS_MAX8997 tristate "LED support for MAX8997 PMIC" depends on LEDS_CLASS && MFD_MAX8997drivers/leds/Makefile +1
-0@@ -67,6 +67,7 @@ obj-$(CONFIG_LEDS_LTC3220) += leds-ltc3220.o obj-$(CONFIG_LEDS_MAX5970) += leds-max5970.o obj-$(CONFIG_LEDS_MAX77650) += leds-max77650.o obj-$(CONFIG_LEDS_MAX77705) += leds-max77705.o +obj-$(CONFIG_LEDS_MAX8907) += leds-max8907.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.odrivers/leds/leds-max8907.c new file +4
-0@@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/err.h> +#include <linux/leds.h> drivers/leds/leds-max8907.c line 14
Quoted 10 lines
drivers/leds/leds-max8907.c new file +10
-0+#include <linux/mfd/max8907.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regmap.h> + +#define MAX8907_REG_WLED_MODE_ON BIT(0) + +struct max8907_led_data { +struct max8907 *max8907;As asked on v3, what is 'max8907' used for?
Quoted 45 lines
drivers/leds/leds-max8907.c new file +45
-0+struct regmap *regmap; +struct led_classdev cdev; +}; + +static enum led_brightness max8907_led_get_brightness (struct led_classdev *cdev) +{ + struct max8907_led_data *ddata = container_of(cdev, struct max8907_led_data, cdev); +unsigned int brightness_lvl; +int ret; + + ret =regmap_read (ddata->regmap,MAX8907_REG_WLED_MODE_CNTL , &brightness_lvl); +if (ret || !(brightness_lvl &MAX8907_REG_WLED_MODE_ON )) +return LED_OFF ; + + ret =regmap_read (ddata->regmap,MAX8907_REG_WLED_CNTL , &brightness_lvl); +if (ret) +return LED_OFF ; + +return brightness_lvl; +} + +static int max8907_led_set_brightness (struct led_classdev *cdev, +enum led_brightness brightness) +{ + struct max8907_led_data *ddata = container_of(cdev, struct max8907_led_data, cdev); +int brightness_lvl, ret; + + brightness_lvl =clamp (brightness,LED_OFF ,LED_FULL ); + +if (brightness_lvl) { + ret =regmap_write (ddata->regmap,MAX8907_REG_WLED_CNTL , brightness_lvl); +if (ret) +return ret; + } + +return regmap_update_bits (ddata->regmap,MAX8907_REG_WLED_MODE_CNTL , +MAX8907_REG_WLED_MODE_ON , + brightness_lvl ?MAX8907_REG_WLED_MODE_ON :0 ); +} + +static int max8907_led_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct max8907 *max8907 =dev_get_drvdata (dev->parent); +struct led_init_data init_data = { };drivers/leds/leds-max8907.c line 69
Quoted 10 lines
drivers/leds/leds-max8907.c new file +10
-0+struct max8907_led_data *ddata; + + ddata =devm_kzalloc (dev,sizeof (*ddata),GFP_KERNEL ); +if (!ddata) +return -ENOMEM ; + + ddata->max8907 = max8907; + ddata->regmap = max8907->regmap_gen; + + init_data.fwnode =dev_fwnode (dev->parent);This will evaluate to 'pmic'. The sysfs attribute will be incorrect.
Quoted 3 lines
Since there is no child node, why not set '
ddata->cdev.name' directly and use 'devm_led_classdev_register()'?
This is required to be able to reference led in the device tree. Since led node is folded into pmic's node, pmic's node is used to bind led.
Quoted 62 lines
drivers/leds/leds-max8907.c line 82
Quoted 13 lines
drivers/leds/leds-max8907.c new file +13
-0+ + ddata->cdev.brightness =LED_OFF ; + ddata->cdev.flags =LED_CORE_SUSPENDRESUME ; + ddata->cdev.max_brightness =LED_FULL ; + + ddata->cdev.brightness_get = max8907_led_get_brightness; + ddata->cdev.brightness_set_blocking = max8907_led_set_brightness; + +return devm_led_classdev_register_ext (dev, &ddata->cdev, &init_data); +} + +static struct platform_driver max8907_led_driver = { + .driver.name ="max8907-leds" ,Cute. But please expand.
drivers/leds/leds-max8907.c line 88
Quoted 6 lines
drivers/leds/leds-max8907.c new file +6
-0+ .probe = max8907_led_probe, +}; +module_platform_driver (max8907_led_driver); + +MODULE_ALIAS ("platform:max8907-leds" ); +MODULE_AUTHOR ("Svyatolsav Ryhel <[email protected]>" );Your name is misspelt here.
drivers/mfd/max8907.c line 23
Quoted 11 lines
drivers/leds/leds-max8907.c new file +2
-0+MODULE_DESCRIPTION ("MAX8907 LED driver" ); +MODULE_LICENSE ("GPL" );drivers/mfd/max8907.c +1
-0@@ -20,6 +20,7 @@#include <linux/slab.h> static const struct mfd_cell max8907_cells[] = { + { .name ="max8907-leds" , },Separate patch.
Quoted 17 lines
drivers/mfd/max8907.c +0
-0{ .name = "max8907-regulator", }, { .name = "max8907-rtc", }, };include/linux/mfd/max8907.h +1
-2@@ -112,7 +112,7 @@#define MAX8907_REG_CHG_IRQ2_MASK 0x81#define MAX8907_REG_CHG_STAT 0x82#define MAX8907_REG_WLED_MODE_CNTL 0x84 -#define MAX8907_REG_ILED_CNTL 0x84 +#define MAX8907_REG_WLED_CNTL 0x85#define MAX8907_REG_II1RR 0x8E#define MAX8907_REG_II2RR 0x8F#define MAX8907_REG_LDOCTL20 0x9C --Quoted 3 lines
2.53.0
--
Lee Jones
Lee Jones
maintainerQuoted 150 lines · Svyatoslav Ryhel
ср, 4 лист. 2026 р. о 17:16 Lee Jones <[email protected]> пише:
Quoted 149 lines
--- checkpatch.pl (1 issue) ---
Line 38: WARNING: please write a help paragraph that fully describes the config symbol with at least 4 lines
----------------------------------Quoted 32 lines · Svyatoslav Ryhel
Add a small driver to control the LED cell provided by the MAX8907 PMIC. The LED does not require any specific configuration and is folded into the PMIC's node.
Signed-off-by Svyatoslav Ryhel <[email protected]>---
Changes in v2:
- rebased so patch is now applicable to linux/nextChanges in v3:
- added check if led is off for get callback
- added dedicatedMAX8907_REG_WLED_MODE_ONmask
- switched todevm_led_classdev_register_extChanges in v4:
-platform_set_drvdatadropped
- init_data.devicename dropped
- addedMODULE_ALIAS--- drivers/leds/Kconfig | 7 +++ drivers/leds/Makefile | 1 + drivers/leds/leds-max8907.c | 90 +++++++++++++++++++++++++++++++++++++ drivers/mfd/max8907.c | 1 + include/linux/mfd/max8907.h | 2 +- 5 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 drivers/leds/leds-max8907.cdrivers/leds/Kconfig +0
-0drivers/leds/Kconfig config LEDS_MAX77705 · line 821
Quoted 9 lines
drivers/leds/Kconfig +6
-0@@ -813,6 +813,13 @@ config LEDS_MAX77705 help LED driver for MAX77705 PMIC from Maxim Integrated. +config LEDS_MAX8907 + tristate "LED support for MAX8907 PMIC" + depends on LEDS_CLASS && MFD_MAX8907 + help + This option enables support for on-chip LED drivers on + MAXIM MAX8907 PMIC.As requested on v3, please expand this help text to at least 4 lines to satisfy 'checkpatch.pl'.
Quoted 26 lines
drivers/leds/Kconfig +1
-0+ config LEDS_MAX8997 tristate "LED support for MAX8997 PMIC" depends on LEDS_CLASS && MFD_MAX8997drivers/leds/Makefile +1
-0@@ -67,6 +67,7 @@ obj-$(CONFIG_LEDS_LTC3220) += leds-ltc3220.o obj-$(CONFIG_LEDS_MAX5970) += leds-max5970.o obj-$(CONFIG_LEDS_MAX77650) += leds-max77650.o obj-$(CONFIG_LEDS_MAX77705) += leds-max77705.o +obj-$(CONFIG_LEDS_MAX8907) += leds-max8907.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.odrivers/leds/leds-max8907.c new file +4
-0@@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/err.h> +#include <linux/leds.h> drivers/leds/leds-max8907.c line 14
Quoted 10 lines
drivers/leds/leds-max8907.c new file +10
-0+#include <linux/mfd/max8907.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regmap.h> + +#define MAX8907_REG_WLED_MODE_ON BIT(0) + +struct max8907_led_data { +struct max8907 *max8907;As asked on v3, what is 'max8907' used for?
Quoted 45 lines
drivers/leds/leds-max8907.c new file +45
-0+struct regmap *regmap; +struct led_classdev cdev; +}; + +static enum led_brightness max8907_led_get_brightness (struct led_classdev *cdev) +{ + struct max8907_led_data *ddata = container_of(cdev, struct max8907_led_data, cdev); +unsigned int brightness_lvl; +int ret; + + ret =regmap_read (ddata->regmap,MAX8907_REG_WLED_MODE_CNTL , &brightness_lvl); +if (ret || !(brightness_lvl &MAX8907_REG_WLED_MODE_ON )) +return LED_OFF ; + + ret =regmap_read (ddata->regmap,MAX8907_REG_WLED_CNTL , &brightness_lvl); +if (ret) +return LED_OFF ; + +return brightness_lvl; +} + +static int max8907_led_set_brightness (struct led_classdev *cdev, +enum led_brightness brightness) +{ + struct max8907_led_data *ddata = container_of(cdev, struct max8907_led_data, cdev); +int brightness_lvl, ret; + + brightness_lvl =clamp (brightness,LED_OFF ,LED_FULL ); + +if (brightness_lvl) { + ret =regmap_write (ddata->regmap,MAX8907_REG_WLED_CNTL , brightness_lvl); +if (ret) +return ret; + } + +return regmap_update_bits (ddata->regmap,MAX8907_REG_WLED_MODE_CNTL , +MAX8907_REG_WLED_MODE_ON , + brightness_lvl ?MAX8907_REG_WLED_MODE_ON :0 ); +} + +static int max8907_led_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct max8907 *max8907 =dev_get_drvdata (dev->parent); +struct led_init_data init_data = { };drivers/leds/leds-max8907.c line 69
Quoted 10 lines
drivers/leds/leds-max8907.c new file +10
-0+struct max8907_led_data *ddata; + + ddata =devm_kzalloc (dev,sizeof (*ddata),GFP_KERNEL ); +if (!ddata) +return -ENOMEM ; + + ddata->max8907 = max8907; + ddata->regmap = max8907->regmap_gen; + + init_data.fwnode =dev_fwnode (dev->parent);This will evaluate to 'pmic'. The sysfs attribute will be incorrect.
Quoted 6 lines
Quoted 3 lines
Since there is no child node, why not set '
ddata->cdev.name' directly and use 'devm_led_classdev_register()'?This is required to be able to reference led in the device tree. Since led node is folded into pmic's node, pmic's node is used to bind led.
Right, so you need device_set_node() called in led_classdev_register_ext() so fwnode_led_get() can look up the LED via the parent PMIC phandle.
However, passing only 'init_data.fwnode = dev_fwnode(dev->parent)' into led_compose_name() when the parent PMIC node has no 'label', 'function' or 'color' properties causes it to fall through to:
} else if (is_of_node(fwnode)) {
n = snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%s",
to_of_node(fwnode)->name);Which registers the LED in sysfs as '/sys/class/leds/pmic' (and fails with -EINVAL if 'fwnode' is NULL on non-DT platforms).
To bind the parent fwnode while avoiding the node-name fallback, please also populate 'devicename' and 'default_label' (similar to drivers/leds/leds-tps6105x.c):
init_data.fwnode = dev_fwnode(dev->parent);
init_data.devicename = "max8907";
init_data.default_label = ":wled"; /* or "white:backlight" */Signature · 1 line
Lee Jones
чт, 5 лист. 2026 р. о 16:08 Lee Jones <[email protected]> пише:
Quoted 174 lines · Svyatoslav Ryhel
Quoted 151 lines
ср, 4 лист. 2026 р. о 17:16 Lee Jones <[email protected]> пише:
Quoted 149 lines
--- checkpatch.pl (1 issue) ---
Line 38: WARNING: please write a help paragraph that fully describes the config symbol with at least 4 lines
----------------------------------Quoted 32 lines · Svyatoslav Ryhel
Add a small driver to control the LED cell provided by the MAX8907 PMIC. The LED does not require any specific configuration and is folded into the PMIC's node.
Signed-off-by Svyatoslav Ryhel <[email protected]>---
Changes in v2:
- rebased so patch is now applicable to linux/nextChanges in v3:
- added check if led is off for get callback
- added dedicatedMAX8907_REG_WLED_MODE_ONmask
- switched todevm_led_classdev_register_extChanges in v4:
-platform_set_drvdatadropped
- init_data.devicename dropped
- addedMODULE_ALIAS--- drivers/leds/Kconfig | 7 +++ drivers/leds/Makefile | 1 + drivers/leds/leds-max8907.c | 90 +++++++++++++++++++++++++++++++++++++ drivers/mfd/max8907.c | 1 + include/linux/mfd/max8907.h | 2 +- 5 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 drivers/leds/leds-max8907.cdrivers/leds/Kconfig +0
-0drivers/leds/Kconfig config LEDS_MAX77705 · line 821
Quoted 9 lines
drivers/leds/Kconfig +6
-0@@ -813,6 +813,13 @@ config LEDS_MAX77705 help LED driver for MAX77705 PMIC from Maxim Integrated. +config LEDS_MAX8907 + tristate "LED support for MAX8907 PMIC" + depends on LEDS_CLASS && MFD_MAX8907 + help + This option enables support for on-chip LED drivers on + MAXIM MAX8907 PMIC.As requested on v3, please expand this help text to at least 4 lines to satisfy 'checkpatch.pl'.
Quoted 26 lines
drivers/leds/Kconfig +1
-0+ config LEDS_MAX8997 tristate "LED support for MAX8997 PMIC" depends on LEDS_CLASS && MFD_MAX8997drivers/leds/Makefile +1
-0@@ -67,6 +67,7 @@ obj-$(CONFIG_LEDS_LTC3220) += leds-ltc3220.o obj-$(CONFIG_LEDS_MAX5970) += leds-max5970.o obj-$(CONFIG_LEDS_MAX77650) += leds-max77650.o obj-$(CONFIG_LEDS_MAX77705) += leds-max77705.o +obj-$(CONFIG_LEDS_MAX8907) += leds-max8907.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.odrivers/leds/leds-max8907.c new file +4
-0@@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/err.h> +#include <linux/leds.h> drivers/leds/leds-max8907.c line 14
Quoted 10 lines
drivers/leds/leds-max8907.c new file +10
-0+#include <linux/mfd/max8907.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regmap.h> + +#define MAX8907_REG_WLED_MODE_ON BIT(0) + +struct max8907_led_data { +struct max8907 *max8907;As asked on v3, what is 'max8907' used for?
Quoted 45 lines
drivers/leds/leds-max8907.c new file +45
-0+struct regmap *regmap; +struct led_classdev cdev; +}; + +static enum led_brightness max8907_led_get_brightness (struct led_classdev *cdev) +{ + struct max8907_led_data *ddata = container_of(cdev, struct max8907_led_data, cdev); +unsigned int brightness_lvl; +int ret; + + ret =regmap_read (ddata->regmap,MAX8907_REG_WLED_MODE_CNTL , &brightness_lvl); +if (ret || !(brightness_lvl &MAX8907_REG_WLED_MODE_ON )) +return LED_OFF ; + + ret =regmap_read (ddata->regmap,MAX8907_REG_WLED_CNTL , &brightness_lvl); +if (ret) +return LED_OFF ; + +return brightness_lvl; +} + +static int max8907_led_set_brightness (struct led_classdev *cdev, +enum led_brightness brightness) +{ + struct max8907_led_data *ddata = container_of(cdev, struct max8907_led_data, cdev); +int brightness_lvl, ret; + + brightness_lvl =clamp (brightness,LED_OFF ,LED_FULL ); + +if (brightness_lvl) { + ret =regmap_write (ddata->regmap,MAX8907_REG_WLED_CNTL , brightness_lvl); +if (ret) +return ret; + } + +return regmap_update_bits (ddata->regmap,MAX8907_REG_WLED_MODE_CNTL , +MAX8907_REG_WLED_MODE_ON , + brightness_lvl ?MAX8907_REG_WLED_MODE_ON :0 ); +} + +static int max8907_led_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct max8907 *max8907 =dev_get_drvdata (dev->parent); +struct led_init_data init_data = { };drivers/leds/leds-max8907.c line 69
Quoted 10 lines
drivers/leds/leds-max8907.c new file +10
-0+struct max8907_led_data *ddata; + + ddata =devm_kzalloc (dev,sizeof (*ddata),GFP_KERNEL ); +if (!ddata) +return -ENOMEM ; + + ddata->max8907 = max8907; + ddata->regmap = max8907->regmap_gen; + + init_data.fwnode =dev_fwnode (dev->parent);This will evaluate to 'pmic'. The sysfs attribute will be incorrect.
Quoted 6 lines
Quoted 3 lines
Since there is no child node, why not set '
ddata->cdev.name' directly and use 'devm_led_classdev_register()'?This is required to be able to reference led in the device tree. Since led node is folded into pmic's node, pmic's node is used to bind led.
Right, so you need
device_set_node()called inled_classdev_register_ext()sofwnode_led_get()can look up the LED via the parent PMIC phandle.However, passing only 'init_data.fwnode =
dev_fwnode(dev->parent)' intoled_compose_name()when the parent PMIC node has no 'label', 'function' or 'color' properties causes it to fall through to:} else if (is_of_node(fwnode)) { n = snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%s", to_of_node(fwnode)->name);Which registers the LED in sysfs as '
/sys/class/leds/pmic' (and fails with-EINVALif 'fwnode' is NULL on non-DT platforms).
Quoted 8 lines
To bind the parent fwnode while avoiding the node-name fallback, please also populate 'devicename' and '
default_label' (similar todrivers/leds/leds-tps6105x.c):init_data.fwnode = dev_fwnode(dev->parent); init_data.devicename = "max8907"; init_data.default_label = ":wled"; /* or "white:backlight" */
Thank you for your suggestion. I was tinkering a bit and got to conclusion that adding dedicated LED node will be beneficial.
My idea is to add led node without compatible (since it is redundant, pmic has only a single led anyway).
Driver will check for this node and return -ENODEV if node is not present.
Then I will use devm_led_classdev_register_ext but will pass led node and then most of your concerns should be addressed. What do you think about this?
As a prerequisite, this change would require
https://lore.kernel.org/lkml/[email protected]/
I have answered your concerns regarding Sashiko finding.
Quoted 2 lines
--
Lee Jones