From: Kent Gibson <warthog618@gmail.com>
To: "Martin Hundebøll" <martin@geanix.com>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>,
linux-gpio@vger.kernel.org, Esben Haabendal <esben@geanix.com>
Subject: Re: [libgpiod][RFC] helper functions for basic use cases
Date: Wed, 15 May 2024 17:32:03 +0800 [thread overview]
Message-ID: <20240515093203.GB86661@rigel> (raw)
In-Reply-To: <cfa1d2cc41a4c5f924f1599a4da0c8e6fbe00eba.camel@geanix.com>
On Wed, May 15, 2024 at 09:06:50AM +0200, Martin Hundebøll wrote:
> On Mon, 2024-05-13 at 01:28 -0700, Bartosz Golaszewski wrote:
> > > Anyway, have a think about it.
> > > And I'll go take a look at the GLib bindings.
> > >
> >
> > I have thought about it. I agree we could use some simpler
> > interfaces. I don't
> > agree their place is in core libgpiod. I understand we want to make
> > this new
> > interface seamless to use for end-users of libgpiod.
> >
> > How about introducing a new header and a separate shared object:
> > gpiod-ext.h
> > and libgpiod-ext.so respectively? We could put all these new helpers
> > in there,
> > use the gpiod_ext_ prefix for all of them and distros could package
> > the
> > "extended" part of libgpiod together with the core library to avoid
> > having to
> > install multiple packages?
> >
> > We'd keep the clear distinction between the low-level, core C library
> > wrapping
> > the kernel uAPI and the user-friendly C API. Though the user-friendly
> > API in my
> > book could be the GLib library but I understand not everyone wants to
> > use GLib
> > nor is familiar with GObject.
>
> For our embedded use cases we would go far to avoid GLib in our root
> filesystem (and our initrd too). This means relying on libgpiod only.
>
> With the current core API, reading a single gpio line feels cumbersome.
> Especially because we often use gpio labels to run the same binaries on
> multiple hardware variants.
>
> So we would really like to see an "extended" API, with wrappers to:
> * request a single gpio line from chip + offset
That is in my proposal.
> * request a single gpio line from a (unique) label
That one would require migrating a fair chunk of code from tools into
core. Though that deals with multiple lines in parallel, whereas this
would only have to deal with a single line, so could just be a simple
interation to find the line.
Would a function that finds the (chip,offset) for a name be sufficient?
> * read the current value of the requested gpio line
> * set the current value of the requested gpio line
I did consider these, but didn't see a huge advantage over the existing.
gpiod_line_request_get_value(req, offset). Too complicated?
OTOH, if you want to get the line by name then you don't know the offset
:(.
>
> Having those functionalities in a separate shared object is fine.
>
Good to know, but my intent is to make these ext functions still use
the core object so users can still use the existing core functions.
Cheers,
Kent.
prev parent reply other threads:[~2024-05-15 9:32 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-07 2:21 [libgpiod][RFC] helper functions for basic use cases Kent Gibson
2024-05-10 18:37 ` Bartosz Golaszewski
2024-05-11 1:11 ` Kent Gibson
2024-05-13 8:28 ` Bartosz Golaszewski
2024-05-13 10:13 ` Kent Gibson
2024-05-14 13:31 ` Bartosz Golaszewski
2024-05-14 13:38 ` Kent Gibson
2024-05-15 8:26 ` Bartosz Golaszewski
2024-05-15 9:18 ` Kent Gibson
2024-05-15 13:37 ` Kent Gibson
2024-05-15 13:54 ` Bartosz Golaszewski
2024-05-15 14:14 ` Kent Gibson
2024-05-16 0:19 ` Kent Gibson
2024-05-16 13:55 ` Kent Gibson
2024-05-17 10:53 ` Bartosz Golaszewski
2024-05-17 12:37 ` Kent Gibson
2024-05-22 10:59 ` Bartosz Golaszewski
2024-05-22 12:41 ` Kent Gibson
2024-05-24 14:20 ` Bartosz Golaszewski
2024-05-15 7:06 ` Martin Hundebøll
2024-05-15 9:32 ` Kent Gibson [this message]
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=20240515093203.GB86661@rigel \
--to=warthog618@gmail.com \
--cc=brgl@bgdev.pl \
--cc=esben@geanix.com \
--cc=linux-gpio@vger.kernel.org \
--cc=martin@geanix.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 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).