Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1406402 > unrolled thread

[PATCH 0/7] iio: adc: clean up claims on direct mode in ad7* drivers

Started byAlison Schofield <amsfield22@gmail.com>
First post2016-05-24 21:20 +0200
Last post2016-05-29 20:40 +0200
Articles 16 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/7] iio: adc: clean up claims on direct mode in ad7* drivers Alison Schofield <amsfield22@gmail.com> - 2016-05-24 21:20 +0200
    [PATCH 4/7] iio: adc: ad7476: use iio helper function to guarantee  direct mode Alison Schofield <amsfield22@gmail.com> - 2016-05-24 21:20 +0200
      Re: [PATCH 4/7] iio: adc: ad7476: use iio helper function to  guarantee direct mode Daniel Baluta <daniel.baluta@gmail.com> - 2016-05-25 12:40 +0200
        Re: [PATCH 4/7] iio: adc: ad7476: use iio helper function to  guarantee direct mode Jonathan Cameron <jic23@kernel.org> - 2016-05-29 20:40 +0200
    [PATCH 1/7] iio: adc: ad7266: claim direct mode during sensor read Alison Schofield <amsfield22@gmail.com> - 2016-05-24 21:20 +0200
      Re: [PATCH 1/7] iio: adc: ad7266: claim direct mode during sensor read Daniel Baluta <daniel.baluta@gmail.com> - 2016-05-25 12:40 +0200
        Re: [PATCH 1/7] iio: adc: ad7266: claim direct mode during sensor  read Jonathan Cameron <jic23@kernel.org> - 2016-05-29 19:10 +0200
    [PATCH 5/7] iio: adc: ad7887: use iio helper function to guarantee  direct mode Alison Schofield <amsfield22@gmail.com> - 2016-05-24 21:20 +0200
      Re: [PATCH 5/7] iio: adc: ad7887: use iio helper function to  guarantee direct mode Daniel Baluta <daniel.baluta@gmail.com> - 2016-05-25 12:40 +0200
        Re: [PATCH 5/7] iio: adc: ad7887: use iio helper function to  guarantee direct mode Jonathan Cameron <jic23@kernel.org> - 2016-05-29 20:40 +0200
    [PATCH 6/7] iio: adc: ad7923: use iio helper function to guarantee  direct mode Alison Schofield <amsfield22@gmail.com> - 2016-05-24 21:30 +0200
      Re: [PATCH 6/7] iio: adc: ad7923: use iio helper function to  guarantee direct mode Daniel Baluta <daniel.baluta@gmail.com> - 2016-05-25 12:50 +0200
        Re: [PATCH 6/7] iio: adc: ad7923: use iio helper function to  guarantee direct mode Jonathan Cameron <jic23@kernel.org> - 2016-05-29 20:40 +0200
    [PATCH 7/7] iio: adc: ad799x: use iio helper function to guarantee  direct mode Alison Schofield <amsfield22@gmail.com> - 2016-05-24 21:30 +0200
      Re: [PATCH 7/7] iio: adc: ad799x: use iio helper function to  guarantee direct mode Daniel Baluta <daniel.baluta@gmail.com> - 2016-05-25 12:50 +0200
        Re: [PATCH 7/7] iio: adc: ad799x: use iio helper function to  guarantee direct mode Jonathan Cameron <jic23@kernel.org> - 2016-05-29 20:40 +0200

#1406402 — [PATCH 0/7] iio: adc: clean up claims on direct mode in ad7* drivers

FromAlison Schofield <amsfield22@gmail.com>
Date2016-05-24 21:20 +0200
Subject[PATCH 0/7] iio: adc: clean up claims on direct mode in ad7* drivers
Message-ID<rCq1X-7jq-3@gated-at.bofh.it>
This set looks at the ad7* drivers and migrates them to use the 
iio helper functions iio_device_claim|release_direct_mode(). 

The first three (7266,7791,7793) were not already holding a lock on
direct mode, so this will be a change in behavior for those drivers.

The last four (7476,7887,7923,799x) were already locking so these
are migrations to the claim/release helper functions.

Worth noting: This does not clean up all mlock (ab-)uses in ad799x. 
This driver is still using mlock in a few other places not associated
with locking down direct mode. 

