Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Biju Das <biju.das.jz@bp.renesas.com>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	linux-iio@vger.kernel.org,
	"Geert Uytterhoeven" <geert+renesas@glider.be>,
	"Prabhakar Mahadev Lad" <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	linux-renesas-soc@vger.kernel.org,
	"Matt Ranostay" <matt.ranostay@konsulko.com>
Subject: Re: [PATCH v2] iio: chemical: atlas-sensor: Convert enum->pointer for data in the match tables
Date: Mon, 28 Aug 2023 12:42:16 +0100	[thread overview]
Message-ID: <20230828124216.6ef6d056@jic23-huawei> (raw)
In-Reply-To: <20230818185531.336672-1-biju.das.jz@bp.renesas.com>

On Fri, 18 Aug 2023 19:55:31 +0100
Biju Das <biju.das.jz@bp.renesas.com> wrote:

> Convert enum->pointer for data in the match tables, so that
> device_get_match_data() can do match against OF/ACPI/I2C tables, once i2c
> bus type match support added to it.
> 
> Replace enum->struct *atlas_device for data in the match table. Simplify
> the probe() by replacing device_get_match_data() and ID lookup for
> retrieving data by i2c_get_match_data().
> 
> While at it, add const qualifier to struct atlas_device and drop inner
> trailing commas from OF table.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

+CC Matt

Looks good to me so applied to the togreg branch of iio.git but as with the
other patches, there is plenty of time for others to comment before
I push those out as non rebasing.

Thanks,

Jonathan

> ---
> v1->v2:
>  * Added Rb tag from Andy
>  * Dropped id variable removal sentance from commit description
>  * Dropped inner trailing commas from commit description.
> ---
>  drivers/iio/chemical/atlas-sensor.c | 32 +++++++++++++----------------
>  1 file changed, 14 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
> index fb15bb216019..baf93e5e3ca7 100644
> --- a/drivers/iio/chemical/atlas-sensor.c
> +++ b/drivers/iio/chemical/atlas-sensor.c
> @@ -87,7 +87,7 @@ enum {
>  struct atlas_data {
>  	struct i2c_client *client;
>  	struct iio_trigger *trig;
> -	struct atlas_device *chip;
> +	const struct atlas_device *chip;
>  	struct regmap *regmap;
>  	struct irq_work work;
>  	unsigned int interrupt_enabled;
> @@ -353,7 +353,7 @@ struct atlas_device {
>  	int delay;
>  };
>  
> -static struct atlas_device atlas_devices[] = {
> +static const struct atlas_device atlas_devices[] = {
>  	[ATLAS_PH_SM] = {
>  				.channels = atlas_ph_channels,
>  				.num_channels = 3,
> @@ -589,30 +589,29 @@ static const struct iio_info atlas_info = {
>  };
>  
>  static const struct i2c_device_id atlas_id[] = {
> -	{ "atlas-ph-sm", ATLAS_PH_SM },
> -	{ "atlas-ec-sm", ATLAS_EC_SM },
> -	{ "atlas-orp-sm", ATLAS_ORP_SM },
> -	{ "atlas-do-sm", ATLAS_DO_SM },
> -	{ "atlas-rtd-sm", ATLAS_RTD_SM },
> +	{ "atlas-ph-sm", (kernel_ulong_t)&atlas_devices[ATLAS_PH_SM] },
> +	{ "atlas-ec-sm", (kernel_ulong_t)&atlas_devices[ATLAS_EC_SM] },
> +	{ "atlas-orp-sm", (kernel_ulong_t)&atlas_devices[ATLAS_ORP_SM] },
> +	{ "atlas-do-sm", (kernel_ulong_t)&atlas_devices[ATLAS_DO_SM] },
> +	{ "atlas-rtd-sm", (kernel_ulong_t)&atlas_devices[ATLAS_RTD_SM] },
>  	{}
>  };
>  MODULE_DEVICE_TABLE(i2c, atlas_id);
>  
>  static const struct of_device_id atlas_dt_ids[] = {
> -	{ .compatible = "atlas,ph-sm", .data = (void *)ATLAS_PH_SM, },
> -	{ .compatible = "atlas,ec-sm", .data = (void *)ATLAS_EC_SM, },
> -	{ .compatible = "atlas,orp-sm", .data = (void *)ATLAS_ORP_SM, },
> -	{ .compatible = "atlas,do-sm", .data = (void *)ATLAS_DO_SM, },
> -	{ .compatible = "atlas,rtd-sm", .data = (void *)ATLAS_RTD_SM, },
> +	{ .compatible = "atlas,ph-sm", .data = &atlas_devices[ATLAS_PH_SM] },
> +	{ .compatible = "atlas,ec-sm", .data = &atlas_devices[ATLAS_EC_SM] },
> +	{ .compatible = "atlas,orp-sm", .data = &atlas_devices[ATLAS_ORP_SM] },
> +	{ .compatible = "atlas,do-sm", .data = &atlas_devices[ATLAS_DO_SM] },
> +	{ .compatible = "atlas,rtd-sm", .data = &atlas_devices[ATLAS_RTD_SM] },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, atlas_dt_ids);
>  
>  static int atlas_probe(struct i2c_client *client)
>  {
> -	const struct i2c_device_id *id = i2c_client_get_device_id(client);
>  	struct atlas_data *data;
> -	struct atlas_device *chip;
> +	const struct atlas_device *chip;
>  	struct iio_trigger *trig;
>  	struct iio_dev *indio_dev;
>  	int ret;
> @@ -621,10 +620,7 @@ static int atlas_probe(struct i2c_client *client)
>  	if (!indio_dev)
>  		return -ENOMEM;
>  
> -	if (!dev_fwnode(&client->dev))
> -		chip = &atlas_devices[id->driver_data];
> -	else
> -		chip = &atlas_devices[(unsigned long)device_get_match_data(&client->dev)];
> +	chip = i2c_get_match_data(client);
>  
>  	indio_dev->info = &atlas_info;
>  	indio_dev->name = ATLAS_DRV_NAME;


      reply	other threads:[~2023-08-28 11:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18 18:55 [PATCH v2] iio: chemical: atlas-sensor: Convert enum->pointer for data in the match tables Biju Das
2023-08-28 11:42 ` Jonathan Cameron [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=20230828124216.6ef6d056@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=geert+renesas@glider.be \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=matt.ranostay@konsulko.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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