Re: [PATCH 1/2] platform: make platform_get_irq_optional() optional
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- Subject: Re: [PATCH 1/2] platform: make platform_get_irq_optional() optional
- From: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
- Date: Tue, 18 Jan 2022 15:29:45 +0100
- Cc: Andrew Lunn <andrew@xxxxxxx>, Ulf Hansson <ulf.hansson@xxxxxxxxxx>, Vignesh Raghavendra <vigneshr@xxxxxx>, KVM list <kvm@xxxxxxxxxxxxxxx>, "Rafael J. Wysocki" <rafael@xxxxxxxxxx>, linux-iio@xxxxxxxxxxxxxxx, Linus Walleij <linus.walleij@xxxxxxxxxx>, Amit Kucheria <amitk@xxxxxxxxxx>, ALSA Development Mailing List <alsa-devel@xxxxxxxxxxxxxxxx>, Jaroslav Kysela <perex@xxxxxxxx>, Guenter Roeck <groeck@xxxxxxxxxxxx>, Thierry Reding <thierry.reding@xxxxxxxxx>, MTD Maling List <linux-mtd@xxxxxxxxxxxxxxxxxxx>, Linux I2C <linux-i2c@xxxxxxxxxxxxxxx>, Miquel Raynal <miquel.raynal@xxxxxxxxxxx>, linux-phy@xxxxxxxxxxxxxxxxxxx, linux-spi <linux-spi@xxxxxxxxxxxxxxx>, Jiri Slaby <jirislaby@xxxxxxxxxx>, "David S. Miller" <davem@xxxxxxxxxxxxx>, Khuong Dinh <khuong@xxxxxxxxxxxxxxxxxxxxxx>, Florian Fainelli <f.fainelli@xxxxxxxxx>, Matthias Schiffer <matthias.schiffer@xxxxxxxxxxxxxxx>, Kamal Dasu <kdasu.kdev@xxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Lee Jones <lee.jones@xxxxxxxxxx>, Bartosz Golaszewski <brgl@xxxxxxxx>, Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>, Kishon Vijay Abraham I <kishon@xxxxxx>, bcm-kernel-feedback-list <bcm-kernel-feedback-list@xxxxxxxxxxxx>, "open list:SERIAL DRIVERS" <linux-serial@xxxxxxxxxxxxxxx>, Jakub Kicinski <kuba@xxxxxxxxxx>, Zhang Rui <rui.zhang@xxxxxxxxx>, platform-driver-x86@xxxxxxxxxxxxxxx, Linux PWM List <linux-pwm@xxxxxxxxxxxxxxx>, Robert Richter <rric@xxxxxxxxxx>, Saravanan Sekar <sravanhome@xxxxxxxxx>, Corey Minyard <minyard@xxxxxxx>, Linux PM list <linux-pm@xxxxxxxxxxxxxxx>, Liam Girdwood <lgirdwood@xxxxxxxxx>, Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>, John Garry <john.garry@xxxxxxxxxx>, Peter Korsgaard <peter@xxxxxxxxxxxxx>, William Breathitt Gray <vilhelm.gray@xxxxxxxxx>, Mark Gross <markgross@xxxxxxxxxx>, Hans de Goede <hdegoede@xxxxxxxxxx>, Alex Williamson <alex.williamson@xxxxxxxxxx>, Mark Brown <broonie@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Takashi Iwai <tiwai@xxxxxxxx>, Matthias Brugger <matthias.bgg@xxxxxxxxx>, openipmi-developer@xxxxxxxxxxxxxxxxxxxxx, Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>, Benson Leung <bleung@xxxxxxxxxxxx>, Pengutronix Kernel Team <kernel@xxxxxxxxxxxxxx>, Linux ARM <linux-arm-kernel@xxxxxxxxxxxxxxxxxxx>, linux-edac@xxxxxxxxxxxxxxx, Tony Luck <tony.luck@xxxxxxxxx>, Richard Weinberger <richard@xxxxxx>, Mun Yew Tham <mun.yew.tham@xxxxxxxxx>, Eric Auger <eric.auger@xxxxxxxxxx>, netdev <netdev@xxxxxxxxxxxxxxx>, "open list:GPIO SUBSYSTEM" <linux-gpio@xxxxxxxxxxxxxxx>, Cornelia Huck <cohuck@xxxxxxxxxx>, Linux MMC List <linux-mmc@xxxxxxxxxxxxxxx>, Joakim Zhang <qiangqing.zhang@xxxxxxx>, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, Linux-Renesas <linux-renesas-soc@xxxxxxxxxxxxxxx>, Sergey Shtylyov <s.shtylyov@xxxxxx>, Vinod Koul <vkoul@xxxxxxxxxx>, James Morse <james.morse@xxxxxxx>, Zha Qipeng <qipeng.zha@xxxxxxxxx>, Sebastian Reichel <sre@xxxxxxxxxx>, Niklas Söderlund <niklas.soderlund@xxxxxxxxxxxx>, linux-mediatek@xxxxxxxxxxxxxxxxxxx, Brian Norris <computersforpeace@xxxxxxxxx>, Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx>
- In-reply-to: <CAMuHMdWkwV9XE_R5FZ=jPtDwLpDbEngG6+X2JmiDJCZJZvUjYA@mail.gmail.com>
- References: <20220117092444.opoedfcf5k5u6otq@pengutronix.de> <CAMuHMdUgZUeraHadRAi2Z=DV+NuNBrKPkmAKsvFvir2MuquVoA@mail.gmail.com> <20220117114923.d5vajgitxneec7j7@pengutronix.de> <CAMuHMdWCKERO20R2iVHq8P=BaoauoBAtiampWzfMRYihi3Sb0g@mail.gmail.com> <20220117170609.yxaamvqdkivs56ju@pengutronix.de> <CAMuHMdXbuZqEpYivyS6hkaRN+CwTOGaHq_OROwVAWvDD6OXODQ@mail.gmail.com> <20220118090913.pjumkq4zf4iqtlha@pengutronix.de> <CAMuHMdUW8+Y_=uszD+JOZO3Lpa9oDayk+GO+cg276i2f2T285w@mail.gmail.com> <20220118120806.pbjsat4ulg3vnhsh@pengutronix.de> <CAMuHMdWkwV9XE_R5FZ=jPtDwLpDbEngG6+X2JmiDJCZJZvUjYA@mail.gmail.com>
On Tue, Jan 18, 2022 at 01:49:15PM +0100, Geert Uytterhoeven wrote:
> nst the magic not-found value (so no implementation detail magic
> > > > leaks into the caller code) and just pass it to the next API function=
> .
> > > > (And my expectation would be that if you chose to represent not-found=
> by
> > > > (void *)66 instead of NULL, you won't have to adapt any user, just th=
> e
> > > > framework internal checks. This is a good thing!)
> > >
> > > Ah, there is the wrong assumption: drivers sometimes do need to know
> > > if the resource was found, and thus do need to know about (void *)66,
> > > -ENODEV, or -ENXIO. I already gave examples for IRQ and clk before.
> > > I can imagine these exist for gpiod and regulator, too, as soon as
> > > you go beyond the trivial "enable" and "disable" use-cases.
> >
> > My premise is that every user who has to check for "not found"
> > explicitly should not use (clk|gpiod)_get_optional() but
> > (clk|gpiod)_get() and do proper (and explicit) error handling for
> > -ENODEV. (clk|gpiod)_get_optional() is only for these trivial use-cases.
> >
> > > And 0/NULL vs. > 0 is the natural check here: missing, but not
> > > an error.
> >
> > For me it it 100% irrelevant if "not found" is an error for the query
> > function or not. I just have to be able to check for "not found" and
> > react accordingly.
> >
> > And adding a function
> >
> > def platform_get_irq_opional():
> > ret =3D platform_get_irq()
> > if ret =3D=3D -ENXIO:
> > return 0
> > return ret
> >
> > it's not a useful addition to the API if I cannot use 0 as a dummy
> > because it doesn't simplify the caller enough to justify the additional
> > function.
> >
> > The only thing I need to be able is to distinguish the cases "there is
> > an irq", "there is no irq" and anything else is "there is a problem I
> > cannot handle and so forward it to my caller". The semantic of
> > platform_get_irq() is able to satisfy this requirement[1], so why introdu=
> ce
> > platform_get_irq_opional() for the small advantage that I can check for
> > not-found using
> >
> > if (!irq)
> >
> > instead of
> >
> > if (irq !=3D -ENXIO)
> >
> > ? The semantic of platform_get_irq() is easier ("Either a usable
> > non-negative irq number or a negative error number") compared to
> > platform_get_irq_optional() ("Either a usable positive irq number or a
> > negative error number or 0 meaning not found"). Usage of
> > platform_get_irq() isn't harder or more expensive (neither for a human
> > reader nor for a maching running the resulting compiled code).
> > For a human reader
> >
> > if (irq !=3D -ENXIO)
> >
> > is even easier to understand because for
> >
> > if (!irq)
> >
> > they have to check where the value comes from, see it's
> > platform_get_irq_optional() and understand that 0 means not-found.
>
> "vIRQ zero does not exist."
With that statement in mind I would expect that a function that gives me
an (v)irq number never returns 0.
> > This function just adds overhead because as a irq framework user I have
> > to understand another function. For me the added benefit is too small to
> > justify the additional function. And you break out-of-tree drivers.
> > These are all no major counter arguments, but as the advantage isn't
> > major either, they still matter.
> >
> > Best regards
> > Uwe
> >
> > [1] the only annoying thing is the error message.
>
> So there's still a need for two functions.
Or a single function not emitting an error message together with the
callers being responsible for calling dev_err().
So the options in my preference order (first is best) are:
- Remove the printk from platform_get_irq() and remove
platform_get_irq_optional();
- Rename platform_get_irq_optional() to platform_get_irq_silently()
- Keep platform_get_irq_optional() as is
- Collect underpants
- ?
- Change semantic of platform_get_irq_optional()
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
Attachment:
signature.asc
Description: PGP signature
[Index of Archives]
[Linux Kernel]
[Linux ARM (vger)]
[Linux ARM MSM]
[Linux Omap]
[Linux Arm]
[Linux Tegra]
[Fedora ARM]
[Linux for Samsung SOC]
[eCos]
[Linux Fastboot]
[Gcc Help]
[Git]
[DCCP]
[IETF Announce]
[Security]
[Linux MIPS]
[Yosemite Campsites]
|