mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: development@redaril.me
Cc: "Peter Rosin" <peda@lysator.liu.se>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: afe: iio-rescale: Add platform IDs
Date: Tue, 13 Oct 2026 23:50:53 +0300	[thread overview]
Message-ID: <as6ZrXFDWKLqPPvn@ashevche-desk.local> (raw)
In-Reply-To: <20261008-iio_rescale_platform_ids-v1-1-019f1c144022@redaril.me>

On Thu, Oct 08, 2026 at 11:27:59PM +0200, Fabio Forni via B4 Relay wrote:

> When a rescaler is probed starting from a `struct swnode`,

How? Pure platform devices can't be probed from struct swnode.

> device_get_match_data() will always set rescale->cfg to NULL,
> because device_get_match_data() is unimplemented for software nodes.
> 
> This commit makes the probe function fall back to platform IDs when

Read Submitting Patches documentation on imperative mode (search for
'This patch').

> it couldn't fetch the rescaler configuration from the match table.

...

> +static const struct platform_device_id rescale_platform_ids[] = {
> +	{ .name = "current-sense-amplifier",
> +	  .driver_data = CURRENT_SENSE_AMPLIFIER, },

Drop trailing inner commas and make these one-liners (yes, long ones).

	{ .name = "current-sense-amplifier", .driver_data = CURRENT_SENSE_AMPLIFIER },

> +	{ .name = "current-sense-shunt",
> +	  .driver_data = CURRENT_SENSE_SHUNT, },
> +	{ .name = "voltage-divider",
> +	  .driver_data = VOLTAGE_DIVIDER, },
> +	{ .name = "temperature-sense-rtd",
> +	  .driver_data = TEMP_SENSE_RTD, },
> +	{ .name = "temperature-transducer",
> +	  .driver_data = TEMP_TRANSDUCER, },
> +	{ }
> +};


>  static int rescale_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct iio_dev *indio_dev;
>  	struct iio_channel *source;
>  	struct rescale *rescale;
> +	const struct platform_device_id *id;

Keep reversed xmas tree order, please.

>  	int sizeof_ext_info;
>  	int sizeof_priv;
>  	int i;

...

>  	rescale->cfg = device_get_match_data(dev);
> +	if (!rescale->cfg) {
> +		id = platform_get_device_id(pdev);
> +		if (!id)
> +			return dev_err_probe(dev,
> +					     -EINVAL,

ENODATA

> +					     "missing or invalid device configuration");
> +
> +		rescale->cfg = &rescale_cfg[id->driver_data];
> +	}

And it's better to make it a helper, actually we have drivers [1] that do
something similar, I would recommend you considering adding that helper
directly into platform driver core. But at least local one is a good start.

[1] for example, drivers/pinctrl/intel/pinctrl-intel.c.

-- 
With Best Regards,
Andy Shevchenko



      reply	other threads:[~2026-10-13 20:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08 21:27 Fabio Forni via B4 Relay
2026-10-13 20:50 ` Andy Shevchenko [this message]

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=as6ZrXFDWKLqPPvn@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=development@redaril.me \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=peda@lysator.liu.se \
    /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

all inboxes | Powered by JetHome®