Devicetree
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Svyatoslav Ryhel <clamor95@gmail.com>
Cc: "Daniel Thompson" <danielt@kernel.org>,
	"Jingoo Han" <jingoohan1@gmail.com>,
	"Rob Herring" <robh@kernel.org>,
	"Pavel Machek" <pavel@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Nuno Sá" <nuno.sa@analog.com>, "Helge Deller" <deller@gmx.de>,
	dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-iio@vger.kernel.org, linux-fbdev@vger.kernel.org,
	"Andy Shevchenko" <andy@kernel.org>
Subject: Re: [PATCH v1 2/6] mfd: lm3533: Convert to use OF bindings
Date: Mon, 18 May 2026 10:28:33 +0100	[thread overview]
Message-ID: <20260518092833.GR305027@google.com> (raw)
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

  reply	other threads:[~2026-05-18  9:28 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-17  7:43 [PATCH v1 0/6] mfd: lm3533: convert to OF bindings, improve support Svyatoslav Ryhel
2026-05-17  7:43 ` [PATCH v1 1/6] dt-bindings: leds: Document TI LM3533 LED controller Svyatoslav Ryhel
2026-05-17  7:58   ` sashiko-bot
2026-05-17 13:44   ` Jonathan Cameron
2026-05-17 14:26     ` Svyatoslav Ryhel
2026-05-17  7:43 ` [PATCH v1 2/6] mfd: lm3533: Convert to use OF bindings Svyatoslav Ryhel
2026-05-17  7:55   ` Andy Shevchenko
2026-05-17 10:11     ` Svyatoslav Ryhel
2026-05-17  8:32   ` sashiko-bot
2026-05-17 11:10   ` Svyatoslav Ryhel
2026-05-18  9:28     ` Lee Jones [this message]
2026-05-18  9:51       ` Svyatoslav Ryhel
2026-05-17  7:43 ` [PATCH v1 3/6] mfd: lm3533: Add support for VIN power supply Svyatoslav Ryhel
2026-05-17  8:47   ` sashiko-bot
2026-05-17  7:43 ` [PATCH v1 4/6] mfd: lm3533: set DMA mask Svyatoslav Ryhel
2026-05-17  9:09   ` sashiko-bot
2026-05-17  7:43 ` [PATCH v1 5/6] video: backlight: lm3533_bl: Set initial mapping mode from DT Svyatoslav Ryhel
2026-05-17  9:28   ` sashiko-bot
2026-05-17  7:43 ` [PATCH v1 6/6] video: leds: backlight: lm3533: Support getting LED sources " Svyatoslav Ryhel
2026-05-17  9:45   ` sashiko-bot
2026-05-17  7:59 ` [PATCH v1 0/6] mfd: lm3533: convert to OF bindings, improve support Andy Shevchenko
2026-05-17 10:13   ` Svyatoslav Ryhel
2026-05-17 10:20     ` Andy Shevchenko
2026-05-17 10:34       ` Svyatoslav Ryhel
2026-05-17 10:40         ` Andy Shevchenko
2026-05-17 10:44           ` Svyatoslav Ryhel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260518092833.GR305027@google.com \
    --to=lee@kernel.org \
    --cc=andy@kernel.org \
    --cc=clamor95@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=danielt@kernel.org \
    --cc=deller@gmx.de \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jic23@kernel.org \
    --cc=jingoohan1@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=pavel@kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox