From: Jonathan Cameron <jic23@kernel.org>
To: Alec Berg <alecaberg@chromium.org>, linux-iio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Vincent Palatin <vpalatin@chromium.org>,
olof@lixom.net
Subject: Re: [PATCH] iio: querying buffer scan_mask should return 0/1
Date: Wed, 19 Mar 2014 20:31:40 +0000 [thread overview]
Message-ID: <77ce5285-713f-4f2e-97b0-702c93404d82@email.android.com> (raw)
In-Reply-To: <1395255044-20173-1-git-send-email-alecaberg@chromium.org>
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.
next prev parent reply other threads:[~2014-03-19 20:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-19 18:50 [PATCH] iio: querying buffer scan_mask should return 0/1 Alec Berg
2014-03-19 20:31 ` Jonathan Cameron [this message]
2014-03-19 21:33 ` Alec Berg
2014-03-19 22:03 ` Jonathan Cameron
2014-03-22 12:21 ` 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=77ce5285-713f-4f2e-97b0-702c93404d82@email.android.com \
--to=jic23@kernel.org \
--cc=alecaberg@chromium.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olof@lixom.net \
--cc=vpalatin@chromium.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