All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Russell King - ARM Linux <linux@armlinux.org.uk>
Cc: Arvind Yadav <arvind.yadav.cs@gmail.com>,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	Chen-Yu Tsai <wens@csie.org>, Wan ZongShun <mcuos.com@gmail.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Lee Jones <lee.jones@linaro.org>,
	lkml <linux-kernel@vger.kernel.org>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 01/10 v4] Input: ep93xx_keypad: Fix platform_get_irq's error checking
Date: Mon, 20 Nov 2017 08:48:40 -0800	[thread overview]
Message-ID: <CAKdAkRQwuTgupMtSs_BmDNDDnW78z8vm9s41BcOHmDiKR3uPHw@mail.gmail.com> (raw)
In-Reply-To: <20171120162941.GD31757@n2100.armlinux.org.uk>

On Mon, Nov 20, 2017 at 8:29 AM, Russell King - ARM Linux
<linux@armlinux.org.uk> wrote:
> On Mon, Nov 20, 2017 at 09:56:21PM +0530, Arvind Yadav wrote:
>> The platform_get_irq() function returns negative if an error occurs.
>> zero or positive number on success. platform_get_irq() error checking
>> for zero is not correct.
>>
>> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
>> ---
>> changes in v2 :
>>               Return keypad->irq insted of -ENXIO.
>> changes in v3 :
>>               Add failure case '<= 0' instead of '< 0'. IRQ0 is not valid.
>> changes ib v4 :
>>               Return -ENXIO insted of keypad->irq. Which was not correct in v3.
>>
>>  drivers/input/keyboard/ep93xx_keypad.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
>> index f77b295..c6eb31a 100644
>> --- a/drivers/input/keyboard/ep93xx_keypad.c
>> +++ b/drivers/input/keyboard/ep93xx_keypad.c
>> @@ -257,7 +257,7 @@ static int ep93xx_keypad_probe(struct platform_device *pdev)
>>       }
>>
>>       keypad->irq = platform_get_irq(pdev, 0);
>> -     if (!keypad->irq) {
>> +     if (keypad->irq <= 0) {
>>               err = -ENXIO;
>
> Still not right.
>
>                 err = keypad->irq < 0 ? keypad->irq : -ENXIO;
>
> would have the right effect.
>
> However, I disagree with the idea of making platform_get_irq() return
> an error if there is a zero irq specified as suggested in a previous
> review - zero means "not present" and that is not necessarily an error -
> it's up to the driver to decide whether it can proceed without an
> interrupt, or whether it should error out on the probe function.

We used to return 0 from platform_get_irq() in early 2.6 days on
errors but not anymore and I do not think keeping treating 0 there as
special makes much sense.

We already return -ENXIO for missing resources, and I do not think
that anyone actually defines IRQ resource with 0 number and attaches
it to devices in home that drivers would recognize it as missing
interrupt and work without it. Also, in case of DT we do not recognize
IRQ 0 as valid and try to fetch it from other sources (static board
data), I think ACPI is similar.

I think we should also return -ENXIO in case of res->start == 0 and
leave it to the driver to check and decide if it wants to deal with
missing interrupt. Most of them do not.


Thanks.

-- 
Dmitry

WARNING: multiple messages have this Message-ID (diff)
From: dmitry.torokhov@gmail.com (Dmitry Torokhov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 01/10 v4] Input: ep93xx_keypad: Fix platform_get_irq's error checking
Date: Mon, 20 Nov 2017 08:48:40 -0800	[thread overview]
Message-ID: <CAKdAkRQwuTgupMtSs_BmDNDDnW78z8vm9s41BcOHmDiKR3uPHw@mail.gmail.com> (raw)
In-Reply-To: <20171120162941.GD31757@n2100.armlinux.org.uk>

On Mon, Nov 20, 2017 at 8:29 AM, Russell King - ARM Linux
<linux@armlinux.org.uk> wrote:
> On Mon, Nov 20, 2017 at 09:56:21PM +0530, Arvind Yadav wrote:
>> The platform_get_irq() function returns negative if an error occurs.
>> zero or positive number on success. platform_get_irq() error checking
>> for zero is not correct.
>>
>> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
>> ---
>> changes in v2 :
>>               Return keypad->irq insted of -ENXIO.
>> changes in v3 :
>>               Add failure case '<= 0' instead of '< 0'. IRQ0 is not valid.
>> changes ib v4 :
>>               Return -ENXIO insted of keypad->irq. Which was not correct in v3.
>>
>>  drivers/input/keyboard/ep93xx_keypad.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
>> index f77b295..c6eb31a 100644
>> --- a/drivers/input/keyboard/ep93xx_keypad.c
>> +++ b/drivers/input/keyboard/ep93xx_keypad.c
>> @@ -257,7 +257,7 @@ static int ep93xx_keypad_probe(struct platform_device *pdev)
>>       }
>>
>>       keypad->irq = platform_get_irq(pdev, 0);
>> -     if (!keypad->irq) {
>> +     if (keypad->irq <= 0) {
>>               err = -ENXIO;
>
> Still not right.
>
>                 err = keypad->irq < 0 ? keypad->irq : -ENXIO;
>
> would have the right effect.
>
> However, I disagree with the idea of making platform_get_irq() return
> an error if there is a zero irq specified as suggested in a previous
> review - zero means "not present" and that is not necessarily an error -
> it's up to the driver to decide whether it can proceed without an
> interrupt, or whether it should error out on the probe function.

We used to return 0 from platform_get_irq() in early 2.6 days on
errors but not anymore and I do not think keeping treating 0 there as
special makes much sense.

We already return -ENXIO for missing resources, and I do not think
that anyone actually defines IRQ resource with 0 number and attaches
it to devices in home that drivers would recognize it as missing
interrupt and work without it. Also, in case of DT we do not recognize
IRQ 0 as valid and try to fetch it from other sources (static board
data), I think ACPI is similar.

I think we should also return -ENXIO in case of res->start == 0 and
leave it to the driver to check and decide if it wants to deal with
missing interrupt. Most of them do not.


Thanks.

-- 
Dmitry

  reply	other threads:[~2017-11-20 16:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-20 16:26 [PATCH 01/10 v4] Input: ep93xx_keypad: Fix platform_get_irq's error checking Arvind Yadav
2017-11-20 16:26 ` Arvind Yadav
2017-11-20 16:29 ` Russell King - ARM Linux
2017-11-20 16:29   ` Russell King - ARM Linux
2017-11-20 16:48   ` Dmitry Torokhov [this message]
2017-11-20 16:48     ` Dmitry Torokhov

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=CAKdAkRQwuTgupMtSs_BmDNDDnW78z8vm9s41BcOHmDiKR3uPHw@mail.gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=arvind.yadav.cs@gmail.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=linux@roeck-us.net \
    --cc=maxime.ripard@free-electrons.com \
    --cc=mcuos.com@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.