From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: linux-input@vger.kernel.org, Allison Randal <allison@lohutok.net>,
Arnd Bergmann <arnd@arndb.de>,
H Hartley Sweeten <hsweeten@visionengravers.com>,
Olof Johansson <olof@lixom.net>,
Thomas Gleixner <tglx@linutronix.de>,
LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org,
Tang Bin <tangbin@cmss.chinamobile.com>
Subject: Re: Input: ep93xx_keypad: Checking for a failed platform_get_irq() call in ep93xx_keypad_probe()
Date: Thu, 9 Apr 2020 13:48:19 -0700 [thread overview]
Message-ID: <20200409204819.GR75430@dtor-ws> (raw)
In-Reply-To: <11aecb68-d243-2eeb-0cc8-50e1ec22bd71@web.de>
Hi Markus,
On Wed, Apr 08, 2020 at 06:52:31PM +0200, Markus Elfring wrote:
> Hello,
>
> I have taken another look at the implementation of the function “ep93xx_keypad_probe”.
> A software analysis approach points the following source code out for
> further development considerations.
> https://elixir.bootlin.com/linux/v5.6.3/source/drivers/input/keyboard/ep93xx_keypad.c#L252
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/input/keyboard/ep93xx_keypad.c?id=f5e94d10e4c468357019e5c28d48499f677b284f#n252
>
> keypad->irq = platform_get_irq(pdev, 0);
> if (!keypad->irq) {
> err = -ENXIO;
> goto failed_free;
> }
>
>
> The software documentation is providing the following information
> for the used programming interface.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/base/platform.c?id=f5e94d10e4c468357019e5c28d48499f677b284f#n221
> https://elixir.bootlin.com/linux/v5.6.3/source/drivers/base/platform.c#L202
>
> “…
> * Return: IRQ number on success, negative error number on failure.
> …”
>
> Would you like to reconsider the shown condition check?
Platform code historically allowed creating IRQ resources with IRQ
number 0 to indicate "no interrupt assigned", so this driver tries to
filter out such conditions. The negative IRQs (errors) will be rejected
by request_irq() but I guess we can lose -EPROBE_DEFER. We could do
if (keypad->irq <= 0) {
err = keypad->irq ?: -ENXIO : keypad->irq;
goto failed_free;
}
or, maybe we should take a look at platform_get_irq() and see if we can
stop it returning 0 interrupt numbers and clean up the drivers.
Thanks.
--
Dmitry
next prev parent reply other threads:[~2020-04-09 20:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-08 16:52 Input: ep93xx_keypad: Checking for a failed platform_get_irq() call in ep93xx_keypad_probe() Markus Elfring
2020-04-09 20:48 ` Dmitry Torokhov [this message]
2020-04-10 2:52 ` Input: ep93xx_keypad: Checking for a failed platform_get_irq()call " Tang Bin
2020-04-10 2:56 ` Tang Bin
2020-04-10 5:45 ` Input: ep93xx_keypad: Checking for a failed platform_get_irq() call " Markus Elfring
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=20200409204819.GR75430@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=Markus.Elfring@web.de \
--cc=allison@lohutok.net \
--cc=arnd@arndb.de \
--cc=hsweeten@visionengravers.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olof@lixom.net \
--cc=tangbin@cmss.chinamobile.com \
--cc=tglx@linutronix.de \
/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).