linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>
Subject: Re: [libgpiod][RFC v2] core: implement v2.0 API
Date: Sun, 30 May 2021 09:27:20 +0800	[thread overview]
Message-ID: <20210530012720.GA11390@sol> (raw)
In-Reply-To: <CAMRc=MfP5jEDqONYA0b7Dmm1hi38C8V1XSaX6xm03Cv4mpCJMQ@mail.gmail.com>

On Sat, May 29, 2021 at 08:19:32PM +0200, Bartosz Golaszewski wrote:
> On Sat, May 29, 2021 at 1:23 AM Kent Gibson <warthog618@gmail.com> wrote:
> >
> 

[snip]

I meant to reply to this section as well but managed to snip it out...

> > > > the gpiod_chip_request_lines() or gpiod_line_request_reconfigure_lines()
> > > > is called it isn't too complex and so can be translated to the uAPI.
> > > > The check has to be performed as part of those functions either way, and
> > > > validating a transitional config doesn't prove anything.
> > > >
> > >
> > > Indeed. OTOH with return values in mutators taking integer values we
> > > would throw errors on invalid values passed. I need to think about it
> > > some more.
> > >
> >
> > I was assuming separate mutators for each of the enum values, as you do
> > for the active level but, with the offset and subset variants
> > multiplying the number of mutators, I can see why you would go with the
> > parameterized versions.  While you could still perform the range
> > checking as part of the translation to uAPI, that can more difficult for
> > the user to debug - depending on how many mutators they have applied.
> >
> > It is a trade-off, but I still lean towards the error-less mutators as
> > it simplifies user code - consolidating the error checking into one
> > place. A parameter being out of range means the user is doing something
> > stupid, or running a future app against an old libgpiod, in which case
> > they should be fine with slightly tougher debugging.
> >
> 
> Having error-less mutators here would mean something like a hundred
> functions just for setting the line config. I think that even with
> mutators taking enums we already have enough symbols. Let's keep them.
> 

We don't want separate mutators for each enum value as that would
explode the symbol space.  Agreed.

To be clear, in my "trade-off" paragraph above I was referring to your
existing parameterised error-less mutators, not the parameter-less
error-less mutators that I had been assuming.
Different paragraph and different things.

So, to conclude, I would lean towards keeping your existing mutators that
don't return error codes, rather than adding error codes.
And only performing the validation when the config is translated to uAPI,
not providing some functions to perform interim validation.
i.e. wrt error handling I'm fine with the mutators as they are.

OK?

Cheers,
Kent.

      parent reply	other threads:[~2021-05-30  1:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18 19:18 [libgpiod][RFC v2] core: implement v2.0 API Bartosz Golaszewski
2021-05-27 11:27 ` Kent Gibson
2021-05-28 13:51   ` Bartosz Golaszewski
2021-05-28 23:23     ` Kent Gibson
2021-05-29  5:10       ` Kent Gibson
2021-05-29 18:19       ` Bartosz Golaszewski
2021-05-30  0:45         ` Kent Gibson
2021-06-01 19:57           ` Bartosz Golaszewski
2021-06-02  3:12             ` Kent Gibson
2021-06-02  8:36               ` Bartosz Golaszewski
2021-06-02 10:43                 ` Kent Gibson
2021-05-30  1:27         ` 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=20210530012720.GA11390@sol \
    --to=warthog618@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).