linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>,
	devicetree@vger.kernel.org, linux-pwm@vger.kernel.org,
	Paul Barker <pbarker@konsulko.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Marcel Ziswiler <marcel.ziswiler@toradex.com>,
	Igor Opaniuk <igor.opaniuk@toradex.com>,
	Philippe Schenker <philippe.schenker@toradex.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Chen-Yu Tsai <wens@csie.org>,
	Claudiu Beznea <claudiu.beznea@microchip.com>,
	Fabio Estevam <festevam@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Heiko Stuebner <heiko@sntech.de>,
	Kevin Hilman <khilman@baylibre.com>,
	Ludovic Desroches <ludovic.desroches@microchip.com>,
	Maxime Ripard <mripard@kernel.org>,
	NXP Linux Team <linux-imx@nxp.com>,
	Nicolas Ferre <nicolas.ferre@microchip.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Paul Cercueil <paul@crapouillou.net>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Ray Jui <rjui@broadcom.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Scott Branden <sbranden@broadcom.com>,
	Shawn Guo <shawnguo@kernel.org>,
	bcm-kernel-feedback-list@broadcom.com,
	linux-amlogic@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	linux-rockchip@lists.infradead.org
Subject: Re: [RFC PATCH 1/7] pwm: rename the PWM_POLARITY_INVERSED enum
Date: Thu, 19 Mar 2020 17:37:00 +0100	[thread overview]
Message-ID: <20200319163700.GA3354541@ulmo> (raw)
In-Reply-To: <20200319065039.szhh5dm6v3ejwijd@pengutronix.de>

