linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	David Lechner <dlechner@baylibre.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Michael Hennerich <michael.hennerich@analog.com>,
	Antoniu Miclaus <antoniu.miclaus@analog.com>,
	Jinjie Ruan <ruanjinjie@huawei.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Basavaraj Natikar <Basavaraj.Natikar@amd.com>,
	linux-input@vger.kernel.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org, Jiri Kosina <jikos@kernel.org>,
	Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>
Subject: Re: [PATCH v1 14/22] iio: imu: st_lsm6dsx: Get platform data via dev_get_platdata()
Date: Tue, 3 Sep 2024 09:10:57 +0200	[thread overview]
Message-ID: <Zta2gaV_8qintFts@lore-rh-laptop> (raw)
In-Reply-To: <20240902222824.1145571-15-andy.shevchenko@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3263 bytes --]

> From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Access to platform data via dev_get_platdata() getter to make code cleaner.
> 
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index ed0267929725..3958b5e1a3f6 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -2132,14 +2132,11 @@ st_lsm6dsx_get_drdy_reg(struct st_lsm6dsx_hw *hw,
>  			const struct st_lsm6dsx_reg **drdy_reg)
>  {
>  	struct device *dev = hw->dev;
> +	const struct st_sensors_platform_data *pdata = dev_get_platdata(dev);

nit: I guess you can move pdata pointer in the 'if' block, since it is just
used there.

Regards,
Lorenzo

>  	int err = 0, drdy_pin;
>  
> -	if (device_property_read_u32(dev, "st,drdy-int-pin", &drdy_pin) < 0) {
> -		struct st_sensors_platform_data *pdata;
> -
> -		pdata = (struct st_sensors_platform_data *)dev->platform_data;
> +	if (device_property_read_u32(dev, "st,drdy-int-pin", &drdy_pin) < 0)
>  		drdy_pin = pdata ? pdata->drdy_int_pin : 1;
> -	}
>  
>  	switch (drdy_pin) {
>  	case 1:
> @@ -2162,14 +2159,13 @@ st_lsm6dsx_get_drdy_reg(struct st_lsm6dsx_hw *hw,
>  static int st_lsm6dsx_init_shub(struct st_lsm6dsx_hw *hw)
>  {
>  	const struct st_lsm6dsx_shub_settings *hub_settings;
> -	struct st_sensors_platform_data *pdata;
>  	struct device *dev = hw->dev;
> +	const struct st_sensors_platform_data *pdata = dev_get_platdata(dev);
>  	unsigned int data;
>  	int err = 0;
>  
>  	hub_settings = &hw->settings->shub_settings;
>  
> -	pdata = (struct st_sensors_platform_data *)dev->platform_data;
>  	if (device_property_read_bool(dev, "st,pullups") ||
>  	    (pdata && pdata->pullups)) {
>  		if (hub_settings->pullup_en.sec_page) {
> @@ -2524,9 +2520,9 @@ static irqreturn_t st_lsm6dsx_sw_trigger_handler_thread(int irq,
>  
>  static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw)
>  {
> -	struct st_sensors_platform_data *pdata;
>  	const struct st_lsm6dsx_reg *reg;
>  	struct device *dev = hw->dev;
> +	const struct st_sensors_platform_data *pdata = dev_get_platdata(dev);
>  	unsigned long irq_type;
>  	bool irq_active_low;
>  	int err;
> @@ -2554,7 +2550,6 @@ static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw)
>  	if (err < 0)
>  		return err;
>  
> -	pdata = (struct st_sensors_platform_data *)dev->platform_data;
>  	if (device_property_read_bool(dev, "drive-open-drain") ||
>  	    (pdata && pdata->open_drain)) {
>  		reg = &hw->settings->irq_config.od;
> @@ -2639,7 +2634,7 @@ static int st_lsm6dsx_init_regulators(struct device *dev)
>  int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
>  		     struct regmap *regmap)
>  {
> -	struct st_sensors_platform_data *pdata = dev->platform_data;
> +	const struct st_sensors_platform_data *pdata = dev_get_platdata(dev);
>  	const struct st_lsm6dsx_shub_settings *hub_settings;
>  	struct st_lsm6dsx_hw *hw;
>  	const char *name = NULL;
> -- 
> 2.46.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2024-09-03  7:11 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-02 22:16 [PATCH v1 00/22] iio: use dev_get_platdata() to access platform_data Andy Shevchenko
2024-09-02 22:16 ` [PATCH v1 01/22] iio: accel: hid-sensor-accel-3d: Get platform data via dev_get_platdata() Andy Shevchenko
2024-09-02 22:16 ` [PATCH v1 02/22] iio: adc: ad7266: " Andy Shevchenko
2024-09-02 22:16 ` [PATCH v1 03/22] iio: adc: ad7791: " Andy Shevchenko
2024-09-02 22:16 ` [PATCH v1 04/22] iio: adc: ad7887: " Andy Shevchenko
2024-09-02 22:16 ` [PATCH v1 05/22] iio: adc: ad7793: " Andy Shevchenko
2024-09-02 22:16 ` [PATCH v1 06/22] iio: adc: ltc2497: " Andy Shevchenko
2024-09-02 22:16 ` [PATCH v1 07/22] iio: dac: ad5504: " Andy Shevchenko
2024-09-02 22:16 ` [PATCH v1 08/22] iio: dac: ad5791: " Andy Shevchenko
2024-09-02 22:16 ` [PATCH v1 09/22] iio: dac: m62332: " Andy Shevchenko
2024-09-02 22:16 ` [PATCH v1 10/22] iio: dac: max517: " Andy Shevchenko
2024-09-03 19:47   ` Jonathan Cameron
2024-09-03 20:02     ` Andy Shevchenko
2024-09-02 22:16 ` [PATCH v1 11/22] iio: frequency: ad9523: " Andy Shevchenko
2024-09-02 22:16 ` [PATCH v1 12/22] iio: frequency: adf4350: " Andy Shevchenko
2024-09-02 22:16 ` [PATCH v1 13/22] iio: gyro: hid-sensor-gyro-3d: " Andy Shevchenko
2024-09-02 22:16 ` [PATCH v1 14/22] iio: imu: st_lsm6dsx: " Andy Shevchenko
2024-09-03  7:10   ` Lorenzo Bianconi [this message]
2024-09-03 10:38     ` Andy Shevchenko
2024-09-02 22:17 ` [PATCH v1 15/22] iio: light: hid-sensor-als: " Andy Shevchenko
2024-09-02 22:17 ` [PATCH v1 16/22] iio: light: hid-sensor-prox: " Andy Shevchenko
2024-09-02 22:17 ` [PATCH v1 17/22] iio: light: lm3533-als: " Andy Shevchenko
2024-09-03  6:33   ` Johan Hovold
2024-09-02 22:17 ` [PATCH v1 18/22] iio: magnetometer: hid-sensor-magn-3d: " Andy Shevchenko
2024-09-02 22:17 ` [PATCH v1 19/22] iio: orientation: hid-sensor-incl-3d: " Andy Shevchenko
2024-09-02 22:17 ` [PATCH v1 20/22] iio: orientation: hid-sensor-rotation: " Andy Shevchenko
2024-09-02 22:17 ` [PATCH v1 21/22] iio: position: hid-sensor-custom-intel-hinge: " Andy Shevchenko
2024-09-02 22:17 ` [PATCH v1 22/22] iio: pressure: hid-sensor-press: " Andy Shevchenko
2024-09-03 17:57 ` [PATCH v1 00/22] iio: use dev_get_platdata() to access platform_data Andy Shevchenko
2024-09-07 15:42   ` Jonathan Cameron
2024-09-09  9:17     ` Andy Shevchenko

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=Zta2gaV_8qintFts@lore-rh-laptop \
    --to=lorenzo@kernel.org \
    --cc=Basavaraj.Natikar@amd.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=antoniu.miclaus@analog.com \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=jikos@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    --cc=ruanjinjie@huawei.com \
    --cc=srinivas.pandruvada@linux.intel.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).