linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Svyatoslav Ryhel <clamor95@gmail.com>
Cc: "Lee Jones" <lee@kernel.org>,
	"Daniel Thompson" <danielt@kernel.org>,
	"Jingoo Han" <jingoohan1@gmail.com>,
	"Pavel Machek" <pavel@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"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
Subject: Re: [PATCH v5 08/14] mfd: lm3533: Convert to use OF bindings
Date: Fri, 31 Jul 2026 17:13:02 +0200	[thread overview]
Message-ID: <amy7fpjsUwZ9qJmF@hovoldconsulting.com> (raw)
In-Reply-To: <CAPVz0n2trouADTziWXnpt=-hwKdsZWGQib+-nVCLaSLibTbATg@mail.gmail.com>

On Tue, Jul 14, 2026 at 04:57:01PM +0300, Svyatoslav Ryhel wrote:
> пт, 3 лип. 2026 р. о 14:03 Johan Hovold <johan@kernel.org> пише:
> >
> > On Wed, Jun 17, 2026 at 11:00:25AM +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.
> > >
> > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > Reviewed-by: Daniel Thompson (RISCstar) <danielt@kernel.org> #for backlight
> > > ---
> > >  drivers/iio/light/lm3533-als.c      |  67 +++++---
> > >  drivers/leds/leds-lm3533.c          |  50 ++++--
> > >  drivers/mfd/lm3533-core.c           | 236 ++++++++++++----------------
> > >  drivers/mfd/lm3533-ctrlbank.c       |   5 -
> > >  drivers/video/backlight/lm3533_bl.c |  55 +++++--
> > >  include/linux/mfd/lm3533.h          |  52 +-----
> > >  6 files changed, 220 insertions(+), 245 deletions(-)
> >
> > >  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;
> > > @@ -803,12 +817,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;
> > > @@ -817,25 +825,27 @@ 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);
> >
> > Why are you reparenting the iio device here?
> >
> 
> Because every cell has its own binding now and using phandle to parent
> when device has its own node is not a good practice.
> 
> > That's an ABI break.
> >
> 
> This driver does not have any active users in the kernel and no
> activity for more then 2 years.

We have never required board files to be upstream.

And a working driver does not need to be changed every year.

In any case, something like this at a minimum needs to be highlighted in
the commit message.

> > > +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,
> >
> > You should also remove the platform module alias below.
> >
> 
> Why?

Because your change makes it obsolete. The driver now only supports OF
probing.

> > > @@ -680,15 +684,22 @@ 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);
> >
> > Here too you appear to be reparenting the class devices.
> >
> > >       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);
> >
> > This does not seem to be necessary.
> >
> 
> Agreed.
> 
> > >               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_MAX_CURRENT_MIN,
> > > +                              LM3533_MAX_CURRENT_MAX);
> >
> > Why clamp instead of having lm3533_led_setup() fail below?
> >
> 
> According to OF schema default lower margin is set to
> LM3533_MAX_CURRENT_MIN so clamping seems a good option here, even
> though it will clamp max value.

Just let it fail to probe. The driver already have the necessary checks.

> > > +
> > > +     device_property_read_u32(&pdev->dev, "ti,pwm-config-mask", &led->pwm);
> > > +
> > > +     ret = lm3533_led_setup(led);
> > >       if (ret)
> > >               goto err_deregister;
> > >
> > > @@ -725,9 +736,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,
> >
> > Remove platform alias below as well.
> >
> 
> Why?

Same reason as above.