[-- Attachment #1: Type: text/plain, Size: 6885 bytes --]

On Thu, Mar 19, 2020 at 07:50:39AM +0100, Uwe Kleine-König wrote:
> 
> [Dropped Tony Prisk from recipients as the address bounces]
> 
> Hello,
> 
> On Wed, Mar 18, 2020 at 11:59:53PM +0100, Thierry Reding wrote:
> > On Tue, Mar 17, 2020 at 10:00:42PM +0100, Uwe Kleine-König wrote:
> > > Hello,
> > > 
> > > On Tue, Mar 17, 2020 at 06:40:43PM +0100, Thierry Reding wrote:
> > > > On Tue, Mar 17, 2020 at 02:32:25PM +0200, Oleksandr Suvorov wrote:
> > > > > The polarity enum definition PWM_POLARITY_INVERSED is misspelled.
> > > > > Rename it to PWM_POLARITY_INVERTED.
> > > > 
> > > > It isn't misspelled. "inversed" is a synonym for "inverted". Both
> > > > spellings are correct.
> > > 
> > > Some time ago I stumbled about "inversed", too. My spell checker doesn't
> > > know it and I checked some dictionaries and none of them knew that word:
> > > 
> > > https://www.lexico.com/search?utf8=%E2%9C%93&filter=dictionary&dictionary=en&query=inversed
> > > https://de.pons.com/%C3%BCbersetzung/englisch-deutsch/inversed
> > > https://dictionary.cambridge.org/spellcheck/english-german/?q=inversed
> > > 
> > > https://en.wiktionary.org/wiki/inverse#Verb mentions "inverse" as a verb
> > > having "inversed" as past participle.
> > 
> > Here are the first three results from a Google query:
> > 
> > 	https://www.yourdictionary.com/inversed
> 
> There is something fishy. In the Verb section it says indeed, that it is
> the past participle and simple past of inverse. The entry for inverse
> however only has sections that identify this word as adjective or noun;
> not a verb.
> 
> > 	https://www.dictionary.com/browse/inversed
> 
> Not sure I'd count this as hint that inversed exists. The entry shown to
> me under this URL is about "inverse" and it has
> 
> 	verb (used with object), in·versed, in·vers·ing.
> 		? to invert.
> 
> Does this mean: "Did you mean invert instead?"
> 
> > 	https://en.wiktionary.org/wiki/inversed
> 
> Yeah, that's the one I found, too.
> 
> I still have the impression that "inversed" is in use because people
> don't know better and understand the intended meaning. And this results
> in leaking of this word into the references.
> 
> > > Having said this I think (independent of the question if "inversed"
> > > exists) using two similar terms for the same thing just results in
> > > confusion. I hit that in the past already and I like it being addressed.
> > 
> > I don't know. It's pretty common to use different words for the same
> > thing. They're called synonyms.
> 
> In literature yes, I agree. In a novel it is annoying to repeat the same
> words over and over again and some variation is good. In programming
> however the goal is a different one. There the goal should be to be
> precise and consistent.

We also need to make sure that things don't break. It's a very bad idea
to have a macro with the same name as an enum value for reasons I stated
before. I think that's the most important thing here.

Also, if inversed is a synonym of inverted, we don't loose any precision
at all. All you have to remember is that you're dealing with a device
tree constant in one case and an API enumeration in the other.

So I think the current form is actually more precise, though I guess it
could be confusing if you don't care about the difference.

> > > > And as you noted in the cover letter, there's a conflict between the
> > > > macro defined in dt-bindings/pwm/pwm.txt. If they end up being included
> > > > in the wrong order you'll get a compile error.
> > > 
> > > There are also other symbols that exist twice (GPIO_ACTIVE_HIGH was the
> > > first to come to my mind). I'm not aware of any problems related to
> > > these. What am I missing?
> > 
> > There's currently no problem, obviously. But if for some reason the
> > include files end up being included in a different order (i.e. the
> > dt-bindings header is included before linux/pwm.h) then the macro will
> > be evaluated and result in something like:
> > 
> > 	enum pwm_polarity {
> > 		PWM_POLARITY_NORMAL,
> > 		1,
> > 	};
> > 
> > and that's not valid C, so will cause a build error.
> 
> I admit I didn't look closely here and I assume you are right. If I
> understand Oleksandr right this is only an intermediate step and when
> the series is applied completely this issue is gone. Still it might be
> worth to improve the series here.

	$ gcc -o /dev/null -x c - <<- EOF
	>     #define PWM_POLARITY_INVERTED (1 << 0)
	>
	>     enum pwm_polarity {
	>         PWM_POLARITY_NORMAL,
	>         PWM_POLARITY_INVERTED,
	>     };
	> EOF
	<stdin>:1:35: error: expected identifier before ‘(’ token
	<stdin>:5:9: note: in expansion of macro ‘PWM_POLARITY_INVERTED’

Q.E.D.

> My original question was about similar problems with GPIO_ACTIVE_HIGH.
> Are you aware of problems there?

The problem exists there equally. We're probably not running into it
because drivers don't end up including dt-bindings/gpio/gpio.h and
include/linux/gpio/machine.h at the same time. Or they end up always
including them in the right order.

For PWM the situation is slightly more complicated because we only have
one header for the kernel API, so the likelihood of including it along
with the dt-bindings header is increased compared to GPIO.

> > > > Note that DT bindings are an ABI and can
> > > > never change, whereas the enum pwm_polarity is part of a Linux internal
> > > > API and doesn't have the same restrictions as an ABI.
> > > 
> > > I thought only binary device trees (dtb) are supposed to be ABI.
> > 
> > Yes, the DTB is the ABI. dt-bindings/pwm/pwm.h is used to generate DTBs,
> > which basically makes it ABI as well.
> 
> We disagree here. With this argument you could fix quite some things as
> ABI.

I don't understand what you're trying to say.

> > Yes, the symbol name may not be part of the ABI, but changing the
> > symbol becomes very inconvenient because everyone that depends on it
> > would have to change.
> 
> Oleksandr adapted all in-tree users, so it only affects out-of-tree
> users. In my book this is fine.

There used to be a time when it was assumed that eventually device tree
sources would live outside of the kernel tree. Given that they are a HW
description, they really ought not to be relying on the Linux kernel
tree as a way of keeping them consistent. That's really only out of
convenience.

> > Why bother?
> 
> To make the API more precise and consistent. That's a good goal in my
> eyes.

PWM_POLARITY_INVERTED is not part of the API. It doesn't exist for
anything other than to make the device tree more readable.

I now regret that we ever introduced this in the first place. Perhaps it
would've been better to just deal with raw numbers instead.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2020-03-19 16:37 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200317123231.2843297-1-oleksandr.suvorov@toradex.com>
2020-03-17 12:32 ` [RFC PATCH 1/7] pwm: rename the PWM_POLARITY_INVERSED enum Oleksandr Suvorov
2020-03-17 13:34   ` Paul Barker
2020-03-17 21:32     ` Uwe Kleine-König
2020-03-17 16:26   ` Claudiu.Beznea
2020-03-17 16:39     ` Oleksandr Suvorov
2020-03-17 17:40   ` Thierry Reding
2020-03-17 21:00     ` Uwe Kleine-König
2020-03-18 22:59       ` Thierry Reding
2020-03-19  6:50         ` Uwe Kleine-König
2020-03-19 16:37           ` Thierry Reding [this message]
2020-03-19 17:30             ` Uwe Kleine-König
2020-03-19 11:40         ` Oleksandr Suvorov
2020-03-19 12:10           ` Uwe Kleine-König
2020-03-19 12:57             ` Oleksandr Suvorov
2020-03-19 16:44           ` Thierry Reding
2020-03-18 11:47     ` Oleksandr Suvorov
2020-03-17 12:32 ` [RFC PATCH 2/7] dt-bindings: pwm: document the PWM polarity flag Oleksandr Suvorov
2020-03-17 17:43   ` Thierry Reding
2020-03-17 21:30     ` Uwe Kleine-König
2020-03-18 23:05       ` Thierry Reding
2020-03-19  7:05         ` Uwe Kleine-König
2020-03-19 17:04           ` Thierry Reding
2020-03-30 21:00             ` Rob Herring
2020-03-18 23:19       ` Thierry Reding
2020-03-17 22:58   ` Laurent Pinchart
2020-03-17 12:32 ` [RFC PATCH 3/7] dt-bindings: pwm: add normal " Oleksandr Suvorov
2020-03-17 13:36   ` Paul Barker
2020-03-17 14:06     ` Oleksandr Suvorov
2020-03-17 21:36   ` Uwe Kleine-König
2020-03-17 22:56   ` Laurent Pinchart
2020-03-18  9:20     ` Uwe Kleine-König
2020-03-17 12:32 ` [RFC PATCH 4/7] dt-bindings: pwm: add description of PWM polarity Oleksandr Suvorov
2020-03-17 23:01   ` Laurent Pinchart
2020-03-18 11:37     ` Oleksandr Suvorov
2020-03-18 12:29       ` Laurent Pinchart
2020-03-18 12:36         ` Oleksandr Suvorov
2020-03-17 12:32 ` [RFC PATCH 5/7] pwm: replace polarity enum with macros Oleksandr Suvorov
2020-03-17 12:32 ` [RFC PATCH 6/7] arm64: dts: pwm: replace polarity constant with macro Oleksandr Suvorov
2020-03-20 10:03   ` Krzysztof Kozlowski
2020-03-17 12:32 ` [RFC PATCH 7/7] arm: " Oleksandr Suvorov
2020-03-20 10:02   ` Krzysztof Kozlowski

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=20200319163700.GA3354541@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=claudiu.beznea@microchip.com \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=festevam@gmail.com \
    --cc=heiko@sntech.de \
    --cc=igor.opaniuk@toradex.com \
    --cc=kernel@pengutronix.de \
    --cc=khilman@baylibre.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=ludovic.desroches@microchip.com \
    --cc=marcel.ziswiler@toradex.com \
    --cc=mripard@kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=oleksandr.suvorov@toradex.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=paul@crapouillou.net \
    --cc=pbarker@konsulko.com \
    --cc=philippe.schenker@toradex.com \
    --cc=rjui@broadcom.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sbranden@broadcom.com \
    --cc=shawnguo@kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=wens@csie.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).