Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* [PATCH v1] fbdev: Use named initializers for struct i2c_device_id
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-18 16:08 UTC (permalink / raw)
  To: Helge Deller
  Cc: Kees Cook, Abdun Nihaal, linux-fbdev, dri-devel, linux-kernel

While being less compact, using named initializers allows to more easily
see which members of the structs are assigned which value without having
to lookup the declaration of the struct. And it's also more robust
against changes to the struct definition.

While touching all these arrays, unify usage of whitespace in the list
terminator.

This patch doesn't modify the compiled arrays, only their representation
in source form benefits. The former was confirmed with x86 and arm64
builds.

Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
Hello,

this patch is part of a bigger quest to use named initializers for
mainly struct i2c_device_id::driver_data to be able to modify
i2c_device_id. See e.g.
https://lore.kernel.org/all/20260518111203.639603-2-u.kleine-koenig@baylibre.com/
for the details.

This patch here isn't critical for this quest, as no driver makes use of
.driver_data, so apart from the better readability this is only about
consistency with other subsystems.

Best regards
Uwe

 drivers/video/fbdev/matrox/matroxfb_maven.c | 2 +-
 drivers/video/fbdev/ssd1307fb.c             | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/matrox/matroxfb_maven.c b/drivers/video/fbdev/matrox/matroxfb_maven.c
index 2ea65da6075c..fe057a0b57ec 100644
--- a/drivers/video/fbdev/matrox/matroxfb_maven.c
+++ b/drivers/video/fbdev/matrox/matroxfb_maven.c
@@ -1282,7 +1282,7 @@ static void maven_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id maven_id[] = {
-	{ "maven" },
+	{ .name = "maven" },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, maven_id);
diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
index 83dd31fa1fab..644b8d97b381 100644
--- a/drivers/video/fbdev/ssd1307fb.c
+++ b/drivers/video/fbdev/ssd1307fb.c
@@ -784,10 +784,10 @@ static void ssd1307fb_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id ssd1307fb_i2c_id[] = {
-	{ "ssd1305fb" },
-	{ "ssd1306fb" },
-	{ "ssd1307fb" },
-	{ "ssd1309fb" },
+	{ .name = "ssd1305fb" },
+	{ .name = "ssd1306fb" },
+	{ .name = "ssd1307fb" },
+	{ .name = "ssd1309fb" },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, ssd1307fb_i2c_id);

base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
-- 
2.47.3


^ permalink raw reply related

* [PATCH] backlight: Use named initializers for arrays of i2c_device_data
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-18 11:12 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han
  Cc: Michael Hennerich, Helge Deller, Junjie Cao, Jianhua Lu,
	Flavio Suligoi, dri-devel, linux-fbdev, linux-kernel

While being less compact, using named initializers allows to more easily
see which members of the structs are assigned which value without having
to lookup the declaration of the struct. And it's also more robust
against changes to the struct definition.

The mentioned robustness is relevant for a planned change to struct
i2c_device_id that replaces .driver_data by an anonymous union.

While touching all these arrays, unify usage of whitespace in the list
terminator.

This patch doesn't modify the compiled arrays, only their representation
in source form benefits. The former was confirmed with x86 and arm64
builds.

Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
Hello,

