linux-pci.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>,
	"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	"Pali Rohár" <pali@kernel.org>,
	"Shawn Guo" <shawn.guo@linaro.org>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] PCI: mvebu: switch to using gpiod API
Date: Wed, 14 Sep 2022 21:00:36 +0800	[thread overview]
Message-ID: <YyHQdN14bI4WeCKp@sol> (raw)
In-Reply-To: <CAMRc=MdrX5Pz1d-SM2PPikEYw0zJBe6GCdr4pEfgBLMi1J9PAQ@mail.gmail.com>

On Wed, Sep 14, 2022 at 02:10:21PM +0200, Bartosz Golaszewski wrote:
> On Wed, Sep 14, 2022 at 12:35 PM Linus Walleij <linus.walleij@linaro.org> wrote:
> >
> > On Wed, Sep 7, 2022 at 12:41 AM Dmitry Torokhov
> > <dmitry.torokhov@gmail.com> wrote:
> >
> > > Linus, do you think we should introduce GPIOD_OUT_INACTIVE /
> > > GPIOD_OUT_ACTIVE or GPIOD_OUT_DEASSERTED / GPIOD_OUT_ASSERTED and
> > > deprecate existing GPIOD_OUT_LOW and GPIO_OUT_HIGH?
> >
> > They should rather be replaced everywhere in one go.
> >
> > I think it is just a half-measure unless we also add
> > #define GPIOD_ASSERTED 1
> > #define GPIOD_DEASSERTED 0
> > to be used instead of 1/0 in gpiod_set_value().
> >
> 
> We've had that discussion for libgpiod and went with
> GPIOD_VALUE_ACTIVE and GPIOD_VALUE_INACTIVE but...
> 
> > It would also imply changing the signature of the function
> > gpiod_set_value() to gpiod_set_state() as we are not
> > really setting a value but a state.
> >
> 

I might be in the minority here, but in this context value and state mean
the same thing to me, so changing from one to the other provides no
additional clarity and is at best pointless.

The key distinction is whether you are describing a physical or logical
value/state.
High/low should be reserved for physical.
Active/inactive describe logical.

(I personally dislike "deassert" as it is a manufactured word that feels
very awkward.)

So for gpiod_set_value(), which expects a logical value, you would use
ACTIVE/INACTIVE.  For gpiod_set_raw_value(), which expects a physical
value, you would use HIGH/LOW.

Given there are gpiod functions that expect both, there is a case for
both to pairings exist, and for the caller to use the appropriate one
for the call.

Changing gpiod_set_value() to gpiod_set_state(), while leaving
gpiod_set_raw_value() as is, does not reduce confusion - at least not for
me.

Cheers,
Kent.

> ... now that you've mentioned it it does seem like
> GPIOD_STATE_ACTIVE/INACTIVE makes much more sense as well as naming
> the relevant functions gpiod_line_request_set_line_state() etc.
> 
> > I have thought about changing this, but the problem is that I felt
> > it should be accompanied with a change fixing as many users
> > as possible.
> >
> > I think this is one of those occasions where we should merge
> > the new defines, and then send Linus Torvalds a sed script
> > that he can run at the end of the merge window to change all
> > gpiod_set_value(...., 1) -> gpiod_set_state(...., GPIOD_ASSERTED);
> > everywhere.
> >
> > After all users are changed, the GPIOD_ASSERTED/DEASSERTED
> > defined can be turned into an enum.
> >
> > That would be the silver bullet against a lot of confusion IMO.
> >
> > We would need Bartosz' input on this.
> >
> 
> We can also let Linus know that we'll do it ourselves late in the
> merge window and send a separate PR on Saturday before rc1?
> 
> Bart
> 
> > Yours,
> > Linus Walleij

  parent reply	other threads:[~2022-09-14 13:00 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-06 20:43 [PATCH 1/2] PCI: histb: switch to using gpiod API Dmitry Torokhov
2022-09-06 20:43 ` [PATCH 2/2] PCI: mvebu: " Dmitry Torokhov
2022-09-06 21:16   ` Pali Rohár
2022-09-06 21:26     ` Dmitry Torokhov
2022-09-06 21:40       ` Dmitry Torokhov
2022-09-06 21:42         ` Pali Rohár
2022-09-06 21:41       ` Pali Rohár
2022-09-06 21:52         ` Dmitry Torokhov
2022-09-06 22:09           ` Pali Rohár
2022-09-06 22:41             ` Dmitry Torokhov
2022-09-11 12:58               ` Pali Rohár
2022-09-14 10:35               ` Linus Walleij
2022-09-14 12:10                 ` Bartosz Golaszewski
2022-09-14 12:48                   ` Linus Walleij
2022-09-14 13:00                   ` Kent Gibson [this message]
2022-09-14 13:36                     ` Linus Walleij
2022-09-15  2:23                   ` Kent Gibson
2022-09-15  8:51                     ` Linus Walleij
2022-09-15  9:30                       ` Kent Gibson
2022-09-16  7:22                         ` Bartosz Golaszewski
2022-09-18 14:37                           ` Linus Walleij
2022-09-18 23:58                           ` Kent Gibson
2022-09-08  8:42     ` Linus Walleij
2022-09-07  4:11   ` kernel test robot
2022-09-06 21:08 ` [PATCH 1/2] PCI: histb: " Pali Rohár
2022-09-06 21:41   ` Dmitry Torokhov
2022-09-06 21:46     ` Pali Rohár
2022-09-08  8:37 ` Linus Walleij
2022-11-11 15:01 ` Lorenzo Pieralisi
2022-11-11 15:20   ` Dmitry Torokhov
2022-11-14 10:58 ` (subset) " Lorenzo Pieralisi

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=YyHQdN14bI4WeCKp@sol \
    --to=warthog618@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=brgl@bgdev.pl \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kw@linux.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=pali@kernel.org \
    --cc=robh@kernel.org \
    --cc=shawn.guo@linaro.org \
    --cc=thomas.petazzoni@bootlin.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).