Re: [PATCH] [RFT] sh: mach-r2d: Handle virq offset in cascaded IRL demux

From: Sergey Shtylyov
Date: Sun Jul 09 2023 - 08:51:06 EST


On 7/9/23 2:58 PM, John Paul Adrian Glaubitz wrote:
[...]
>> diff --git a/arch/sh/boards/mach-r2d/irq.c b/arch/sh/boards/mach-r2d/irq.c
>> index e34f81e9ae813b8d..c37b40398c5bc83e 100644
>> --- a/arch/sh/boards/mach-r2d/irq.c
>> +++ b/arch/sh/boards/mach-r2d/irq.c
>> @@ -117,10 +117,10 @@ static unsigned char irl2irq[R2D_NR_IRL];
>>
>> int rts7751r2d_irq_demux(int irq)
>> {
>> - if (irq >= R2D_NR_IRL || irq < 0 || !irl2irq[irq])
>> + if (irq >= 16 + R2D_NR_IRL || irq < 16 || !irl2irq[irq - 16])
>> return irq;
>>
>> - return irl2irq[irq];
>> + return irl2irq[irq - 16];
>> }
>>
>> /*
>
> Btw, I think this needs to be adjusted to test for "ret <= 0" since IRQs cannot
> be zero anymore, correct?
>
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/mfd/sm501.c#n1389

No, just ignore IRQ0 from now on, it can't be returned. Else you'd just complicate
your code as you'd have to add a separate check for IRQ0 in order to return -EINVAL
in this case (you can't return 0 from probe in case of ret == 0 as that would mean
successful probe when it's not). My patch to platfrom_get_irq() ensures that IRQ0
check in its users is never needed, in order to avoid the (badly scaling) checks)...

> Adrian

MBR, Sergey