2014-11-14 22:04:23

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH] nios2: fix error handling of irq_of_parse_and_map

Return value of irq_of_parse_and_map() is unsigned int, with 0
indicating failure, so testing for negative result never works.

Signed-off-by: Dmitry Torokhov <[email protected]>
---

Not tested, found by casual code inspection.

arch/nios2/kernel/time.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/nios2/kernel/time.c b/arch/nios2/kernel/time.c
index d90ca1b..23729e8 100644
--- a/arch/nios2/kernel/time.c
+++ b/arch/nios2/kernel/time.c
@@ -228,7 +228,7 @@ static __init void nios2_clockevent_init(struct device_node *timer)
nios2_timer_get_base_and_freq(timer, &iobase, &freq);

irq = irq_of_parse_and_map(timer, 0);
- if (irq < 0)
+ if (!irq)
panic("Unable to parse timer irq\n");

nios2_ce.timer.base = iobase;
--
2.1.0.rc2.206.gedb03e5


--
Dmitry


2014-11-17 09:25:01

by Tobias Klauser

[permalink] [raw]
Subject: Re: [PATCH] nios2: fix error handling of irq_of_parse_and_map

On 2014-11-14 at 23:04:19 +0100, Dmitry Torokhov <[email protected]> wrote:
> Return value of irq_of_parse_and_map() is unsigned int, with 0
> indicating failure, so testing for negative result never works.
>
> Signed-off-by: Dmitry Torokhov <[email protected]>

Reviewed-by: Tobias Klauser <[email protected]>

Thanks for catching this.

2014-11-17 10:04:13

by Ley Foon Tan

[permalink] [raw]
Subject: Re: [PATCH] nios2: fix error handling of irq_of_parse_and_map

On Mon, Nov 17, 2014 at 5:24 PM, Tobias Klauser <[email protected]> wrote:
> On 2014-11-14 at 23:04:19 +0100, Dmitry Torokhov <[email protected]> wrote:
>> Return value of irq_of_parse_and_map() is unsigned int, with 0
>> indicating failure, so testing for negative result never works.
>>
>> Signed-off-by: Dmitry Torokhov <[email protected]>
>
> Reviewed-by: Tobias Klauser <[email protected]>
>
> Thanks for catching this.
Thanks for your patch.

Regards
Ley Foon