From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 In-Reply-To: <77ce5285-713f-4f2e-97b0-702c93404d82@email.android.com> References: <1395255044-20173-1-git-send-email-alecaberg@chromium.org> <77ce5285-713f-4f2e-97b0-702c93404d82@email.android.com> From: Alec Berg Date: Wed, 19 Mar 2014 14:33:48 -0700 Message-ID: Subject: Re: [PATCH] iio: querying buffer scan_mask should return 0/1 To: Jonathan Cameron Cc: Alec Berg , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Palatin , olof@lixom.net Content-Type: multipart/alternative; boundary=089e0149ce3cae108304f4fc69ce List-ID: --089e0149ce3cae108304f4fc69ce Content-Type: text/plain; charset=UTF-8 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 wrote: > > > On March 19, 2014 6:50:44 PM GMT+00:00, 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(). > 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 > >--- > > 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. > --089e0149ce3cae108304f4fc69ce Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I'm using x86, not sure what other architectures, if a= ny, that it affects.

Thanks.


On Wed, Mar 19, 2014 at 1:31 = PM, Jonathan Cameron <jic23@kernel.org> wrote:


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. =C2=A0Which architectures? =C2=A0Change is fine = BTW. Will pick when I get a few mins...
>
>Additionally, it's important for the sysfs interface to consistentl= y
>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,=
> =C2=A0 =C2=A0 =C2=A0 int ret;
> =C2=A0 =C2=A0 =C2=A0 struct iio_dev *indio_dev =3D dev_to_iio_dev(dev)= ;
>
>- =C2=A0 =C2=A0 =C2=A0ret =3D test_bit(to_iio_dev_attr(attr)->addres= s,
>+ =C2=A0 =C2=A0 =C2=A0/* Ensure ret is 0 or 1. */
>+ =C2=A0 =C2=A0 =C2=A0ret =3D !!test_bit(to_iio_dev_attr(attr)->addr= ess,
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0indio_dev->buffer->scan_mask);
>
> =C2=A0 =C2=A0 =C2=A0 return sprintf(buf, "%d\n", ret);
>@@ -866,7 +867,8 @@ int iio_scan_mask_query(struct iio_dev *indio_dev,<= br> > =C2=A0 =C2=A0 =C2=A0 if (!buffer->scan_mask)
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;
>
>- =C2=A0 =C2=A0 =C2=A0return test_bit(bit, buffer->scan_mask);
>+ =C2=A0 =C2=A0 =C2=A0/* Ensure return value is 0 or 1. */
>+ =C2=A0 =C2=A0 =C2=A0return !!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 brev= ity.

--089e0149ce3cae108304f4fc69ce-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from saturn.retrosnub.co.uk ([178.18.118.26]:34736 "EHLO saturn.retrosnub.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753794AbaCSWCl (ORCPT ); Wed, 19 Mar 2014 18:02:41 -0400 Message-ID: <532A143D.9070108@kernel.org> Date: Wed, 19 Mar 2014 22:03:41 +0000 From: Jonathan Cameron MIME-Version: 1.0 To: Alec Berg CC: Alec Berg , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Palatin , olof@lixom.net Subject: Re: [PATCH] iio: querying buffer scan_mask should return 0/1 References: <1395255044-20173-1-git-send-email-alecaberg@chromium.org> <77ce5285-713f-4f2e-97b0-702c93404d82@email.android.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Sender: linux-iio-owner@vger.kernel.org List-Id: linux-iio@vger.kernel.org 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 > wrote: > > > > On March 19, 2014 6:50:44 PM GMT+00:00, 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(). > 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 > > >--- > > 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. > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from saturn.retrosnub.co.uk ([178.18.118.26]:34293 "EHLO saturn.retrosnub.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753818AbaCSUbr (ORCPT ); Wed, 19 Mar 2014 16:31:47 -0400 In-Reply-To: <1395255044-20173-1-git-send-email-alecaberg@chromium.org> References: <1395255044-20173-1-git-send-email-alecaberg@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Subject: Re: [PATCH] iio: querying buffer scan_mask should return 0/1 From: Jonathan Cameron Date: Wed, 19 Mar 2014 20:31:40 +0000 To: Alec Berg , linux-iio@vger.kernel.org CC: linux-kernel@vger.kernel.org, Vincent Palatin , olof@lixom.net Message-ID: <77ce5285-713f-4f2e-97b0-702c93404d82@email.android.com> Sender: linux-iio-owner@vger.kernel.org List-Id: linux-iio@vger.kernel.org On March 19, 2014 6:50:44 PM GMT+00:00, 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(). 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 >--- > 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. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from saturn.retrosnub.co.uk ([178.18.118.26]:53271 "EHLO saturn.retrosnub.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750738AbaCVMT7 (ORCPT ); Sat, 22 Mar 2014 08:19:59 -0400 Message-ID: <532D8030.40607@kernel.org> Date: Sat, 22 Mar 2014 12:21:04 +0000 From: Jonathan Cameron MIME-Version: 1.0 To: Alec Berg , linux-iio@vger.kernel.org CC: linux-kernel@vger.kernel.org, Vincent Palatin , olof@lixom.net Subject: Re: [PATCH] iio: querying buffer scan_mask should return 0/1 References: <1395255044-20173-1-git-send-email-alecaberg@chromium.org> In-Reply-To: <1395255044-20173-1-git-send-email-alecaberg@chromium.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Sender: linux-iio-owner@vger.kernel.org List-Id: linux-iio@vger.kernel.org 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 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); > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa0-f73.google.com ([209.85.219.73]:35961 "EHLO mail-oa0-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750943AbaCSS5a (ORCPT ); Wed, 19 Mar 2014 14:57:30 -0400 Received: by mail-oa0-f73.google.com with SMTP id n16so1749025oag.4 for ; Wed, 19 Mar 2014 11:57:30 -0700 (PDT) From: Alec Berg To: Jonathan Cameron , linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Vincent Palatin , olof@lixom.net, Alec Berg Subject: [PATCH] iio: querying buffer scan_mask should return 0/1 Date: Wed, 19 Mar 2014 11:50:44 -0700 Message-Id: <1395255044-20173-1-git-send-email-alecaberg@chromium.org> Sender: linux-iio-owner@vger.kernel.org List-Id: linux-iio@vger.kernel.org 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 --- 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