Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Kai-Heng Feng <kai.heng.feng@canonical.com>
Subject: Re: [PATCH v2 4/8] iio: accel: adxl345: Make use of device properties
Date: Sat, 26 Feb 2022 19:05:58 +0000	[thread overview]
Message-ID: <20220226190558.6a05ef7c@jic23-huawei> (raw)
In-Reply-To: <20220222090009.2060-4-andriy.shevchenko@linux.intel.com>

On Tue, 22 Feb 2022 11:00:05 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Convert the module to be property provider agnostic and allow
> it to be used on non-OF platforms.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> v2: no changes
>  drivers/iio/accel/adxl345.h      |  2 +-
>  drivers/iio/accel/adxl345_core.c |  5 ++++-
>  drivers/iio/accel/adxl345_i2c.c  | 11 ++++-------
>  drivers/iio/accel/adxl345_spi.c  |  3 +--
>  4 files changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/iio/accel/adxl345.h b/drivers/iio/accel/adxl345.h
> index 9b0d4f487c43..d7e67cb08538 100644
> --- a/drivers/iio/accel/adxl345.h
> +++ b/drivers/iio/accel/adxl345.h
> @@ -13,6 +13,6 @@ enum adxl345_device_type {
>  	ADXL375 = 2,
>  };
>  
> -int adxl345_core_probe(struct device *dev, struct regmap *regmap, enum adxl345_device_type type);
> +int adxl345_core_probe(struct device *dev, struct regmap *regmap);

Ah! They shorten again :)

Temporary long ugly lines is of course fine so I'll leave them be.

Jonathan

>  
>  #endif /* _ADXL345_H_ */
> diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
> index 0f34c349aa1e..315a408115b3 100644
> --- a/drivers/iio/accel/adxl345_core.c
> +++ b/drivers/iio/accel/adxl345_core.c
> @@ -8,6 +8,7 @@
>   */
>  
>  #include <linux/module.h>
> +#include <linux/property.h>
>  #include <linux/regmap.h>
>  
>  #include <linux/iio/iio.h>
> @@ -213,14 +214,16 @@ static void adxl345_powerdown(void *regmap)
>  	regmap_write(regmap, ADXL345_REG_POWER_CTL, ADXL345_POWER_CTL_STANDBY);
>  }
>  
> -int adxl345_core_probe(struct device *dev, struct regmap *regmap, enum adxl345_device_type type)
> +int adxl345_core_probe(struct device *dev, struct regmap *regmap)
>  {
> +	enum adxl345_device_type type;
>  	struct adxl345_data *data;
>  	struct iio_dev *indio_dev;
>  	const char *name;
>  	u32 regval;
>  	int ret;
>  
> +	type = (uintptr_t)device_get_match_data(dev);
>  	switch (type) {
>  	case ADXL345:
>  		name = "adxl345";
> diff --git a/drivers/iio/accel/adxl345_i2c.c b/drivers/iio/accel/adxl345_i2c.c
> index 1e42cf3a2991..861d8477d799 100644
> --- a/drivers/iio/accel/adxl345_i2c.c
> +++ b/drivers/iio/accel/adxl345_i2c.c
> @@ -19,19 +19,16 @@ static const struct regmap_config adxl345_i2c_regmap_config = {
>  	.val_bits = 8,
>  };
>  
> -static int adxl345_i2c_probe(struct i2c_client *client,
> -			     const struct i2c_device_id *id)
> +static int adxl345_i2c_probe(struct i2c_client *client)
>  {
> +	enum adxl345_device_type type;
>  	struct regmap *regmap;
>  
> -	if (!id)
> -		return -ENODEV;
> -
>  	regmap = devm_regmap_init_i2c(client, &adxl345_i2c_regmap_config);
>  	if (IS_ERR(regmap))
>  		return dev_err_probe(&client->dev, PTR_ERR(regmap), "Error initializing regmap\n");
>  
> -	return adxl345_core_probe(&client->dev, regmap, id->driver_data);
> +	return adxl345_core_probe(&client->dev, regmap);
>  }
>  
>  static const struct i2c_device_id adxl345_i2c_id[] = {
> @@ -55,7 +52,7 @@ static struct i2c_driver adxl345_i2c_driver = {
>  		.name	= "adxl345_i2c",
>  		.of_match_table = adxl345_of_match,
>  	},
> -	.probe		= adxl345_i2c_probe,
> +	.probe_new	= adxl345_i2c_probe,
>  	.id_table	= adxl345_i2c_id,
>  };
>  
> diff --git a/drivers/iio/accel/adxl345_spi.c b/drivers/iio/accel/adxl345_spi.c
> index 34b7001d519f..ee4c50c8a95b 100644
> --- a/drivers/iio/accel/adxl345_spi.c
> +++ b/drivers/iio/accel/adxl345_spi.c
> @@ -22,7 +22,6 @@ static const struct regmap_config adxl345_spi_regmap_config = {
>  
>  static int adxl345_spi_probe(struct spi_device *spi)
>  {
> -	const struct spi_device_id *id = spi_get_device_id(spi);
>  	struct regmap *regmap;
>  
>  	/* Bail out if max_speed_hz exceeds 5 MHz */
> @@ -34,7 +33,7 @@ static int adxl345_spi_probe(struct spi_device *spi)
>  	if (IS_ERR(regmap))
>  		return dev_err_probe(&spi->dev, PTR_ERR(regmap), "Error initializing regmap\n");
>  
> -	return adxl345_core_probe(&spi->dev, regmap, id->driver_data);
> +	return adxl345_core_probe(&spi->dev, regmap);
>  }
>  
>  static const struct spi_device_id adxl345_spi_id[] = {


  reply	other threads:[~2022-02-26 18:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22  9:00 [PATCH v2 1/8] iio: accel: adxl345: Convert to use dev_err_probe() Andy Shevchenko
2022-02-22  9:00 ` [PATCH v2 2/8] iio: accel: adxl345: Set driver_data for OF enumeration Andy Shevchenko
2022-02-22  9:00 ` [PATCH v2 3/8] iio: accel: adxl345: Get rid of name parameter in adxl345_core_probe() Andy Shevchenko
2022-02-26 18:54   ` Jonathan Cameron
2022-02-22  9:00 ` [PATCH v2 4/8] iio: accel: adxl345: Make use of device properties Andy Shevchenko
2022-02-26 19:05   ` Jonathan Cameron [this message]
2022-02-27 11:22   ` Jonathan Cameron
2022-02-22  9:00 ` [PATCH v2 5/8] iio: accel: adxl345: Add ACPI HID table Andy Shevchenko
2022-02-22  9:00 ` [PATCH v2 6/8] iio: accel: adxl345: Extract adxl345_powerup() helper Andy Shevchenko
2022-02-22  9:00 ` [PATCH v2 7/8] iio: accel: adxl345: Drop comma in terminator entries Andy Shevchenko
2022-02-22  9:00 ` [PATCH v2 8/8] iio: accel: adxl345: Remove unneeded blank lines Andy Shevchenko
2022-02-23  3:10 ` [PATCH v2 1/8] iio: accel: adxl345: Convert to use dev_err_probe() Kai-Heng Feng
2022-02-26 19:12   ` Jonathan Cameron

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=20220226190558.6a05ef7c@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=kai.heng.feng@canonical.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.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