From: Jonathan Cameron <jic23@kernel.org>
To: Mircea Caprioru <mircea.caprioru@analog.com>
Cc: <Michael.Hennerich@analog.com>, <alexandru.ardelean@analog.com>,
<lars@metafoo.de>, <gregkh@linuxfoundation.org>,
<linux-kernel@vger.kernel.org>, <linux-iio@vger.kernel.org>,
Sergiu Cuciurean <sergiu.cuciurean@analog.com>
Subject: Re: [PATCH 2/5] iio: adc: palmas_gpadc: Replace indio_dev->mlock with own device lock
Date: Sun, 21 Feb 2021 16:38:26 +0000 [thread overview]
Message-ID: <20210221163826.10ba97be@archlinux> (raw)
In-Reply-To: <20200928131333.36646-2-mircea.caprioru@analog.com>
On Mon, 28 Sep 2020 16:13:30 +0300
Mircea Caprioru <mircea.caprioru@analog.com> wrote:
> From: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
>
> As part of the general cleanup of indio_dev->mlock, this change replaces
> it with a local lock on the device's state structure.
>
> This is part of a bigger cleanup.
> Link: https://lore.kernel.org/linux-iio/CA+U=Dsoo6YABe5ODLp+eFNPGFDjk5ZeQEceGkqjxXcVEhLWubw@mail.gmail.com/
>
> Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
> Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Applied,
Thanks,
Jonathan
> ---
> drivers/iio/adc/palmas_gpadc.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c
> index 889b88768b63..14874f11614d 100644
> --- a/drivers/iio/adc/palmas_gpadc.c
> +++ b/drivers/iio/adc/palmas_gpadc.c
> @@ -90,6 +90,12 @@ static struct palmas_gpadc_info palmas_gpadc_info[] = {
> * 3: 800 uA
> * @extended_delay: enable the gpadc extended delay mode
> * @auto_conversion_period: define the auto_conversion_period
> + * @lock: Lock to protect the device state during a potential concurrent
> + * read access from userspace. Reading a raw value requires a sequence
> + * of register writes, then a wait for a completion callback,
> + * and finally a register read, during which userspace could issue
> + * another read request. This lock protects a read access from
> + * ocurring before another one has finished.
> *
> * This is the palmas_gpadc structure to store run-time information
> * and pointers for this driver instance.
> @@ -110,6 +116,7 @@ struct palmas_gpadc {
> bool wakeup1_enable;
> bool wakeup2_enable;
> int auto_conversion_period;
> + struct mutex lock;
> };
>
> /*
> @@ -388,7 +395,7 @@ static int palmas_gpadc_read_raw(struct iio_dev *indio_dev,
> if (adc_chan > PALMAS_ADC_CH_MAX)
> return -EINVAL;
>
> - mutex_lock(&indio_dev->mlock);
> + mutex_lock(&adc->lock);
>
> switch (mask) {
> case IIO_CHAN_INFO_RAW:
> @@ -414,12 +421,12 @@ static int palmas_gpadc_read_raw(struct iio_dev *indio_dev,
> goto out;
> }
>
> - mutex_unlock(&indio_dev->mlock);
> + mutex_unlock(&adc->lock);
> return ret;
>
> out:
> palmas_gpadc_read_done(adc, adc_chan);
> - mutex_unlock(&indio_dev->mlock);
> + mutex_unlock(&adc->lock);
>
> return ret;
> }
> @@ -516,6 +523,9 @@ static int palmas_gpadc_probe(struct platform_device *pdev)
> adc->dev = &pdev->dev;
> adc->palmas = dev_get_drvdata(pdev->dev.parent);
> adc->adc_info = palmas_gpadc_info;
> +
> + mutex_init(&adc->lock);
> +
> init_completion(&adc->conv_completion);
> dev_set_drvdata(&pdev->dev, indio_dev);
>
next prev parent reply other threads:[~2021-02-21 16:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-28 13:13 [PATCH 1/5] iio: adc: spear_adc: Replace indio_dev->mlock with own device lock Mircea Caprioru
2020-09-28 13:13 ` [PATCH 2/5] iio: adc: palmas_gpadc: " Mircea Caprioru
2021-02-21 16:38 ` Jonathan Cameron [this message]
2020-09-28 13:13 ` [PATCH 3/5] iio: adc: npcm_adc: " Mircea Caprioru
2021-02-21 16:39 ` Jonathan Cameron
2020-09-28 13:13 ` [PATCH 4/5] iio: adc: vf610_adc: " Mircea Caprioru
2020-09-29 16:14 ` Jonathan Cameron
2020-09-30 5:57 ` Alexandru Ardelean
2020-09-30 10:49 ` Jonathan Cameron
2020-09-28 13:13 ` [PATCH 5/5] iio: adc: rockchip_saradc: " Mircea Caprioru
2020-09-29 16:23 ` Jonathan Cameron
2021-02-21 16:37 ` [PATCH 1/5] iio: adc: spear_adc: " 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=20210221163826.10ba97be@archlinux \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=alexandru.ardelean@analog.com \
--cc=gregkh@linuxfoundation.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mircea.caprioru@analog.com \
--cc=sergiu.cuciurean@analog.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.