linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: querying buffer scan_mask should return 0/1
@ 2014-03-19 18:50 Alec Berg
  2014-03-19 20:31 ` Jonathan Cameron
  2014-03-22 12:21 ` Jonathan Cameron
  0 siblings, 2 replies; 4+ messages in thread
From: Alec Berg @ 2014-03-19 18:50 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: linux-kernel, Vincent Palatin, olof, Alec Berg

Ensure that querying the IIO buffer scan_mask returns a value of
0 or 1. Currently querying the scan mask has the value returned
by test_bit(), which returns either true or false. For some
architectures test_bit() may return -1 for true, which will appear
to return an error when returning from iio_scan_mask_query().

Additionally, it's important for the sysfs interface to consistently
return the same thing when querying the scan_mask.

Signed-off-by: Alec Berg <alecaberg@chromium.org>
---
 drivers/iio/industrialio-buffer.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index c67d83b..fe25042 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -165,7 +165,8 @@ static ssize_t iio_scan_el_show(struct device *dev,
 	int ret;
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 
-	ret = test_bit(to_iio_dev_attr(attr)->address,
+	/* Ensure ret is 0 or 1. */
+	ret = !!test_bit(to_iio_dev_attr(attr)->address,
 		       indio_dev->buffer->scan_mask);
 
 	return sprintf(buf, "%d\n", ret);
@@ -866,7 +867,8 @@ int iio_scan_mask_query(struct iio_dev *indio_dev,
 	if (!buffer->scan_mask)
 		return 0;
 
-	return test_bit(bit, buffer->scan_mask);
+	/* Ensure return value is 0 or 1. */
+	return !!test_bit(bit, buffer->scan_mask);
 };
 EXPORT_SYMBOL_GPL(iio_scan_mask_query);
 
-- 
1.9.0.279.gdc9e3eb


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: querying buffer scan_mask should return 0/1
  2014-03-19 18:50 [PATCH] iio: querying buffer scan_mask should return 0/1 Alec Berg
@ 2014-03-19 20:31 ` Jonathan Cameron
       [not found]   ` <CAGgO2Lgka8-S70ydrNRErwUPYNmTXvpNk-k6ApFNpqjGRVjH4Q@mail.gmail.com>
  2014-03-22 12:21 ` Jonathan Cameron
  1 sibling, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2014-03-19 20:31 UTC (permalink / raw)
  To: Alec Berg, linux-iio; +Cc: linux-kernel, Vincent Palatin, olof



On March 19, 2014 6:50:44 PM GMT+00:00, Alec Berg <alecaberg@chromium.org> wrote:
>Ensure that querying the IIO buffer scan_mask returns a value of
>0 or 1. Currently querying the scan mask has the value returned
>by test_bit(), which returns either true or false. For some
>architectures test_bit() may return -1 for true, which will appear
>to return an error when returning from iio_scan_mask_query().
I'm curious now.  Which architectures?  Change is fine BTW. Will pick when I get a few mins...
>
>Additionally, it's important for the sysfs interface to consistently
>return the same thing when querying the scan_mask.
>
>Signed-off-by: Alec Berg <alecaberg@chromium.org>
>---
> drivers/iio/industrialio-buffer.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/iio/industrialio-buffer.c
>b/drivers/iio/industrialio-buffer.c
>index c67d83b..fe25042 100644
>--- a/drivers/iio/industrialio-buffer.c
>+++ b/drivers/iio/industrialio-buffer.c
>@@ -165,7 +165,8 @@ static ssize_t iio_scan_el_show(struct device *dev,
> 	int ret;
> 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> 
>-	ret = test_bit(to_iio_dev_attr(attr)->address,
>+	/* Ensure ret is 0 or 1. */
>+	ret = !!test_bit(to_iio_dev_attr(attr)->address,
> 		       indio_dev->buffer->scan_mask);
> 
> 	return sprintf(buf, "%d\n", ret);
>@@ -866,7 +867,8 @@ int iio_scan_mask_query(struct iio_dev *indio_dev,
> 	if (!buffer->scan_mask)
> 		return 0;
> 
>-	return test_bit(bit, buffer->scan_mask);
>+	/* Ensure return value is 0 or 1. */
>+	return !!test_bit(bit, buffer->scan_mask);
> };
> EXPORT_SYMBOL_GPL(iio_scan_mask_query);
> 

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: querying buffer scan_mask should return 0/1
       [not found]   ` <CAGgO2Lgka8-S70ydrNRErwUPYNmTXvpNk-k6ApFNpqjGRVjH4Q@mail.gmail.com>
@ 2014-03-19 22:03     ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2014-03-19 22:03 UTC (permalink / raw)
  To: Alec Berg; +Cc: Alec Berg, linux-iio, linux-kernel, Vincent Palatin, olof

Ah, an obscure platform used by hardly anyone ;)

Oops.

Given timing this will be post the merge window, but I'll mark it for stable.

On 19/03/14 21:33, Alec Berg wrote:
> I'm using x86, not sure what other architectures, if any, that it affects.
>
> Thanks.
>
>
> On Wed, Mar 19, 2014 at 1:31 PM, Jonathan Cameron <jic23@kernel.org <mailto:jic23@kernel.org>> wrote:
>
>
>
>     On March 19, 2014 6:50:44 PM GMT+00:00, Alec Berg <alecaberg@chromium.org <mailto:alecaberg@chromium.org>> wrote:
>      >Ensure that querying the IIO buffer scan_mask returns a value of
>      >0 or 1. Currently querying the scan mask has the value returned
>      >by test_bit(), which returns either true or false. For some
>      >architectures test_bit() may return -1 for true, which will appear
>      >to return an error when returning from iio_scan_mask_query().
>     I'm curious now.  Which architectures?  Change is fine BTW. Will pick when I get a few mins...
>      >
>      >Additionally, it's important for the sysfs interface to consistently
>      >return the same thing when querying the scan_mask.
>      >
>      >Signed-off-by: Alec Berg <alecaberg@chromium.org <mailto:alecaberg@chromium.org>>
>      >---
>      > drivers/iio/industrialio-buffer.c | 6 ++++--
>      > 1 file changed, 4 insertions(+), 2 deletions(-)
>      >
>      >diff --git a/drivers/iio/industrialio-buffer.c
>      >b/drivers/iio/industrialio-buffer.c
>      >index c67d83b..fe25042 100644
>      >--- a/drivers/iio/industrialio-buffer.c
>      >+++ b/drivers/iio/industrialio-buffer.c
>      >@@ -165,7 +165,8 @@ static ssize_t iio_scan_el_show(struct device *dev,
>      >       int ret;
>      >       struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>      >
>      >-      ret = test_bit(to_iio_dev_attr(attr)->address,
>      >+      /* Ensure ret is 0 or 1. */
>      >+      ret = !!test_bit(to_iio_dev_attr(attr)->address,
>      >                      indio_dev->buffer->scan_mask);
>      >
>      >       return sprintf(buf, "%d\n", ret);
>      >@@ -866,7 +867,8 @@ int iio_scan_mask_query(struct iio_dev *indio_dev,
>      >       if (!buffer->scan_mask)
>      >               return 0;
>      >
>      >-      return test_bit(bit, buffer->scan_mask);
>      >+      /* Ensure return value is 0 or 1. */
>      >+      return !!test_bit(bit, buffer->scan_mask);
>      > };
>      > EXPORT_SYMBOL_GPL(iio_scan_mask_query);
>      >
>
>     --
>     Sent from my Android phone with K-9 Mail. Please excuse my brevity.
>
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: querying buffer scan_mask should return 0/1
  2014-03-19 18:50 [PATCH] iio: querying buffer scan_mask should return 0/1 Alec Berg
  2014-03-19 20:31 ` Jonathan Cameron
@ 2014-03-22 12:21 ` Jonathan Cameron
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2014-03-22 12:21 UTC (permalink / raw)
  To: Alec Berg, linux-iio; +Cc: linux-kernel, Vincent Palatin, olof

On 19/03/14 18:50, Alec Berg wrote:
> Ensure that querying the IIO buffer scan_mask returns a value of
> 0 or 1. Currently querying the scan mask has the value returned
> by test_bit(), which returns either true or false. For some
> architectures test_bit() may return -1 for true, which will appear
> to return an error when returning from iio_scan_mask_query().
>
> Additionally, it's important for the sysfs interface to consistently
> return the same thing when querying the scan_mask.
>
> Signed-off-by: Alec Berg <alecaberg@chromium.org>
Applied to the fixes-togreg branch of iio.git and
marked for stable.

This will probably now go in shortly after rc1.

Thanks,

Jonathan
> ---
>   drivers/iio/industrialio-buffer.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index c67d83b..fe25042 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -165,7 +165,8 @@ static ssize_t iio_scan_el_show(struct device *dev,
>   	int ret;
>   	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>
> -	ret = test_bit(to_iio_dev_attr(attr)->address,
> +	/* Ensure ret is 0 or 1. */
> +	ret = !!test_bit(to_iio_dev_attr(attr)->address,
>   		       indio_dev->buffer->scan_mask);
>
>   	return sprintf(buf, "%d\n", ret);
> @@ -866,7 +867,8 @@ int iio_scan_mask_query(struct iio_dev *indio_dev,
>   	if (!buffer->scan_mask)
>   		return 0;
>
> -	return test_bit(bit, buffer->scan_mask);
> +	/* Ensure return value is 0 or 1. */
> +	return !!test_bit(bit, buffer->scan_mask);
>   };
>   EXPORT_SYMBOL_GPL(iio_scan_mask_query);
>
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-22 12:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-19 18:50 [PATCH] iio: querying buffer scan_mask should return 0/1 Alec Berg
2014-03-19 20:31 ` Jonathan Cameron
     [not found]   ` <CAGgO2Lgka8-S70ydrNRErwUPYNmTXvpNk-k6ApFNpqjGRVjH4Q@mail.gmail.com>
2014-03-19 22:03     ` Jonathan Cameron
2014-03-22 12:21 ` Jonathan Cameron

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).