From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Kent Gibson <warthog618@gmail.com>
Cc: "open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: Re: [libgpiod][PATCH] core: Basic port to uAPI v2
Date: Fri, 2 Oct 2020 16:48:02 +0300 [thread overview]
Message-ID: <CAHp75VfVDsxHDcnwdO5TL=wx-rB6=cuCWOxj0oP7+kpZvKuH6A@mail.gmail.com> (raw)
In-Reply-To: <20201002063148.32667-1-warthog618@gmail.com>
On Fri, Oct 2, 2020 at 9:32 AM Kent Gibson <warthog618@gmail.com> wrote:
>
> Port existing implementation from GPIO uAPI v1 to v2.
> The libgpiod external interface remains unchanged, only the internal
> implementation switches from uAPI v1 to v2.
Cool!
> This is a minimal port - uAPI v2 features are only used where it
> simplifies the implementation, specifically multiple events on a bulk can
> now be handled directly by the kernel in a single v2 line request rather
> than being emulated by multiple v1 event requests.
...
> + if (config->flags & GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE)
> + bias_flags++;
> + if (config->flags & GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP)
> + bias_flags++;
> + if (config->flags & GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN)
> + bias_flags++;
> + if (bias_flags > 1)
> + return false;
Seems to me like an emulation of hweight(), although I don't know if
we have in standard libraries such.
...
> - if (values) {
> - for (i = 0; i < gpiod_line_bulk_num_lines(bulk); i++)
> - data.values[i] = (uint8_t)!!values[i];
> + for (i = 0; i < gpiod_line_bulk_num_lines(bulk); i++) {
> + lines_bitmap_set_bit(&lv.mask, i);
> + lines_bitmap_assign_bit(&lv.bits, i, values && values[i]);
> }
Hmm... What about
for (i = 0; i < gpiod_line_bulk_num_lines(bulk); i++)
lines_bitmap_set_bit(&lv.mask, i);
if (values) {
for (i = 0; i < gpiod_line_bulk_num_lines(bulk); i++)
lines_bitmap_assign_bit(&lv.bits, i, values[i]);
}
?
...
> /*
> * 16 is the maximum number of events the kernel can store in the FIFO
> * so we can allocate the buffer on the stack.
> + *
> + * NOTE: This is no longer strictly true for uAPI v2. While 16 is
> + * the default for single line, a request with multiple lines will
for a single
> + * have a larger buffer. So need to rethink the allocation here,
So we (I, ...?) need
> + * or at least the comment above...
> */
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2020-10-02 13:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-02 6:31 [libgpiod][PATCH] core: Basic port to uAPI v2 Kent Gibson
2020-10-02 13:48 ` Andy Shevchenko [this message]
2020-10-02 16:06 ` Kent Gibson
2020-10-05 10:27 ` Bartosz Golaszewski
2020-10-12 10:37 ` Bartosz Golaszewski
2020-10-13 7:08 ` Bartosz Golaszewski
2020-10-13 8:30 ` Kent Gibson
2020-10-14 3:17 ` Kent Gibson
2020-10-14 7:37 ` Bartosz Golaszewski
2020-10-14 8:51 ` Kent Gibson
2020-10-14 8:52 ` Bartosz Golaszewski
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='CAHp75VfVDsxHDcnwdO5TL=wx-rB6=cuCWOxj0oP7+kpZvKuH6A@mail.gmail.com' \
--to=andy.shevchenko@gmail.com \
--cc=bgolaszewski@baylibre.com \
--cc=linux-gpio@vger.kernel.org \
--cc=warthog618@gmail.com \
/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.