mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] leds: s2m: Wire up of_match_table in platform drivers
@ 2026-07-22 16:15 kr494167
  2026-07-22 16:15 ` [PATCH v2 1/2] leds: rgb: s2m: Wire up of_match_table in platform driver kr494167
  2026-07-22 16:15 ` [PATCH v2 2/2] leds: flash: " kr494167
  0 siblings, 2 replies; 4+ messages in thread
From: kr494167 @ 2026-07-22 16:15 UTC (permalink / raw)
  To: lee, pavel; +Cc: kauschluss, linux-leds, linux-kernel, Surendra

From: Surendra <kr494167@gmail.com>

This patch series fixes missing .of_match_table assignments in the
Samsung S2M PMIC RGB and Flash LED platform drivers.

Both drivers define and export of_match_table via MODULE_DEVICE_TABLE(of, ...)
but never assign it to .of_match_table in the platform_driver struct.

Changes in v2:
- Capitalize subject line descriptions after subsystem prefix per LED guidelines.
- Validate dev->parent in probe() to prevent NULL pointer dereferences if probed
  without parent MFD driver data.
- Update author name to full name.

Surendra (2):
  leds: rgb: s2m: Wire up of_match_table in platform driver
  leds: flash: s2m: Wire up of_match_table in platform driver

 drivers/leds/flash/leds-s2m-flash.c | 10 +++++++++-
 drivers/leds/rgb/leds-s2m-rgb.c     | 10 +++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] leds: rgb: s2m: Wire up of_match_table in platform driver
  2026-07-22 16:15 [PATCH v2 0/2] leds: s2m: Wire up of_match_table in platform drivers kr494167
@ 2026-07-22 16:15 ` kr494167
  2026-07-22 18:07   ` Kaustabh Chakraborty
  2026-07-22 16:15 ` [PATCH v2 2/2] leds: flash: " kr494167
  1 sibling, 1 reply; 4+ messages in thread
From: kr494167 @ 2026-07-22 16:15 UTC (permalink / raw)
  To: lee, pavel; +Cc: kauschluss, linux-leds, linux-kernel, Surendra

From: Surendra <kr494167@gmail.com>

The driver defines and registers s2m_rgb_of_match_table via
MODULE_DEVICE_TABLE(of, ...) but never assigns it to the platform
driver's .of_match_table field. As a result, the kernel never matches
this driver against a DT node with compatible "samsung,s2mu005-rgb",
making the MODULE_DEVICE_TABLE entry dead code.

Wire the table up so that DT-based probing and module auto-loading
work as intended. In addition, validate dev->parent in s2m_rgb_probe()
to prevent a NULL pointer dereference if probed without parent driver data.

Fixes: 63ccd117f425 ("leds: rgb: Add support for Samsung S2M series PMIC RGB LED device")
Signed-off-by: Surendra <kr494167@gmail.com>
---
 drivers/leds/rgb/leds-s2m-rgb.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/rgb/leds-s2m-rgb.c b/drivers/leds/rgb/leds-s2m-rgb.c
index d239f54eee90..7ac2b1160c1e 100644
--- a/drivers/leds/rgb/leds-s2m-rgb.c
+++ b/drivers/leds/rgb/leds-s2m-rgb.c
@@ -363,11 +363,18 @@ static const struct mc_subled s2mu005_rgb_subled_info[] = {
 static int s2m_rgb_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct sec_pmic_dev *pmic_drvdata = dev_get_drvdata(dev->parent);
+	struct sec_pmic_dev *pmic_drvdata;
 	struct s2m_rgb *rgb;
 	struct led_init_data init_data = {};
 	int ret;
 
+	if (!dev->parent)
+		return -ENODEV;
+
+	pmic_drvdata = dev_get_drvdata(dev->parent);
+	if (!pmic_drvdata)
+		return -ENODEV;
+
 	rgb = devm_kzalloc(dev, sizeof(*rgb), GFP_KERNEL);
 	if (!rgb)
 		return -ENOMEM;
@@ -415,6 +422,7 @@ MODULE_DEVICE_TABLE(of, s2m_rgb_of_match_table);
 static struct platform_driver s2m_rgb_driver = {
 	.driver = {
 		.name = "s2m-rgb",
+		.of_match_table = s2m_rgb_of_match_table,
 	},
 	.probe = s2m_rgb_probe,
 	.id_table = s2m_rgb_id_table,
-- 
2.55.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] leds: flash: s2m: Wire up of_match_table in platform driver
  2026-07-22 16:15 [PATCH v2 0/2] leds: s2m: Wire up of_match_table in platform drivers kr494167
  2026-07-22 16:15 ` [PATCH v2 1/2] leds: rgb: s2m: Wire up of_match_table in platform driver kr494167