> > >  static int lm3533_device_init(struct lm3533 *lm3533)
> > >  {
> > > -     struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
> > > +     struct device *dev = lm3533->dev;
> > > +     struct mfd_cell *lm3533_devices;
> > > +     u32 count = 0, reg, nchilds;
> >
> > Don't mix multiple declarations with initialisation like this.
> >
> 
> Checkpatch does not complain on style issue, hence this is not prohibited.

Checkpatch does not define good style.

> > >       int ret;
> > >
> > > -     dev_dbg(lm3533->dev, "%s\n", __func__);
> > > +     nchilds = device_get_child_node_count(dev);
> > > +     if (!nchilds || nchilds > LM3533_CELLS_MAX)
> > > +             return dev_err_probe(dev, -ENODEV,
> > > +                                  "num of child nodes is not supported\n");
> > >
> > > -     if (!pdata) {
> > > -             dev_err(lm3533->dev, "no platform data\n");
> > > -             return -EINVAL;
> > > -     }
> > > +     lm3533_devices = devm_kcalloc(dev, nchilds, sizeof(*lm3533_devices),
> > > +                                   GFP_KERNEL);
> > > +     if (!lm3533_devices)
> > > +             return -ENOMEM;
> > >
> > > -     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");
> > > +     device_for_each_child_node_scoped(dev, child) {
> > > +             if (count >= nchilds)
> > > +                     break;
> >
> > How could count be larger than nchilds?
> >
> 
> Only if the tree is malformed, hence this check was added.

But you've just retrieved nchilds by parsing the tree and counting the
child nodes. So how can count possibly be larger than nchilds here?

> > > +
> > > +             if (fwnode_device_is_compatible(child, "ti,lm3533-als")) {
> > > +                     lm3533_devices[count].name = "lm3533-als";
> > > +                     lm3533_devices[count].of_compatible = "ti,lm3533-als";
> > > +                     lm3533_devices[count].id = PLATFORM_DEVID_NONE;
> > > +
> > > +                     lm3533->have_als = true;
> > > +                     count++;
> > > +             } else 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 node %pfw\n", child);
> > > +                             continue;
> > > +                     }
> > > +
> > > +                     lm3533_devices[count].name = "lm3533-backlight";
> > > +                     lm3533_devices[count].of_compatible = "ti,lm3533-backlight";
> > > +                     lm3533_devices[count].id = reg;
> > > +                     lm3533_devices[count].of_reg = reg;
> > > +                     lm3533_devices[count].use_of_reg = true;
> > > +
> > > +                     lm3533->have_backlights = true;
> > > +                     count++;
> > > +             } else 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 node %pfw\n", child);
> > > +                             continue;
> > > +                     }
> > > +
> > > +                     lm3533_devices[count].name = "lm3533-leds";
> > > +                     lm3533_devices[count].of_compatible = "ti,lm3533-leds";
> > > +                     lm3533_devices[count].id = reg - LM3533_HVLED_ID_MAX;
> > > +                     lm3533_devices[count].of_reg = reg;
> > > +                     lm3533_devices[count].use_of_reg = true;
> > > +
> > > +                     lm3533->have_leds = true;
> > > +                     count++;
> > > +             }
> > > +     }
> >
> > Why do you need the above at all? Shouldn't you be able to just use
> > of_platform_populate().
> >
> 
> of_platform_populate() is not a part of mfd framework.

We have several MFD drivers using of_platform_populate().

> > >
> > >       lm3533_enable(lm3533);
> > >
> > >       ret = regmap_update_bits(lm3533->regmap, LM3533_REG_BOOST_PWM,
> > >                                LM3533_BOOST_FREQ_MASK,
> > > -                              pdata->boost_freq << LM3533_BOOST_FREQ_SHIFT);
> > > +                              lm3533->boost_freq << LM3533_BOOST_FREQ_SHIFT);
> > >       if (ret) {
> > > -             dev_err(lm3533->dev, "failed to set boost frequency\n");
> > > +             dev_err(dev, "failed to set boost frequency\n");
> > >               goto err_disable;
> > >       }
> > >
> > >       ret = regmap_update_bits(lm3533->regmap, LM3533_REG_BOOST_PWM,
> > >                                LM3533_BOOST_OVP_MASK,
> > > -                              pdata->boost_ovp << LM3533_BOOST_OVP_SHIFT);
> > > +                              lm3533->boost_ovp << LM3533_BOOST_OVP_SHIFT);
> > >       if (ret) {
> > > -             dev_err(lm3533->dev, "failed to set boost ovp\n");
> > > +             dev_err(dev, "failed to set boost ovp\n");
> > >               goto err_disable;
> > >       }
> > >
> > > -     lm3533_device_als_init(lm3533);
> > > -     lm3533_device_bl_init(lm3533);
> > > -     lm3533_device_led_init(lm3533);
> > > +     ret = mfd_add_devices(dev, 0, lm3533_devices, count, NULL, 0, NULL);
> > > +     if (ret) {
> > > +             dev_err(dev, "failed to add MFD devices: %d\n", ret);
> > > +             goto err_disable;
> > > +     }
> > >
> > >       return 0;
> > >
> > > @@ -504,7 +440,26 @@ 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");
> >
> > Please use brackets around multline statements for readability
> > throughout.
> >
> 
> Checkpatch does not complain on style issue, hence this is not prohibited.

Checkpatch is irrelevant.

> > > +
> > > +     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;
> >
> > Again, why clamp instead of failing probe?
> >
> 
> According to OF schema default lower margin is set to
> LM3533_BOOST_FREQ_MIN so clamping seems a good option here, even
> though it will clamp max value.

Just let the driver fail to probe as the sanity checks are already
there.

> > >       return lm3533_device_init(lm3533);
> > >  }
> > > @@ -518,6 +473,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" },
> > >       { }

Shouldn't you drop i2c probing now as well?