the mentioned change to i2c_device_id is the following:

	diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
	index 23ff24080dfd..aebd3a5e90af 100644
	--- a/include/linux/mod_devicetable.h
	+++ b/include/linux/mod_devicetable.h
	@@ -477,7 +477,11 @@ struct rpmsg_device_id {

	 struct i2c_device_id {
		char name[I2C_NAME_SIZE];
	-	kernel_ulong_t driver_data;	/* Data private to the driver */
	+	union {
	+		/* Data private to the driver */
	+		kernel_ulong_t driver_data;
	+		const void *driver_data_ptr;
	+	};
	 };

	 /* pci_epf */

and this requires that .driver_data is assigned via a named initializer
for static data. This requirement isn't a bad one because named
initializers are also much better readable than list initializers.

The union added to struct i2c_device_id enables further cleanups like:

	diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c
	index 0123ca8157a8..dfb0b07500a7 100644
	--- a/drivers/regulator/ad5398.c
	+++ b/drivers/regulator/ad5398.c
	@@ -207,8 +207,8 @@ struct ad5398_current_data_format {
	 static const struct ad5398_current_data_format df_10_4_120 = {10, 4, 0, 120000};

	 static const struct i2c_device_id ad5398_id[] = {
	-	{ .name = "ad5398", .driver_data = (kernel_ulong_t)&df_10_4_120 },
	-	{ .name = "ad5821", .driver_data = (kernel_ulong_t)&df_10_4_120 },
	+	{ .name = "ad5398", .driver_data_ptr = &df_10_4_120 },
	+	{ .name = "ad5821", .driver_data_ptr = &df_10_4_120 },
	 	{ }
	 };
	 MODULE_DEVICE_TABLE(i2c, ad5398_id);
	@@ -219,8 +219,7 @@ static int ad5398_probe(struct i2c_client *client)
	 	struct regulator_init_data *init_data = dev_get_platdata(&client->dev);
	 	struct regulator_config config = { };
	 	struct ad5398_chip_info *chip;
	-	const struct ad5398_current_data_format *df =
	-	                (struct ad5398_current_data_format *)id->driver_data;
	+	const struct ad5398_current_data_format *df = id->driver_data;

	 	chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
	 	if (!chip)

that are an improvement for readability (again!) and it keeps some
properties of the pointers (here: being const) without having to pay
attention for that. (I didn't find a backlight driver that benefits, so
this is "only" a regulator driver example.)

My additional motivation for this effort is CHERI[1]. This is a hardware
extension that uses 128 bit pointers but unsigned long is still 64 bit.
So with CHERI you cannot store pointers in unsigned long variables.

Best regards
Uwe

[1] https://cheri-alliance.org/discover-cheri/
    https://lwn.net/Articles/1037974/
---
 drivers/video/backlight/adp8860_bl.c |  6 +++---
 drivers/video/backlight/adp8870_bl.c |  2 +-
 drivers/video/backlight/arcxcnn_bl.c |  2 +-
 drivers/video/backlight/aw99706.c    |  2 +-
 drivers/video/backlight/bd6107.c     |  2 +-
 drivers/video/backlight/ktz8866.c    |  4 ++--
 drivers/video/backlight/lm3509_bl.c  |  4 ++--
 drivers/video/backlight/lm3630a_bl.c |  4 ++--
 drivers/video/backlight/lm3639_bl.c  |  4 ++--
 drivers/video/backlight/lp855x_bl.c  | 14 +++++++-------
 drivers/video/backlight/lv5207lp.c   |  2 +-
 drivers/video/backlight/mp3309c.c    |  2 +-
 12 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
index d4bbd7a7406b..09dd67702431 100644
--- a/drivers/video/backlight/adp8860_bl.c
+++ b/drivers/video/backlight/adp8860_bl.c
@@ -790,9 +790,9 @@ static SIMPLE_DEV_PM_OPS(adp8860_i2c_pm_ops, adp8860_i2c_suspend,
 			adp8860_i2c_resume);
 
 static const struct i2c_device_id adp8860_id[] = {
-	{ "adp8860", adp8860 },
-	{ "adp8861", adp8861 },
-	{ "adp8863", adp8863 },
+	{ .name = "adp8860", .driver_data = adp8860 },
+	{ .name = "adp8861", .driver_data = adp8861 },
+	{ .name = "adp8863", .driver_data = adp8863 },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, adp8860_id);
diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
index e09e20492e7c..d009f2c8a11d 100644
--- a/drivers/video/backlight/adp8870_bl.c
+++ b/drivers/video/backlight/adp8870_bl.c
@@ -962,7 +962,7 @@ static SIMPLE_DEV_PM_OPS(adp8870_i2c_pm_ops, adp8870_i2c_suspend,
 			adp8870_i2c_resume);
 
 static const struct i2c_device_id adp8870_id[] = {
-	{ "adp8870" },
+	{ .name = "adp8870" },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, adp8870_id);
diff --git a/drivers/video/backlight/arcxcnn_bl.c b/drivers/video/backlight/arcxcnn_bl.c
index 1d5a570cfe02..f46eeab02e90 100644
--- a/drivers/video/backlight/arcxcnn_bl.c
+++ b/drivers/video/backlight/arcxcnn_bl.c
@@ -382,7 +382,7 @@ static const struct of_device_id arcxcnn_dt_ids[] = {
 MODULE_DEVICE_TABLE(of, arcxcnn_dt_ids);
 
 static const struct i2c_device_id arcxcnn_ids[] = {
-	{"arc2c0608", ARC2C0608},
+	{ .name = "arc2c0608", .driver_data = ARC2C0608 },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, arcxcnn_ids);
diff --git a/drivers/video/backlight/aw99706.c b/drivers/video/backlight/aw99706.c
index 938f352aaab7..18299faf06ad 100644
--- a/drivers/video/backlight/aw99706.c
+++ b/drivers/video/backlight/aw99706.c
@@ -443,7 +443,7 @@ static int aw99706_resume(struct device *dev)
 static DEFINE_SIMPLE_DEV_PM_OPS(aw99706_pm_ops, aw99706_suspend, aw99706_resume);
 
 static const struct i2c_device_id aw99706_ids[] = {
-	{ "aw99706" },
+	{ .name = "aw99706" },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, aw99706_ids);
diff --git a/drivers/video/backlight/bd6107.c b/drivers/video/backlight/bd6107.c
index 74567af84e97..6778b4030b02 100644
--- a/drivers/video/backlight/bd6107.c
+++ b/drivers/video/backlight/bd6107.c
@@ -179,7 +179,7 @@ static void bd6107_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id bd6107_ids[] = {
-	{ "bd6107" },
+	{ .name = "bd6107" },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, bd6107_ids);
diff --git a/drivers/video/backlight/ktz8866.c b/drivers/video/backlight/ktz8866.c
index 351c2b4d63ed..53c1301dbb8c 100644
--- a/drivers/video/backlight/ktz8866.c
+++ b/drivers/video/backlight/ktz8866.c
@@ -179,8 +179,8 @@ static void ktz8866_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id ktz8866_ids[] = {
-	{ "ktz8866" },
-	{}
+	{ .name = "ktz8866" },
+	{ }
 };
 MODULE_DEVICE_TABLE(i2c, ktz8866_ids);
 
diff --git a/drivers/video/backlight/lm3509_bl.c b/drivers/video/backlight/lm3509_bl.c
index 24e1a19ff72d..53136c5e1460 100644
--- a/drivers/video/backlight/lm3509_bl.c
+++ b/drivers/video/backlight/lm3509_bl.c
@@ -311,8 +311,8 @@ static void lm3509_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id lm3509_id[] = {
-	{ LM3509_NAME },
-	{}
+	{ .name = LM3509_NAME },
+	{ }
 };
 
 MODULE_DEVICE_TABLE(i2c, lm3509_id);
diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c
index 37651c2b9393..8f49e59ce374 100644
--- a/drivers/video/backlight/lm3630a_bl.c
+++ b/drivers/video/backlight/lm3630a_bl.c
@@ -596,8 +596,8 @@ static void lm3630a_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id lm3630a_id[] = {
-	{ LM3630A_NAME },
-	{}
+	{ .name = LM3630A_NAME },
+	{ }
 };
 
 MODULE_DEVICE_TABLE(i2c, lm3630a_id);
diff --git a/drivers/video/backlight/lm3639_bl.c b/drivers/video/backlight/lm3639_bl.c
index 37ccc631c498..ea748b80b737 100644
--- a/drivers/video/backlight/lm3639_bl.c
+++ b/drivers/video/backlight/lm3639_bl.c
@@ -403,8 +403,8 @@ static void lm3639_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id lm3639_id[] = {
-	{ LM3639_NAME },
-	{}
+	{ .name = LM3639_NAME },
+	{ }
 };
 
 MODULE_DEVICE_TABLE(i2c, lm3639_id);
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index d191560ce285..43a2123d3a4d 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -570,13 +570,13 @@ static const struct of_device_id lp855x_dt_ids[] __maybe_unused = {
 MODULE_DEVICE_TABLE(of, lp855x_dt_ids);
 
 static const struct i2c_device_id lp855x_ids[] = {
-	{"lp8550", LP8550},
-	{"lp8551", LP8551},
-	{"lp8552", LP8552},
-	{"lp8553", LP8553},
-	{"lp8555", LP8555},
-	{"lp8556", LP8556},
-	{"lp8557", LP8557},
+	{ .name = "lp8550", .driver_data = LP8550 },
+	{ .name = "lp8551", .driver_data = LP8551 },
+	{ .name = "lp8552", .driver_data = LP8552 },
+	{ .name = "lp8553", .driver_data = LP8553 },
+	{ .name = "lp8555", .driver_data = LP8555 },
+	{ .name = "lp8556", .driver_data = LP8556 },
+	{ .name = "lp8557", .driver_data = LP8557 },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, lp855x_ids);
diff --git a/drivers/video/backlight/lv5207lp.c b/drivers/video/backlight/lv5207lp.c
index a205f004eab2..e643ab9c3536 100644
--- a/drivers/video/backlight/lv5207lp.c
+++ b/drivers/video/backlight/lv5207lp.c
@@ -131,7 +131,7 @@ static void lv5207lp_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id lv5207lp_ids[] = {
-	{ "lv5207lp" },
+	{ .name = "lv5207lp" },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, lv5207lp_ids);
diff --git a/drivers/video/backlight/mp3309c.c b/drivers/video/backlight/mp3309c.c
index 9337110ce6e5..413cfe27dfd9 100644
--- a/drivers/video/backlight/mp3309c.c
+++ b/drivers/video/backlight/mp3309c.c
@@ -400,7 +400,7 @@ static const struct of_device_id mp3309c_match_table[] = {
 MODULE_DEVICE_TABLE(of, mp3309c_match_table);
 
 static const struct i2c_device_id mp3309c_id[] = {
-	{ "mp3309c" },
+	{ .name = "mp3309c" },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, mp3309c_id);

base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
-- 
2.47.3


^ permalink raw reply related

* Re: [PATCH v1 2/6] mfd: lm3533: Convert to use OF bindings
From: Svyatoslav Ryhel @ 2026-05-18  9:51 UTC (permalink / raw)
  To: Lee Jones
  Cc: Daniel Thompson, Jingoo Han, Rob Herring, Pavel Machek,
	Krzysztof Kozlowski, Conor Dooley, David Lechner,
	Jonathan Cameron, Nuno Sá, Helge Deller, dri-devel,
	linux-leds, devicetree, linux-kernel, linux-iio, linux-fbdev,
	Andy Shevchenko
In-Reply-To: <20260518092833.GR305027@google.com>

пн, 18 трав. 2026 р. о 12:28 Lee Jones <lee@kernel.org> пише:
>
> On Sun, 17 May 2026, Svyatoslav Ryhel wrote:
>
> > нд, 17 трав. 2026 р. о 10:43 Svyatoslav Ryhel <clamor95@gmail.com> пише:
> > >
> > > Since there are no users of this driver via platform data, remove the
> > > platform data support and switch to using Device Tree bindings.
> > > Additionally, optimize functions used only by platform data.
> > >
> > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > ---
> > >  drivers/iio/light/lm3533-als.c      | 123 +++++--------
> > >  drivers/leds/leds-lm3533.c          |  60 ++++---
> > >  drivers/mfd/lm3533-core.c           | 257 +++++++++-------------------
> > >  drivers/video/backlight/lm3533_bl.c |  52 ++++--
> > >  include/linux/mfd/lm3533.h          |  51 +-----
> > >  5 files changed, 202 insertions(+), 341 deletions(-)
>
> Please snip replies.
>
> [...]
>
> > > -static int lm3533_device_led_init(struct lm3533 *lm3533)
> > > -{
> > > -       struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
> > > -       int i;
> > > -       int ret;
> > > -
> > > -       if (!pdata->leds || pdata->num_leds == 0)
> > > -               return 0;
> > > -
> > > -       if (pdata->num_leds > ARRAY_SIZE(lm3533_led_devs))
> > > -               pdata->num_leds = ARRAY_SIZE(lm3533_led_devs);
> > > -
> > > -       for (i = 0; i < pdata->num_leds; ++i) {
> > > -               lm3533_led_devs[i].platform_data = &pdata->leds[i];
> > > -               lm3533_led_devs[i].pdata_size = sizeof(pdata->leds[i]);
> > > +               dev_err(dev, "failed to set boost ovp\n");
> > > +               goto err_disable;
> > >         }
> > >
> > > -       ret = mfd_add_devices(lm3533->dev, 0, lm3533_led_devs,
> > > -                             pdata->num_leds, NULL, 0, NULL);
> > > +       ret = devm_mfd_add_devices(dev, 0, lm3533_child_devices,
> > > +                                  ARRAY_SIZE(lm3533_child_devices),
> > > +                                  NULL, 0, NULL);
> >
> > Question to Lee Jones. Would you find acceptable if the driver will
> > build cell list dynamically based on the nodes in the device tree?
> > This is LED controller after all, not all leds can be populated and
> > same LED control bank can be linked to all LVLEDs for example.
> >
> > If you are ok, would this implementation satisfy you?
>
> Generally not.  Create the non-dynamical information statically
> (obviously not 'const'), then you can add dynamic data as you go.
>

Hm, code I have proposed below creates mfd_cell structure with 7 cells
(max amount of children), and fills each slot with devices described
in the device tree. This seems to fit your expectation. LM3533 is
basically a LED controller but it is set as mfd and IMHO would be
undesirable to create dummy devices.

> >         struct mfd_cell lm3533_cells[LM3533_CELLS_MAX];
> >         u32 count = 0, reg;
> >         int ret;
> >
> >         device_for_each_child_node_scoped(lm3533->dev, child) {
> >                 if (!fwnode_device_is_available(child))
> >                         continue;
> >
> >                 if (count >= LM3533_CELLS_MAX)
> >                         break;
> >
> >                 if (fwnode_device_is_compatible(child, "ti,lm3533-als")) {
> >                         lm3533_cells[count].name = "lm3533-als";
> >                         lm3533_cells[count].id = PLATFORM_DEVID_NONE;
> >                         lm3533_cells[count].of_compatible = "ti,lm3533-als";
> >
> >                         lm3533->have_als = true;
> >                 }
> >
> >                 if (fwnode_device_is_compatible(child, "ti,lm3533-backlight")) {
> >                         ret = fwnode_property_read_u32(child, "reg", &reg);
> >                         if (ret || reg > LM3533_HVLED_ID_MAX) {
> >                                 dev_err(dev, "invalid backlight reg %d\n", reg);
> >                                 continue;
> >                         }
> >
> >                         lm3533_cells[count].name = "lm3533-backlight";
> >                         lm3533_cells[count].id = reg;
> >                         lm3533_cells[count].of_compatible =
> > "ti,lm3533-backlight";
> >
> >                         lm3533->have_backlights = true;
> >                 }
> >
> >                 if (fwnode_device_is_compatible(child, "ti,lm3533-leds")) {
> >                         ret = fwnode_property_read_u32(child, "reg", &reg);
> >                         if (ret || reg < LM3533_HVLED_ID_MAX ||
> >                             reg > LM3533_LVLED_ID_MAX) {
> >                                 dev_err(dev, "invalid LED reg %d\n", reg);
> >                                 continue;
> >                         }
> >
> >                         lm3533_cells[count].name = "lm3533-leds";
> >                         lm3533_cells[count].id = reg - LM3533_HVLED_ID_MAX;
> >                         lm3533_cells[count].of_compatible = "ti,lm3533-leds";
> >
> >                         lm3533->have_leds = true;
> >                 }
> >
> >                 count++;
> >         }
> >
> > >         if (ret) {
> > > -               dev_err(lm3533->dev, "failed to add LED devices\n");
> > > -               return ret;
> > > -       }
> > > -
> > > -       lm3533->have_leds = 1;
> > > -
> > > -       return 0;
> > > -}
>
> [...]
>
> --
> Lee Jones

^ permalink raw reply

* Re: [PATCH v1 2/6] mfd: lm3533: Convert to use OF bindings
From: Lee Jones @ 2026-05-18  9:28 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: Daniel Thompson, Jingoo Han, Rob Herring, Pavel Machek,
	Krzysztof Kozlowski, Conor Dooley, David Lechner,
	Jonathan Cameron, Nuno Sá, Helge Deller, dri-devel,
	linux-leds, devicetree, linux-kernel, linux-iio, linux-fbdev,
	Andy Shevchenko
In-Reply-To: <CAPVz0n3gLYXab4H+DihfTkdBkGPqTvmoFVY1Cwuafd70KPtYbA@mail.gmail.com>

On Sun, 17 May 2026, Svyatoslav Ryhel wrote:

> нд, 17 трав. 2026 р. о 10:43 Svyatoslav Ryhel <clamor95@gmail.com> пише:
> >
> > Since there are no users of this driver via platform data, remove the
> > platform data support and switch to using Device Tree bindings.
> > Additionally, optimize functions used only by platform data.
> >
> > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > ---
> >  drivers/iio/light/lm3533-als.c      | 123 +++++--------
> >  drivers/leds/leds-lm3533.c          |  60 ++++---
> >  drivers/mfd/lm3533-core.c           | 257 +++++++++-------------------
> >  drivers/video/backlight/lm3533_bl.c |  52 ++++--
> >  include/linux/mfd/lm3533.h          |  51 +-----
> >  5 files changed, 202 insertions(+), 341 deletions(-)

Please snip replies.

[...]

> > -static int lm3533_device_led_init(struct lm3533 *lm3533)
> > -{
> > -       struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
> > -       int i;
> > -       int ret;
> > -
> > -       if (!pdata->leds || pdata->num_leds == 0)
> > -               return 0;
> > -
> > -       if (pdata->num_leds > ARRAY_SIZE(lm3533_led_devs))
> > -               pdata->num_leds = ARRAY_SIZE(lm3533_led_devs);
> > -
> > -       for (i = 0; i < pdata->num_leds; ++i) {
> > -               lm3533_led_devs[i].platform_data = &pdata->leds[i];
> > -               lm3533_led_devs[i].pdata_size = sizeof(pdata->leds[i]);
> > +               dev_err(dev, "failed to set boost ovp\n");
> > +               goto err_disable;
> >         }
> >
> > -       ret = mfd_add_devices(lm3533->dev, 0, lm3533_led_devs,
> > -                             pdata->num_leds, NULL, 0, NULL);
> > +       ret = devm_mfd_add_devices(dev, 0, lm3533_child_devices,
> > +                                  ARRAY_SIZE(lm3533_child_devices),
> > +                                  NULL, 0, NULL);
> 
> Question to Lee Jones. Would you find acceptable if the driver will
> build cell list dynamically based on the nodes in the device tree?
> This is LED controller after all, not all leds can be populated and
> same LED control bank can be linked to all LVLEDs for example.
> 
> If you are ok, would this implementation satisfy you?

Generally not.  Create the non-dynamical information statically
(obviously not 'const'), then you can add dynamic data as you go.

>         struct mfd_cell lm3533_cells[LM3533_CELLS_MAX];
>         u32 count = 0, reg;
>         int ret;
> 
>         device_for_each_child_node_scoped(lm3533->dev, child) {
>                 if (!fwnode_device_is_available(child))
>                         continue;
> 
>                 if (count >= LM3533_CELLS_MAX)
>                         break;
> 
>                 if (fwnode_device_is_compatible(child, "ti,lm3533-als")) {
>                         lm3533_cells[count].name = "lm3533-als";
>                         lm3533_cells[count].id = PLATFORM_DEVID_NONE;
>                         lm3533_cells[count].of_compatible = "ti,lm3533-als";
> 
>                         lm3533->have_als = true;
>                 }
> 
>                 if (fwnode_device_is_compatible(child, "ti,lm3533-backlight")) {
>                         ret = fwnode_property_read_u32(child, "reg", &reg);
>                         if (ret || reg > LM3533_HVLED_ID_MAX) {
>                                 dev_err(dev, "invalid backlight reg %d\n", reg);
>                                 continue;
>                         }
> 
>                         lm3533_cells[count].name = "lm3533-backlight";
>                         lm3533_cells[count].id = reg;
>                         lm3533_cells[count].of_compatible =
> "ti,lm3533-backlight";
> 
>                         lm3533->have_backlights = true;
>                 }
> 
>                 if (fwnode_device_is_compatible(child, "ti,lm3533-leds")) {
>                         ret = fwnode_property_read_u32(child, "reg", &reg);
>                         if (ret || reg < LM3533_HVLED_ID_MAX ||
>                             reg > LM3533_LVLED_ID_MAX) {
>                                 dev_err(dev, "invalid LED reg %d\n", reg);
>                                 continue;
>                         }
> 
>                         lm3533_cells[count].name = "lm3533-leds";
>                         lm3533_cells[count].id = reg - LM3533_HVLED_ID_MAX;
>                         lm3533_cells[count].of_compatible = "ti,lm3533-leds";
> 
>                         lm3533->have_leds = true;
>                 }
> 
>                 count++;
>         }
> 
> >         if (ret) {
> > -               dev_err(lm3533->dev, "failed to add LED devices\n");
> > -               return ret;
> > -       }
> > -
> > -       lm3533->have_leds = 1;
> > -
> > -       return 0;
> > -}

[...]

-- 
Lee Jones

^ permalink raw reply

* Re: [PATCH v1 1/6] dt-bindings: leds: Document TI LM3533 LED controller
From: Svyatoslav Ryhel @ 2026-05-17 14:26 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, David Lechner, Nuno Sá,
	Andy Shevchenko, Helge Deller, dri-devel, linux-leds, devicetree,
	linux-kernel, linux-iio, linux-fbdev
In-Reply-To: <20260517144453.61cc210c@jic23-huawei>

нд, 17 трав. 2026 р. о 16:45 Jonathan Cameron <jic23@kernel.org> пише:
>
> On Sun, 17 May 2026 10:43:01 +0300
> Svyatoslav Ryhel <clamor95@gmail.com> wrote:
>
> > Document the LM3533 - a complete power source for backlight, keypad and
> > indicator LEDs in smartphone handsets. The high-voltage inductive boost
> > converter provides the power for two series LED strings display backlight
> > and keypad functions.
> >
> > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> Hi Svyatoslav,
>
> I focused on the ALS part.. A few comments.
>
> > +# see ti,lm3533.yaml for an example
> > diff --git a/Documentation/devicetree/bindings/leds/ti,lm3533.yaml b/Documentation/devicetree/bindings/leds/ti,lm3533.yaml
> > new file mode 100644
> > index 000000000000..2e200f172400
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/leds/ti,lm3533.yaml
> > @@ -0,0 +1,190 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/leds/ti,lm3533.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: TI LM3533 Complete Lighting Power Solution
> > +
> > +description: >
> > +  The LM3533 is a complete power source for backlight, keypad, and indicator LEDs
> > +  in smartphone handsets. The high-voltage inductive boost converter provides the
> > +  power for two high voltage series LED strings for display backlight and four low
> > +  voltage control banks for individual LEDs. Additionally, LM3533 features an ALS
> > +  sensor support.
> Mention it is an interface for an external ALS.
>

Noted, thank you!

> > +  light-sensor:
> > +    type: object
> > +    additionalProperties: false
> > +
> > +    properties:
> > +      compatible:
> > +        const: ti,lm3533-als
> > +
> > +      interrupts:
> > +        maxItems: 1
> > +
> > +      ti,resistor-ohm:
> > +        $ref: /schemas/types.yaml#/definitions/uint32
> > +        description:
> > +          Internal configuration resister value when ALS is in Analog Sensor
> > +          mode and PWM mode is disabled.
>
> Good to note why this is a firmware thing rather than a userspace controlled
> thing. I looked it up, it's because expectation is the input is a current from
> the external analog ALS and these are used to convert it to a voltage with target
> range.
>

I will include your explanation.

> > +        minimum: 1575
> > +        maximum: 200000
> > +
> > +      ti,pwm-mode:
> > +        type: boolean
> > +        description:
> > +          Switch for mode in which ALS is running. If this property is set
> > +          then ALS is running in PWM mode, internal resistor value is set to
> > +          high-impedance (0) and ti,resistor-ohm property is ignored.
> I'd mention the ALS is an external device - so this is saying what interface thing
> thing connected is using.
>

Noted

> > +
> > +    required:
> > +      - compatible
> > +
> > +    anyOf:
> > +      - required:
> > +          - ti,resistor-ohm
> > +      - required:
> > +          - ti,pwm-mode
> > +
> > +patternProperties:
> > +  "^backlight@[01]$":
> > +    $ref: /schemas/leds/backlight/ti,lm3533-backlight.yaml#
> > +
> > +  "^led@[2-5]$":
> > +    $ref: /schemas/leds/ti,lm3533-leds.yaml#
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - light-sensor
> > +  - backlight@0
> > +  - backlight@1
>
> Similar for the led nodes.
>
> > +  - led@2
> > +  - led@3
> > +  - led@4
> > +  - led@5
>
> Curious - why are all the led nodes required?  What if some aren't wired to anything?
>

This is limitations of mfd devices. If it has subnodes, all subnodes
must be present to reflect mfd composition. Unused nodes should be
disabled.

However, I have asked Lee if he is fine if I will program dynamic mfd
composition based on the device tree. If he is fine, "required"
props/nodes list will be reduced.

> > +
> > +additionalProperties: false
>

^ permalink raw reply

* Re: [PATCH v1 1/6] dt-bindings: leds: Document TI LM3533 LED controller
From: Jonathan Cameron @ 2026-05-17 13:44 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, David Lechner, Nuno Sá,
	Andy Shevchenko, Helge Deller, dri-devel, linux-leds, devicetree,
	linux-kernel, linux-iio, linux-fbdev
In-Reply-To: <20260517074306.30937-2-clamor95@gmail.com>

On Sun, 17 May 2026 10:43:01 +0300
Svyatoslav Ryhel <clamor95@gmail.com> wrote:

> Document the LM3533 - a complete power source for backlight, keypad and
> indicator LEDs in smartphone handsets. The high-voltage inductive boost
> converter provides the power for two series LED strings display backlight
> and keypad functions.
> 
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Hi Svyatoslav,

I focused on the ALS part.. A few comments.

> +# see ti,lm3533.yaml for an example
> diff --git a/Documentation/devicetree/bindings/leds/ti,lm3533.yaml b/Documentation/devicetree/bindings/leds/ti,lm3533.yaml
> new file mode 100644
> index 000000000000..2e200f172400
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/ti,lm3533.yaml
> @@ -0,0 +1,190 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/leds/ti,lm3533.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: TI LM3533 Complete Lighting Power Solution
> +
> +description: >
> +  The LM3533 is a complete power source for backlight, keypad, and indicator LEDs
> +  in smartphone handsets. The high-voltage inductive boost converter provides the
> +  power for two high voltage series LED strings for display backlight and four low
> +  voltage control banks for individual LEDs. Additionally, LM3533 features an ALS
> +  sensor support.
Mention it is an interface for an external ALS.

> +  light-sensor:
> +    type: object
> +    additionalProperties: false
> +
> +    properties:
> +      compatible:
> +        const: ti,lm3533-als
> +
> +      interrupts:
> +        maxItems: 1
> +
> +      ti,resistor-ohm:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        description:
> +          Internal configuration resister value when ALS is in Analog Sensor
> +          mode and PWM mode is disabled.

Good to note why this is a firmware thing rather than a userspace controlled
thing. I looked it up, it's because expectation is the input is a current from
the external analog ALS and these are used to convert it to a voltage with target
range.

> +        minimum: 1575
> +        maximum: 200000
> +
> +      ti,pwm-mode:
> +        type: boolean
> +        description:
> +          Switch for mode in which ALS is running. If this property is set
> +          then ALS is running in PWM mode, internal resistor value is set to
> +          high-impedance (0) and ti,resistor-ohm property is ignored.
I'd mention the ALS is an external device - so this is saying what interface thing
thing connected is using.

> +
> +    required:
> +      - compatible
> +
> +    anyOf:
> +      - required:
> +          - ti,resistor-ohm
> +      - required:
> +          - ti,pwm-mode
> +
> +patternProperties:
> +  "^backlight@[01]$":
> +    $ref: /schemas/leds/backlight/ti,lm3533-backlight.yaml#
> +
> +  "^led@[2-5]$":
> +    $ref: /schemas/leds/ti,lm3533-leds.yaml#
> +
> +required:
> +  - compatible
> +  - reg
> +  - light-sensor
> +  - backlight@0
> +  - backlight@1

Similar for the led nodes.

> +  - led@2
> +  - led@3
> +  - led@4
> +  - led@5

Curious - why are all the led nodes required?  What if some aren't wired to anything?

> +
> +additionalProperties: false


^ permalink raw reply

* [PATCH] staging: sm750: rename CamelCase variable Bpp to bpp
From: Rupesh Majhi @ 2026-05-17 13:19 UTC (permalink / raw)
  To: gregkh
  Cc: sudipm.mukherjee, teddy.wang, linux-fbdev, linux-staging,
	linux-kernel, Rupesh Majhi

Rename the CamelCase variable 'Bpp' to 'bpp' in both the header
and implementation files to comply with Linux kernel coding style.

Issue found by checkpatch.

Signed-off-by: Rupesh Majhi <zoone.rupert@gmail.com>
---
 drivers/staging/sm750fb/sm750_accel.c | 22 +++++++++++-----------
 drivers/staging/sm750fb/sm750_accel.h |  6 +++---
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c
index ec2f0a6aa57d..59449a84728a 100644
--- a/drivers/staging/sm750fb/sm750_accel.c
+++ b/drivers/staging/sm750fb/sm750_accel.c
@@ -85,7 +85,7 @@ void sm750_hw_set2dformat(struct lynx_accel *accel, int fmt)
 }
 
 int sm750_hw_fillrect(struct lynx_accel *accel,
-		      u32 base, u32 pitch, u32 Bpp,
+		      u32 base, u32 pitch, u32 bpp,
 		      u32 x, u32 y, u32 width, u32 height,
 		      u32 color, u32 rop)
 {
@@ -103,14 +103,14 @@ int sm750_hw_fillrect(struct lynx_accel *accel,
 
 	write_dpr(accel, DE_WINDOW_DESTINATION_BASE, base); /* dpr40 */
 	write_dpr(accel, DE_PITCH,
-		  ((pitch / Bpp << DE_PITCH_DESTINATION_SHIFT) &
+		  ((pitch / bpp << DE_PITCH_DESTINATION_SHIFT) &
 		   DE_PITCH_DESTINATION_MASK) |
-		  (pitch / Bpp & DE_PITCH_SOURCE_MASK)); /* dpr10 */
+		  (pitch / bpp & DE_PITCH_SOURCE_MASK)); /* dpr10 */
 
 	write_dpr(accel, DE_WINDOW_WIDTH,
-		  ((pitch / Bpp << DE_WINDOW_WIDTH_DST_SHIFT) &
+		  ((pitch / bpp << DE_WINDOW_WIDTH_DST_SHIFT) &
 		   DE_WINDOW_WIDTH_DST_MASK) |
-		   (pitch / Bpp & DE_WINDOW_WIDTH_SRC_MASK)); /* dpr44 */
+		   (pitch / bpp & DE_WINDOW_WIDTH_SRC_MASK)); /* dpr44 */
 
 	write_dpr(accel, DE_FOREGROUND, color); /* DPR14 */
 
@@ -139,7 +139,7 @@ int sm750_hw_fillrect(struct lynx_accel *accel,
  * @sy: Starting y coordinate of source surface
  * @dest_base: Address of destination: offset in frame buffer
  * @dest_pitch: Pitch value of destination surface in BYTE
- * @Bpp: Color depth of destination surface
+ * @bpp: Color depth of destination surface
  * @dx: Starting x coordinate of destination surface
  * @dy: Starting y coordinate of destination surface
  * @width: width of rectangle in pixel value
@@ -150,7 +150,7 @@ int sm750_hw_copyarea(struct lynx_accel *accel,
 		      unsigned int source_base, unsigned int source_pitch,
 		      unsigned int sx, unsigned int sy,
 		      unsigned int dest_base, unsigned int dest_pitch,
-		      unsigned int Bpp, unsigned int dx, unsigned int dy,
+		      unsigned int bpp, unsigned int dx, unsigned int dy,
 		      unsigned int width, unsigned int height,
 		      unsigned int rop2)
 {
@@ -251,9 +251,9 @@ int sm750_hw_copyarea(struct lynx_accel *accel,
 	 * pixel values. Need Byte to pixel conversion.
 	 */
 	write_dpr(accel, DE_PITCH,
-		  ((dest_pitch / Bpp << DE_PITCH_DESTINATION_SHIFT) &
+		  ((dest_pitch / bpp << DE_PITCH_DESTINATION_SHIFT) &
 		   DE_PITCH_DESTINATION_MASK) |
-		  (source_pitch / Bpp & DE_PITCH_SOURCE_MASK)); /* dpr10 */
+		  (source_pitch / bpp & DE_PITCH_SOURCE_MASK)); /* dpr10 */
 
 	/*
 	 * Screen Window width in Pixels.
@@ -261,9 +261,9 @@ int sm750_hw_copyarea(struct lynx_accel *accel,
 	 * for a given point.
 	 */
 	write_dpr(accel, DE_WINDOW_WIDTH,
-		  ((dest_pitch / Bpp << DE_WINDOW_WIDTH_DST_SHIFT) &
+		  ((dest_pitch / bpp << DE_WINDOW_WIDTH_DST_SHIFT) &
 		   DE_WINDOW_WIDTH_DST_MASK) |
-		  (source_pitch / Bpp & DE_WINDOW_WIDTH_SRC_MASK)); /* dpr3c */
+		  (source_pitch / bpp & DE_WINDOW_WIDTH_SRC_MASK)); /* dpr3c */
 
 	ret = accel->de_wait();
 	if (ret)
diff --git a/drivers/staging/sm750fb/sm750_accel.h b/drivers/staging/sm750fb/sm750_accel.h
index 2c79cb730a0a..d15a40cacb84 100644
--- a/drivers/staging/sm750fb/sm750_accel.h
+++ b/drivers/staging/sm750fb/sm750_accel.h
@@ -190,7 +190,7 @@ void sm750_hw_set2dformat(struct lynx_accel *accel, int fmt);
 void sm750_hw_de_init(struct lynx_accel *accel);
 
 int sm750_hw_fillrect(struct lynx_accel *accel,
-		      u32 base, u32 pitch, u32 Bpp,
+		      u32 base, u32 pitch, u32 bpp,
 		      u32 x, u32 y, u32 width, u32 height,
 		      u32 color, u32 rop);
 
@@ -202,7 +202,7 @@ int sm750_hw_fillrect(struct lynx_accel *accel,
  * @sy: Starting y coordinate of source surface
  * @dBase: Address of destination: offset in frame buffer
  * @dPitch: Pitch value of destination surface in BYTE
- * @Bpp: Color depth of destination surface
+ * @bpp: Color depth of destination surface
  * @dx: Starting x coordinate of destination surface
  * @dy: Starting y coordinate of destination surface
  * @width: width of rectangle in pixel value
@@ -213,7 +213,7 @@ int sm750_hw_copyarea(struct lynx_accel *accel,
 		      unsigned int sBase, unsigned int sPitch,
 		      unsigned int sx, unsigned int sy,
 		      unsigned int dBase, unsigned int dPitch,
-		      unsigned int Bpp, unsigned int dx, unsigned int dy,
+		      unsigned int bpp, unsigned int dx, unsigned int dy,
 		      unsigned int width, unsigned int height,
 		      unsigned int rop2);
 
-- 
2.43.0


^ permalink raw reply related

* Re: [PATCH v1 2/6] mfd: lm3533: Convert to use OF bindings
From: Svyatoslav Ryhel @ 2026-05-17 11:10 UTC (permalink / raw)
  To: Lee Jones
  Cc: Daniel Thompson, Jingoo Han, Rob Herring, Pavel Machek,
	Krzysztof Kozlowski, Conor Dooley, David Lechner,
	Jonathan Cameron, Nuno Sá, Helge Deller, dri-devel,
	linux-leds, devicetree, linux-kernel, linux-iio, linux-fbdev,
	Svyatoslav Ryhel, Andy Shevchenko
In-Reply-To: <20260517074306.30937-3-clamor95@gmail.com>

нд, 17 трав. 2026 р. о 10:43 Svyatoslav Ryhel <clamor95@gmail.com> пише:
>
> Since there are no users of this driver via platform data, remove the
> platform data support and switch to using Device Tree bindings.
> Additionally, optimize functions used only by platform data.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
>  drivers/iio/light/lm3533-als.c      | 123 +++++--------
>  drivers/leds/leds-lm3533.c          |  60 ++++---
>  drivers/mfd/lm3533-core.c           | 257 +++++++++-------------------
>  drivers/video/backlight/lm3533_bl.c |  52 ++++--
>  include/linux/mfd/lm3533.h          |  51 +-----
>  5 files changed, 202 insertions(+), 341 deletions(-)
>
> diff --git a/drivers/iio/light/lm3533-als.c b/drivers/iio/light/lm3533-als.c
> index 99f0b903018c..853abb96e13f 100644
> --- a/drivers/iio/light/lm3533-als.c
> +++ b/drivers/iio/light/lm3533-als.c
> @@ -16,15 +16,18 @@
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/mfd/core.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/platform_device.h>
> +#include <linux/property.h>
>  #include <linux/slab.h>
>  #include <linux/uaccess.h>
> +#include <linux/units.h>
>
>  #include <linux/mfd/lm3533.h>
>
>
> -#define LM3533_ALS_RESISTOR_MIN                        1
> -#define LM3533_ALS_RESISTOR_MAX                        127
> +#define LM3533_ALS_RESISTOR_MIN                        1575
> +#define LM3533_ALS_RESISTOR_MAX                        200000
>  #define LM3533_ALS_CHANNEL_CURRENT_MAX         2
>  #define LM3533_ALS_THRESH_MAX                  3
>  #define LM3533_ALS_ZONE_MAX                    4
> @@ -56,6 +59,9 @@ struct lm3533_als {
>
>         atomic_t zone;
>         struct mutex thresh_mutex;
> +
> +       bool pwm_mode;
> +       u32 r_select;
>  };
>
>
> @@ -714,64 +720,6 @@ static const struct attribute_group lm3533_als_attribute_group = {
>         .attrs = lm3533_als_attributes
>  };
>
> -static int lm3533_als_set_input_mode(struct lm3533_als *als, bool pwm_mode)
> -{
> -       u8 mask = LM3533_ALS_INPUT_MODE_MASK;
> -       u8 val;
> -       int ret;
> -
> -       if (pwm_mode)
> -               val = mask;     /* pwm input */
> -       else
> -               val = 0;        /* analog input */
> -
> -       ret = lm3533_update(als->lm3533, LM3533_REG_ALS_CONF, val, mask);
> -       if (ret) {
> -               dev_err(&als->pdev->dev, "failed to set input mode %d\n",
> -                                                               pwm_mode);
> -               return ret;
> -       }
> -
> -       return 0;
> -}
> -
> -static int lm3533_als_set_resistor(struct lm3533_als *als, u8 val)
> -{
> -       int ret;
> -
> -       if (val < LM3533_ALS_RESISTOR_MIN || val > LM3533_ALS_RESISTOR_MAX) {
> -               dev_err(&als->pdev->dev, "invalid resistor value\n");
> -               return -EINVAL;
> -       }
> -
> -       ret = lm3533_write(als->lm3533, LM3533_REG_ALS_RESISTOR_SELECT, val);
> -       if (ret) {
> -               dev_err(&als->pdev->dev, "failed to set resistor\n");
> -               return ret;
> -       }
> -
> -       return 0;
> -}
> -
> -static int lm3533_als_setup(struct lm3533_als *als,
> -                           const struct lm3533_als_platform_data *pdata)
> -{
> -       int ret;
> -
> -       ret = lm3533_als_set_input_mode(als, pdata->pwm_mode);
> -       if (ret)
> -               return ret;
> -
> -       /* ALS input is always high impedance in PWM-mode. */
> -       if (!pdata->pwm_mode) {
> -               ret = lm3533_als_set_resistor(als, pdata->r_select);
> -               if (ret)
> -                       return ret;
> -       }
> -
> -       return 0;
> -}
> -
>  static int lm3533_als_setup_irq(struct lm3533_als *als, void *dev)
>  {
>         u8 mask = LM3533_ALS_INT_ENABLE_MASK;
> @@ -784,7 +732,8 @@ static int lm3533_als_setup_irq(struct lm3533_als *als, void *dev)
>                 return ret;
>         }
>
> -       ret = request_threaded_irq(als->irq, NULL, lm3533_als_isr,
> +       ret = devm_request_threaded_irq(&als->pdev->dev, als->irq, NULL,
> +                                       lm3533_als_isr,
>                                         IRQF_TRIGGER_LOW | IRQF_ONESHOT,
>                                         dev_name(&als->pdev->dev), dev);
>         if (ret) {
> @@ -828,7 +777,6 @@ static const struct iio_info lm3533_als_info = {
>
>  static int lm3533_als_probe(struct platform_device *pdev)
>  {
> -       const struct lm3533_als_platform_data *pdata;
>         struct lm3533 *lm3533;
>         struct lm3533_als *als;
>         struct iio_dev *indio_dev;
> @@ -838,12 +786,6 @@ static int lm3533_als_probe(struct platform_device *pdev)
>         if (!lm3533)
>                 return -EINVAL;
>
> -       pdata = dev_get_platdata(&pdev->dev);
> -       if (!pdata) {
> -               dev_err(&pdev->dev, "no platform data\n");
> -               return -EINVAL;
> -       }
> -
>         indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*als));
>         if (!indio_dev)
>                 return -ENOMEM;
> @@ -852,31 +794,52 @@ static int lm3533_als_probe(struct platform_device *pdev)
>         indio_dev->channels = lm3533_als_channels;
>         indio_dev->num_channels = ARRAY_SIZE(lm3533_als_channels);
>         indio_dev->name = dev_name(&pdev->dev);
> -       iio_device_set_parent(indio_dev, pdev->dev.parent);
>         indio_dev->modes = INDIO_DIRECT_MODE;
>
>         als = iio_priv(indio_dev);
>         als->lm3533 = lm3533;
>         als->pdev = pdev;
> -       als->irq = lm3533->irq;
> +       als->irq = platform_get_irq_optional(pdev, 0);
>         atomic_set(&als->zone, 0);
>         mutex_init(&als->thresh_mutex);
>
>         platform_set_drvdata(pdev, indio_dev);
>
> -       if (als->irq) {
> +       if (als->irq > 0) {
>                 ret = lm3533_als_setup_irq(als, indio_dev);
>                 if (ret)
>                         return ret;
>         }
>
> -       ret = lm3533_als_setup(als, pdata);
> +       device_property_read_u32(&pdev->dev, "ti,resistor-value-ohm",
> +                                &als->r_select);
> +
> +       als->r_select = clamp(als->r_select, LM3533_ALS_RESISTOR_MIN,
> +                             LM3533_ALS_RESISTOR_MAX);
> +       als->r_select = DIV_ROUND_UP(2 * MICRO, 10 * als->r_select);
> +
> +       als->pwm_mode = device_property_read_bool(&pdev->dev, "ti,pwm-mode");
> +
> +       ret = lm3533_update(lm3533, LM3533_REG_ALS_CONF, als->pwm_mode ?
> +                           LM3533_ALS_INPUT_MODE_MASK : 0,
> +                           LM3533_ALS_INPUT_MODE_MASK);
>         if (ret)
> -               goto err_free_irq;
> +               return dev_err_probe(&pdev->dev, ret,
> +                                    "failed to set input mode %d\n",
> +                                    als->pwm_mode);
> +
> +       /* ALS input is always high impedance in PWM-mode. */
> +       if (!als->pwm_mode) {
> +               ret = lm3533_write(lm3533, LM3533_REG_ALS_RESISTOR_SELECT,
> +                                  (u8)als->r_select);
> +               if (ret)
> +                       return dev_err_probe(&pdev->dev, ret,
> +                                            "failed to set resistor\n");
> +       }
>
>         ret = lm3533_als_enable(als);
>         if (ret)
> -               goto err_free_irq;
> +               return ret;
>
>         ret = iio_device_register(indio_dev);
>         if (ret) {
> @@ -888,9 +851,6 @@ static int lm3533_als_probe(struct platform_device *pdev)
>
>  err_disable:
>         lm3533_als_disable(als);
> -err_free_irq:
> -       if (als->irq)
> -               free_irq(als->irq, indio_dev);
>
>         return ret;
>  }
> @@ -903,13 +863,18 @@ static void lm3533_als_remove(struct platform_device *pdev)
>         lm3533_als_set_int_mode(indio_dev, false);
>         iio_device_unregister(indio_dev);
>         lm3533_als_disable(als);
> -       if (als->irq)
> -               free_irq(als->irq, indio_dev);
>  }
>
> +static const struct of_device_id lm3533_als_match_table[] = {
> +       { .compatible = "ti,lm3533-als" },
> +       { }
> +};
> +MODULE_DEVICE_TABLE(of, lm3533_als_match_table);
> +
>  static struct platform_driver lm3533_als_driver = {
>         .driver = {
>                 .name   = "lm3533-als",
> +               .of_match_table = lm3533_als_match_table,
>         },
>         .probe          = lm3533_als_probe,
>         .remove         = lm3533_als_remove,
> diff --git a/drivers/leds/leds-lm3533.c b/drivers/leds/leds-lm3533.c
> index 45795f2a1042..f6345bc1f443 100644
> --- a/drivers/leds/leds-lm3533.c
> +++ b/drivers/leds/leds-lm3533.c
> @@ -10,8 +10,10 @@
>  #include <linux/module.h>
>  #include <linux/leds.h>
>  #include <linux/mfd/core.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/mutex.h>
>  #include <linux/platform_device.h>
> +#include <linux/property.h>
>  #include <linux/slab.h>
>
>  #include <linux/mfd/lm3533.h>
> @@ -48,6 +50,9 @@ struct lm3533_led {
>
>         struct mutex mutex;
>         unsigned long flags;
> +
> +       u32 max_current;
> +       u32 pwm;
>  };
>
>
> @@ -632,22 +637,20 @@ static const struct attribute_group *lm3533_led_attribute_groups[] = {
>         NULL
>  };
>
> -static int lm3533_led_setup(struct lm3533_led *led,
> -                                       struct lm3533_led_platform_data *pdata)
> +static int lm3533_led_setup(struct lm3533_led *led)
>  {
>         int ret;
>
> -       ret = lm3533_ctrlbank_set_max_current(&led->cb, pdata->max_current);
> +       ret = lm3533_ctrlbank_set_max_current(&led->cb, led->max_current);
>         if (ret)
>                 return ret;
>
> -       return lm3533_ctrlbank_set_pwm(&led->cb, pdata->pwm);
> +       return lm3533_ctrlbank_set_pwm(&led->cb, led->pwm);
>  }
>
>  static int lm3533_led_probe(struct platform_device *pdev)
>  {
>         struct lm3533 *lm3533;
> -       struct lm3533_led_platform_data *pdata;
>         struct lm3533_led *led;
>         int ret;
>
> @@ -657,30 +660,30 @@ static int lm3533_led_probe(struct platform_device *pdev)
>         if (!lm3533)
>                 return -EINVAL;
>
> -       pdata = dev_get_platdata(&pdev->dev);
> -       if (!pdata) {
> -               dev_err(&pdev->dev, "no platform data\n");
> -               return -EINVAL;
> -       }
> -
> -       if (pdev->id < 0 || pdev->id >= LM3533_LVCTRLBANK_COUNT) {
> -               dev_err(&pdev->dev, "illegal LED id %d\n", pdev->id);
> -               return -EINVAL;
> -       }
> +       if (pdev->id < LM3533_LVCTRLBANK_MIN || pdev->id > LM3533_LVCTRLBANK_MAX)
> +               return dev_err_probe(&pdev->dev, -EINVAL,
> +                                    "illegal LED id %d\n", pdev->id);
>
>         led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
>         if (!led)
>                 return -ENOMEM;
>
>         led->lm3533 = lm3533;
> -       led->cdev.name = pdata->name;
> -       led->cdev.default_trigger = pdata->default_trigger;
>         led->cdev.brightness_set_blocking = lm3533_led_set;
>         led->cdev.brightness_get = lm3533_led_get;
>         led->cdev.blink_set = lm3533_led_blink_set;
>         led->cdev.brightness = LED_OFF;
>         led->cdev.groups = lm3533_led_attribute_groups;
> -       led->id = pdev->id;
> +       led->id = pdev->id - LM3533_LVCTRLBANK_MIN;
> +
> +       led->cdev.name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s-%d",
> +                                       pdev->name, led->id);
> +       if (!led->cdev.name)
> +               return -ENOMEM;
> +
> +       led->cdev.default_trigger = "none";
> +       device_property_read_string(&pdev->dev, "linux,default-trigger",
> +                                   &led->cdev.default_trigger);
>
>         mutex_init(&led->mutex);
>
> @@ -694,15 +697,23 @@ static int lm3533_led_probe(struct platform_device *pdev)
>
>         platform_set_drvdata(pdev, led);
>
> -       ret = led_classdev_register(pdev->dev.parent, &led->cdev);
> +       ret = led_classdev_register(&pdev->dev, &led->cdev);
>         if (ret) {
> -               dev_err(&pdev->dev, "failed to register LED %d\n", pdev->id);
> +               dev_err(&pdev->dev, "failed to register LED %d\n", led->id);
>                 return ret;
>         }
>
>         led->cb.dev = led->cdev.dev;
>
> -       ret = lm3533_led_setup(led, pdata);
> +       device_property_read_u32(&pdev->dev, "led-max-microamp",
> +                                &led->max_current);
> +       led->max_current = clamp(led->max_current, LM3533_LED_MAX_CURRENT_MIN,
> +                                LM3533_LED_MAX_CURRENT_MAX);
> +
> +       led->pwm = 0;
> +       device_property_read_u32(&pdev->dev, "ti,pwm-config-mask", &led->pwm);
> +
> +       ret = lm3533_led_setup(led);
>         if (ret)
>                 goto err_deregister;
>
> @@ -739,9 +750,16 @@ static void lm3533_led_shutdown(struct platform_device *pdev)
>         lm3533_led_set(&led->cdev, LED_OFF);            /* disable blink */
>  }
>
> +static const struct of_device_id lm3533_led_match_table[] = {
> +       { .compatible = "ti,lm3533-leds" },
> +       { }
> +};
> +MODULE_DEVICE_TABLE(of, lm3533_led_match_table);
> +
>  static struct platform_driver lm3533_led_driver = {
>         .driver = {
>                 .name = "lm3533-leds",
> +               .of_match_table = lm3533_led_match_table,
>         },
>         .probe          = lm3533_led_probe,
>         .remove         = lm3533_led_remove,
> diff --git a/drivers/mfd/lm3533-core.c b/drivers/mfd/lm3533-core.c
> index 0a2409d00b2e..83ebd780f39d 100644
> --- a/drivers/mfd/lm3533-core.c
> +++ b/drivers/mfd/lm3533-core.c
> @@ -14,19 +14,26 @@
>  #include <linux/gpio/consumer.h>
>  #include <linux/i2c.h>
>  #include <linux/mfd/core.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/property.h>
>  #include <linux/regmap.h>
>  #include <linux/seq_file.h>
>  #include <linux/slab.h>
>  #include <linux/uaccess.h>
> +#include <linux/units.h>
>
>  #include <linux/mfd/lm3533.h>
>
>
>  #define LM3533_BOOST_OVP_MASK          0x06
>  #define LM3533_BOOST_OVP_SHIFT         1
> +#define LM3533_BOOST_OVP_MIN           16000000
> +#define LM3533_BOOST_OVP_MAX           40000000
>
>  #define LM3533_BOOST_FREQ_MASK         0x01
>  #define LM3533_BOOST_FREQ_SHIFT                0
> +#define LM3533_BOOST_FREQ_MIN          500000
> +#define LM3533_BOOST_FREQ_MAX          1000000
>
>  #define LM3533_BL_ID_MASK              1
>  #define LM3533_LED_ID_MASK             3
> @@ -42,42 +49,14 @@
>
>  #define LM3533_REG_MAX                 0xb2
>
> -
> -static struct mfd_cell lm3533_als_devs[] = {
> -       {
> -               .name   = "lm3533-als",
> -               .id     = -1,
> -       },
> -};
> -
> -static struct mfd_cell lm3533_bl_devs[] = {
> -       {
> -               .name   = "lm3533-backlight",
> -               .id     = 0,
> -       },
> -       {
> -               .name   = "lm3533-backlight",
> -               .id     = 1,
> -       },
> -};
> -
> -static struct mfd_cell lm3533_led_devs[] = {
> -       {
> -               .name   = "lm3533-leds",
> -               .id     = 0,
> -       },
> -       {
> -               .name   = "lm3533-leds",
> -               .id     = 1,
> -       },
> -       {
> -               .name   = "lm3533-leds",
> -               .id     = 2,
> -       },
> -       {
> -               .name   = "lm3533-leds",
> -               .id     = 3,
> -       },
> +static struct mfd_cell lm3533_child_devices[] = {
> +       MFD_CELL_OF("lm3533-als", NULL, NULL, 0, 0, "ti,lm3533-als"),
> +       MFD_CELL_OF_REG("lm3533-backlight", NULL, NULL, 0, 0, "ti,lm3533-backlight", 0),
> +       MFD_CELL_OF_REG("lm3533-backlight", NULL, NULL, 0, 1, "ti,lm3533-backlight", 1),
> +       MFD_CELL_OF_REG("lm3533-leds", NULL, NULL, 0, 0, "ti,lm3533-leds", 2),
> +       MFD_CELL_OF_REG("lm3533-leds", NULL, NULL, 0, 1, "ti,lm3533-leds", 3),
> +       MFD_CELL_OF_REG("lm3533-leds", NULL, NULL, 0, 2, "ti,lm3533-leds", 4),
> +       MFD_CELL_OF_REG("lm3533-leds", NULL, NULL, 0, 3, "ti,lm3533-leds", 5),
>  };
>
>  int lm3533_read(struct lm3533 *lm3533, u8 reg, u8 *val)
> @@ -132,35 +111,6 @@ int lm3533_update(struct lm3533 *lm3533, u8 reg, u8 val, u8 mask)
>  }
>  EXPORT_SYMBOL_GPL(lm3533_update);
>
> -static int lm3533_set_boost_freq(struct lm3533 *lm3533,
> -                                               enum lm3533_boost_freq freq)
> -{
> -       int ret;
> -
> -       ret = lm3533_update(lm3533, LM3533_REG_BOOST_PWM,
> -                                       freq << LM3533_BOOST_FREQ_SHIFT,
> -                                       LM3533_BOOST_FREQ_MASK);
> -       if (ret)
> -               dev_err(lm3533->dev, "failed to set boost frequency\n");
> -
> -       return ret;
> -}
> -
> -
> -static int lm3533_set_boost_ovp(struct lm3533 *lm3533,
> -                                               enum lm3533_boost_ovp ovp)
> -{
> -       int ret;
> -
> -       ret = lm3533_update(lm3533, LM3533_REG_BOOST_PWM,
> -                                       ovp << LM3533_BOOST_OVP_SHIFT,
> -                                       LM3533_BOOST_OVP_MASK);
> -       if (ret)
> -               dev_err(lm3533->dev, "failed to set boost ovp\n");
> -
> -       return ret;
> -}
> -
>  /*
>   * HVLED output config -- output hvled controlled by backlight bl
>   */
> @@ -376,136 +326,45 @@ static struct attribute_group lm3533_attribute_group = {
>         .attrs          = lm3533_attributes
>  };
>
> -static int lm3533_device_als_init(struct lm3533 *lm3533)
> +static int lm3533_device_init(struct lm3533 *lm3533)
>  {
> -       struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
> +       struct device *dev = lm3533->dev;
>         int ret;
>
> -       if (!pdata->als)
> -               return 0;
> -
> -       lm3533_als_devs[0].platform_data = pdata->als;
> -       lm3533_als_devs[0].pdata_size = sizeof(*pdata->als);
> +       lm3533_enable(lm3533);
>
> -       ret = mfd_add_devices(lm3533->dev, 0, lm3533_als_devs, 1, NULL,
> -                             0, NULL);
> +       ret = lm3533_update(lm3533, LM3533_REG_BOOST_PWM,
> +                           lm3533->boost_freq << LM3533_BOOST_FREQ_SHIFT,
> +                           LM3533_BOOST_FREQ_MASK);
>         if (ret) {
> -               dev_err(lm3533->dev, "failed to add ALS device\n");
> -               return ret;
> -       }
> -
> -       lm3533->have_als = 1;
> -
> -       return 0;
> -}
> -
> -static int lm3533_device_bl_init(struct lm3533 *lm3533)
> -{
> -       struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
> -       int i;
> -       int ret;
> -
> -       if (!pdata->backlights || pdata->num_backlights == 0)
> -               return 0;
> -
> -       if (pdata->num_backlights > ARRAY_SIZE(lm3533_bl_devs))
> -               pdata->num_backlights = ARRAY_SIZE(lm3533_bl_devs);
> -
> -       for (i = 0; i < pdata->num_backlights; ++i) {
> -               lm3533_bl_devs[i].platform_data = &pdata->backlights[i];
> -               lm3533_bl_devs[i].pdata_size = sizeof(pdata->backlights[i]);
> +               dev_err(dev, "failed to set boost frequency\n");
> +               goto err_disable;
>         }
>
> -       ret = mfd_add_devices(lm3533->dev, 0, lm3533_bl_devs,
> -                             pdata->num_backlights, NULL, 0, NULL);
> +       ret = lm3533_update(lm3533, LM3533_REG_BOOST_PWM,
> +                           lm3533->boost_ovp << LM3533_BOOST_OVP_SHIFT,
> +                           LM3533_BOOST_OVP_MASK);
>         if (ret) {
> -               dev_err(lm3533->dev, "failed to add backlight devices\n");
> -               return ret;
> -       }
> -
> -       lm3533->have_backlights = 1;
> -
> -       return 0;
> -}
> -
> -static int lm3533_device_led_init(struct lm3533 *lm3533)
> -{
> -       struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
> -       int i;
> -       int ret;
> -
> -       if (!pdata->leds || pdata->num_leds == 0)
> -               return 0;
> -
> -       if (pdata->num_leds > ARRAY_SIZE(lm3533_led_devs))
> -               pdata->num_leds = ARRAY_SIZE(lm3533_led_devs);
> -
> -       for (i = 0; i < pdata->num_leds; ++i) {
> -               lm3533_led_devs[i].platform_data = &pdata->leds[i];
> -               lm3533_led_devs[i].pdata_size = sizeof(pdata->leds[i]);
> +               dev_err(dev, "failed to set boost ovp\n");
> +               goto err_disable;
>         }
>
> -       ret = mfd_add_devices(lm3533->dev, 0, lm3533_led_devs,
> -                             pdata->num_leds, NULL, 0, NULL);
> +       ret = devm_mfd_add_devices(dev, 0, lm3533_child_devices,
> +                                  ARRAY_SIZE(lm3533_child_devices),
> +                                  NULL, 0, NULL);

Question to Lee Jones. Would you find acceptable if the driver will
build cell list dynamically based on the nodes in the device tree?
This is LED controller after all, not all leds can be populated and
same LED control bank can be linked to all LVLEDs for example.

If you are ok, would this implementation satisfy you?

        struct mfd_cell lm3533_cells[LM3533_CELLS_MAX];
        u32 count = 0, reg;
        int ret;

        device_for_each_child_node_scoped(lm3533->dev, child) {
                if (!fwnode_device_is_available(child))
                        continue;

                if (count >= LM3533_CELLS_MAX)
                        break;

                if (fwnode_device_is_compatible(child, "ti,lm3533-als")) {
                        lm3533_cells[count].name = "lm3533-als";
                        lm3533_cells[count].id = PLATFORM_DEVID_NONE;
                        lm3533_cells[count].of_compatible = "ti,lm3533-als";

                        lm3533->have_als = true;
                }

                if (fwnode_device_is_compatible(child, "ti,lm3533-backlight")) {
                        ret = fwnode_property_read_u32(child, "reg", &reg);
                        if (ret || reg > LM3533_HVLED_ID_MAX) {
                                dev_err(dev, "invalid backlight reg %d\n", reg);
                                continue;
                        }

                        lm3533_cells[count].name = "lm3533-backlight";
                        lm3533_cells[count].id = reg;
                        lm3533_cells[count].of_compatible =
"ti,lm3533-backlight";

                        lm3533->have_backlights = true;
                }

                if (fwnode_device_is_compatible(child, "ti,lm3533-leds")) {
                        ret = fwnode_property_read_u32(child, "reg", &reg);
                        if (ret || reg < LM3533_HVLED_ID_MAX ||
                            reg > LM3533_LVLED_ID_MAX) {
                                dev_err(dev, "invalid LED reg %d\n", reg);
                                continue;
                        }

                        lm3533_cells[count].name = "lm3533-leds";
                        lm3533_cells[count].id = reg - LM3533_HVLED_ID_MAX;
                        lm3533_cells[count].of_compatible = "ti,lm3533-leds";

                        lm3533->have_leds = true;
                }

                count++;
        }

>         if (ret) {
> -               dev_err(lm3533->dev, "failed to add LED devices\n");
> -               return ret;
> -       }
> -
> -       lm3533->have_leds = 1;
> -
> -       return 0;
> -}
> -
> -static int lm3533_device_setup(struct lm3533 *lm3533,
> -                                       struct lm3533_platform_data *pdata)
> -{
> -       int ret;
> -
> -       ret = lm3533_set_boost_freq(lm3533, pdata->boost_freq);
> -       if (ret)
> -               return ret;
> -
> -       return lm3533_set_boost_ovp(lm3533, pdata->boost_ovp);
> -}
> -
> -static int lm3533_device_init(struct lm3533 *lm3533)
> -{
> -       struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
> -       int ret;
> -
> -       dev_dbg(lm3533->dev, "%s\n", __func__);
> -
> -       if (!pdata) {
> -               dev_err(lm3533->dev, "no platform data\n");
> -               return -EINVAL;
> +               dev_err(dev, "failed to add MFD devices: %d\n", ret);
> +               goto err_disable;
>         }
>
> -       lm3533->hwen = devm_gpiod_get(lm3533->dev, NULL, GPIOD_OUT_LOW);
> -       if (IS_ERR(lm3533->hwen))
> -               return dev_err_probe(lm3533->dev, PTR_ERR(lm3533->hwen), "failed to request HWEN GPIO\n");
> -       gpiod_set_consumer_name(lm3533->hwen, "lm3533-hwen");
> -
> -       lm3533_enable(lm3533);
> -
> -       ret = lm3533_device_setup(lm3533, pdata);
> -       if (ret)
> +       ret = sysfs_create_group(&dev->kobj, &lm3533_attribute_group);
> +       if (ret) {
> +               dev_err(dev, "failed to create sysfs attributes\n");
>                 goto err_disable;
> -
> -       lm3533_device_als_init(lm3533);
> -       lm3533_device_bl_init(lm3533);
> -       lm3533_device_led_init(lm3533);
> -
> -       ret = sysfs_create_group(&lm3533->dev->kobj, &lm3533_attribute_group);
> -       if (ret < 0) {
> -               dev_err(lm3533->dev, "failed to create sysfs attributes\n");
> -               goto err_unregister;
>         }
>
>         return 0;
>
> -err_unregister:
> -       mfd_remove_devices(lm3533->dev);
>  err_disable:
>         lm3533_disable(lm3533);
>
> @@ -517,8 +376,6 @@ static void lm3533_device_exit(struct lm3533 *lm3533)
>         dev_dbg(lm3533->dev, "%s\n", __func__);
>
>         sysfs_remove_group(&lm3533->dev->kobj, &lm3533_attribute_group);
> -
> -       mfd_remove_devices(lm3533->dev);
>         lm3533_disable(lm3533);
>  }
>
> @@ -589,7 +446,40 @@ static int lm3533_i2c_probe(struct i2c_client *i2c)
>                 return PTR_ERR(lm3533->regmap);
>
>         lm3533->dev = &i2c->dev;
> -       lm3533->irq = i2c->irq;
> +
> +       lm3533->hwen = devm_gpiod_get_optional(lm3533->dev, "enable",
> +                                              GPIOD_OUT_LOW);
> +       if (IS_ERR(lm3533->hwen))
> +               return dev_err_probe(lm3533->dev, PTR_ERR(lm3533->hwen),
> +                                    "failed to get HWEN GPIO\n");
> +
> +       device_property_read_u32(lm3533->dev, "ti,boost-ovp-microvolt",
> +                                &lm3533->boost_ovp);
> +
> +       lm3533->boost_ovp = clamp(lm3533->boost_ovp, LM3533_BOOST_OVP_MIN,
> +                                 LM3533_BOOST_OVP_MAX);
> +       lm3533->boost_ovp = lm3533->boost_ovp / (8 * MICRO) - 2;
> +
> +       device_property_read_u32(lm3533->dev, "ti,boost-freq-hz",
> +                                &lm3533->boost_freq);
> +
> +       lm3533->boost_freq = clamp(lm3533->boost_freq, LM3533_BOOST_FREQ_MIN,
> +                                  LM3533_BOOST_FREQ_MAX);
> +       lm3533->boost_freq = lm3533->boost_freq / (500 * KILO) - 1;
> +
> +       device_for_each_child_node_scoped(lm3533->dev, child) {
> +               if (!fwnode_device_is_available(child))
> +                       continue;
> +
> +               if (fwnode_device_is_compatible(child, "ti,lm3533-als"))
> +                       lm3533->have_als = true;
> +
> +               if (fwnode_device_is_compatible(child, "ti,lm3533-backlight"))
> +                       lm3533->have_backlights = true;
> +
> +               if (fwnode_device_is_compatible(child, "ti,lm3533-leds"))
> +                       lm3533->have_leds = true;
> +       }
>
>         return lm3533_device_init(lm3533);
>  }
> @@ -603,6 +493,12 @@ static void lm3533_i2c_remove(struct i2c_client *i2c)
>         lm3533_device_exit(lm3533);
>  }
>
> +static const struct of_device_id lm3533_match_table[] = {
> +       { .compatible = "ti,lm3533" },
> +       { }
> +};
> +MODULE_DEVICE_TABLE(of, lm3533_match_table);
> +
>  static const struct i2c_device_id lm3533_i2c_ids[] = {
>         { "lm3533" },
>         { }
> @@ -612,6 +508,7 @@ MODULE_DEVICE_TABLE(i2c, lm3533_i2c_ids);
>  static struct i2c_driver lm3533_i2c_driver = {
>         .driver = {
>                    .name = "lm3533",
> +                  .of_match_table = lm3533_match_table,
>         },
>         .id_table       = lm3533_i2c_ids,
>         .probe          = lm3533_i2c_probe,
> diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
> index babfd3ceec86..42da652df58d 100644
> --- a/drivers/video/backlight/lm3533_bl.c
> +++ b/drivers/video/backlight/lm3533_bl.c
> @@ -9,7 +9,9 @@
>
>  #include <linux/module.h>
>  #include <linux/init.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/platform_device.h>
> +#include <linux/property.h>
>  #include <linux/backlight.h>
>  #include <linux/slab.h>
>
> @@ -27,6 +29,9 @@ struct lm3533_bl {
>         struct lm3533_ctrlbank cb;
>         struct backlight_device *bd;
>         int id;
> +
> +       u32 max_current;
> +       u32 pwm;
>  };
>
>
> @@ -246,25 +251,24 @@ static struct attribute_group lm3533_bl_attribute_group = {
>         .attrs          = lm3533_bl_attributes
>  };
>
> -static int lm3533_bl_setup(struct lm3533_bl *bl,
> -                                       struct lm3533_bl_platform_data *pdata)
> +static int lm3533_bl_setup(struct lm3533_bl *bl)
>  {
>         int ret;
>
> -       ret = lm3533_ctrlbank_set_max_current(&bl->cb, pdata->max_current);
> +       ret = lm3533_ctrlbank_set_max_current(&bl->cb, bl->max_current);
>         if (ret)
>                 return ret;
>
> -       return lm3533_ctrlbank_set_pwm(&bl->cb, pdata->pwm);
> +       return lm3533_ctrlbank_set_pwm(&bl->cb, bl->pwm);
>  }
>
>  static int lm3533_bl_probe(struct platform_device *pdev)
>  {
>         struct lm3533 *lm3533;
> -       struct lm3533_bl_platform_data *pdata;
>         struct lm3533_bl *bl;
>         struct backlight_device *bd;
>         struct backlight_properties props;
> +       char *name = NULL;
>         int ret;
>
>         dev_dbg(&pdev->dev, "%s\n", __func__);
> @@ -273,12 +277,6 @@ static int lm3533_bl_probe(struct platform_device *pdev)
>         if (!lm3533)
>                 return -EINVAL;
>
> -       pdata = dev_get_platdata(&pdev->dev);
> -       if (!pdata) {
> -               dev_err(&pdev->dev, "no platform data\n");
> -               return -EINVAL;
> -       }
> -
>         if (pdev->id < 0 || pdev->id >= LM3533_HVCTRLBANK_COUNT) {
>                 dev_err(&pdev->dev, "illegal backlight id %d\n", pdev->id);
>                 return -EINVAL;
> @@ -295,13 +293,20 @@ static int lm3533_bl_probe(struct platform_device *pdev)
>         bl->cb.id = lm3533_bl_get_ctrlbank_id(bl);
>         bl->cb.dev = NULL;                      /* until registered */
>
> +       name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s-%d",
> +                             pdev->name, pdev->id);
> +       if (!name)
> +               return -ENOMEM;
> +
>         memset(&props, 0, sizeof(props));
>         props.type = BACKLIGHT_RAW;
>         props.max_brightness = LM3533_BL_MAX_BRIGHTNESS;
> -       props.brightness = pdata->default_brightness;
> -       bd = devm_backlight_device_register(&pdev->dev, pdata->name,
> -                                       pdev->dev.parent, bl, &lm3533_bl_ops,
> -                                       &props);
> +       props.brightness = LM3533_BL_MAX_BRIGHTNESS;
> +       device_property_read_u32(&pdev->dev, "default-brightness",
> +                                &props.brightness);
> +
> +       bd = devm_backlight_device_register(&pdev->dev, name, &pdev->dev,
> +                                           bl, &lm3533_bl_ops, &props);
>         if (IS_ERR(bd)) {
>                 dev_err(&pdev->dev, "failed to register backlight device\n");
>                 return PTR_ERR(bd);
> @@ -320,7 +325,15 @@ static int lm3533_bl_probe(struct platform_device *pdev)
>
>         backlight_update_status(bd);
>
> -       ret = lm3533_bl_setup(bl, pdata);
> +       device_property_read_u32(&pdev->dev, "led-max-microamp",
> +                                &bl->max_current);
> +       bl->max_current = clamp(bl->max_current, LM3533_LED_MAX_CURRENT_MIN,
> +                               LM3533_LED_MAX_CURRENT_MAX);
> +
> +       bl->pwm = 0;
> +       device_property_read_u32(&pdev->dev, "ti,pwm-config-mask", &bl->pwm);
> +
> +       ret = lm3533_bl_setup(bl);
>         if (ret)
>                 goto err_sysfs_remove;
>
> @@ -381,10 +394,17 @@ static void lm3533_bl_shutdown(struct platform_device *pdev)
>         lm3533_ctrlbank_disable(&bl->cb);
>  }
>
> +static const struct of_device_id lm3533_bl_match_table[] = {
> +       { .compatible = "ti,lm3533-backlight" },
> +       { }
> +};
> +MODULE_DEVICE_TABLE(of, lm3533_bl_match_table);
> +
>  static struct platform_driver lm3533_bl_driver = {
>         .driver = {
>                 .name   = "lm3533-backlight",
>                 .pm     = &lm3533_bl_pm_ops,
> +               .of_match_table = lm3533_bl_match_table,
>         },
>         .probe          = lm3533_bl_probe,
>         .remove         = lm3533_bl_remove,
> diff --git a/include/linux/mfd/lm3533.h b/include/linux/mfd/lm3533.h
> index 69059a7a2ce5..3aa962d4c747 100644
> --- a/include/linux/mfd/lm3533.h
> +++ b/include/linux/mfd/lm3533.h
> @@ -15,6 +15,9 @@
>  #define LM3533_ATTR_RW(_name) \
>         DEVICE_ATTR(_name, S_IRUGO | S_IWUSR , show_##_name, store_##_name)
>
> +#define LM3533_LED_MAX_CURRENT_MIN     5000
> +#define LM3533_LED_MAX_CURRENT_MAX     29800
> +
>  struct device;
>  struct gpio_desc;
>  struct regmap;
> @@ -25,7 +28,9 @@ struct lm3533 {
>         struct regmap *regmap;
>
>         struct gpio_desc *hwen;
> -       int irq;
> +
> +       u32 boost_ovp;
> +       u32 boost_freq;
>
>         unsigned have_als:1;
>         unsigned have_backlights:1;
> @@ -38,50 +43,6 @@ struct lm3533_ctrlbank {
>         int id;
>  };
>
> -struct lm3533_als_platform_data {
> -       unsigned pwm_mode:1;            /* PWM input mode (default analog) */
> -       u8 r_select;                    /* 1 - 127 (ignored in PWM-mode) */
> -};
> -
> -struct lm3533_bl_platform_data {
> -       char *name;
> -       u16 max_current;                /* 5000 - 29800 uA (800 uA step) */
> -       u8 default_brightness;          /* 0 - 255 */
> -       u8 pwm;                         /* 0 - 0x3f */
> -};
> -
> -struct lm3533_led_platform_data {
> -       char *name;
> -       const char *default_trigger;
> -       u16 max_current;                /* 5000 - 29800 uA (800 uA step) */
> -       u8 pwm;                         /* 0 - 0x3f */
> -};
> -
> -enum lm3533_boost_freq {
> -       LM3533_BOOST_FREQ_500KHZ,
> -       LM3533_BOOST_FREQ_1000KHZ,
> -};
> -
> -enum lm3533_boost_ovp {
> -       LM3533_BOOST_OVP_16V,
> -       LM3533_BOOST_OVP_24V,
> -       LM3533_BOOST_OVP_32V,
> -       LM3533_BOOST_OVP_40V,
> -};
> -
> -struct lm3533_platform_data {
> -       enum lm3533_boost_ovp boost_ovp;
> -       enum lm3533_boost_freq boost_freq;
> -
> -       struct lm3533_als_platform_data *als;
> -
> -       struct lm3533_bl_platform_data *backlights;
> -       int num_backlights;
> -
> -       struct lm3533_led_platform_data *leds;
> -       int num_leds;
> -};
> -
>  extern int lm3533_ctrlbank_enable(struct lm3533_ctrlbank *cb);
>  extern int lm3533_ctrlbank_disable(struct lm3533_ctrlbank *cb);
>
> --
> 2.51.0
>

^ permalink raw reply

* Re: [PATCH v1 0/6] mfd: lm3533: convert to OF bindings, improve support
From: Svyatoslav Ryhel @ 2026-05-17 10:44 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Helge Deller,
	dri-devel, linux-leds, devicetree, linux-kernel, linux-iio,
	linux-fbdev, johan
In-Reply-To: <agmbFQHezUl5Nydn@ashevche-desk.local>

нд, 17 трав. 2026 р. о 13:40 Andy Shevchenko <andriy.shevchenko@intel.com> пише:
>
> On Sun, May 17, 2026 at 01:34:32PM +0300, Svyatoslav Ryhel wrote:
> > нд, 17 трав. 2026 р. о 13:20 Andy Shevchenko <andriy.shevchenko@intel.com> пише:
> > > On Sun, May 17, 2026 at 01:13:22PM +0300, Svyatoslav Ryhel wrote:
> > > > нд, 17 трав. 2026 р. о 10:59 Andy Shevchenko <andriy.shevchenko@intel.com> пише:
> > > > > On Sun, May 17, 2026 at 10:43:00AM +0300, Svyatoslav Ryhel wrote:
> > > > > > Convert LM3533 to OF bindings, add missing VIN supply, add support for
> > > > > > setting mapping mode and LED sources based on device tree.
> > > > >
> > > > > How is this being different to
> > > > > https://lore.kernel.org/lkml/20250218132702.114669-1-clamor95@gmail.com/
> > > > > ?
> > > >
> > > > I have decided to have a fresh look, this is continuation.
> > >
> > > Then it should be something like v4?
> >
> > That was more than a year ago, lets start fresh. Those patches are
> > gone, though I did add many of suggestions from there.
> >
> > > > > What about this comment
> > > > > https://lore.kernel.org/lkml/ZmBcvtLCzllQDWVX@hovoldconsulting.com/
> > > > > ? Have you talked to Bjorn A and Johan?
> > > >
> > > > No, but since grep -r "lm3533_platform_data" * gives 0 results there
> > > > are no platform_data users of lm3533.
> > >
> > > Johan was against driver removal (while it sounds logical due to above) and
> > > referred to some other patches from somebody else. I think you need to
> > > synchronise with the people to have a clear roadmap that all stakeholders
> > > are agree with. With that, the split and other technical issues can be solved
> > > during the normal process.
> >
> > And this discussion was 2 years ago, and
> >
> > "This device is used in a bunch of Sony phones and Bjorn A posted a
> > series adding devicetree bindings a few years ago"
> >
> > They have had more than enough time, don't you think? You would
> > definitely know if there were any activity since you are IIO reviewer
> > and would be included, were there any activity?
>
> At least it's polite to Cc them your version.
>

I assume yes, I have added Johan but there is no email for Bjorn A.

> --
> With Best Regards,
> Andy Shevchenko
>
>

^ permalink raw reply

* Re: [PATCH v1 0/6] mfd: lm3533: convert to OF bindings, improve support
From: Andy Shevchenko @ 2026-05-17 10:40 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Helge Deller,
	dri-devel, linux-leds, devicetree, linux-kernel, linux-iio,
	linux-fbdev
In-Reply-To: <CAPVz0n3Kn5VVxWxCgq2EcRiOaLWnB85hD+-S2Eou=H1PyycJCQ@mail.gmail.com>

On Sun, May 17, 2026 at 01:34:32PM +0300, Svyatoslav Ryhel wrote:
> нд, 17 трав. 2026 р. о 13:20 Andy Shevchenko <andriy.shevchenko@intel.com> пише:
> > On Sun, May 17, 2026 at 01:13:22PM +0300, Svyatoslav Ryhel wrote:
> > > нд, 17 трав. 2026 р. о 10:59 Andy Shevchenko <andriy.shevchenko@intel.com> пише:
> > > > On Sun, May 17, 2026 at 10:43:00AM +0300, Svyatoslav Ryhel wrote:
> > > > > Convert LM3533 to OF bindings, add missing VIN supply, add support for
> > > > > setting mapping mode and LED sources based on device tree.
> > > >
> > > > How is this being different to
> > > > https://lore.kernel.org/lkml/20250218132702.114669-1-clamor95@gmail.com/
> > > > ?
> > >
> > > I have decided to have a fresh look, this is continuation.
> >
> > Then it should be something like v4?
> 
> That was more than a year ago, lets start fresh. Those patches are
> gone, though I did add many of suggestions from there.
> 
> > > > What about this comment
> > > > https://lore.kernel.org/lkml/ZmBcvtLCzllQDWVX@hovoldconsulting.com/
> > > > ? Have you talked to Bjorn A and Johan?
> > >
> > > No, but since grep -r "lm3533_platform_data" * gives 0 results there
> > > are no platform_data users of lm3533.
> >
> > Johan was against driver removal (while it sounds logical due to above) and
> > referred to some other patches from somebody else. I think you need to
> > synchronise with the people to have a clear roadmap that all stakeholders
> > are agree with. With that, the split and other technical issues can be solved
> > during the normal process.
> 
> And this discussion was 2 years ago, and
> 
> "This device is used in a bunch of Sony phones and Bjorn A posted a
> series adding devicetree bindings a few years ago"
> 
> They have had more than enough time, don't you think? You would
> definitely know if there were any activity since you are IIO reviewer
> and would be included, were there any activity?

At least it's polite to Cc them your version.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply

* Re: [PATCH v1 0/6] mfd: lm3533: convert to OF bindings, improve support
From: Svyatoslav Ryhel @ 2026-05-17 10:34 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Helge Deller,
	dri-devel, linux-leds, devicetree, linux-kernel, linux-iio,
	linux-fbdev
In-Reply-To: <agmWVdi3TkBb2cxV@ashevche-desk.local>

нд, 17 трав. 2026 р. о 13:20 Andy Shevchenko <andriy.shevchenko@intel.com> пише:
>
> On Sun, May 17, 2026 at 01:13:22PM +0300, Svyatoslav Ryhel wrote:
> > нд, 17 трав. 2026 р. о 10:59 Andy Shevchenko <andriy.shevchenko@intel.com> пише:
> > > On Sun, May 17, 2026 at 10:43:00AM +0300, Svyatoslav Ryhel wrote:
> > > > Convert LM3533 to OF bindings, add missing VIN supply, add support for
> > > > setting mapping mode and LED sources based on device tree.
> > >
> > > How is this being different to
> > > https://lore.kernel.org/lkml/20250218132702.114669-1-clamor95@gmail.com/
> > > ?
> >
> > I have decided to have a fresh look, this is continuation.
>
> Then it should be something like v4?
>

That was more than a year ago, lets start fresh. Those patches are
gone, though I did add many of suggestions from there.

> > > What about this comment
> > > https://lore.kernel.org/lkml/ZmBcvtLCzllQDWVX@hovoldconsulting.com/
> > > ? Have you talked to Bjorn A and Johan?
> >
> > No, but since grep -r "lm3533_platform_data" * gives 0 results there
> > are no platform_data users of lm3533.
>
> Johan was against driver removal (while it sounds logical due to above) and
> referred to some other patches from somebody else. I think you need to
> synchronise with the people to have a clear roadmap that all stakeholders
> are agree with. With that, the split and other technical issues can be solved
> during the normal process.
>

And this discussion was 2 years ago, and

"This device is used in a bunch of Sony phones and Bjorn A posted a
series adding devicetree bindings a few years ago"

They have had more than enough time, don't you think? You would
definitely know if there were any activity since you are IIO reviewer
and would be included, were there any activity?

> --
> With Best Regards,
> Andy Shevchenko
>
>

^ permalink raw reply

* Re: [PATCH v1 0/6] mfd: lm3533: convert to OF bindings, improve support
From: Andy Shevchenko @ 2026-05-17 10:20 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Helge Deller,
	dri-devel, linux-leds, devicetree, linux-kernel, linux-iio,
	linux-fbdev
In-Reply-To: <CAPVz0n0tfbwa1AbgO4eKrmNunHvmTFLDqXDFd1=VfLayuafH8w@mail.gmail.com>

On Sun, May 17, 2026 at 01:13:22PM +0300, Svyatoslav Ryhel wrote:
> нд, 17 трав. 2026 р. о 10:59 Andy Shevchenko <andriy.shevchenko@intel.com> пише:
> > On Sun, May 17, 2026 at 10:43:00AM +0300, Svyatoslav Ryhel wrote:
> > > Convert LM3533 to OF bindings, add missing VIN supply, add support for
> > > setting mapping mode and LED sources based on device tree.
> >
> > How is this being different to
> > https://lore.kernel.org/lkml/20250218132702.114669-1-clamor95@gmail.com/
> > ?
> 
> I have decided to have a fresh look, this is continuation.

Then it should be something like v4?

> > What about this comment
> > https://lore.kernel.org/lkml/ZmBcvtLCzllQDWVX@hovoldconsulting.com/
> > ? Have you talked to Bjorn A and Johan?
> 
> No, but since grep -r "lm3533_platform_data" * gives 0 results there
> are no platform_data users of lm3533.

Johan was against driver removal (while it sounds logical due to above) and
referred to some other patches from somebody else. I think you need to
synchronise with the people to have a clear roadmap that all stakeholders
are agree with. With that, the split and other technical issues can be solved
during the normal process.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply

* Re: [PATCH v1 0/6] mfd: lm3533: convert to OF bindings, improve support
From: Svyatoslav Ryhel @ 2026-05-17 10:13 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Helge Deller,
	dri-devel, linux-leds, devicetree, linux-kernel, linux-iio,
	linux-fbdev
In-Reply-To: <agl1T8O6kwP7SFZ1@ashevche-desk.local>

нд, 17 трав. 2026 р. о 10:59 Andy Shevchenko <andriy.shevchenko@intel.com> пише:
>
> On Sun, May 17, 2026 at 10:43:00AM +0300, Svyatoslav Ryhel wrote:
> > Convert LM3533 to OF bindings, add missing VIN supply, add support for
> > setting mapping mode and LED sources based on device tree.
>
> How is this being different to
> https://lore.kernel.org/lkml/20250218132702.114669-1-clamor95@gmail.com/
> ?
>

I have decided to have a fresh look, this is continuation.

> What about this comment
> https://lore.kernel.org/lkml/ZmBcvtLCzllQDWVX@hovoldconsulting.com/
> ? Have you talked to Bjorn A and Johan?
>

No, but since grep -r "lm3533_platform_data" * gives 0 results there
are no platform_data users of lm3533.

> --
> With Best Regards,
> Andy Shevchenko
>
>

^ permalink raw reply

* Re: [PATCH v1 2/6] mfd: lm3533: Convert to use OF bindings
From: Svyatoslav Ryhel @ 2026-05-17 10:11 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Helge Deller,
	dri-devel, linux-leds, devicetree, linux-kernel, linux-iio,
	linux-fbdev
In-Reply-To: <agl0Z_EGzX8X4No4@ashevche-desk.local>

нд, 17 трав. 2026 р. о 10:55 Andy Shevchenko <andriy.shevchenko@intel.com> пише:
>
> On Sun, May 17, 2026 at 10:43:02AM +0300, Svyatoslav Ryhel wrote:
> > Since there are no users of this driver via platform data, remove the
> > platform data support and switch to using Device Tree bindings.
> > Additionally, optimize functions used only by platform data.
>
> This is a mixture of at least (!) three patches:

Maybe you can make a list of how to split it then. I have tried to
make it complete and remain readable. I am open to your suggestions.

> - devm conversion

This will be dropped.

> - the change of some constants

If you mean LM3533_ALS_RESISTOR_MIN and LM3533_ALS_RESISTOR_MAX they
are used explicitly in r_select value. Previously it was passed via
pdata as register value and now it is obtained from the device tree as
resistance in Ohms and register value is actually calculated.
Naturally ALS_RESISTOR boundaries changed.

> - the rest
>
> --
> With Best Regards,
> Andy Shevchenko
>
>

^ permalink raw reply

* Re: [PATCH v1 0/6] mfd: lm3533: convert to OF bindings, improve support
From: Andy Shevchenko @ 2026-05-17  7:59 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Helge Deller,
	dri-devel, linux-leds, devicetree, linux-kernel, linux-iio,
	linux-fbdev
In-Reply-To: <20260517074306.30937-1-clamor95@gmail.com>

On Sun, May 17, 2026 at 10:43:00AM +0300, Svyatoslav Ryhel wrote:
> Convert LM3533 to OF bindings, add missing VIN supply, add support for
> setting mapping mode and LED sources based on device tree. 

How is this being different to
https://lore.kernel.org/lkml/20250218132702.114669-1-clamor95@gmail.com/
?

What about this comment
https://lore.kernel.org/lkml/ZmBcvtLCzllQDWVX@hovoldconsulting.com/
? Have you talked to Bjorn A and Johan?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply

* Re: [PATCH v1 2/6] mfd: lm3533: Convert to use OF bindings
From: Andy Shevchenko @ 2026-05-17  7:55 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Helge Deller,
	dri-devel, linux-leds, devicetree, linux-kernel, linux-iio,
	linux-fbdev
In-Reply-To: <20260517074306.30937-3-clamor95@gmail.com>

On Sun, May 17, 2026 at 10:43:02AM +0300, Svyatoslav Ryhel wrote:
> Since there are no users of this driver via platform data, remove the
> platform data support and switch to using Device Tree bindings.
> Additionally, optimize functions used only by platform data.

This is a mixture of at least (!) three patches:
- devm conversion
- the change of some constants
- the rest

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply

* [PATCH v1 6/6] video: leds: backlight: lm3533: Support getting LED sources from DT
From: Svyatoslav Ryhel @ 2026-05-17  7:43 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Helge Deller,
	Svyatoslav Ryhel
  Cc: dri-devel, linux-leds, devicetree, linux-kernel, linux-iio,
	linux-fbdev
In-Reply-To: <20260517074306.30937-1-clamor95@gmail.com>

Add Control Bank to HVLED/LVLED muxing support based on the led-sources
defined in the device tree.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/leds/leds-lm3533.c          | 55 +++++++++++++++++++++++++++--
 drivers/video/backlight/lm3533_bl.c | 39 +++++++++++++++++++-
 2 files changed, 91 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/leds-lm3533.c b/drivers/leds/leds-lm3533.c
index f6345bc1f443..c4eaf30880a1 100644
--- a/drivers/leds/leds-lm3533.c
+++ b/drivers/leds/leds-lm3533.c
@@ -7,6 +7,7 @@
  * Author: Johan Hovold <jhovold@gmail.com>
  */
 
+#include <linux/bits.h>
 #include <linux/module.h>
 #include <linux/leds.h>
 #include <linux/mfd/core.h>
@@ -26,6 +27,12 @@
 #define LM3533_ALS_CHANNEL_LV_MIN	1
 #define LM3533_ALS_CHANNEL_LV_MAX	2
 
+#define LM3533_REG_OUTPUT_CONF1			0x10
+#define   OUTPUT_CONF1_MASK			GENMASK(7, 2)
+#define   OUTPUT_CONF1_SHIFT			2
+#define LM3533_REG_OUTPUT_CONF2			0x11
+#define   OUTPUT_CONF2_MASK			GENMASK(3, 0)
+#define   OUTPUT_CONF2_SHIFT			6
 #define LM3533_REG_CTRLBANK_BCONF_BASE		0x1b
 #define LM3533_REG_PATTERN_ENABLE		0x28
 #define LM3533_REG_PATTERN_LOW_TIME_BASE	0x71
@@ -40,7 +47,7 @@
 #define LM3533_REG_CTRLBANK_BCONF_ALS_CHANNEL_MASK	0x01
 
 #define LM3533_LED_FLAG_PATTERN_ENABLE		1
-
+#define LM3533_MAX_LEDS				5
 
 struct lm3533_led {
 	struct lm3533 *lm3533;
@@ -53,6 +60,9 @@ struct lm3533_led {
 
 	u32 max_current;
 	u32 pwm;
+
+	u32 num_leds;
+	u32 leds[LM3533_MAX_LEDS];
 };
 
 
@@ -639,7 +649,30 @@ static const struct attribute_group *lm3533_led_attribute_groups[] = {
 
 static int lm3533_led_setup(struct lm3533_led *led)
 {
-	int ret;
+	u32 output_cfg_shift = 0;
+	u32 output_cfg_val = 0;
+	int ret, i;
+
+	if (led->num_leds) {
+		for (i = 0; i < led->num_leds; i++) {
+			output_cfg_shift = led->leds[i] * 2;
+			output_cfg_val |= led->id << output_cfg_shift;
+		}
+
+		/* LVLED1, LVLED2 and LVLED3 */
+		ret = lm3533_update(led->lm3533, LM3533_REG_OUTPUT_CONF1,
+				    output_cfg_val << OUTPUT_CONF1_SHIFT,
+				    OUTPUT_CONF1_MASK);
+		if (ret)
+			return ret;
+
+		/* LVLED4 and LVLED5 */
+		ret = lm3533_update(led->lm3533, LM3533_REG_OUTPUT_CONF1,
+				    output_cfg_val >> OUTPUT_CONF2_SHIFT,
+				    OUTPUT_CONF2_MASK);
+		if (ret)
+			return ret;
+	}
 
 	ret = lm3533_ctrlbank_set_max_current(&led->cb, led->max_current);
 	if (ret)
@@ -713,6 +746,24 @@ static int lm3533_led_probe(struct platform_device *pdev)
 	led->pwm = 0;
 	device_property_read_u32(&pdev->dev, "ti,pwm-config-mask", &led->pwm);
 
+	led->num_leds = device_property_count_u32(&pdev->dev, "led-sources");
+
+	/*
+	 * If led-sources property is not set then either this Control Bank uses
+	 * its default LVLED or is not linked to any LVLED at all.
+	 */
+	if (led->num_leds <= 0 || led->num_leds > LM3533_MAX_LEDS)
+		led->num_leds = 0;
+
+	if (led->num_leds > 0 && led->num_leds < LM3533_MAX_LEDS) {
+		ret = device_property_read_u32_array(&pdev->dev, "led-sources",
+						     led->leds, led->num_leds);
+		if (ret) {
+			dev_err(&pdev->dev, "failed to get led-sources\n");
+			goto err_deregister;
+		}
+	}
+
 	ret = lm3533_led_setup(led);
 	if (ret)
 		goto err_deregister;
diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
index be9114b7e0ad..2898cb229643 100644
--- a/drivers/video/backlight/lm3533_bl.c
+++ b/drivers/video/backlight/lm3533_bl.c
@@ -7,6 +7,7 @@
  * Author: Johan Hovold <jhovold@gmail.com>
  */
 
+#include <linux/bits.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/mod_devicetable.h>
@@ -21,9 +22,12 @@
 #define LM3533_HVCTRLBANK_COUNT		2
 #define LM3533_BL_MAX_BRIGHTNESS	255
 
+#define LM3533_REG_OUTPUT_CONF1		0x10
+#define   OUTPUT_CONF1_MASK		GENMASK(1, 0)
 #define LM3533_REG_CTRLBANK_AB_BCONF	0x1a
 #define   CTRLBANK_AB_BCONF_MODE(n)	BIT(2 * (n) + 1)
 
+#define LM3533_MAX_LED_STRINGS		2
 
 struct lm3533_bl {
 	struct lm3533 *lm3533;
@@ -34,6 +38,9 @@ struct lm3533_bl {
 	u32 max_current;
 	u32 pwm;
 	bool linear;
+
+	u32 num_leds;
+	u32 led_strings[LM3533_MAX_LED_STRINGS];
 };
 
 
@@ -248,7 +255,8 @@ static struct attribute_group lm3533_bl_attribute_group = {
 static int lm3533_bl_setup(struct lm3533_bl *bl)
 {
 	int id = lm3533_bl_get_ctrlbank_id(bl);
-	int ret;
+	u32 output_cfg_val = 0;
+	int ret, i;
 
 	ret = lm3533_update(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF,
 			    bl->linear ? CTRLBANK_AB_BCONF_MODE(id) : 0,
@@ -256,6 +264,16 @@ static int lm3533_bl_setup(struct lm3533_bl *bl)
 	if (ret)
 		return ret;
 
+	if (bl->num_leds) {
+		for (i = 0; i < bl->num_leds; i++)
+			output_cfg_val |= id << bl->led_strings[i];
+
+		ret = lm3533_update(bl->lm3533, LM3533_REG_OUTPUT_CONF1,
+				    output_cfg_val, OUTPUT_CONF1_MASK);
+		if (ret)
+			return ret;
+	}
+
 	ret = lm3533_ctrlbank_set_max_current(&bl->cb, bl->max_current);
 	if (ret)
 		return ret;
@@ -337,6 +355,25 @@ static int lm3533_bl_probe(struct platform_device *pdev)
 	bl->linear = device_property_read_bool(&pdev->dev,
 					       "ti,linear-mapping-mode");
 
+	bl->num_leds = device_property_count_u32(&pdev->dev, "led-sources");
+
+	/*
+	 * If led-sources property is not set then either this Control Bank uses
+	 * its default HVLED or is not linked to any HVLED at all.
+	 */
+	if (bl->num_leds <= 0 || bl->num_leds > LM3533_MAX_LED_STRINGS)
+		bl->num_leds = 0;
+
+	if (bl->num_leds > 0 && bl->num_leds < LM3533_MAX_LED_STRINGS) {
+		ret = device_property_read_u32_array(&pdev->dev, "led-sources",
+						     bl->led_strings,
+						     bl->num_leds);
+		if (ret) {
+			dev_err(&pdev->dev, "failed to get led-sources\n");
+			goto err_sysfs_remove;
+		}
+	}
+
 	ret = lm3533_bl_setup(bl);
 	if (ret)
 		goto err_sysfs_remove;
-- 
2.51.0


^ permalink raw reply related

* [PATCH v1 5/6] video: backlight: lm3533_bl: Set initial mapping mode from DT
From: Svyatoslav Ryhel @ 2026-05-17  7:43 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Helge Deller,
	Svyatoslav Ryhel
  Cc: dri-devel, linux-leds, devicetree, linux-kernel, linux-iio,
	linux-fbdev
In-Reply-To: <20260517074306.30937-1-clamor95@gmail.com>

Add support to obtain the initial mapping mode from DT instead of leaving
it unconfigured. Additionally, update the linear sysfs code, which uses a
similar coding pattern.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/video/backlight/lm3533_bl.c | 32 ++++++++++++++++-------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
index 42da652df58d..be9114b7e0ad 100644
--- a/drivers/video/backlight/lm3533_bl.c
+++ b/drivers/video/backlight/lm3533_bl.c
@@ -22,6 +22,7 @@
 #define LM3533_BL_MAX_BRIGHTNESS	255
 
 #define LM3533_REG_CTRLBANK_AB_BCONF	0x1a
+#define   CTRLBANK_AB_BCONF_MODE(n)	BIT(2 * (n) + 1)
 
 
 struct lm3533_bl {
@@ -32,6 +33,7 @@ struct lm3533_bl {
 
 	u32 max_current;
 	u32 pwm;
+	bool linear;
 };
 
 
@@ -135,8 +137,9 @@ static ssize_t show_linear(struct device *dev,
 				struct device_attribute *attr, char *buf)
 {
 	struct lm3533_bl *bl = dev_get_drvdata(dev);
+	int id = lm3533_bl_get_ctrlbank_id(bl);
+	u8 mask = CTRLBANK_AB_BCONF_MODE(id);
 	u8 val;
-	u8 mask;
 	int linear;
 	int ret;
 
@@ -144,8 +147,6 @@ static ssize_t show_linear(struct device *dev,
 	if (ret)
 		return ret;
 
-	mask = 1 << (2 * lm3533_bl_get_ctrlbank_id(bl) + 1);
-
 	if (val & mask)
 		linear = 1;
 	else
@@ -159,23 +160,16 @@ static ssize_t store_linear(struct device *dev,
 					const char *buf, size_t len)
 {
 	struct lm3533_bl *bl = dev_get_drvdata(dev);
+	int id = lm3533_bl_get_ctrlbank_id(bl);
 	unsigned long linear;
-	u8 mask;
-	u8 val;
 	int ret;
 
 	if (kstrtoul(buf, 0, &linear))
 		return -EINVAL;
 
-	mask = 1 << (2 * lm3533_bl_get_ctrlbank_id(bl) + 1);
-
-	if (linear)
-		val = mask;
-	else
-		val = 0;
-
-	ret = lm3533_update(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF, val,
-									mask);
+	ret = lm3533_update(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF,
+			    linear ? CTRLBANK_AB_BCONF_MODE(id) : 0,
+			    CTRLBANK_AB_BCONF_MODE(id));
 	if (ret)
 		return ret;
 
@@ -253,8 +247,15 @@ static struct attribute_group lm3533_bl_attribute_group = {
 
 static int lm3533_bl_setup(struct lm3533_bl *bl)
 {
+	int id = lm3533_bl_get_ctrlbank_id(bl);
 	int ret;
 
+	ret = lm3533_update(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF,
+			    bl->linear ? CTRLBANK_AB_BCONF_MODE(id) : 0,
+			    CTRLBANK_AB_BCONF_MODE(id));
+	if (ret)
+		return ret;
+
 	ret = lm3533_ctrlbank_set_max_current(&bl->cb, bl->max_current);
 	if (ret)
 		return ret;
@@ -333,6 +334,9 @@ static int lm3533_bl_probe(struct platform_device *pdev)
 	bl->pwm = 0;
 	device_property_read_u32(&pdev->dev, "ti,pwm-config-mask", &bl->pwm);
 
+	bl->linear = device_property_read_bool(&pdev->dev,
+					       "ti,linear-mapping-mode");
+
 	ret = lm3533_bl_setup(bl);
 	if (ret)
 		goto err_sysfs_remove;
-- 
2.51.0


^ permalink raw reply related

* [PATCH v1 4/6] mfd: lm3533: set DMA mask
From: Svyatoslav Ryhel @ 2026-05-17  7:43 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Helge Deller,
	Svyatoslav Ryhel
  Cc: dri-devel, linux-leds, devicetree, linux-kernel, linux-iio,
	linux-fbdev
In-Reply-To: <20260517074306.30937-1-clamor95@gmail.com>

Missing coherent_dma_mask assigning triggers the following warning in
dmesg:

[    3.287872] platform lm3533-backlight.0: DMA mask not set

Since this warning might be elevated to an error in the future, set
coherent_dma_mask to zero because both the core and cells do not utilize
DMA.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/mfd/lm3533-core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mfd/lm3533-core.c b/drivers/mfd/lm3533-core.c
index 131eb1a1c8eb..c7914afd564c 100644
--- a/drivers/mfd/lm3533-core.c
+++ b/drivers/mfd/lm3533-core.c
@@ -499,6 +499,10 @@ static int lm3533_i2c_probe(struct i2c_client *i2c)
 			lm3533->have_leds = true;
 	}
 
+	/* Parent I2C controller uses DMA, LM3533 and child devices do not */
+	i2c->dev.coherent_dma_mask = 0;
+	i2c->dev.dma_mask = &i2c->dev.coherent_dma_mask;
+
 	return lm3533_device_init(lm3533);
 }
 
-- 
2.51.0


^ permalink raw reply related

* [PATCH v1 3/6] mfd: lm3533: Add support for VIN power supply
From: Svyatoslav Ryhel @ 2026-05-17  7:43 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Helge Deller,
	Svyatoslav Ryhel
  Cc: dri-devel, linux-leds, devicetree, linux-kernel, linux-iio,
	linux-fbdev
In-Reply-To: <20260517074306.30937-1-clamor95@gmail.com>

Add support for 2.7V-5.5V VIN power supply.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/mfd/lm3533-core.c  | 22 ++++++++++++++++++++--
 include/linux/mfd/lm3533.h |  1 +
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/lm3533-core.c b/drivers/mfd/lm3533-core.c
index 83ebd780f39d..131eb1a1c8eb 100644
--- a/drivers/mfd/lm3533-core.c
+++ b/drivers/mfd/lm3533-core.c
@@ -173,14 +173,25 @@ static int lm3533_set_lvled_config(struct lm3533 *lm3533, u8 lvled, u8 led)
 	return ret;
 }
 
-static void lm3533_enable(struct lm3533 *lm3533)
+static int lm3533_enable(struct lm3533 *lm3533)
 {
+	int ret;
+
+	ret = regulator_enable(lm3533->vin_supply);
+	if (ret) {
+		dev_err(lm3533->dev, "failed to enable vin power supply\n");
+		return ret;
+	}
+
 	gpiod_set_value(lm3533->hwen, 1);
+
+	return 0;
 }
 
 static void lm3533_disable(struct lm3533 *lm3533)
 {
 	gpiod_set_value(lm3533->hwen, 0);
+	regulator_disable(lm3533->vin_supply);
 }
 
 enum lm3533_attribute_type {
@@ -331,7 +342,9 @@ static int lm3533_device_init(struct lm3533 *lm3533)
 	struct device *dev = lm3533->dev;
 	int ret;
 
-	lm3533_enable(lm3533);
+	ret = lm3533_enable(lm3533);
+	if (ret)
+		return ret;
 
 	ret = lm3533_update(lm3533, LM3533_REG_BOOST_PWM,
 			    lm3533->boost_freq << LM3533_BOOST_FREQ_SHIFT,
@@ -453,6 +466,11 @@ static int lm3533_i2c_probe(struct i2c_client *i2c)
 		return dev_err_probe(lm3533->dev, PTR_ERR(lm3533->hwen),
 				     "failed to get HWEN GPIO\n");
 
+	lm3533->vin_supply = devm_regulator_get(lm3533->dev, "vin");
+	if (IS_ERR(lm3533->vin_supply))
+		return dev_err_probe(lm3533->dev, PTR_ERR(lm3533->vin_supply),
+				     "failed to get vin-supply\n");
+
 	device_property_read_u32(lm3533->dev, "ti,boost-ovp-microvolt",
 				 &lm3533->boost_ovp);
 
diff --git a/include/linux/mfd/lm3533.h b/include/linux/mfd/lm3533.h
index 3aa962d4c747..e355a3ac982e 100644
--- a/include/linux/mfd/lm3533.h
+++ b/include/linux/mfd/lm3533.h
@@ -28,6 +28,7 @@ struct lm3533 {
 	struct regmap *regmap;
 
 	struct gpio_desc *hwen;
+	struct regulator *vin_supply;
 
 	u32 boost_ovp;
 	u32 boost_freq;
-- 
2.51.0


^ permalink raw reply related

* [PATCH v1 2/6] mfd: lm3533: Convert to use OF bindings
From: Svyatoslav Ryhel @ 2026-05-17  7:43 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Helge Deller,
	Svyatoslav Ryhel
  Cc: dri-devel, linux-leds, devicetree, linux-kernel, linux-iio,
	linux-fbdev
In-Reply-To: <20260517074306.30937-1-clamor95@gmail.com>

Since there are no users of this driver via platform data, remove the
platform data support and switch to using Device Tree bindings.
Additionally, optimize functions used only by platform data.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/iio/light/lm3533-als.c      | 123 +++++--------
 drivers/leds/leds-lm3533.c          |  60 ++++---
 drivers/mfd/lm3533-core.c           | 257 +++++++++-------------------
 drivers/video/backlight/lm3533_bl.c |  52 ++++--
 include/linux/mfd/lm3533.h          |  51 +-----
 5 files changed, 202 insertions(+), 341 deletions(-)

diff --git a/drivers/iio/light/lm3533-als.c b/drivers/iio/light/lm3533-als.c
index 99f0b903018c..853abb96e13f 100644
--- a/drivers/iio/light/lm3533-als.c
+++ b/drivers/iio/light/lm3533-als.c
@@ -16,15 +16,18 @@
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/mfd/core.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
+#include <linux/units.h>
 
 #include <linux/mfd/lm3533.h>
 
 
-#define LM3533_ALS_RESISTOR_MIN			1
-#define LM3533_ALS_RESISTOR_MAX			127
+#define LM3533_ALS_RESISTOR_MIN			1575
+#define LM3533_ALS_RESISTOR_MAX			200000
 #define LM3533_ALS_CHANNEL_CURRENT_MAX		2
 #define LM3533_ALS_THRESH_MAX			3
 #define LM3533_ALS_ZONE_MAX			4
@@ -56,6 +59,9 @@ struct lm3533_als {
 
 	atomic_t zone;
 	struct mutex thresh_mutex;
+
+	bool pwm_mode;
+	u32 r_select;
 };
 
 
@@ -714,64 +720,6 @@ static const struct attribute_group lm3533_als_attribute_group = {
 	.attrs = lm3533_als_attributes
 };
 
-static int lm3533_als_set_input_mode(struct lm3533_als *als, bool pwm_mode)
-{
-	u8 mask = LM3533_ALS_INPUT_MODE_MASK;
-	u8 val;
-	int ret;
-
-	if (pwm_mode)
-		val = mask;	/* pwm input */
-	else
-		val = 0;	/* analog input */
-
-	ret = lm3533_update(als->lm3533, LM3533_REG_ALS_CONF, val, mask);
-	if (ret) {
-		dev_err(&als->pdev->dev, "failed to set input mode %d\n",
-								pwm_mode);
-		return ret;
-	}
-
-	return 0;
-}
-
-static int lm3533_als_set_resistor(struct lm3533_als *als, u8 val)
-{
-	int ret;
-
-	if (val < LM3533_ALS_RESISTOR_MIN || val > LM3533_ALS_RESISTOR_MAX) {
-		dev_err(&als->pdev->dev, "invalid resistor value\n");
-		return -EINVAL;
-	}
-
-	ret = lm3533_write(als->lm3533, LM3533_REG_ALS_RESISTOR_SELECT, val);
-	if (ret) {
-		dev_err(&als->pdev->dev, "failed to set resistor\n");
-		return ret;
-	}
-
-	return 0;
-}
-
-static int lm3533_als_setup(struct lm3533_als *als,
-			    const struct lm3533_als_platform_data *pdata)
-{
-	int ret;
-
-	ret = lm3533_als_set_input_mode(als, pdata->pwm_mode);
-	if (ret)
-		return ret;
-
-	/* ALS input is always high impedance in PWM-mode. */
-	if (!pdata->pwm_mode) {
-		ret = lm3533_als_set_resistor(als, pdata->r_select);
-		if (ret)
-			return ret;
-	}
-
-	return 0;
-}
-
 static int lm3533_als_setup_irq(struct lm3533_als *als, void *dev)
 {
 	u8 mask = LM3533_ALS_INT_ENABLE_MASK;
@@ -784,7 +732,8 @@ static int lm3533_als_setup_irq(struct lm3533_als *als, void *dev)
 		return ret;
 	}
 
-	ret = request_threaded_irq(als->irq, NULL, lm3533_als_isr,
+	ret = devm_request_threaded_irq(&als->pdev->dev, als->irq, NULL,
+					lm3533_als_isr,
 					IRQF_TRIGGER_LOW | IRQF_ONESHOT,
 					dev_name(&als->pdev->dev), dev);
 	if (ret) {
@@ -828,7 +777,6 @@ static const struct iio_info lm3533_als_info = {
 
 static int lm3533_als_probe(struct platform_device *pdev)
 {
-	const struct lm3533_als_platform_data *pdata;
 	struct lm3533 *lm3533;
 	struct lm3533_als *als;
 	struct iio_dev *indio_dev;
@@ -838,12 +786,6 @@ static int lm3533_als_probe(struct platform_device *pdev)
 	if (!lm3533)
 		return -EINVAL;
 
-	pdata = dev_get_platdata(&pdev->dev);
-	if (!pdata) {
-		dev_err(&pdev->dev, "no platform data\n");
-		return -EINVAL;
-	}
-
 	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*als));
 	if (!indio_dev)
 		return -ENOMEM;
@@ -852,31 +794,52 @@ static int lm3533_als_probe(struct platform_device *pdev)
 	indio_dev->channels = lm3533_als_channels;
 	indio_dev->num_channels = ARRAY_SIZE(lm3533_als_channels);
 	indio_dev->name = dev_name(&pdev->dev);
-	iio_device_set_parent(indio_dev, pdev->dev.parent);
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
 	als = iio_priv(indio_dev);
 	als->lm3533 = lm3533;
 	als->pdev = pdev;
-	als->irq = lm3533->irq;
+	als->irq = platform_get_irq_optional(pdev, 0);
 	atomic_set(&als->zone, 0);
 	mutex_init(&als->thresh_mutex);
 
 	platform_set_drvdata(pdev, indio_dev);
 
-	if (als->irq) {
+	if (als->irq > 0) {
 		ret = lm3533_als_setup_irq(als, indio_dev);
 		if (ret)
 			return ret;
 	}
 
-	ret = lm3533_als_setup(als, pdata);
+	device_property_read_u32(&pdev->dev, "ti,resistor-value-ohm",
+				 &als->r_select);
+
+	als->r_select = clamp(als->r_select, LM3533_ALS_RESISTOR_MIN,
+			      LM3533_ALS_RESISTOR_MAX);
+	als->r_select = DIV_ROUND_UP(2 * MICRO, 10 * als->r_select);
+
+	als->pwm_mode = device_property_read_bool(&pdev->dev, "ti,pwm-mode");
+
+	ret = lm3533_update(lm3533, LM3533_REG_ALS_CONF, als->pwm_mode ?
+			    LM3533_ALS_INPUT_MODE_MASK : 0,
+			    LM3533_ALS_INPUT_MODE_MASK);
 	if (ret)
-		goto err_free_irq;
+		return dev_err_probe(&pdev->dev, ret,
+				     "failed to set input mode %d\n",
+				     als->pwm_mode);
+
+	/* ALS input is always high impedance in PWM-mode. */
+	if (!als->pwm_mode) {
+		ret = lm3533_write(lm3533, LM3533_REG_ALS_RESISTOR_SELECT,
+				   (u8)als->r_select);
+		if (ret)
+			return dev_err_probe(&pdev->dev, ret,
+					     "failed to set resistor\n");
+	}
 
 	ret = lm3533_als_enable(als);
 	if (ret)
-		goto err_free_irq;
+		return ret;
 
 	ret = iio_device_register(indio_dev);
 	if (ret) {
@@ -888,9 +851,6 @@ static int lm3533_als_probe(struct platform_device *pdev)
 
 err_disable:
 	lm3533_als_disable(als);
-err_free_irq:
-	if (als->irq)
-		free_irq(als->irq, indio_dev);
 
 	return ret;
 }
@@ -903,13 +863,18 @@ static void lm3533_als_remove(struct platform_device *pdev)
 	lm3533_als_set_int_mode(indio_dev, false);
 	iio_device_unregister(indio_dev);
 	lm3533_als_disable(als);
-	if (als->irq)
-		free_irq(als->irq, indio_dev);
 }
 
+static const struct of_device_id lm3533_als_match_table[] = {
+	{ .compatible = "ti,lm3533-als" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, lm3533_als_match_table);
+
 static struct platform_driver lm3533_als_driver = {
 	.driver	= {
 		.name	= "lm3533-als",
+		.of_match_table = lm3533_als_match_table,
 	},
 	.probe		= lm3533_als_probe,
 	.remove		= lm3533_als_remove,
diff --git a/drivers/leds/leds-lm3533.c b/drivers/leds/leds-lm3533.c
index 45795f2a1042..f6345bc1f443 100644
--- a/drivers/leds/leds-lm3533.c
+++ b/drivers/leds/leds-lm3533.c
@@ -10,8 +10,10 @@
 #include <linux/module.h>
 #include <linux/leds.h>
 #include <linux/mfd/core.h>
+#include <linux/mod_devicetable.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 
 #include <linux/mfd/lm3533.h>
@@ -48,6 +50,9 @@ struct lm3533_led {
 
 	struct mutex mutex;
 	unsigned long flags;
+
+	u32 max_current;
+	u32 pwm;
 };
 
 
@@ -632,22 +637,20 @@ static const struct attribute_group *lm3533_led_attribute_groups[] = {
 	NULL
 };
 
-static int lm3533_led_setup(struct lm3533_led *led,
-					struct lm3533_led_platform_data *pdata)
+static int lm3533_led_setup(struct lm3533_led *led)
 {
 	int ret;
 
-	ret = lm3533_ctrlbank_set_max_current(&led->cb, pdata->max_current);
+	ret = lm3533_ctrlbank_set_max_current(&led->cb, led->max_current);
 	if (ret)
 		return ret;
 
-	return lm3533_ctrlbank_set_pwm(&led->cb, pdata->pwm);
+	return lm3533_ctrlbank_set_pwm(&led->cb, led->pwm);
 }
 
 static int lm3533_led_probe(struct platform_device *pdev)
 {
 	struct lm3533 *lm3533;
-	struct lm3533_led_platform_data *pdata;
 	struct lm3533_led *led;
 	int ret;
 
@@ -657,30 +660,30 @@ static int lm3533_led_probe(struct platform_device *pdev)
 	if (!lm3533)
 		return -EINVAL;
 
-	pdata = dev_get_platdata(&pdev->dev);
-	if (!pdata) {
-		dev_err(&pdev->dev, "no platform data\n");
-		return -EINVAL;
-	}
-
-	if (pdev->id < 0 || pdev->id >= LM3533_LVCTRLBANK_COUNT) {
-		dev_err(&pdev->dev, "illegal LED id %d\n", pdev->id);
-		return -EINVAL;
-	}
+	if (pdev->id < LM3533_LVCTRLBANK_MIN || pdev->id > LM3533_LVCTRLBANK_MAX)
+		return dev_err_probe(&pdev->dev, -EINVAL,
+				     "illegal LED id %d\n", pdev->id);
 
 	led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
 	if (!led)
 		return -ENOMEM;
 
 	led->lm3533 = lm3533;
-	led->cdev.name = pdata->name;
-	led->cdev.default_trigger = pdata->default_trigger;
 	led->cdev.brightness_set_blocking = lm3533_led_set;
 	led->cdev.brightness_get = lm3533_led_get;
 	led->cdev.blink_set = lm3533_led_blink_set;
 	led->cdev.brightness = LED_OFF;
 	led->cdev.groups = lm3533_led_attribute_groups;
-	led->id = pdev->id;
+	led->id = pdev->id - LM3533_LVCTRLBANK_MIN;
+
+	led->cdev.name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s-%d",
+					pdev->name, led->id);
+	if (!led->cdev.name)
+		return -ENOMEM;
+
+	led->cdev.default_trigger = "none";
+	device_property_read_string(&pdev->dev, "linux,default-trigger",
+				    &led->cdev.default_trigger);
 
 	mutex_init(&led->mutex);
 
@@ -694,15 +697,23 @@ static int lm3533_led_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, led);
 
-	ret = led_classdev_register(pdev->dev.parent, &led->cdev);
+	ret = led_classdev_register(&pdev->dev, &led->cdev);
 	if (ret) {
-		dev_err(&pdev->dev, "failed to register LED %d\n", pdev->id);
+		dev_err(&pdev->dev, "failed to register LED %d\n", led->id);
 		return ret;
 	}
 
 	led->cb.dev = led->cdev.dev;
 
-	ret = lm3533_led_setup(led, pdata);
+	device_property_read_u32(&pdev->dev, "led-max-microamp",
+				 &led->max_current);
+	led->max_current = clamp(led->max_current, LM3533_LED_MAX_CURRENT_MIN,
+				 LM3533_LED_MAX_CURRENT_MAX);
+
+	led->pwm = 0;
+	device_property_read_u32(&pdev->dev, "ti,pwm-config-mask", &led->pwm);
+
+	ret = lm3533_led_setup(led);
 	if (ret)
 		goto err_deregister;
 
@@ -739,9 +750,16 @@ static void lm3533_led_shutdown(struct platform_device *pdev)
 	lm3533_led_set(&led->cdev, LED_OFF);		/* disable blink */
 }
 
+static const struct of_device_id lm3533_led_match_table[] = {
+	{ .compatible = "ti,lm3533-leds" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, lm3533_led_match_table);
+
 static struct platform_driver lm3533_led_driver = {
 	.driver = {
 		.name = "lm3533-leds",
+		.of_match_table = lm3533_led_match_table,
 	},
 	.probe		= lm3533_led_probe,
 	.remove		= lm3533_led_remove,
diff --git a/drivers/mfd/lm3533-core.c b/drivers/mfd/lm3533-core.c
index 0a2409d00b2e..83ebd780f39d 100644
--- a/drivers/mfd/lm3533-core.c
+++ b/drivers/mfd/lm3533-core.c
@@ -14,19 +14,26 @@
 #include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/mfd/core.h>
+#include <linux/mod_devicetable.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
+#include <linux/units.h>
 
 #include <linux/mfd/lm3533.h>
 
 
 #define LM3533_BOOST_OVP_MASK		0x06
 #define LM3533_BOOST_OVP_SHIFT		1
+#define LM3533_BOOST_OVP_MIN		16000000
+#define LM3533_BOOST_OVP_MAX		40000000
 
 #define LM3533_BOOST_FREQ_MASK		0x01
 #define LM3533_BOOST_FREQ_SHIFT		0
+#define LM3533_BOOST_FREQ_MIN		500000
+#define LM3533_BOOST_FREQ_MAX		1000000
 
 #define LM3533_BL_ID_MASK		1
 #define LM3533_LED_ID_MASK		3
@@ -42,42 +49,14 @@
 
 #define LM3533_REG_MAX			0xb2
 
-
-static struct mfd_cell lm3533_als_devs[] = {
-	{
-		.name	= "lm3533-als",
-		.id	= -1,
-	},
-};
-
-static struct mfd_cell lm3533_bl_devs[] = {
-	{
-		.name	= "lm3533-backlight",
-		.id	= 0,
-	},
-	{
-		.name	= "lm3533-backlight",
-		.id	= 1,
-	},
-};
-
-static struct mfd_cell lm3533_led_devs[] = {
-	{
-		.name	= "lm3533-leds",
-		.id	= 0,
-	},
-	{
-		.name	= "lm3533-leds",
-		.id	= 1,
-	},
-	{
-		.name	= "lm3533-leds",
-		.id	= 2,
-	},
-	{
-		.name	= "lm3533-leds",
-		.id	= 3,
-	},
+static struct mfd_cell lm3533_child_devices[] = {
+	MFD_CELL_OF("lm3533-als", NULL, NULL, 0, 0, "ti,lm3533-als"),
+	MFD_CELL_OF_REG("lm3533-backlight", NULL, NULL, 0, 0, "ti,lm3533-backlight", 0),
+	MFD_CELL_OF_REG("lm3533-backlight", NULL, NULL, 0, 1, "ti,lm3533-backlight", 1),
+	MFD_CELL_OF_REG("lm3533-leds", NULL, NULL, 0, 0, "ti,lm3533-leds", 2),
+	MFD_CELL_OF_REG("lm3533-leds", NULL, NULL, 0, 1, "ti,lm3533-leds", 3),
+	MFD_CELL_OF_REG("lm3533-leds", NULL, NULL, 0, 2, "ti,lm3533-leds", 4),
+	MFD_CELL_OF_REG("lm3533-leds", NULL, NULL, 0, 3, "ti,lm3533-leds", 5),
 };
 
 int lm3533_read(struct lm3533 *lm3533, u8 reg, u8 *val)
@@ -132,35 +111,6 @@ int lm3533_update(struct lm3533 *lm3533, u8 reg, u8 val, u8 mask)
 }
 EXPORT_SYMBOL_GPL(lm3533_update);
 
-static int lm3533_set_boost_freq(struct lm3533 *lm3533,
-						enum lm3533_boost_freq freq)
-{
-	int ret;
-
-	ret = lm3533_update(lm3533, LM3533_REG_BOOST_PWM,
-					freq << LM3533_BOOST_FREQ_SHIFT,
-					LM3533_BOOST_FREQ_MASK);
-	if (ret)
-		dev_err(lm3533->dev, "failed to set boost frequency\n");
-
-	return ret;
-}
-
-
-static int lm3533_set_boost_ovp(struct lm3533 *lm3533,
-						enum lm3533_boost_ovp ovp)
-{
-	int ret;
-
-	ret = lm3533_update(lm3533, LM3533_REG_BOOST_PWM,
-					ovp << LM3533_BOOST_OVP_SHIFT,
-					LM3533_BOOST_OVP_MASK);
-	if (ret)
-		dev_err(lm3533->dev, "failed to set boost ovp\n");
-
-	return ret;
-}
-
 /*
  * HVLED output config -- output hvled controlled by backlight bl
  */
@@ -376,136 +326,45 @@ static struct attribute_group lm3533_attribute_group = {
 	.attrs		= lm3533_attributes
 };
 
-static int lm3533_device_als_init(struct lm3533 *lm3533)
+static int lm3533_device_init(struct lm3533 *lm3533)
 {
-	struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
+	struct device *dev = lm3533->dev;
 	int ret;
 
-	if (!pdata->als)
-		return 0;
-
-	lm3533_als_devs[0].platform_data = pdata->als;
-	lm3533_als_devs[0].pdata_size = sizeof(*pdata->als);
+	lm3533_enable(lm3533);
 
-	ret = mfd_add_devices(lm3533->dev, 0, lm3533_als_devs, 1, NULL,
-			      0, NULL);
+	ret = lm3533_update(lm3533, LM3533_REG_BOOST_PWM,
+			    lm3533->boost_freq << LM3533_BOOST_FREQ_SHIFT,
+			    LM3533_BOOST_FREQ_MASK);
 	if (ret) {
-		dev_err(lm3533->dev, "failed to add ALS device\n");
-		return ret;
-	}
-
-	lm3533->have_als = 1;
-
-	return 0;
-}
-
-static int lm3533_device_bl_init(struct lm3533 *lm3533)
-{
-	struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
-	int i;
-	int ret;
-
-	if (!pdata->backlights || pdata->num_backlights == 0)
-		return 0;
-
-	if (pdata->num_backlights > ARRAY_SIZE(lm3533_bl_devs))
-		pdata->num_backlights = ARRAY_SIZE(lm3533_bl_devs);
-
-	for (i = 0; i < pdata->num_backlights; ++i) {
-		lm3533_bl_devs[i].platform_data = &pdata->backlights[i];
-		lm3533_bl_devs[i].pdata_size = sizeof(pdata->backlights[i]);
+		dev_err(dev, "failed to set boost frequency\n");
+		goto err_disable;
 	}
 
-	ret = mfd_add_devices(lm3533->dev, 0, lm3533_bl_devs,
-			      pdata->num_backlights, NULL, 0, NULL);
+	ret = lm3533_update(lm3533, LM3533_REG_BOOST_PWM,
+			    lm3533->boost_ovp << LM3533_BOOST_OVP_SHIFT,
+			    LM3533_BOOST_OVP_MASK);
 	if (ret) {
-		dev_err(lm3533->dev, "failed to add backlight devices\n");
-		return ret;
-	}
-
-	lm3533->have_backlights = 1;
-
-	return 0;
-}
-
-static int lm3533_device_led_init(struct lm3533 *lm3533)
-{
-	struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
-	int i;
-	int ret;
-
-	if (!pdata->leds || pdata->num_leds == 0)
-		return 0;
-
-	if (pdata->num_leds > ARRAY_SIZE(lm3533_led_devs))
-		pdata->num_leds = ARRAY_SIZE(lm3533_led_devs);
-
-	for (i = 0; i < pdata->num_leds; ++i) {
-		lm3533_led_devs[i].platform_data = &pdata->leds[i];
-		lm3533_led_devs[i].pdata_size = sizeof(pdata->leds[i]);
+		dev_err(dev, "failed to set boost ovp\n");
+		goto err_disable;
 	}
 
-	ret = mfd_add_devices(lm3533->dev, 0, lm3533_led_devs,
-			      pdata->num_leds, NULL, 0, NULL);
+	ret = devm_mfd_add_devices(dev, 0, lm3533_child_devices,
+				   ARRAY_SIZE(lm3533_child_devices),
+				   NULL, 0, NULL);
 	if (ret) {
-		dev_err(lm3533->dev, "failed to add LED devices\n");
-		return ret;
-	}
-
-	lm3533->have_leds = 1;
-
-	return 0;
-}
-
-static int lm3533_device_setup(struct lm3533 *lm3533,
-					struct lm3533_platform_data *pdata)
-{
-	int ret;
-
-	ret = lm3533_set_boost_freq(lm3533, pdata->boost_freq);
-	if (ret)
-		return ret;
-
-	return lm3533_set_boost_ovp(lm3533, pdata->boost_ovp);
-}
-
-static int lm3533_device_init(struct lm3533 *lm3533)
-{
-	struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
-	int ret;
-
-	dev_dbg(lm3533->dev, "%s\n", __func__);
-
-	if (!pdata) {
-		dev_err(lm3533->dev, "no platform data\n");
-		return -EINVAL;
+		dev_err(dev, "failed to add MFD devices: %d\n", ret);
+		goto err_disable;
 	}
 
-	lm3533->hwen = devm_gpiod_get(lm3533->dev, NULL, GPIOD_OUT_LOW);
-	if (IS_ERR(lm3533->hwen))
-		return dev_err_probe(lm3533->dev, PTR_ERR(lm3533->hwen), "failed to request HWEN GPIO\n");
-	gpiod_set_consumer_name(lm3533->hwen, "lm3533-hwen");
-
-	lm3533_enable(lm3533);
-
-	ret = lm3533_device_setup(lm3533, pdata);
-	if (ret)
+	ret = sysfs_create_group(&dev->kobj, &lm3533_attribute_group);
+	if (ret) {
+		dev_err(dev, "failed to create sysfs attributes\n");
 		goto err_disable;
-
-	lm3533_device_als_init(lm3533);
-	lm3533_device_bl_init(lm3533);
-	lm3533_device_led_init(lm3533);
-
-	ret = sysfs_create_group(&lm3533->dev->kobj, &lm3533_attribute_group);
-	if (ret < 0) {
-		dev_err(lm3533->dev, "failed to create sysfs attributes\n");
-		goto err_unregister;
 	}
 
 	return 0;
 
-err_unregister:
-	mfd_remove_devices(lm3533->dev);
 err_disable:
 	lm3533_disable(lm3533);
 
@@ -517,8 +376,6 @@ static void lm3533_device_exit(struct lm3533 *lm3533)
 	dev_dbg(lm3533->dev, "%s\n", __func__);
 
 	sysfs_remove_group(&lm3533->dev->kobj, &lm3533_attribute_group);
-
-	mfd_remove_devices(lm3533->dev);
 	lm3533_disable(lm3533);
 }
 
@@ -589,7 +446,40 @@ static int lm3533_i2c_probe(struct i2c_client *i2c)
 		return PTR_ERR(lm3533->regmap);
 
 	lm3533->dev = &i2c->dev;
-	lm3533->irq = i2c->irq;
+
+	lm3533->hwen = devm_gpiod_get_optional(lm3533->dev, "enable",
+					       GPIOD_OUT_LOW);
+	if (IS_ERR(lm3533->hwen))
+		return dev_err_probe(lm3533->dev, PTR_ERR(lm3533->hwen),
+				     "failed to get HWEN GPIO\n");
+
+	device_property_read_u32(lm3533->dev, "ti,boost-ovp-microvolt",
+				 &lm3533->boost_ovp);
+
+	lm3533->boost_ovp = clamp(lm3533->boost_ovp, LM3533_BOOST_OVP_MIN,
+				  LM3533_BOOST_OVP_MAX);
+	lm3533->boost_ovp = lm3533->boost_ovp / (8 * MICRO) - 2;
+
+	device_property_read_u32(lm3533->dev, "ti,boost-freq-hz",
+				 &lm3533->boost_freq);
+
+	lm3533->boost_freq = clamp(lm3533->boost_freq, LM3533_BOOST_FREQ_MIN,
+				   LM3533_BOOST_FREQ_MAX);
+	lm3533->boost_freq = lm3533->boost_freq / (500 * KILO) - 1;
+
+	device_for_each_child_node_scoped(lm3533->dev, child) {
+		if (!fwnode_device_is_available(child))
+			continue;
+
+		if (fwnode_device_is_compatible(child, "ti,lm3533-als"))
+			lm3533->have_als = true;
+
+		if (fwnode_device_is_compatible(child, "ti,lm3533-backlight"))
+			lm3533->have_backlights = true;
+
+		if (fwnode_device_is_compatible(child, "ti,lm3533-leds"))
+			lm3533->have_leds = true;
+	}
 
 	return lm3533_device_init(lm3533);
 }
@@ -603,6 +493,12 @@ static void lm3533_i2c_remove(struct i2c_client *i2c)
 	lm3533_device_exit(lm3533);
 }
 
+static const struct of_device_id lm3533_match_table[] = {
+	{ .compatible = "ti,lm3533" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, lm3533_match_table);
+
 static const struct i2c_device_id lm3533_i2c_ids[] = {
 	{ "lm3533" },
 	{ }
@@ -612,6 +508,7 @@ MODULE_DEVICE_TABLE(i2c, lm3533_i2c_ids);
 static struct i2c_driver lm3533_i2c_driver = {
 	.driver = {
 		   .name = "lm3533",
+		   .of_match_table = lm3533_match_table,
 	},
 	.id_table	= lm3533_i2c_ids,
 	.probe		= lm3533_i2c_probe,
diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
index babfd3ceec86..42da652df58d 100644
--- a/drivers/video/backlight/lm3533_bl.c
+++ b/drivers/video/backlight/lm3533_bl.c
@@ -9,7 +9,9 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/backlight.h>
 #include <linux/slab.h>
 
@@ -27,6 +29,9 @@ struct lm3533_bl {
 	struct lm3533_ctrlbank cb;
 	struct backlight_device *bd;
 	int id;
+
+	u32 max_current;
+	u32 pwm;
 };
 
 
@@ -246,25 +251,24 @@ static struct attribute_group lm3533_bl_attribute_group = {
 	.attrs		= lm3533_bl_attributes
 };
 
-static int lm3533_bl_setup(struct lm3533_bl *bl,
-					struct lm3533_bl_platform_data *pdata)
+static int lm3533_bl_setup(struct lm3533_bl *bl)
 {
 	int ret;
 
-	ret = lm3533_ctrlbank_set_max_current(&bl->cb, pdata->max_current);
+	ret = lm3533_ctrlbank_set_max_current(&bl->cb, bl->max_current);
 	if (ret)
 		return ret;
 
-	return lm3533_ctrlbank_set_pwm(&bl->cb, pdata->pwm);
+	return lm3533_ctrlbank_set_pwm(&bl->cb, bl->pwm);
 }
 
 static int lm3533_bl_probe(struct platform_device *pdev)
 {
 	struct lm3533 *lm3533;
-	struct lm3533_bl_platform_data *pdata;
 	struct lm3533_bl *bl;
 	struct backlight_device *bd;
 	struct backlight_properties props;
+	char *name = NULL;
 	int ret;
 
 	dev_dbg(&pdev->dev, "%s\n", __func__);
@@ -273,12 +277,6 @@ static int lm3533_bl_probe(struct platform_device *pdev)
 	if (!lm3533)
 		return -EINVAL;
 
-	pdata = dev_get_platdata(&pdev->dev);
-	if (!pdata) {
-		dev_err(&pdev->dev, "no platform data\n");
-		return -EINVAL;
-	}
-
 	if (pdev->id < 0 || pdev->id >= LM3533_HVCTRLBANK_COUNT) {
 		dev_err(&pdev->dev, "illegal backlight id %d\n", pdev->id);
 		return -EINVAL;
@@ -295,13 +293,20 @@ static int lm3533_bl_probe(struct platform_device *pdev)
 	bl->cb.id = lm3533_bl_get_ctrlbank_id(bl);
 	bl->cb.dev = NULL;			/* until registered */
 
+	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s-%d",
+			      pdev->name, pdev->id);
+	if (!name)
+		return -ENOMEM;
+
 	memset(&props, 0, sizeof(props));
 	props.type = BACKLIGHT_RAW;
 	props.max_brightness = LM3533_BL_MAX_BRIGHTNESS;
-	props.brightness = pdata->default_brightness;
-	bd = devm_backlight_device_register(&pdev->dev, pdata->name,
-					pdev->dev.parent, bl, &lm3533_bl_ops,
-					&props);
+	props.brightness = LM3533_BL_MAX_BRIGHTNESS;
+	device_property_read_u32(&pdev->dev, "default-brightness",
+				 &props.brightness);
+
+	bd = devm_backlight_device_register(&pdev->dev, name, &pdev->dev,
+					    bl, &lm3533_bl_ops, &props);
 	if (IS_ERR(bd)) {
 		dev_err(&pdev->dev, "failed to register backlight device\n");
 		return PTR_ERR(bd);
@@ -320,7 +325,15 @@ static int lm3533_bl_probe(struct platform_device *pdev)
 
 	backlight_update_status(bd);
 
-	ret = lm3533_bl_setup(bl, pdata);
+	device_property_read_u32(&pdev->dev, "led-max-microamp",
+				 &bl->max_current);
+	bl->max_current = clamp(bl->max_current, LM3533_LED_MAX_CURRENT_MIN,
+				LM3533_LED_MAX_CURRENT_MAX);
+
+	bl->pwm = 0;
+	device_property_read_u32(&pdev->dev, "ti,pwm-config-mask", &bl->pwm);
+
+	ret = lm3533_bl_setup(bl);
 	if (ret)
 		goto err_sysfs_remove;
 
@@ -381,10 +394,17 @@ static void lm3533_bl_shutdown(struct platform_device *pdev)
 	lm3533_ctrlbank_disable(&bl->cb);
 }
 
+static const struct of_device_id lm3533_bl_match_table[] = {
+	{ .compatible = "ti,lm3533-backlight" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, lm3533_bl_match_table);
+
 static struct platform_driver lm3533_bl_driver = {
 	.driver = {
 		.name	= "lm3533-backlight",
 		.pm	= &lm3533_bl_pm_ops,
+		.of_match_table = lm3533_bl_match_table,
 	},
 	.probe		= lm3533_bl_probe,
 	.remove		= lm3533_bl_remove,
diff --git a/include/linux/mfd/lm3533.h b/include/linux/mfd/lm3533.h
index 69059a7a2ce5..3aa962d4c747 100644
--- a/include/linux/mfd/lm3533.h
+++ b/include/linux/mfd/lm3533.h
@@ -15,6 +15,9 @@
 #define LM3533_ATTR_RW(_name) \
 	DEVICE_ATTR(_name, S_IRUGO | S_IWUSR , show_##_name, store_##_name)
 
+#define LM3533_LED_MAX_CURRENT_MIN	5000
+#define LM3533_LED_MAX_CURRENT_MAX	29800
+
 struct device;
 struct gpio_desc;
 struct regmap;
@@ -25,7 +28,9 @@ struct lm3533 {
 	struct regmap *regmap;
 
 	struct gpio_desc *hwen;
-	int irq;
+
+	u32 boost_ovp;
+	u32 boost_freq;
 
 	unsigned have_als:1;
 	unsigned have_backlights:1;
@@ -38,50 +43,6 @@ struct lm3533_ctrlbank {
 	int id;
 };
 
-struct lm3533_als_platform_data {
-	unsigned pwm_mode:1;		/* PWM input mode (default analog) */
-	u8 r_select;			/* 1 - 127 (ignored in PWM-mode) */
-};
-
-struct lm3533_bl_platform_data {
-	char *name;
-	u16 max_current;		/* 5000 - 29800 uA (800 uA step) */
-	u8 default_brightness;		/* 0 - 255 */
-	u8 pwm;				/* 0 - 0x3f */
-};
-
-struct lm3533_led_platform_data {
-	char *name;
-	const char *default_trigger;
-	u16 max_current;		/* 5000 - 29800 uA (800 uA step) */
-	u8 pwm;				/* 0 - 0x3f */
-};
-
-enum lm3533_boost_freq {
-	LM3533_BOOST_FREQ_500KHZ,
-	LM3533_BOOST_FREQ_1000KHZ,
-};
-
-enum lm3533_boost_ovp {
-	LM3533_BOOST_OVP_16V,
-	LM3533_BOOST_OVP_24V,
-	LM3533_BOOST_OVP_32V,
-	LM3533_BOOST_OVP_40V,
-};
-
-struct lm3533_platform_data {
-	enum lm3533_boost_ovp boost_ovp;
-	enum lm3533_boost_freq boost_freq;
-
-	struct lm3533_als_platform_data *als;
-
-	struct lm3533_bl_platform_data *backlights;
-	int num_backlights;
-
-	struct lm3533_led_platform_data *leds;
-	int num_leds;
-};
-
 extern int lm3533_ctrlbank_enable(struct lm3533_ctrlbank *cb);
 extern int lm3533_ctrlbank_disable(struct lm3533_ctrlbank *cb);
 
-- 
2.51.0


^ permalink raw reply related

* [PATCH v1 1/6] dt-bindings: leds: Document TI LM3533 LED controller
From: Svyatoslav Ryhel @ 2026-05-17  7:43 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Helge Deller,
	Svyatoslav Ryhel
  Cc: dri-devel, linux-leds, devicetree, linux-kernel, linux-iio,
	linux-fbdev
In-Reply-To: <20260517074306.30937-1-clamor95@gmail.com>

Document the LM3533 - a complete power source for backlight, keypad and
indicator LEDs in smartphone handsets. The high-voltage inductive boost
converter provides the power for two series LED strings display backlight
and keypad functions.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 .../leds/backlight/ti,lm3533-backlight.yaml   |  68 +++++++
 .../bindings/leds/ti,lm3533-leds.yaml         |  66 ++++++
 .../devicetree/bindings/leds/ti,lm3533.yaml   | 190 ++++++++++++++++++
 3 files changed, 324 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/backlight/ti,lm3533-backlight.yaml
 create mode 100644 Documentation/devicetree/bindings/leds/ti,lm3533-leds.yaml
 create mode 100644 Documentation/devicetree/bindings/leds/ti,lm3533.yaml

diff --git a/Documentation/devicetree/bindings/leds/backlight/ti,lm3533-backlight.yaml b/Documentation/devicetree/bindings/leds/backlight/ti,lm3533-backlight.yaml
new file mode 100644
index 000000000000..866b0fb8ed04
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/backlight/ti,lm3533-backlight.yaml
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/backlight/ti,lm3533-backlight.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TI LM3533 high voltage series LED strings
+
+description:
+  This is part of the TI LM3533 MFD device. It represents two high voltage series
+  LED strings for display backlight controlled by the TI LM3533.
+
+maintainers:
+  - Svyatoslav Ryhel <clamor95@gmail.com>
+
+allOf:
+  - $ref: /schemas/leds/backlight/common.yaml#
+
+properties:
+  compatible:
+    const: ti,lm3533-backlight
+
+  reg:
+    description: Control bank selection (0 = bank A, 1 = bank B).
+    maximum: 1
+
+  led-max-microamp:
+    description: maximum current in uA with a 800 uA step.
+    minimum: 5000
+    maximum: 29800
+    default: 5000
+
+  led-sources:
+    description: |
+      HVLED strings associated with this control bank:
+        0 - HVLED1
+        1 - HVLED2
+    minItems: 1
+    maxItems: 2
+    items:
+      maximum: 1
+
+  ti,pwm-config-mask:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: |
+      Control Bank PWM Configuration Register mask that allows to configure
+      PWM input in Zones 0-4
+      BIT(0) - PWM Input is enabled
+      BIT(1) - PWM Input is enabled in Zone 0
+      BIT(2) - PWM Input is enabled in Zone 1
+      BIT(3) - PWM Input is enabled in Zone 2
+      BIT(4) - PWM Input is enabled in Zone 3
+      BIT(5) - PWM Input is enabled in Zone 4
+
+  ti,linear-mapping-mode:
+    description:
+      Enable linear mapping mode. If disabled, then it will use exponential
+      mapping mode in which the ramp up/down appears to have a more uniform
+      transition to the human eye.
+    type: boolean
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+# see ti,lm3533.yaml for an example
diff --git a/Documentation/devicetree/bindings/leds/ti,lm3533-leds.yaml b/Documentation/devicetree/bindings/leds/ti,lm3533-leds.yaml
new file mode 100644
index 000000000000..a582d7d2f955
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/ti,lm3533-leds.yaml
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/ti,lm3533-leds.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TI LM3533 low voltage control banks for individual LEDs
+
+description:
+  This is part of the TI LM3533 MFD device. It represents four low voltage
+  control banks for individual LEDs provided by the TI LM3533.
+
+maintainers:
+  - Svyatoslav Ryhel <clamor95@gmail.com>
+
+allOf:
+  - $ref: /schemas/leds/common.yaml#
+
+properties:
+  compatible:
+    const: ti,lm3533-leds
+
+  reg:
+    description:
+      Control bank selection (2 = bank C, 3 = bank D, 4 = bank E, 5 = bank F).
+    minimum: 2
+    maximum: 5
+
+  led-max-microamp:
+    description: maximum current in uA with a 800 uA step.
+    minimum: 5000
+    maximum: 29800
+    default: 5000
+
+  led-sources:
+    description: |
+      LVLED associated with this control bank. May be more than 1 source per bank.
+        0 - LVLED1
+        1 - LVLED2
+        2 - LVLED3
+        3 - LVLED4
+        4 - LVLED5
+    minItems: 1
+    maxItems: 5
+    items:
+      maximum: 5
+
+  ti,pwm-config-mask:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: |
+      Control Bank PWM Configuration Register mask that allows to configure
+      PWM input in Zones 0-4
+      BIT(0) - PWM Input is enabled
+      BIT(1) - PWM Input is enabled in Zone 0
+      BIT(2) - PWM Input is enabled in Zone 1
+      BIT(3) - PWM Input is enabled in Zone 2
+      BIT(4) - PWM Input is enabled in Zone 3
+      BIT(5) - PWM Input is enabled in Zone 4
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+# see ti,lm3533.yaml for an example
diff --git a/Documentation/devicetree/bindings/leds/ti,lm3533.yaml b/Documentation/devicetree/bindings/leds/ti,lm3533.yaml
new file mode 100644
index 000000000000..2e200f172400
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/ti,lm3533.yaml
@@ -0,0 +1,190 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/ti,lm3533.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TI LM3533 Complete Lighting Power Solution
+
+description: >
+  The LM3533 is a complete power source for backlight, keypad, and indicator LEDs
+  in smartphone handsets. The high-voltage inductive boost converter provides the
+  power for two high voltage series LED strings for display backlight and four low
+  voltage control banks for individual LEDs. Additionally, LM3533 features an ALS
+  sensor support.
+
+  https://www.ti.com/product/LM3533
+
+maintainers:
+  - Svyatoslav Ryhel <clamor95@gmail.com>
+
+properties:
+  compatible:
+    const: ti,lm3533
+
+  reg:
+    maxItems: 1
+
+  enable-gpios:
+    description: GPIO connected to the HWEN pin.
+    maxItems: 1
+
+  vin-supply:
+    description: Supply connected to the IN line (2.7 V to 5.5 V).
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
+  ti,boost-ovp-microvolt:
+    description: boost OVP select (16V, 24V, 32V, 40V)
+    enum: [ 16000000, 24000000, 32000000, 40000000 ]
+    default: 16000000
+
+  ti,boost-freq-hz:
+    description: boost frequency select (500KHz or 1MHz)
+    enum: [ 500000, 1000000 ]
+    default: 500000
+
+  light-sensor:
+    type: object
+    additionalProperties: false
+
+    properties:
+      compatible:
+        const: ti,lm3533-als
+
+      interrupts:
+        maxItems: 1
+
+      ti,resistor-ohm:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description:
+          Internal configuration resister value when ALS is in Analog Sensor
+          mode and PWM mode is disabled.
+        minimum: 1575
+        maximum: 200000
+
+      ti,pwm-mode:
+        type: boolean
+        description:
+          Switch for mode in which ALS is running. If this property is set
+          then ALS is running in PWM mode, internal resistor value is set to
+          high-impedance (0) and ti,resistor-ohm property is ignored.
+
+    required:
+      - compatible
+
+    anyOf:
+      - required:
+          - ti,resistor-ohm
+      - required:
+          - ti,pwm-mode
+
+patternProperties:
+  "^backlight@[01]$":
+    $ref: /schemas/leds/backlight/ti,lm3533-backlight.yaml#
+
+  "^led@[2-5]$":
+    $ref: /schemas/leds/ti,lm3533-leds.yaml#
+
+required:
+  - compatible
+  - reg
+  - light-sensor
+  - backlight@0
+  - backlight@1
+  - led@2
+  - led@3
+  - led@4
+  - led@5
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        led-controller@36 {
+            compatible = "ti,lm3533";
+            reg = <0x36>;
+
+            enable-gpios = <&gpio 110 GPIO_ACTIVE_HIGH>;
+            vin-supply = <&vdd_3v3_bat>;
+
+            ti,boost-ovp-microvolt = <24000000>;
+            ti,boost-freq-hz = <500000>;
+
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            backlight@0 {
+                compatible = "ti,lm3533-backlight";
+                reg = <0>;
+
+                default-brightness = <113>;
+
+                led-max-microamp = <23400>;
+                led-sources = <0>;
+            };
+
+            backlight@1 {
+                compatible = "ti,lm3533-backlight";
+                reg = <1>;
+
+                default-brightness = <113>;
+
+                led-max-microamp = <23400>;
+                led-sources = <1>;
+            };
+
+            led@2 {
+                compatible = "ti,lm3533-leds";
+                reg = <2>;
+
+                led-max-microamp = <23400>;
+                led-sources = <0>;
+            };
+
+            led@3 {
+                compatible = "ti,lm3533-leds";
+                reg = <3>;
+
+                led-max-microamp = <23400>;
+                led-sources = <1>;
+            };
+
+            led@4 {
+                compatible = "ti,lm3533-leds";
+                reg = <4>;
+
+                led-max-microamp = <23400>;
+                led-sources = <2>;
+            };
+
+            led@5 {
+                compatible = "ti,lm3533-leds";
+                reg = <5>;
+
+                led-max-microamp = <23400>;
+                led-sources = <3 4>;
+            };
+
+            light-sensor {
+                compatible = "ti,lm3533-als";
+
+                interrupt-parent = <&gpio>;
+                interrupts = <80 IRQ_TYPE_LEVEL_LOW>;
+
+                ti,pwm-mode;
+            };
+        };
+    };
+...
-- 
2.51.0


^ permalink raw reply related

* [PATCH v1 0/6] mfd: lm3533: convert to OF bindings, improve support
From: Svyatoslav Ryhel @ 2026-05-17  7:43 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Helge Deller,
	Svyatoslav Ryhel
  Cc: dri-devel, linux-leds, devicetree, linux-kernel, linux-iio,
	linux-fbdev

Convert LM3533 to OF bindings, add missing VIN supply, add support for
setting mapping mode and LED sources based on device tree. 

Svyatoslav Ryhel (6):
  dt-bindings: leds: Document TI LM3533 LED controller
  mfd: lm3533: Convert to use OF bindings
  mfd: lm3533: Add support for VIN power supply
  mfd: lm3533: set DMA mask
  video: backlight: lm3533_bl: Set initial mapping mode from DT
  video: leds: backlight: lm3533: Support getting LED sources from DT

 .../leds/backlight/ti,lm3533-backlight.yaml   |  68 +++++
 .../bindings/leds/ti,lm3533-leds.yaml         |  66 ++++
 .../devicetree/bindings/leds/ti,lm3533.yaml   | 190 ++++++++++++
 drivers/iio/light/lm3533-als.c                | 123 +++-----
 drivers/leds/leds-lm3533.c                    | 117 ++++++--
 drivers/mfd/lm3533-core.c                     | 281 +++++++-----------
 drivers/video/backlight/lm3533_bl.c           | 123 ++++++--
 include/linux/mfd/lm3533.h                    |  52 +---
 8 files changed, 660 insertions(+), 360 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/leds/backlight/ti,lm3533-backlight.yaml
 create mode 100644 Documentation/devicetree/bindings/leds/ti,lm3533-leds.yaml
 create mode 100644 Documentation/devicetree/bindings/leds/ti,lm3533.yaml

-- 
2.51.0


^ permalink raw reply

* Re: [PATCH] staging: sm750fb: fix CamelCase variables name in sm750
From: kernel test robot @ 2026-05-17  4:00 UTC (permalink / raw)
  To: Emmanuel Arias, sudipm.mukherjee, teddy.wang, gregkh
  Cc: llvm, oe-kbuild-all, linux-fbdev, linux-staging, linux-kernel,
	Emmanuel Arias
In-Reply-To: <20260516222613.1178800-1-eamanu@riseup.net>

Hi Emmanuel,

kernel test robot noticed the following build errors:

[auto build test ERROR on staging/staging-testing]

url:    https://github.com/intel-lab-lkp/linux/commits/Emmanuel-Arias/staging-sm750fb-fix-CamelCase-variables-name-in-sm750/20260517-062807
base:   staging/staging-testing
patch link:    https://lore.kernel.org/r/20260516222613.1178800-1-eamanu%40riseup.net
patch subject: [PATCH] staging: sm750fb: fix CamelCase variables name in sm750
config: riscv-randconfig-001-20260517 (https://download.01.org/0day-ci/archive/20260517/202605171120.K414qtus-lkp@intel.com/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 5bac06718f502014fade905512f1d26d578a18f3)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260517/202605171120.K414qtus-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605171120.K414qtus-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/staging/sm750fb/sm750_hw.c:43:13: error: no member named 'pvReg' in 'struct sm750_dev'
      43 |         sm750_dev->pvReg =
         |         ~~~~~~~~~  ^
   drivers/staging/sm750fb/sm750_hw.c:45:18: error: no member named 'pvReg' in 'struct sm750_dev'
      45 |         if (!sm750_dev->pvReg) {
         |              ~~~~~~~~~  ^
   drivers/staging/sm750fb/sm750_hw.c:51:41: error: no member named 'pvReg' in 'struct sm750_dev'
      51 |         sm750_dev->accel.dpr_base = sm750_dev->pvReg + DE_BASE_ADDR_TYPE1;
         |                                     ~~~~~~~~~  ^
   drivers/staging/sm750fb/sm750_hw.c:52:45: error: no member named 'pvReg' in 'struct sm750_dev'
      52 |         sm750_dev->accel.dp_port_base = sm750_dev->pvReg + DE_PORT_ADDR_TYPE1;
         |                                         ~~~~~~~~~  ^
   drivers/staging/sm750fb/sm750_hw.c:54:23: error: no member named 'pvReg' in 'struct sm750_dev'
      54 |         mmio750 = sm750_dev->pvReg;
         |                   ~~~~~~~~~  ^
   drivers/staging/sm750fb/sm750_hw.c:78:21: error: no member named 'pvReg' in 'struct sm750_dev'
      78 |         iounmap(sm750_dev->pvReg);
         |                 ~~~~~~~~~  ^
   6 errors generated.


vim +43 drivers/staging/sm750fb/sm750_hw.c

efe9bc08bf479b Elise Lennion    2016-10-11  27  
700591a9adc8b1 Mike Rapoport    2015-10-26  28  int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
81dee67e215b23 Sudip Mukherjee  2015-03-03  29  {
81dee67e215b23 Sudip Mukherjee  2015-03-03  30  	int ret;
81dee67e215b23 Sudip Mukherjee  2015-03-03  31  
e359b6a863e19f Mike Rapoport    2015-10-26  32  	sm750_dev->vidreg_start = pci_resource_start(pdev, 1);
e359b6a863e19f Mike Rapoport    2015-10-26  33  	sm750_dev->vidreg_size = SZ_2M;
81dee67e215b23 Sudip Mukherjee  2015-03-03  34  
8225489ddb9006 Artem Lytkin     2026-02-16  35  	/* reserve the vidreg space of smi adaptor */
9a52ae2dd8c24a Anatoly Stepanov 2015-06-29  36  	ret = pci_request_region(pdev, 1, "sm750fb");
9a52ae2dd8c24a Anatoly Stepanov 2015-06-29  37  	if (ret) {
e5448f8d2ec5b4 Artem Lytkin     2026-02-23  38  		dev_err(&pdev->dev, "Can not request PCI regions.\n");
8225489ddb9006 Artem Lytkin     2026-02-16  39  		return ret;
81dee67e215b23 Sudip Mukherjee  2015-03-03  40  	}
81dee67e215b23 Sudip Mukherjee  2015-03-03  41  
81dee67e215b23 Sudip Mukherjee  2015-03-03  42  	/* now map mmio and vidmem */
fdc234d85210d9 Benjamin Philip  2021-07-28 @43  	sm750_dev->pvReg =
fdc234d85210d9 Benjamin Philip  2021-07-28  44  		ioremap(sm750_dev->vidreg_start, sm750_dev->vidreg_size);
e359b6a863e19f Mike Rapoport    2015-10-26  45  	if (!sm750_dev->pvReg) {
e5448f8d2ec5b4 Artem Lytkin     2026-02-23  46  		dev_err(&pdev->dev, "mmio failed\n");
81dee67e215b23 Sudip Mukherjee  2015-03-03  47  		ret = -EFAULT;
8225489ddb9006 Artem Lytkin     2026-02-16  48  		goto err_release_region;
81dee67e215b23 Sudip Mukherjee  2015-03-03  49  	}
81dee67e215b23 Sudip Mukherjee  2015-03-03  50  
5865a858dbc9cb Yiming Qian      2025-09-09  51  	sm750_dev->accel.dpr_base = sm750_dev->pvReg + DE_BASE_ADDR_TYPE1;
5865a858dbc9cb Yiming Qian      2025-09-09  52  	sm750_dev->accel.dp_port_base = sm750_dev->pvReg + DE_PORT_ADDR_TYPE1;
81dee67e215b23 Sudip Mukherjee  2015-03-03  53  
efe9bc08bf479b Elise Lennion    2016-10-11  54  	mmio750 = sm750_dev->pvReg;
efe9bc08bf479b Elise Lennion    2016-10-11  55  	sm750_set_chip_type(sm750_dev->devid, sm750_dev->revid);
81dee67e215b23 Sudip Mukherjee  2015-03-03  56  
e359b6a863e19f Mike Rapoport    2015-10-26  57  	sm750_dev->vidmem_start = pci_resource_start(pdev, 0);
f5016082f63d42 Eric S. Stone    2016-10-22  58  	/*
f5016082f63d42 Eric S. Stone    2016-10-22  59  	 * don't use pdev_resource[x].end - resource[x].start to
878336c3362d09 Stefan Wolz      2016-06-23  60  	 * calculate the resource size, it's only the maximum available
878336c3362d09 Stefan Wolz      2016-06-23  61  	 * size but not the actual size, using
3fcb465f1e74ef Elise Lennion    2016-10-13  62  	 * @ddk750_get_vm_size function can be safe.
878336c3362d09 Stefan Wolz      2016-06-23  63  	 */
3fcb465f1e74ef Elise Lennion    2016-10-13  64  	sm750_dev->vidmem_size = ddk750_get_vm_size();
81dee67e215b23 Sudip Mukherjee  2015-03-03  65  
81dee67e215b23 Sudip Mukherjee  2015-03-03  66  	/* reserve the vidmem space of smi adaptor */
f50b4602fea62f Jennifer Guo     2026-05-09  67  	sm750_dev->vmem =
fdc234d85210d9 Benjamin Philip  2021-07-28  68  		ioremap_wc(sm750_dev->vidmem_start, sm750_dev->vidmem_size);
f50b4602fea62f Jennifer Guo     2026-05-09  69  	if (!sm750_dev->vmem) {
e5448f8d2ec5b4 Artem Lytkin     2026-02-23  70  		dev_err(&pdev->dev, "Map video memory failed\n");
81dee67e215b23 Sudip Mukherjee  2015-03-03  71  		ret = -EFAULT;
8225489ddb9006 Artem Lytkin     2026-02-16  72  		goto err_unmap_reg;
81dee67e215b23 Sudip Mukherjee  2015-03-03  73  	}
8225489ddb9006 Artem Lytkin     2026-02-16  74  
8225489ddb9006 Artem Lytkin     2026-02-16  75  	return 0;
8225489ddb9006 Artem Lytkin     2026-02-16  76  
8225489ddb9006 Artem Lytkin     2026-02-16  77  err_unmap_reg:
8225489ddb9006 Artem Lytkin     2026-02-16  78  	iounmap(sm750_dev->pvReg);
8225489ddb9006 Artem Lytkin     2026-02-16  79  err_release_region:
8225489ddb9006 Artem Lytkin     2026-02-16  80  	pci_release_region(pdev, 1);
81dee67e215b23 Sudip Mukherjee  2015-03-03  81  	return ret;
81dee67e215b23 Sudip Mukherjee  2015-03-03  82  }
81dee67e215b23 Sudip Mukherjee  2015-03-03  83  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply

* Re: [PATCH] staging: sm750fb: fix CamelCase variables name in sm750
From: kernel test robot @ 2026-05-17  2:57 UTC (permalink / raw)
  To: Emmanuel Arias, sudipm.mukherjee, teddy.wang, gregkh
  Cc: oe-kbuild-all, linux-fbdev, linux-staging, linux-kernel,
	Emmanuel Arias
In-Reply-To: <20260516222613.1178800-1-eamanu@riseup.net>

Hi Emmanuel,

kernel test robot noticed the following build errors:

[auto build test ERROR on staging/staging-testing]

url:    https://github.com/intel-lab-lkp/linux/commits/Emmanuel-Arias/staging-sm750fb-fix-CamelCase-variables-name-in-sm750/20260517-062807
base:   staging/staging-testing
patch link:    https://lore.kernel.org/r/20260516222613.1178800-1-eamanu%40riseup.net
patch subject: [PATCH] staging: sm750fb: fix CamelCase variables name in sm750
config: parisc-randconfig-002-20260517 (https://download.01.org/0day-ci/archive/20260517/202605171049.KbaBnrJV-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260517/202605171049.KbaBnrJV-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605171049.KbaBnrJV-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/staging/sm750fb/sm750_hw.c: In function 'hw_sm750_map':
>> drivers/staging/sm750fb/sm750_hw.c:43:13: error: 'struct sm750_dev' has no member named 'pvReg'; did you mean 'pv_reg'?
     sm750_dev->pvReg =
                ^~~~~
                pv_reg
   drivers/staging/sm750fb/sm750_hw.c:45:18: error: 'struct sm750_dev' has no member named 'pvReg'; did you mean 'pv_reg'?
     if (!sm750_dev->pvReg) {
                     ^~~~~
                     pv_reg
   drivers/staging/sm750fb/sm750_hw.c:51:41: error: 'struct sm750_dev' has no member named 'pvReg'; did you mean 'pv_reg'?
     sm750_dev->accel.dpr_base = sm750_dev->pvReg + DE_BASE_ADDR_TYPE1;
                                            ^~~~~
                                            pv_reg
   drivers/staging/sm750fb/sm750_hw.c:52:45: error: 'struct sm750_dev' has no member named 'pvReg'; did you mean 'pv_reg'?
     sm750_dev->accel.dp_port_base = sm750_dev->pvReg + DE_PORT_ADDR_TYPE1;
                                                ^~~~~
                                                pv_reg
   drivers/staging/sm750fb/sm750_hw.c:54:23: error: 'struct sm750_dev' has no member named 'pvReg'; did you mean 'pv_reg'?
     mmio750 = sm750_dev->pvReg;
                          ^~~~~
                          pv_reg
   drivers/staging/sm750fb/sm750_hw.c:78:21: error: 'struct sm750_dev' has no member named 'pvReg'; did you mean 'pv_reg'?
     iounmap(sm750_dev->pvReg);
                        ^~~~~
                        pv_reg


vim +43 drivers/staging/sm750fb/sm750_hw.c

efe9bc08bf479b Elise Lennion    2016-10-11  27  
700591a9adc8b1 Mike Rapoport    2015-10-26  28  int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
81dee67e215b23 Sudip Mukherjee  2015-03-03  29  {
81dee67e215b23 Sudip Mukherjee  2015-03-03  30  	int ret;
81dee67e215b23 Sudip Mukherjee  2015-03-03  31  
e359b6a863e19f Mike Rapoport    2015-10-26  32  	sm750_dev->vidreg_start = pci_resource_start(pdev, 1);
e359b6a863e19f Mike Rapoport    2015-10-26  33  	sm750_dev->vidreg_size = SZ_2M;
81dee67e215b23 Sudip Mukherjee  2015-03-03  34  
8225489ddb9006 Artem Lytkin     2026-02-16  35  	/* reserve the vidreg space of smi adaptor */
9a52ae2dd8c24a Anatoly Stepanov 2015-06-29  36  	ret = pci_request_region(pdev, 1, "sm750fb");
9a52ae2dd8c24a Anatoly Stepanov 2015-06-29  37  	if (ret) {
e5448f8d2ec5b4 Artem Lytkin     2026-02-23  38  		dev_err(&pdev->dev, "Can not request PCI regions.\n");
8225489ddb9006 Artem Lytkin     2026-02-16  39  		return ret;
81dee67e215b23 Sudip Mukherjee  2015-03-03  40  	}
81dee67e215b23 Sudip Mukherjee  2015-03-03  41  
81dee67e215b23 Sudip Mukherjee  2015-03-03  42  	/* now map mmio and vidmem */
fdc234d85210d9 Benjamin Philip  2021-07-28 @43  	sm750_dev->pvReg =
fdc234d85210d9 Benjamin Philip  2021-07-28  44  		ioremap(sm750_dev->vidreg_start, sm750_dev->vidreg_size);
e359b6a863e19f Mike Rapoport    2015-10-26  45  	if (!sm750_dev->pvReg) {
e5448f8d2ec5b4 Artem Lytkin     2026-02-23  46  		dev_err(&pdev->dev, "mmio failed\n");
81dee67e215b23 Sudip Mukherjee  2015-03-03  47  		ret = -EFAULT;
8225489ddb9006 Artem Lytkin     2026-02-16  48  		goto err_release_region;
81dee67e215b23 Sudip Mukherjee  2015-03-03  49  	}
81dee67e215b23 Sudip Mukherjee  2015-03-03  50  
5865a858dbc9cb Yiming Qian      2025-09-09  51  	sm750_dev->accel.dpr_base = sm750_dev->pvReg + DE_BASE_ADDR_TYPE1;
5865a858dbc9cb Yiming Qian      2025-09-09  52  	sm750_dev->accel.dp_port_base = sm750_dev->pvReg + DE_PORT_ADDR_TYPE1;
81dee67e215b23 Sudip Mukherjee  2015-03-03  53  
efe9bc08bf479b Elise Lennion    2016-10-11  54  	mmio750 = sm750_dev->pvReg;
efe9bc08bf479b Elise Lennion    2016-10-11  55  	sm750_set_chip_type(sm750_dev->devid, sm750_dev->revid);
81dee67e215b23 Sudip Mukherjee  2015-03-03  56  
e359b6a863e19f Mike Rapoport    2015-10-26  57  	sm750_dev->vidmem_start = pci_resource_start(pdev, 0);
f5016082f63d42 Eric S. Stone    2016-10-22  58  	/*
f5016082f63d42 Eric S. Stone    2016-10-22  59  	 * don't use pdev_resource[x].end - resource[x].start to
878336c3362d09 Stefan Wolz      2016-06-23  60  	 * calculate the resource size, it's only the maximum available
878336c3362d09 Stefan Wolz      2016-06-23  61  	 * size but not the actual size, using
3fcb465f1e74ef Elise Lennion    2016-10-13  62  	 * @ddk750_get_vm_size function can be safe.
878336c3362d09 Stefan Wolz      2016-06-23  63  	 */
3fcb465f1e74ef Elise Lennion    2016-10-13  64  	sm750_dev->vidmem_size = ddk750_get_vm_size();
81dee67e215b23 Sudip Mukherjee  2015-03-03  65  
81dee67e215b23 Sudip Mukherjee  2015-03-03  66  	/* reserve the vidmem space of smi adaptor */
f50b4602fea62f Jennifer Guo     2026-05-09  67  	sm750_dev->vmem =
fdc234d85210d9 Benjamin Philip  2021-07-28  68  		ioremap_wc(sm750_dev->vidmem_start, sm750_dev->vidmem_size);
f50b4602fea62f Jennifer Guo     2026-05-09  69  	if (!sm750_dev->vmem) {
e5448f8d2ec5b4 Artem Lytkin     2026-02-23  70  		dev_err(&pdev->dev, "Map video memory failed\n");
81dee67e215b23 Sudip Mukherjee  2015-03-03  71  		ret = -EFAULT;
8225489ddb9006 Artem Lytkin     2026-02-16  72  		goto err_unmap_reg;
81dee67e215b23 Sudip Mukherjee  2015-03-03  73  	}
8225489ddb9006 Artem Lytkin     2026-02-16  74  
8225489ddb9006 Artem Lytkin     2026-02-16  75  	return 0;
8225489ddb9006 Artem Lytkin     2026-02-16  76  
8225489ddb9006 Artem Lytkin     2026-02-16  77  err_unmap_reg:
8225489ddb9006 Artem Lytkin     2026-02-16  78  	iounmap(sm750_dev->pvReg);
8225489ddb9006 Artem Lytkin     2026-02-16  79  err_release_region:
8225489ddb9006 Artem Lytkin     2026-02-16  80  	pci_release_region(pdev, 1);
81dee67e215b23 Sudip Mukherjee  2015-03-03  81  	return ret;
81dee67e215b23 Sudip Mukherjee  2015-03-03  82  }
81dee67e215b23 Sudip Mukherjee  2015-03-03  83  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply


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