[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191006101359.1f256fd7@archlinux>
Date: Sun, 6 Oct 2019 10:13:59 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Alexandru Ardelean <alexandru.ardelean@...log.com>
Cc: <linux-iio@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 04/10] iio: imu: adis: create an unlocked version of
adis_check_status()
On Thu, 26 Sep 2019 14:18:06 +0300
Alexandru Ardelean <alexandru.ardelean@...log.com> wrote:
> This one also gets re-used in certain operations, so it makes sense to
> have an unlocked version of this to group it with other
> reads/writes/operations to have a single lock for the whole state change.
>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@...log.com>
Applied.
Thanks,
J
> ---
> drivers/iio/imu/adis.c | 8 ++++----
> include/linux/iio/imu/adis.h | 13 ++++++++++++-
> 2 files changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/imu/adis.c b/drivers/iio/imu/adis.c
> index dc30f70d36f3..e461b9ae22a5 100644
> --- a/drivers/iio/imu/adis.c
> +++ b/drivers/iio/imu/adis.c
> @@ -277,18 +277,18 @@ int adis_enable_irq(struct adis *adis, bool enable)
> EXPORT_SYMBOL(adis_enable_irq);
>
> /**
> - * adis_check_status() - Check the device for error conditions
> + * __adis_check_status() - Check the device for error conditions (unlocked)
> * @adis: The adis device
> *
> * Returns 0 on success, a negative error code otherwise
> */
> -int adis_check_status(struct adis *adis)
> +int __adis_check_status(struct adis *adis)
> {
> uint16_t status;
> int ret;
> int i;
>
> - ret = adis_read_reg_16(adis, adis->data->diag_stat_reg, &status);
> + ret = __adis_read_reg_16(adis, adis->data->diag_stat_reg, &status);
> if (ret < 0)
> return ret;
>
> @@ -306,7 +306,7 @@ int adis_check_status(struct adis *adis)
>
> return -EIO;
> }
> -EXPORT_SYMBOL_GPL(adis_check_status);
> +EXPORT_SYMBOL_GPL(__adis_check_status);
>
> /**
> * adis_reset() - Reset the device
> diff --git a/include/linux/iio/imu/adis.h b/include/linux/iio/imu/adis.h
> index 3a028c40e04e..f4ffba0c36b1 100644
> --- a/include/linux/iio/imu/adis.h
> +++ b/include/linux/iio/imu/adis.h
> @@ -263,7 +263,18 @@ static inline int adis_read_reg_32(struct adis *adis, unsigned int reg,
> }
>
> int adis_enable_irq(struct adis *adis, bool enable);
> -int adis_check_status(struct adis *adis);
> +int __adis_check_status(struct adis *adis);
> +
> +static inline int adis_check_status(struct adis *adis)
> +{
> + int ret;
> +
> + mutex_lock(&adis->state_lock);
> + ret = __adis_check_status(adis);
> + mutex_unlock(&adis->state_lock);
> +
> + return ret;
> +}
>
> int adis_initial_startup(struct adis *adis);
>
Powered by blists - more mailing lists