All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Artur Rojek <contact@artur-rojek.eu>
Cc: Paul Cercueil <paul@crapouillou.net>,
	Jonathan Cameron <jic23@kernel.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Chris Morgan <macromorgan@hotmail.com>,
	"open list:BROADCOM NVRAM DRIVER" <linux-mips@vger.kernel.org>,
	linux-iio <linux-iio@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-input <linux-input@vger.kernel.org>
Subject: Re: [PATCH 3/4] iio: add helper function for reading channel offset in buffer
Date: Fri, 19 Aug 2022 11:17:41 +0300	[thread overview]
Message-ID: <CAHp75VeierGKV7BqF+y-vxramA4nk24LOSPRxgmjots_amkg-w@mail.gmail.com> (raw)
In-Reply-To: <20220817105643.95710-4-contact@artur-rojek.eu>

On Wed, Aug 17, 2022 at 1:58 PM Artur Rojek <contact@artur-rojek.eu> wrote:
>
> This is useful for consumers that wish to parse raw buffer data.

...

> +int iio_find_channel_offset_in_buffer(struct iio_dev *indio_dev,
> +                                     const struct iio_chan_spec *chan,
> +                                     struct iio_buffer *buffer)
> +{
> +       int length, offset = 0;
> +       unsigned int si;
> +
> +       if (chan->scan_index < 0 ||
> +           !test_bit(chan->scan_index, buffer->scan_mask)) {
> +               return -EINVAL;
> +       }

Have you run checkpatch? The {} are redundant. But personally I would
split this into two separate conditionals.

> +       for (si = 0; si < chan->scan_index; ++si) {

Just a side crying: where did you, people, get this pre-increment pattern from?!

> +               if (!test_bit(si, buffer->scan_mask))
> +                       continue;

NIH for_each_set_bit()

> +               length = iio_storage_bytes_for_si(indio_dev, si);
> +
> +               /* Account for channel alignment. */
> +               if (offset % length)
> +                       offset += length - (offset % length);
> +               offset += length;
> +       }
> +
> +       return offset;
> +}
> +EXPORT_SYMBOL_GPL(iio_find_channel_offset_in_buffer);

Same Q as per previous patch: IIO namespace?

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2022-08-19  8:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 10:56 [PATCH 0/4] iio/adc-joystick: buffer data parsing fixes Artur Rojek
2022-08-17 10:56 ` [PATCH 1/4] iio/adc: ingenic: fix channel offsets in buffer Artur Rojek
2022-08-19  8:12   ` Andy Shevchenko
2022-08-19 10:07     ` Paul Cercueil
2022-08-19 10:15       ` Andy Shevchenko
2022-08-17 10:56 ` [PATCH 2/4] iio: add iio_channel_cb_get_iio_buffer helper Artur Rojek
2022-08-19  8:14   ` Andy Shevchenko
2022-08-19 17:35     ` Jonathan Cameron
2022-08-19 17:44   ` Jonathan Cameron
2022-08-17 10:56 ` [PATCH 3/4] iio: add helper function for reading channel offset in buffer Artur Rojek
2022-08-19  8:17   ` Andy Shevchenko [this message]
2022-08-19 10:33     ` Artur Rojek
2022-08-19 10:36       ` Andy Shevchenko
2022-08-19 17:49   ` Jonathan Cameron
2022-08-17 10:56 ` [PATCH 4/4] input: joystick: Fix buffer data parsing Artur Rojek
2022-08-19  8:21   ` Andy Shevchenko
2022-08-19 17:53   ` Jonathan Cameron
2022-08-22  9:03     ` Paul Cercueil
2022-08-22 19:01       ` Jonathan Cameron
2022-08-18 18:28 ` [PATCH 0/4] iio/adc-joystick: buffer data parsing fixes Chris Morgan
2022-08-19 10:36   ` Artur Rojek

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=CAHp75VeierGKV7BqF+y-vxramA4nk24LOSPRxgmjots_amkg-w@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=contact@artur-rojek.eu \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=macromorgan@hotmail.com \
    --cc=paul@crapouillou.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.