From: Jonathan Cameron <jic23@kernel.org>
To: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 03/10] iio: imu: adis[16480]: group RW into a single lock in adis_enable_irq()
Date: Sun, 6 Oct 2019 10:13:36 +0100 [thread overview]
Message-ID: <20191006101336.2fdf927f@archlinux> (raw)
In-Reply-To: <20190926111812.15957-4-alexandru.ardelean@analog.com>
On Thu, 26 Sep 2019 14:18:05 +0300
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:
> The adis_enable_irq() does a read & a write. This change keeps a lock for
> the duration of both operations vs for each op.
>
> The change is also needed in adis16480, since that has it's own
> implementation for adis_enable_irq().
>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Applied.
Thanks,
Jonathan
> ---
> drivers/iio/imu/adis.c | 17 +++++++++++------
> drivers/iio/imu/adis16480.c | 4 ++--
> 2 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/imu/adis.c b/drivers/iio/imu/adis.c
> index 4f3be011c898..dc30f70d36f3 100644
> --- a/drivers/iio/imu/adis.c
> +++ b/drivers/iio/imu/adis.c
> @@ -250,12 +250,16 @@ int adis_enable_irq(struct adis *adis, bool enable)
> int ret = 0;
> uint16_t msc;
>
> - if (adis->data->enable_irq)
> - return adis->data->enable_irq(adis, enable);
> + mutex_lock(&adis->state_lock);
> +
> + if (adis->data->enable_irq) {
> + ret = adis->data->enable_irq(adis, enable);
> + goto out_unlock;
> + }
>
> - ret = adis_read_reg_16(adis, adis->data->msc_ctrl_reg, &msc);
> + ret = __adis_read_reg_16(adis, adis->data->msc_ctrl_reg, &msc);
> if (ret)
> - goto error_ret;
> + goto out_unlock;
>
> msc |= ADIS_MSC_CTRL_DATA_RDY_POL_HIGH;
> msc &= ~ADIS_MSC_CTRL_DATA_RDY_DIO2;
> @@ -264,9 +268,10 @@ int adis_enable_irq(struct adis *adis, bool enable)
> else
> msc &= ~ADIS_MSC_CTRL_DATA_RDY_EN;
>
> - ret = adis_write_reg_16(adis, adis->data->msc_ctrl_reg, msc);
> + ret = __adis_write_reg_16(adis, adis->data->msc_ctrl_reg, msc);
>
> -error_ret:
> +out_unlock:
> + mutex_unlock(&adis->state_lock);
> return ret;
> }
> EXPORT_SYMBOL(adis_enable_irq);
> diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
> index b99d73887c9f..dc13d8a33612 100644
> --- a/drivers/iio/imu/adis16480.c
> +++ b/drivers/iio/imu/adis16480.c
> @@ -936,14 +936,14 @@ static int adis16480_enable_irq(struct adis *adis, bool enable)
> uint16_t val;
> int ret;
>
> - ret = adis_read_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, &val);
> + ret = __adis_read_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, &val);
> if (ret < 0)
> return ret;
>
> val &= ~ADIS16480_DRDY_EN_MSK;
> val |= ADIS16480_DRDY_EN(enable);
>
> - return adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, val);
> + return __adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, val);
> }
>
> static int adis16480_initial_setup(struct iio_dev *indio_dev)
next prev parent reply other threads:[~2019-10-06 9:13 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-26 11:18 [PATCH 00/10] iio: imu: adis: cleanup lock usage Alexandru Ardelean
2019-09-26 11:18 ` [PATCH 01/10] iio: imu: adis: rename txrx_lock -> state_lock Alexandru Ardelean
2019-10-06 8:53 ` Jonathan Cameron
2019-10-06 9:06 ` Jonathan Cameron
2019-10-07 10:18 ` Ardelean, Alexandru
2019-09-26 11:18 ` [PATCH 02/10] iio: imu: adis: add unlocked read/write function versions Alexandru Ardelean
2019-10-06 9:12 ` Jonathan Cameron
2019-10-07 21:16 ` Jonathan Cameron
2019-10-08 6:54 ` Ardelean, Alexandru
2019-10-08 8:47 ` Ardelean, Alexandru
2019-10-08 8:58 ` Ardelean, Alexandru
2019-10-12 13:40 ` Jonathan Cameron
2019-09-26 11:18 ` [PATCH 03/10] iio: imu: adis[16480]: group RW into a single lock in adis_enable_irq() Alexandru Ardelean
2019-10-06 9:13 ` Jonathan Cameron [this message]
2019-09-26 11:18 ` [PATCH 04/10] iio: imu: adis: create an unlocked version of adis_check_status() Alexandru Ardelean
2019-10-06 9:13 ` Jonathan Cameron
2019-09-26 11:18 ` [PATCH 05/10] iio: imu: adis: create an unlocked version of adis_reset() Alexandru Ardelean
2019-10-06 9:19 ` Jonathan Cameron
2019-09-26 11:18 ` [PATCH 06/10] iio: imu: adis: protect initial startup routine with state lock Alexandru Ardelean
2019-10-06 9:20 ` Jonathan Cameron
2019-09-26 11:18 ` [PATCH 07/10] iio: imu: adis: group single conversion under a single " Alexandru Ardelean
2019-10-06 9:20 ` Jonathan Cameron
2019-09-26 11:18 ` [PATCH 08/10] iio: imu: adis16400: rework locks using ADIS library's " Alexandru Ardelean
2019-10-06 9:20 ` Jonathan Cameron
2019-09-26 11:18 ` [PATCH 09/10] iio: gyro: adis16136: " Alexandru Ardelean
2019-10-06 9:22 ` Jonathan Cameron
2019-09-26 11:18 ` [PATCH 10/10] iio: imu: adis16480: use state lock for filter freq set Alexandru Ardelean
2019-10-06 9:24 ` 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=20191006101336.2fdf927f@archlinux \
--to=jic23@kernel.org \
--cc=alexandru.ardelean@analog.com \
--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;
as well as URLs for NNTP newsgroup(s).