Alison Schofield (7):
  iio: adc: ad7266: claim direct mode during sensor read
  iio: adc: ad7791: claim direct mode when writing frequency
  iio: adc: ad7793: claim direct mode when writing frequency
  iio: adc: ad7476: use iio helper function to guarantee direct mode
  iio: adc: ad7887: use iio helper function to guarantee direct mode
  iio: adc: ad7923: use iio helper function to guarantee direct mode
  iio: adc: ad799x: use iio helper function to guarantee direct mode

 drivers/iio/adc/ad7266.c |  7 +++----
 drivers/iio/adc/ad7476.c | 11 +++++------
 drivers/iio/adc/ad7791.c | 15 ++++-----------
 drivers/iio/adc/ad7793.c | 13 ++++---------
 drivers/iio/adc/ad7887.c | 11 +++++------
 drivers/iio/adc/ad7923.c | 11 +++++------
 drivers/iio/adc/ad799x.c | 24 +++++++++---------------
 7 files changed, 35 insertions(+), 57 deletions(-)

-- 
2.1.4

[toc] | [next] | [standalone]


#1406403 — [PATCH 4/7] iio: adc: ad7476: use iio helper function to guarantee direct mode

FromAlison Schofield <amsfield22@gmail.com>
Date2016-05-24 21:20 +0200
Subject[PATCH 4/7] iio: adc: ad7476: use iio helper function to guarantee direct mode
Message-ID<rCq1X-7jq-13@gated-at.bofh.it>
In reply to#1406402
Replace the code that guarantees the device stays in direct mode
with iio_device_claim_direct_mode() which does same.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Cc: Daniel Baluta <daniel.baluta@gmail.com>
---
 drivers/iio/adc/ad7476.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
