From: "Ardelean, Alexandru" <alexandru.Ardelean@analog.com>
To: "andy.shevchenko@gmail.com" <andy.shevchenko@gmail.com>
Cc: "pmeerw@pmeerw.ne" <pmeerw@pmeerw.ne>,
"jic23@kernel.org" <jic23@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"knaack.h@gmx.de" <knaack.h@gmx.de>,
"lars@metafoo.de" <lars@metafoo.de>
Subject: Re: [PATCH v2] iio: buffer: Don't allow buffers without any channels enabled to be activated
Date: Thu, 26 Mar 2020 07:42:48 +0000 [thread overview]
Message-ID: <62b90724f16fa3a2c54b7e7f2321587a328d7209.camel@analog.com> (raw)
In-Reply-To: <CAHp75VfVggWZ6WhOa=nUrxyd0dJrTbZd9NnUMhQ_S=kncrAhOw@mail.gmail.com>
On Wed, 2020-03-25 at 17:57 +0200, Andy Shevchenko wrote:
> [External]
>
> On Wed, Mar 25, 2020 at 12:02 PM Alexandru Ardelean
> <alexandru.ardelean@analog.com> wrote:
> > From: Lars-Peter Clausen <lars@metafoo.de>
> >
> > Before activating a buffer make sure that at least one channel is enabled.
> > Activating a buffer with 0 channels enabled doesn't make too much sense and
> > disallowing this case makes sure that individual driver don't have to add
> > special case code to handle it.
> >
> > Currently, without this patch enabling a buffer is possible and no error is
> > produced. With this patch -EINVAL is returned.
> >
> > An example of execution with this patch and some instrumented print-code:
> > root@analog:~# cd /sys/bus/iio/devices/iio\:device3/buffer
> > root@analog:/sys/bus/iio/devices/iio:device3/buffer# echo 1 > enable
> > 0: iio_verify_update 748 indio_dev->masklength 2 *insert_buffer-
> > >scan_mask 00000000
> > 1: iio_verify_update 753
> > 2:__iio_update_buffers 1115 ret -22
> > 3: iio_buffer_store_enable 1241 ret -22
> > -bash: echo: write error: Invalid argument
> > 1, 2 & 3 are exit-error paths. 0 the first print in iio_verify_update()
> > rergardless of error path.
> >
> > Without this patch (and same instrumented print-code):
> > root@analog:~# cd /sys/bus/iio/devices/iio\:device3/buffer
> > root@analog:/sys/bus/iio/devices/iio:device3/buffer# echo 1 > enable
> > 0: iio_verify_update 748 indio_dev->masklength 2 *insert_buffer-
> > >scan_mask 00000000
> > root@analog:/sys/bus/iio/devices/iio:device3/buffer#
> > Buffer is enabled with no error.
> >
> > Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> > ---
> >
> > Changelog v1 -> v2:
> > * moved check in iio_verify_update()
> > * added dev_dbg() message; should help some folks understand the message
> > * documented steps to reproduce
> > * added Fixes tag; hopefully the tag is the good one; if needed, it can be
> > dropped; this has been around for ~8 years; no idea if it's worth
> > backporting
>
> Where?
stable/fixes/lts-kernels
don't have a really good clue about where these things need backporting;
>
> > drivers/iio/industrialio-buffer.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-
> > buffer.c
> > index 5ff34ce8b6a2..e6fa1a4e135d 100644
> > --- a/drivers/iio/industrialio-buffer.c
> > +++ b/drivers/iio/industrialio-buffer.c
> > @@ -686,6 +686,13 @@ static int iio_verify_update(struct iio_dev *indio_dev,
> > bool scan_timestamp;
> > unsigned int modes;
> >
> > + if (insert_buffer &&
> > + bitmap_empty(insert_buffer->scan_mask, indio_dev->masklength)) {
> > + dev_dbg(&indio_dev->dev,
> > + "At least one scan element must be enabled
> > first\n");
> > + return -EINVAL;
> > + }
> > +
> > memset(config, 0, sizeof(*config));
> > config->watermark = ~0;
> >
> > --
> > 2.17.1
> >
>
>
next prev parent reply other threads:[~2020-03-26 7:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-20 10:40 [RFC][PATCH] iio: buffer: Don't allow buffers without any channels enabled to be activated Alexandru Ardelean
2020-03-20 10:55 ` Lars-Peter Clausen
2020-03-20 11:16 ` Ardelean, Alexandru
2020-03-21 18:21 ` Jonathan Cameron
2020-03-21 21:44 ` Andy Shevchenko
2020-03-25 8:17 ` Ardelean, Alexandru
2020-03-25 8:23 ` Ardelean, Alexandru
2020-03-25 10:01 ` [PATCH v2] " Alexandru Ardelean
2020-03-25 10:12 ` Ardelean, Alexandru
2020-03-25 15:57 ` Andy Shevchenko
2020-03-26 7:42 ` Ardelean, Alexandru [this message]
2020-03-26 7:44 ` Lars-Peter Clausen
2020-03-26 7:46 ` Ardelean, Alexandru
2020-03-26 9:30 ` [PATCH v3] " Alexandru Ardelean
2020-03-28 13:13 ` 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=62b90724f16fa3a2c54b7e7f2321587a328d7209.camel@analog.com \
--to=alexandru.ardelean@analog.com \
--cc=andy.shevchenko@gmail.com \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.ne \
/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;
as well as URLs for NNTP newsgroup(s).