> > > @@ -528,6 +489,7 @@ static struct i2c_driver lm3533_i2c_driver = {
> > >       .driver = {
> > >                  .name = "lm3533",
> > >                  .dev_groups = lm3533_attribute_groups,
> > > +                .of_match_table = lm3533_match_table,
> > >       },
> > >       .id_table       = lm3533_i2c_ids,
> > >       .probe          = lm3533_i2c_probe,

Johan

  parent reply	other threads:[~2026-07-31 15:13 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-17  8:00 [PATCH v5 00/14] mfd: lm3533: convert to OF bindings, improve support Svyatoslav Ryhel
2026-06-17  8:00 ` [PATCH v5 01/14] dt-bindings: leds: Document TI LM3533 LED controller Svyatoslav Ryhel
2026-07-03  9:49   ` Johan Hovold
2026-07-14 13:27     ` Svyatoslav Ryhel
2026-07-31 14:39       ` Johan Hovold
2026-06-17  8:00 ` [PATCH v5 02/14] mfd: lm3533: Remove driver specific regmap wrappers Svyatoslav Ryhel
2026-06-17 10:32   ` Andy Shevchenko
2026-07-02 16:12     ` Lee Jones
2026-07-03  9:44   ` Johan Hovold
2026-07-14 13:26     ` Svyatoslav Ryhel
2026-07-31 14:38       ` Johan Hovold
2026-06-17  8:00 ` [PATCH v5 03/14] mfd: lm3533: Remove extern from shared functions in the header Svyatoslav Ryhel
2026-06-17  8:00 ` [PATCH v5 04/14] mfd: lm3533: Pass only regmap and light sensor presence to child devices Svyatoslav Ryhel
2026-07-03  9:50   ` Johan Hovold
2026-07-14 13:28     ` Svyatoslav Ryhel
2026-07-31 14:43       ` Johan Hovold
2026-06-17  8:00 ` [PATCH v5 05/14] iio: light: lm3533-als: Remove redundant pdata helpers Svyatoslav Ryhel
2026-07-03  0:57   ` Jonathan Cameron
2026-07-03  9:55   ` Johan Hovold
2026-07-14 13:31     ` Svyatoslav Ryhel
2026-07-31 14:46       ` Johan Hovold
2026-06-17  8:00 ` [PATCH v5 06/14] mfd: lm3533-core: " Svyatoslav Ryhel
2026-07-03  9:57   ` Johan Hovold
2026-07-14 13:32     ` Svyatoslav Ryhel
2026-07-31 14:54       ` Johan Hovold
2026-07-22  1:25   ` Jonathan Cameron
2026-07-27  8:22     ` Svyatoslav Ryhel
2026-06-17  8:00 ` [PATCH v5 07/14] mfd: lm3533: Use dev_groups in struct device_driver Svyatoslav Ryhel
2026-06-25  7:23   ` Andy Shevchenko
2026-06-25  7:26     ` Andy Shevchenko
2026-07-03 10:11   ` Johan Hovold
2026-06-17  8:00 ` [PATCH v5 08/14] mfd: lm3533: Convert to use OF bindings Svyatoslav Ryhel
2026-07-03 11:03   ` Johan Hovold
2026-07-14 13:57     ` Svyatoslav Ryhel
2026-07-22  1:30       ` Jonathan Cameron
2026-07-27  8:24         ` Svyatoslav Ryhel
2026-07-31 15:13       ` Johan Hovold [this message]
2026-06-17  8:00 ` [PATCH v5 09/14] mfd: lm3533: Add support for VIN power supply Svyatoslav Ryhel
2026-07-03 11:09   ` Johan Hovold
2026-07-14 14:00     ` Svyatoslav Ryhel
2026-06-17  8:00 ` [PATCH v5 10/14] mfd: lm3533: Set DMA mask Svyatoslav Ryhel
2026-07-03 11:18   ` Johan Hovold
2026-06-17  8:00 ` [PATCH v5 11/14] video: backlight: lm3533_bl: Improve logic of sysfs functions Svyatoslav Ryhel
2026-06-17  8:00 ` [PATCH v5 12/14] video: backlight: lm3533_bl: Set initial mapping mode from DT Svyatoslav Ryhel
2026-06-17  8:00 ` [PATCH v5 13/14] video: backlight: lm3533_bl: Implement backlight_scale property Svyatoslav Ryhel
2026-06-17  8:00 ` [PATCH v5 14/14] video: leds: backlight: lm3533: Support getting LED sources from DT Svyatoslav Ryhel
2026-06-24 10:04   ` Daniel Thompson
2026-07-02 16:18 ` [PATCH v5 00/14] mfd: lm3533: convert to OF bindings, improve support Lee Jones
2026-07-03  8:50   ` 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=amy7fpjsUwZ9qJmF@hovoldconsulting.com \
    --to=johan@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=lee@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;
as well as URLs for NNTP newsgroup(s).