index be85c2a..810c9a9 100644
--- a/drivers/iio/adc/ad7476.c
+++ b/drivers/iio/adc/ad7476.c
@@ -106,12 +106,11 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
 
 	switch (m) {
 	case IIO_CHAN_INFO_RAW:
-		mutex_lock(&indio_dev->mlock);
-		if (iio_buffer_enabled(indio_dev))
-			ret = -EBUSY;
-		else
-			ret = ad7476_scan_direct(st);
-		mutex_unlock(&indio_dev->mlock);
+		ret = iio_device_claim_direct_mode(indio_dev);
+		if (ret)
+			return ret;
+		ret = ad7476_scan_direct(st);
+		iio_device_release_direct_mode(indio_dev);
 
 		if (ret < 0)
 			return ret;
-- 
2.1.4

[toc] | [prev] | [next] | [standalone]


#1406820 — Re: [PATCH 4/7] iio: adc: ad7476: use iio helper function to guarantee direct mode

FromDaniel Baluta <daniel.baluta@gmail.com>
Date2016-05-25 12:40 +0200
SubjectRe: [PATCH 4/7] iio: adc: ad7476: use iio helper function to guarantee direct mode
Message-ID<rCEoh-8jG-5@gated-at.bofh.it>
In reply to#1406403
On Tue, May 24, 2016 at 10:18 PM, Alison Schofield <amsfield22@gmail.com> wrote:
> Replace the code that guarantees the device stays in direct mode
> with iio_device_claim_direct_mode() which does same.
>
> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
> Cc: Daniel Baluta <daniel.baluta@gmail.com>

Acked-by: Daniel Baluta <daniel.baluta@gmail.com>

> ---
>  drivers/iio/adc/ad7476.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
> index be85c2a..810c9a9 100644
> --- a/drivers/iio/adc/ad7476.c
> +++ b/drivers/iio/adc/ad7476.c
> @@ -106,12 +106,11 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
>
>         switch (m) {
>         case IIO_CHAN_INFO_RAW:
> -               mutex_lock(&indio_dev->mlock);
> -               if (iio_buffer_enabled(indio_dev))
> -                       ret = -EBUSY;
> -               else
> -                       ret = ad7476_scan_direct(st);
> -               mutex_unlock(&indio_dev->mlock);
> +               ret = iio_device_claim_direct_mode(indio_dev);
> +               if (ret)
> +                       return ret;
> +               ret = ad7476_scan_direct(st);
> +               iio_device_release_direct_mode(indio_dev);
>
>                 if (ret < 0)
>                         return ret;
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[toc] | [prev] | [next] | [standalone]


#1408636 — Re: [PATCH 4/7] iio: adc: ad7476: use iio helper function to guarantee direct mode

FromJonathan Cameron <jic23@kernel.org>
Date2016-05-29 20:40 +0200
SubjectRe: [PATCH 4/7] iio: adc: ad7476: use iio helper function to guarantee direct mode
Message-ID<rEdN0-1qk-17@gated-at.bofh.it>
In reply to#1406820
On 25/05/16 11:37, Daniel Baluta wrote:
> On Tue, May 24, 2016 at 10:18 PM, Alison Schofield <amsfield22@gmail.com> wrote:
>> Replace the code that guarantees the device stays in direct mode
>> with iio_device_claim_direct_mode() which does same.
>>
>> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
>> Cc: Daniel Baluta <daniel.baluta@gmail.com>
> 
> Acked-by: Daniel Baluta <daniel.baluta@gmail.com>
Straight forward one. Applied.

Thanks,
> 
>> ---
>>  drivers/iio/adc/ad7476.c | 11 +++++------
>>  1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
>> index be85c2a..810c9a9 100644
>> --- a/drivers/iio/adc/ad7476.c
>> +++ b/drivers/iio/adc/ad7476.c
>> @@ -106,12 +106,11 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
>>
>>         switch (m) {
>>         case IIO_CHAN_INFO_RAW:
>> -               mutex_lock(&indio_dev->mlock);
>> -               if (iio_buffer_enabled(indio_dev))
>> -                       ret = -EBUSY;
>> -               else
>> -                       ret = ad7476_scan_direct(st);
>> -               mutex_unlock(&indio_dev->mlock);
>> +               ret = iio_device_claim_direct_mode(indio_dev);
>> +               if (ret)
>> +                       return ret;
>> +               ret = ad7476_scan_direct(st);
>> +               iio_device_release_direct_mode(indio_dev);
>>
>>                 if (ret < 0)
>>                         return ret;
>> --
>> 2.1.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[toc] | [prev] | [next] | [standalone]


#1406404 — [PATCH 1/7] iio: adc: ad7266: claim direct mode during sensor read

FromAlison Schofield <amsfield22@gmail.com>
Date2016-05-24 21:20 +0200
Subject[PATCH 1/7] iio: adc: ad7266: claim direct mode during sensor read
Message-ID<rCq1X-7jq-11@gated-at.bofh.it>
In reply to#1406402
Driver was checking for direct mode but not locking it down.
Use iio_device_claim_direct_mode() to guarantee device stays
in direct mode.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Cc: Daniel Baluta <daniel.baluta@gmail.com>
---
 drivers/iio/adc/ad7266.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
index 21e19b6..01240ae 100644
--- a/drivers/iio/adc/ad7266.c
+++ b/drivers/iio/adc/ad7266.c
@@ -154,12 +154,11 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,
 
 	switch (m) {
 	case IIO_CHAN_INFO_RAW:
-		if (iio_buffer_enabled(indio_dev))
-			return -EBUSY;
-
-		ret = ad7266_read_single(st, val, chan->address);
+		ret = iio_device_claim_direct_mode(indio_dev);
 		if (ret)
 			return ret;
+		ret = ad7266_read_single(st, val, chan->address);
+		iio_device_release_direct_mode(indio_dev);
 
 		*val = (*val >> 2) & 0xfff;
 		if (chan->scan_type.sign == 's')
-- 
2.1.4

[toc] | [prev] | [next] | [standalone]


#1406826 — Re: [PATCH 1/7] iio: adc: ad7266: claim direct mode during sensor read

FromDaniel Baluta <daniel.baluta@gmail.com>
Date2016-05-25 12:40 +0200
SubjectRe: [PATCH 1/7] iio: adc: ad7266: claim direct mode during sensor read
Message-ID<rCEoi-8jG-19@gated-at.bofh.it>
In reply to#1406404
On Tue, May 24, 2016 at 10:16 PM, Alison Schofield <amsfield22@gmail.com> wrote:
> Driver was checking for direct mode but not locking it down.
> Use iio_device_claim_direct_mode() to guarantee device stays
> in direct mode.
>
> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
> Cc: Daniel Baluta <daniel.baluta@gmail.com>

Acked-by: Daniel Baluta <daniel.baluta@gmail.com>

> ---
>  drivers/iio/adc/ad7266.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
> index 21e19b6..01240ae 100644
> --- a/drivers/iio/adc/ad7266.c
> +++ b/drivers/iio/adc/ad7266.c
> @@ -154,12 +154,11 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,
>
>         switch (m) {
>         case IIO_CHAN_INFO_RAW:
> -               if (iio_buffer_enabled(indio_dev))
> -                       return -EBUSY;
> -
> -               ret = ad7266_read_single(st, val, chan->address);
> +               ret = iio_device_claim_direct_mode(indio_dev);
>                 if (ret)
>                         return ret;
> +               ret = ad7266_read_single(st, val, chan->address);
> +               iio_device_release_direct_mode(indio_dev);
>
>                 *val = (*val >> 2) & 0xfff;
>                 if (chan->scan_type.sign == 's')
> --

[toc] | [prev] | [next] | [standalone]


#1408615 — Re: [PATCH 1/7] iio: adc: ad7266: claim direct mode during sensor read

FromJonathan Cameron <jic23@kernel.org>
Date2016-05-29 19:10 +0200
SubjectRe: [PATCH 1/7] iio: adc: ad7266: claim direct mode during sensor read
Message-ID<rEcnU-Fq-5@gated-at.bofh.it>
In reply to#1406826
On 25/05/16 11:33, Daniel Baluta wrote:
> On Tue, May 24, 2016 at 10:16 PM, Alison Schofield <amsfield22@gmail.com> wrote:
>> Driver was checking for direct mode but not locking it down.
>> Use iio_device_claim_direct_mode() to guarantee device stays
>> in direct mode.
>>
>> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
>> Cc: Daniel Baluta <daniel.baluta@gmail.com>
> 
> Acked-by: Daniel Baluta <daniel.baluta@gmail.com>
Looks good.

Applied to the togreg branch of iio.git - initially pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan
> 
>> ---
>>  drivers/iio/adc/ad7266.c | 7 +++----
>>  1 file changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
>> index 21e19b6..01240ae 100644
>> --- a/drivers/iio/adc/ad7266.c
>> +++ b/drivers/iio/adc/ad7266.c
>> @@ -154,12 +154,11 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,
>>
>>         switch (m) {
>>         case IIO_CHAN_INFO_RAW:
>> -               if (iio_buffer_enabled(indio_dev))
>> -                       return -EBUSY;
>> -
>> -               ret = ad7266_read_single(st, val, chan->address);
>> +               ret = iio_device_claim_direct_mode(indio_dev);
>>                 if (ret)
>>                         return ret;
>> +               ret = ad7266_read_single(st, val, chan->address);
>> +               iio_device_release_direct_mode(indio_dev);
>>
>>                 *val = (*val >> 2) & 0xfff;
>>                 if (chan->scan_type.sign == 's')
>> --
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

[toc] | [prev] | [next] | [standalone]


#1406406 — [PATCH 5/7] iio: adc: ad7887: use iio helper function to guarantee direct mode

FromAlison Schofield <amsfield22@gmail.com>
Date2016-05-24 21:20 +0200
Subject[PATCH 5/7] iio: adc: ad7887: use iio helper function to guarantee direct mode
Message-ID<rCq1X-7jq-25@gated-at.bofh.it>
In reply to#1406402
Replace the code that guarantees the device stays in direct mode
with iio_device_claim_direct_mode() which does same.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Cc: Daniel Baluta <daniel.baluta@gmail.com>
---
 drivers/iio/adc/ad7887.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c
index 2d3c397..ee2ccc1 100644
--- a/drivers/iio/adc/ad7887.c
+++ b/drivers/iio/adc/ad7887.c
@@ -156,12 +156,11 @@ static int ad7887_read_raw(struct iio_dev *indio_dev,
 
 	switch (m) {
 	case IIO_CHAN_INFO_RAW:
-		mutex_lock(&indio_dev->mlock);
-		if (iio_buffer_enabled(indio_dev))
-			ret = -EBUSY;
-		else
-			ret = ad7887_scan_direct(st, chan->address);
-		mutex_unlock(&indio_dev->mlock);
+		ret = iio_device_claim_direct_mode(indio_dev);
+		if (ret)
+			return ret;
+		ret = ad7887_scan_direct(st, chan->address);
+		iio_device_release_direct_mode(indio_dev);
 
 		if (ret < 0)
 			return ret;
-- 
2.1.4

[toc] | [prev] | [next] | [standalone]


#1406819 — Re: [PATCH 5/7] iio: adc: ad7887: use iio helper function to guarantee direct mode

FromDaniel Baluta <daniel.baluta@gmail.com>
Date2016-05-25 12:40 +0200
SubjectRe: [PATCH 5/7] iio: adc: ad7887: use iio helper function to guarantee direct mode
Message-ID<rCEoh-8jG-3@gated-at.bofh.it>
In reply to#1406406
On Tue, May 24, 2016 at 10:18 PM, Alison Schofield <amsfield22@gmail.com> wrote:
> Replace the code that guarantees the device stays in direct mode
> with iio_device_claim_direct_mode() which does same.
>
> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
> Cc: Daniel Baluta <daniel.baluta@gmail.com>

Acked-by: Daniel Baluta <daniel.baluta@gmail.com>

> ---
>  drivers/iio/adc/ad7887.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c
> index 2d3c397..ee2ccc1 100644
> --- a/drivers/iio/adc/ad7887.c
> +++ b/drivers/iio/adc/ad7887.c
> @@ -156,12 +156,11 @@ static int ad7887_read_raw(struct iio_dev *indio_dev,
>
>         switch (m) {
>         case IIO_CHAN_INFO_RAW:
> -               mutex_lock(&indio_dev->mlock);
> -               if (iio_buffer_enabled(indio_dev))
> -                       ret = -EBUSY;
> -               else
> -                       ret = ad7887_scan_direct(st, chan->address);
> -               mutex_unlock(&indio_dev->mlock);
> +               ret = iio_device_claim_direct_mode(indio_dev);
> +               if (ret)
> +                       return ret;
> +               ret = ad7887_scan_direct(st, chan->address);
> +               iio_device_release_direct_mode(indio_dev);
>
>                 if (ret < 0)
>                         return ret;
> --

[toc] | [prev] | [next] | [standalone]


#1408638 — Re: [PATCH 5/7] iio: adc: ad7887: use iio helper function to guarantee direct mode

FromJonathan Cameron <jic23@kernel.org>
Date2016-05-29 20:40 +0200
SubjectRe: [PATCH 5/7] iio: adc: ad7887: use iio helper function to guarantee direct mode
Message-ID<rEdN0-1qk-19@gated-at.bofh.it>
In reply to#1406819
On 25/05/16 11:38, Daniel Baluta wrote:
> On Tue, May 24, 2016 at 10:18 PM, Alison Schofield <amsfield22@gmail.com> wrote:
>> Replace the code that guarantees the device stays in direct mode
>> with iio_device_claim_direct_mode() which does same.
>>
>> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
>> Cc: Daniel Baluta <daniel.baluta@gmail.com>
> 
> Acked-by: Daniel Baluta <daniel.baluta@gmail.com>
Applied - thanks.

Jonathan
> 
>> ---
>>  drivers/iio/adc/ad7887.c | 11 +++++------
>>  1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c
>> index 2d3c397..ee2ccc1 100644
>> --- a/drivers/iio/adc/ad7887.c
>> +++ b/drivers/iio/adc/ad7887.c
>> @@ -156,12 +156,11 @@ static int ad7887_read_raw(struct iio_dev *indio_dev,
>>
>>         switch (m) {
>>         case IIO_CHAN_INFO_RAW:
>> -               mutex_lock(&indio_dev->mlock);
>> -               if (iio_buffer_enabled(indio_dev))
>> -                       ret = -EBUSY;
>> -               else
>> -                       ret = ad7887_scan_direct(st, chan->address);
>> -               mutex_unlock(&indio_dev->mlock);
>> +               ret = iio_device_claim_direct_mode(indio_dev);
>> +               if (ret)
>> +                       return ret;
>> +               ret = ad7887_scan_direct(st, chan->address);
>> +               iio_device_release_direct_mode(indio_dev);
>>
>>                 if (ret < 0)
>>                         return ret;
>> --
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

[toc] | [prev] | [next] | [standalone]


#1406408 — [PATCH 6/7] iio: adc: ad7923: use iio helper function to guarantee direct mode

FromAlison Schofield <amsfield22@gmail.com>
Date2016-05-24 21:30 +0200
Subject[PATCH 6/7] iio: adc: ad7923: use iio helper function to guarantee direct mode
Message-ID<rCqbE-7np-19@gated-at.bofh.it>
In reply to#1406402
Replace the code that guarantees the device stays in direct mode
with iio_device_claim_direct_mode() which does same.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Cc: Daniel Baluta <daniel.baluta@gmail.com>
---
 drivers/iio/adc/ad7923.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
index 45e29cc..ff444c1 100644
--- a/drivers/iio/adc/ad7923.c
+++ b/drivers/iio/adc/ad7923.c
@@ -233,12 +233,11 @@ static int ad7923_read_raw(struct iio_dev *indio_dev,
 
 	switch (m) {
 	case IIO_CHAN_INFO_RAW:
-		mutex_lock(&indio_dev->mlock);
-		if (iio_buffer_enabled(indio_dev))
-			ret = -EBUSY;
-		else
-			ret = ad7923_scan_direct(st, chan->address);
-		mutex_unlock(&indio_dev->mlock);
+		ret = iio_device_claim_direct_mode(indio_dev);
+		if (ret)
+			return ret;
+		ret = ad7923_scan_direct(st, chan->address);
+		iio_device_release_direct_mode(indio_dev);
 
 		if (ret < 0)
 			return ret;
-- 
2.1.4

[toc] | [prev] | [next] | [standalone]


#1406831 — Re: [PATCH 6/7] iio: adc: ad7923: use iio helper function to guarantee direct mode

FromDaniel Baluta <daniel.baluta@gmail.com>
Date2016-05-25 12:50 +0200
SubjectRe: [PATCH 6/7] iio: adc: ad7923: use iio helper function to guarantee direct mode
Message-ID<rCExY-8n2-11@gated-at.bofh.it>
In reply to#1406408
On Tue, May 24, 2016 at 10:19 PM, Alison Schofield <amsfield22@gmail.com> wrote:
> Replace the code that guarantees the device stays in direct mode
> with iio_device_claim_direct_mode() which does same.
>
> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
> Cc: Daniel Baluta <daniel.baluta@gmail.com>

Acked-by: Daniel Baluta <daniel.baluta@gmail.com>


> ---
>  drivers/iio/adc/ad7923.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
> index 45e29cc..ff444c1 100644
> --- a/drivers/iio/adc/ad7923.c
> +++ b/drivers/iio/adc/ad7923.c
> @@ -233,12 +233,11 @@ static int ad7923_read_raw(struct iio_dev *indio_dev,
>
>         switch (m) {
>         case IIO_CHAN_INFO_RAW:
> -               mutex_lock(&indio_dev->mlock);
> -               if (iio_buffer_enabled(indio_dev))
> -                       ret = -EBUSY;
> -               else
> -                       ret = ad7923_scan_direct(st, chan->address);
> -               mutex_unlock(&indio_dev->mlock);
> +               ret = iio_device_claim_direct_mode(indio_dev);
> +               if (ret)
> +                       return ret;
> +               ret = ad7923_scan_direct(st, chan->address);
> +               iio_device_release_direct_mode(indio_dev);
>
>                 if (ret < 0)
>                         return ret;
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[toc] | [prev] | [next] | [standalone]


#1408634 — Re: [PATCH 6/7] iio: adc: ad7923: use iio helper function to guarantee direct mode

FromJonathan Cameron <jic23@kernel.org>
Date2016-05-29 20:40 +0200
SubjectRe: [PATCH 6/7] iio: adc: ad7923: use iio helper function to guarantee direct mode
Message-ID<rEdMZ-1qk-7@gated-at.bofh.it>
In reply to#1406831
On 25/05/16 11:41, Daniel Baluta wrote:
> On Tue, May 24, 2016 at 10:19 PM, Alison Schofield <amsfield22@gmail.com> wrote:
>> Replace the code that guarantees the device stays in direct mode
>> with iio_device_claim_direct_mode() which does same.
>>
>> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
>> Cc: Daniel Baluta <daniel.baluta@gmail.com>
> 
> Acked-by: Daniel Baluta <daniel.baluta@gmail.com>
Applied, - thanks

Jonathan
> 
> 
>> ---
>>  drivers/iio/adc/ad7923.c | 11 +++++------
>>  1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
>> index 45e29cc..ff444c1 100644
>> --- a/drivers/iio/adc/ad7923.c
>> +++ b/drivers/iio/adc/ad7923.c
>> @@ -233,12 +233,11 @@ static int ad7923_read_raw(struct iio_dev *indio_dev,
>>
>>         switch (m) {
>>         case IIO_CHAN_INFO_RAW:
>> -               mutex_lock(&indio_dev->mlock);
>> -               if (iio_buffer_enabled(indio_dev))
>> -                       ret = -EBUSY;
>> -               else
>> -                       ret = ad7923_scan_direct(st, chan->address);
>> -               mutex_unlock(&indio_dev->mlock);
>> +               ret = iio_device_claim_direct_mode(indio_dev);
>> +               if (ret)
>> +                       return ret;
>> +               ret = ad7923_scan_direct(st, chan->address);
>> +               iio_device_release_direct_mode(indio_dev);
>>
>>                 if (ret < 0)
>>                         return ret;
>> --
>> 2.1.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[toc] | [prev] | [next] | [standalone]


#1406412 — [PATCH 7/7] iio: adc: ad799x: use iio helper function to guarantee direct mode

FromAlison Schofield <amsfield22@gmail.com>
Date2016-05-24 21:30 +0200
Subject[PATCH 7/7] iio: adc: ad799x: use iio helper function to guarantee direct mode
Message-ID<rCqbE-7np-21@gated-at.bofh.it>
In reply to#1406402
Replace the code that guarantees the device stays in direct mode
with iio_device_claim_direct_mode() which does same.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Cc: Daniel Baluta <daniel.baluta@gmail.com>
---
 drivers/iio/adc/ad799x.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
index a3f5254..ec0200d 100644
--- a/drivers/iio/adc/ad799x.c
+++ b/drivers/iio/adc/ad799x.c
@@ -282,12 +282,11 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,
 
 	switch (m) {
 	case IIO_CHAN_INFO_RAW:
-		mutex_lock(&indio_dev->mlock);
-		if (iio_buffer_enabled(indio_dev))
-			ret = -EBUSY;
-		else
-			ret = ad799x_scan_direct(st, chan->scan_index);
-		mutex_unlock(&indio_dev->mlock);
+		ret = iio_device_claim_direct_mode(indio_dev);
+		if (ret)
+			return ret;
+		ret = ad799x_scan_direct(st, chan->scan_index);
+		iio_device_release_direct_mode(indio_dev);
 
 		if (ret < 0)
 			return ret;
@@ -395,11 +394,9 @@ static int ad799x_write_event_config(struct iio_dev *indio_dev,
 	struct ad799x_state *st = iio_priv(indio_dev);
 	int ret;
 
-	mutex_lock(&indio_dev->mlock);
-	if (iio_buffer_enabled(indio_dev)) {
-		ret = -EBUSY;
-		goto done;
-	}
+	ret = iio_device_claim_direct_mode(indio_dev);
+	if (ret)
+		return ret;
 
 	if (state)
 		st->config |= BIT(chan->scan_index) << AD799X_CHANNEL_SHIFT;
@@ -412,10 +409,7 @@ static int ad799x_write_event_config(struct iio_dev *indio_dev,
 		st->config &= ~AD7998_ALERT_EN;
 
 	ret = ad799x_write_config(st, st->config);
-
-done:
-	mutex_unlock(&indio_dev->mlock);
-
+	iio_device_release_direct_mode(indio_dev);
 	return ret;
 }
 
-- 
2.1.4

[toc] | [prev] | [next] | [standalone]


#1406835 — Re: [PATCH 7/7] iio: adc: ad799x: use iio helper function to guarantee direct mode

FromDaniel Baluta <daniel.baluta@gmail.com>
Date2016-05-25 12:50 +0200
SubjectRe: [PATCH 7/7] iio: adc: ad799x: use iio helper function to guarantee direct mode
Message-ID<rCExY-8n2-21@gated-at.bofh.it>
In reply to#1406412
On Tue, May 24, 2016 at 10:20 PM, Alison Schofield <amsfield22@gmail.com> wrote:
> Replace the code that guarantees the device stays in direct mode
> with iio_device_claim_direct_mode() which does same.
>
> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
> Cc: Daniel Baluta <daniel.baluta@gmail.com>

Acked-by: Daniel Baluta <daniel.baluta@gmail.com>


> ---
>  drivers/iio/adc/ad799x.c | 24 +++++++++---------------
>  1 file changed, 9 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
> index a3f5254..ec0200d 100644
> --- a/drivers/iio/adc/ad799x.c
> +++ b/drivers/iio/adc/ad799x.c
> @@ -282,12 +282,11 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,
>
>         switch (m) {
>         case IIO_CHAN_INFO_RAW:
> -               mutex_lock(&indio_dev->mlock);
> -               if (iio_buffer_enabled(indio_dev))
> -                       ret = -EBUSY;
> -               else
> -                       ret = ad799x_scan_direct(st, chan->scan_index);
> -               mutex_unlock(&indio_dev->mlock);
> +               ret = iio_device_claim_direct_mode(indio_dev);
> +               if (ret)
> +                       return ret;
> +               ret = ad799x_scan_direct(st, chan->scan_index);
> +               iio_device_release_direct_mode(indio_dev);
>
>                 if (ret < 0)
>                         return ret;
> @@ -395,11 +394,9 @@ static int ad799x_write_event_config(struct iio_dev *indio_dev,
>         struct ad799x_state *st = iio_priv(indio_dev);
>         int ret;
>
> -       mutex_lock(&indio_dev->mlock);
> -       if (iio_buffer_enabled(indio_dev)) {
> -               ret = -EBUSY;
> -               goto done;
> -       }
> +       ret = iio_device_claim_direct_mode(indio_dev);
> +       if (ret)
> +               return ret;
>
>         if (state)
>                 st->config |= BIT(chan->scan_index) << AD799X_CHANNEL_SHIFT;
> @@ -412,10 +409,7 @@ static int ad799x_write_event_config(struct iio_dev *indio_dev,
>                 st->config &= ~AD7998_ALERT_EN;
>
>         ret = ad799x_write_config(st, st->config);
> -
> -done:
> -       mutex_unlock(&indio_dev->mlock);
> -
> +       iio_device_release_direct_mode(indio_dev);
>         return ret;
>  }
>
> --

[toc] | [prev] | [next] | [standalone]


#1408635 — Re: [PATCH 7/7] iio: adc: ad799x: use iio helper function to guarantee direct mode

FromJonathan Cameron <jic23@kernel.org>
Date2016-05-29 20:40 +0200
SubjectRe: [PATCH 7/7] iio: adc: ad799x: use iio helper function to guarantee direct mode
Message-ID<rEdMZ-1qk-9@gated-at.bofh.it>
In reply to#1406835
On 25/05/16 11:42, Daniel Baluta wrote:
> On Tue, May 24, 2016 at 10:20 PM, Alison Schofield <amsfield22@gmail.com> wrote:
>> Replace the code that guarantees the device stays in direct mode
>> with iio_device_claim_direct_mode() which does same.
>>
>> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
>> Cc: Daniel Baluta <daniel.baluta@gmail.com>
> 
> Acked-by: Daniel Baluta <daniel.baluta@gmail.com>
Applied to the togreg branch of iio.git - initially pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan
> 
> 
>> ---
>>  drivers/iio/adc/ad799x.c | 24 +++++++++---------------
>>  1 file changed, 9 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
>> index a3f5254..ec0200d 100644
>> --- a/drivers/iio/adc/ad799x.c
>> +++ b/drivers/iio/adc/ad799x.c
>> @@ -282,12 +282,11 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,
>>
>>         switch (m) {
>>         case IIO_CHAN_INFO_RAW:
>> -               mutex_lock(&indio_dev->mlock);
>> -               if (iio_buffer_enabled(indio_dev))
>> -                       ret = -EBUSY;
>> -               else
>> -                       ret = ad799x_scan_direct(st, chan->scan_index);
>> -               mutex_unlock(&indio_dev->mlock);
>> +               ret = iio_device_claim_direct_mode(indio_dev);
>> +               if (ret)
>> +                       return ret;
>> +               ret = ad799x_scan_direct(st, chan->scan_index);
>> +               iio_device_release_direct_mode(indio_dev);
>>
>>                 if (ret < 0)
>>                         return ret;
>> @@ -395,11 +394,9 @@ static int ad799x_write_event_config(struct iio_dev *indio_dev,
>>         struct ad799x_state *st = iio_priv(indio_dev);
>>         int ret;
>>
>> -       mutex_lock(&indio_dev->mlock);
>> -       if (iio_buffer_enabled(indio_dev)) {
>> -               ret = -EBUSY;
>> -               goto done;
>> -       }
>> +       ret = iio_device_claim_direct_mode(indio_dev);
>> +       if (ret)
>> +               return ret;
>>
>>         if (state)
>>                 st->config |= BIT(chan->scan_index) << AD799X_CHANNEL_SHIFT;
>> @@ -412,10 +409,7 @@ static int ad799x_write_event_config(struct iio_dev *indio_dev,
>>                 st->config &= ~AD7998_ALERT_EN;
>>
>>         ret = ad799x_write_config(st, st->config);
>> -
>> -done:
>> -       mutex_unlock(&indio_dev->mlock);
>> -
>> +       iio_device_release_direct_mode(indio_dev);
>>         return ret;
>>  }
>>
>> --
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web