devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Svyatoslav Ryhel <clamor95@gmail.com>
Cc: "Lee Jones" <lee@kernel.org>, "Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Pavel Machek" <pavel@ucw.cz>,
	"Daniel Thompson" <danielt@kernel.org>,
	"Jingoo Han" <jingoohan1@gmail.com>,
	"Helge Deller" <deller@gmx.de>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-iio@vger.kernel.org, linux-leds@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org
Subject: Re: [PATCH v2 2/2] mfd: lm3533: convert to use OF
Date: Wed, 19 Feb 2025 16:26:49 +0200	[thread overview]
Message-ID: <Z7XqKcOUt5niXzpv@smile.fi.intel.com> (raw)
In-Reply-To: <20250218132702.114669-3-clamor95@gmail.com>

On Tue, Feb 18, 2025 at 03:27:00PM +0200, Svyatoslav Ryhel wrote:
> Remove platform data and fully relay on OF and device tree
> parsing and binding devices.

Thanks for following the advice, but the problem with this change as it does
too much at once. It should be split to a few simpler ones.
On top of that, this removes MFD participation from the driver but leaves it
under MFD realm. Moreover, looking briefly at the code it looks like it open
codes the parts of MFD. The latter needs a very goo justification which commit
message is missing.

...

> +static const struct of_device_id lm3533_als_match_table[] = {
> +	{ .compatible = "ti,lm3533-als" },
> +	{ },

No comma for the terminator entry. I think I already pointed that out earlier.

> +};

...

> +	device_property_read_string(&pdev->dev, "linux,default-trigger",
> +				    &led->cdev.default_trigger);

One prerequisite patch you probably want is an introduction of

	struct device *dev = &pdev->dev;

in the respective ->probe() implementations. This, in particular, makes the
above lines shorter and fit one line.

...

> +static const struct of_device_id lm3533_led_match_table[] = {
> +	{ .compatible = "ti,lm3533-leds" },
> +	{ },

As per above.

> +};

...

> +		if (!strcmp(comatible, "ti,lm3533-als"))
> +			lm3533->have_als = 1;

If you end up having this, it's not the best what we can do. OF ID tables have
a driver_data field exactly for the cases like this.

...

> +		if (!strcmp(comatible, "ti,lm3533-backlight"))
> +			lm3533->have_backlights = 1;

Ditto.

...

> +		if (!strcmp(comatible, "ti,lm3533-leds"))
> +			lm3533->have_leds = 1;

Ditto.

...

> +		ret = lm3533_update(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF,
> +				    1 << (2 * id + 1), 1 << (2 * id + 1));

BIT() and better to use a temporary variable for this calculation.

> +		if (ret)
> +			return ret;

...

> +		ret = lm3533_update(bl->lm3533, LM3533_REG_OUTPUT_CONF1,
> +				    id | id << 1, BIT(0) | BIT(1));

		mask = GENMASK();
		..., id ? mask : 0, mask);

> +		if (ret)
> +			return ret;
> +	}

...

> +	bd = devm_backlight_device_register(&pdev->dev, pdev->name, pdev->dev.parent,
> +					    bl, &lm3533_bl_ops, &props);


With the advice from above:

	bd = devm_backlight_device_register(dev, pdev->name, dev->parent, bl, &lm3533_bl_ops,
					    &props);


>  	if (IS_ERR(bd)) {
>  		dev_err(&pdev->dev, "failed to register backlight device\n");
>  		return PTR_ERR(bd);

Consider another prerequisite patch (which should come before the firstly
proposed one):

	struct device *dev = &pdev->dev; // yes, this can go in this change
	...

	if (IS_ERR(bd))
		return dev_err_probe(dev, PTR_ERR(bd), "failed to register backlight device\n");

...

> +static const struct of_device_id lm3533_bl_match_table[] = {
> +	{ .compatible = "ti,lm3533-backlight" },
> +	{ },

As per above.

> +};

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-02-19 14:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18 13:26 [PATCH v2 0/2] mfd: lm3533: convert to use OF Svyatoslav Ryhel
2025-02-18 13:26 ` [PATCH v2 1/2] dt-bindings: mfd: Document TI LM3533 MFD Svyatoslav Ryhel
2025-02-21 20:38   ` Rob Herring
2025-02-22  7:01     ` Svyatoslav Ryhel
2025-02-22 14:26       ` Jonathan Cameron
2025-02-22 14:29   ` Jonathan Cameron
2025-02-22 14:39     ` Svyatoslav Ryhel
2025-02-22 17:27       ` Jonathan Cameron
2025-02-18 13:27 ` [PATCH v2 2/2] mfd: lm3533: convert to use OF Svyatoslav Ryhel
2025-02-19 14:26   ` Andy Shevchenko [this message]
2025-02-19 14:36     ` Svyatoslav Ryhel
2025-02-19 15:06       ` Andy Shevchenko
2025-02-19 15:13         ` Svyatoslav Ryhel
2025-02-19 15:23           ` Andy Shevchenko
2025-02-19 17:39             ` Svyatoslav Ryhel
2025-02-19 20:18               ` Andy Shevchenko
2025-02-19 16:02   ` kernel test robot
2025-02-19 20:20     ` Andy Shevchenko
2025-02-19 23:51   ` kernel test robot

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=Z7XqKcOUt5niXzpv@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=clamor95@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=danielt@kernel.org \
    --cc=deller@gmx.de \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jic23@kernel.org \
    --cc=jingoohan1@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --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=pavel@ucw.cz \
    --cc=robh@kernel.org \
    --cc=u.kleine-koenig@baylibre.com \
    /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).