From: Jonathan Cameron <jic23@kernel.org>
To: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: linux-iio@vger.kernel.org, lorenzo.bianconi@redhat.com
Subject: Re: [PATCH] iio: imu: st_lsm6dsx: introduce st_lsm6dsx_device_set_enable routine
Date: Sat, 15 Oct 2022 16:47:03 +0100 [thread overview]
Message-ID: <20221015164703.11ea5783@jic23-huawei> (raw)
In-Reply-To: <e3fbe5d4a3bed41130908669f745f78c8505cf47.1665399959.git.lorenzo@kernel.org>
On Mon, 10 Oct 2022 13:07:26 +0200
Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> Introduce st_lsm6dsx_device_set_enable utility routine and remove
> duplicated code used to enable/disable sensors
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Applied, thanks,
> ---
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 11 +++++++++++
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 14 +++-----------
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 14 ++------------
> 3 files changed, 16 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index 6b57d47be69e..d3a4e21bc114 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -509,6 +509,17 @@ st_lsm6dsx_get_mount_matrix(const struct iio_dev *iio_dev,
> return &hw->orientation;
> }
>
> +static inline int
> +st_lsm6dsx_device_set_enable(struct st_lsm6dsx_sensor *sensor, bool enable)
> +{
> + if (sensor->id == ST_LSM6DSX_ID_EXT0 ||
> + sensor->id == ST_LSM6DSX_ID_EXT1 ||
> + sensor->id == ST_LSM6DSX_ID_EXT2)
> + return st_lsm6dsx_shub_set_enable(sensor, enable);
> +
> + return st_lsm6dsx_sensor_set_enable(sensor, enable);
> +}
> +
> static const
> struct iio_chan_spec_ext_info __maybe_unused st_lsm6dsx_accel_ext_info[] = {
> IIO_MOUNT_MATRIX(IIO_SHARED_BY_ALL, st_lsm6dsx_get_mount_matrix),
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> index e49f2d120ed3..48fe6a45671b 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> @@ -673,17 +673,9 @@ int st_lsm6dsx_update_fifo(struct st_lsm6dsx_sensor *sensor, bool enable)
> goto out;
> }
>
> - if (sensor->id == ST_LSM6DSX_ID_EXT0 ||
> - sensor->id == ST_LSM6DSX_ID_EXT1 ||
> - sensor->id == ST_LSM6DSX_ID_EXT2) {
> - err = st_lsm6dsx_shub_set_enable(sensor, enable);
> - if (err < 0)
> - goto out;
> - } else {
> - err = st_lsm6dsx_sensor_set_enable(sensor, enable);
> - if (err < 0)
> - goto out;
> - }
> + err = st_lsm6dsx_device_set_enable(sensor, enable);
> + if (err < 0)
> + goto out;
>
> err = st_lsm6dsx_set_fifo_odr(sensor, enable);
> if (err < 0)
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index f8bbb005718e..6af2e905c161 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -2317,12 +2317,7 @@ static int st_lsm6dsx_suspend(struct device *dev)
> continue;
> }
>
> - if (sensor->id == ST_LSM6DSX_ID_EXT0 ||
> - sensor->id == ST_LSM6DSX_ID_EXT1 ||
> - sensor->id == ST_LSM6DSX_ID_EXT2)
> - err = st_lsm6dsx_shub_set_enable(sensor, false);
> - else
> - err = st_lsm6dsx_sensor_set_enable(sensor, false);
> + err = st_lsm6dsx_device_set_enable(sensor, false);
> if (err < 0)
> return err;
>
> @@ -2353,12 +2348,7 @@ static int st_lsm6dsx_resume(struct device *dev)
> if (!(hw->suspend_mask & BIT(sensor->id)))
> continue;
>
> - if (sensor->id == ST_LSM6DSX_ID_EXT0 ||
> - sensor->id == ST_LSM6DSX_ID_EXT1 ||
> - sensor->id == ST_LSM6DSX_ID_EXT2)
> - err = st_lsm6dsx_shub_set_enable(sensor, true);
> - else
> - err = st_lsm6dsx_sensor_set_enable(sensor, true);
> + err = st_lsm6dsx_device_set_enable(sensor, true);
> if (err < 0)
> return err;
>
prev parent reply other threads:[~2022-10-15 15:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-10 11:07 [PATCH] iio: imu: st_lsm6dsx: introduce st_lsm6dsx_device_set_enable routine Lorenzo Bianconi
2022-10-15 15:47 ` 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=20221015164703.11ea5783@jic23-huawei \
--to=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=lorenzo@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