@ 2026-07-22 16:15 ` kr494167
  1 sibling, 0 replies; 4+ messages in thread
From: kr494167 @ 2026-07-22 16:15 UTC (permalink / raw)
  To: lee, pavel; +Cc: kauschluss, linux-leds, linux-kernel, Surendra

From: Surendra <kr494167@gmail.com>

The driver defines and registers s2m_fled_of_match_table via
MODULE_DEVICE_TABLE(of, ...) but never assigns it to the platform
driver's .of_match_table field. As a result, the kernel never matches
this driver against a DT node with compatible "samsung,s2mu005-flash",
making the MODULE_DEVICE_TABLE entry dead code.

Wire the table up so that DT-based probing and module auto-loading
work as intended. In addition, validate dev->parent in s2m_fled_probe()
to prevent a NULL pointer dereference if probed without parent driver data.

Fixes: 02149db273a9 ("leds: flash: Add support for Samsung S2M series PMIC flash LED device")
Signed-off-by: Surendra <kr494167@gmail.com>
---
 drivers/leds/flash/leds-s2m-flash.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/flash/leds-s2m-flash.c b/drivers/leds/flash/leds-s2m-flash.c
index 6ee8db094611..6097c75b681b 100644
--- a/drivers/leds/flash/leds-s2m-flash.c
+++ b/drivers/leds/flash/leds-s2m-flash.c
@@ -279,10 +279,17 @@ static int s2mu005_fled_init_channel(struct s2m_led *led, struct device *dev,
 static int s2m_fled_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct sec_pmic_dev *ddata = dev_get_drvdata(dev->parent);
+	struct sec_pmic_dev *ddata;
 	struct s2m_led *led;
 	int ret;
 
+	if (!dev->parent)
+		return -ENODEV;
+
+	ddata = dev_get_drvdata(dev->parent);
+	if (!ddata)
+		return -ENODEV;
+
 	led = devm_kzalloc(dev, sizeof(*led) * MAX_CHANNELS, GFP_KERNEL);
 	if (!led)
 		return -ENOMEM;
@@ -339,6 +346,7 @@ MODULE_DEVICE_TABLE(of, s2m_fled_of_match_table);
 static struct platform_driver s2m_fled_driver = {
 	.driver = {
 		.name = "s2m-flash",
+		.of_match_table = s2m_fled_of_match_table,
 	},
 	.probe = s2m_fled_probe,
 	.id_table = s2m_fled_id_table,
-- 
2.55.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] leds: rgb: s2m: Wire up of_match_table in platform driver
  2026-07-22 16:15 ` [PATCH v2 1/2] leds: rgb: s2m: Wire up of_match_table in platform driver kr494167
@ 2026-07-22 18:07   ` Kaustabh Chakraborty
  0 siblings, 0 replies; 4+ messages in thread
From: Kaustabh Chakraborty @ 2026-07-22 18:07 UTC (permalink / raw)
  To: kr494167, lee, pavel; +Cc: kauschluss, linux-leds, linux-kernel

On 2026-07-22 21:45 +05:30, kr494167 wrote:
> From: Surendra <kr494167@gmail.com>
>
> The driver defines and registers s2m_rgb_of_match_table via
> MODULE_DEVICE_TABLE(of, ...) but never assigns it to the platform
> driver's .of_match_table field. As a result, the kernel never matches
> this driver against a DT node with compatible "samsung,s2mu005-rgb",
> making the MODULE_DEVICE_TABLE entry dead code.
>
> Wire the table up so that DT-based probing and module auto-loading
> work as intended. In addition, validate dev->parent in s2m_rgb_probe()
> to prevent a NULL pointer dereference if probed without parent driver data.
>
> Fixes: 63ccd117f425 ("leds: rgb: Add support for Samsung S2M series PMIC RGB LED device")
> Signed-off-by: Surendra <kr494167@gmail.com>
> ---
>  drivers/leds/rgb/leds-s2m-rgb.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/leds/rgb/leds-s2m-rgb.c b/drivers/leds/rgb/leds-s2m-rgb.c
> index d239f54eee90..7ac2b1160c1e 100644
> --- a/drivers/leds/rgb/leds-s2m-rgb.c
> +++ b/drivers/leds/rgb/leds-s2m-rgb.c
> @@ -363,11 +363,18 @@ static const struct mc_subled s2mu005_rgb_subled_info[] = {
>  static int s2m_rgb_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
> -	struct sec_pmic_dev *pmic_drvdata = dev_get_drvdata(dev->parent);
> +	struct sec_pmic_dev *pmic_drvdata;

This seems to be a separate change. I guess it's preferable having it
as a separate patch.

>  	struct s2m_rgb *rgb;
>  	struct led_init_data init_data = {};
>  	int ret;
>  
> +	if (!dev->parent)
> +		return -ENODEV;
> +
> +	pmic_drvdata = dev_get_drvdata(dev->parent);
> +	if (!pmic_drvdata)
> +		return -ENODEV;
> +

1. This is a MFD sub-device, dev->parent shall always be present. But
there's no harm in being extra careful here.

2. For error codes other than -ENOMEM, we do not return from probe this
way, instead:

	return dev_err_probe(dev, -ENODEV, "error message\n");

>  	rgb = devm_kzalloc(dev, sizeof(*rgb), GFP_KERNEL);
>  	if (!rgb)
>  		return -ENOMEM;
> @@ -415,6 +422,7 @@ MODULE_DEVICE_TABLE(of, s2m_rgb_of_match_table);
>  static struct platform_driver s2m_rgb_driver = {
>  	.driver = {
>  		.name = "s2m-rgb",
> +		.of_match_table = s2m_rgb_of_match_table,

By the way, it works just fine without it, when built as a module.

The reason it wasn't added was in a comment in a previous revision [1],
but it was removed after reviews.

[1] https://lore.kernel.org/all/20260225-s2mu005-pmic-v3-9-b4afee947603@disroot.org/

>  	},
>  	.probe = s2m_rgb_probe,
>  	.id_table = s2m_rgb_id_table,


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-22 18:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-22 16:15 [PATCH v2 0/2] leds: s2m: Wire up of_match_table in platform drivers kr494167
2026-07-22 16:15 ` [PATCH v2 1/2] leds: rgb: s2m: Wire up of_match_table in platform driver kr494167
2026-07-22 18:07   ` Kaustabh Chakraborty
2026-07-22 16:15 ` [PATCH v2 2/2] leds: flash: " kr494167

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®