* [PATCH] driver-core: platform: Avoid to return IRQ 0 in platform_get_irq()
@ 2017-12-05 18:11 Arvind Yadav
2017-12-05 18:20 ` Dmitry Torokhov
0 siblings, 1 reply; 3+ messages in thread
From: Arvind Yadav @ 2017-12-05 18:11 UTC (permalink / raw)
To: gregkh, davem, dmitry.torokhov, linus.walleij; +Cc: linux-kernel
Function platform_get_irq() can return 0. Which means NO_IRQ.
So this change will not allow to return 0.
This change is help to use platform_get_irq() without this,
val = platform_get_irq();
if (val <= 0)
ret = val ? val : -ENODEV;
Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
drivers/base/platform.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index c203fb9..7b3079c 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -127,7 +127,7 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
}
- return r ? r->start : -ENXIO;
+ return r && r->start ? r->start : -ENXIO;
#endif
}
EXPORT_SYMBOL_GPL(platform_get_irq);
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] driver-core: platform: Avoid to return IRQ 0 in platform_get_irq()
2017-12-05 18:11 [PATCH] driver-core: platform: Avoid to return IRQ 0 in platform_get_irq() Arvind Yadav
@ 2017-12-05 18:20 ` Dmitry Torokhov
2017-12-06 6:28 ` Arvind Yadav
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2017-12-05 18:20 UTC (permalink / raw)
To: Arvind Yadav; +Cc: gregkh, davem, linus.walleij, linux-kernel
On Tue, Dec 05, 2017 at 11:41:52PM +0530, Arvind Yadav wrote:
> Function platform_get_irq() can return 0. Which means NO_IRQ.
> So this change will not allow to return 0.
>
> This change is help to use platform_get_irq() without this,
>
> val = platform_get_irq();
> if (val <= 0)
> ret = val ? val : -ENODEV;
>
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
You need to audit the drivers and make sure you are not breaking them
with this. I believe at least i2c designware controller on certain
boards has DEFINE_RES_IRQ(0) which will be broken by this patch.
> ---
> drivers/base/platform.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index c203fb9..7b3079c 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -127,7 +127,7 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
> irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
> }
>
> - return r ? r->start : -ENXIO;
> + return r && r->start ? r->start : -ENXIO;
> #endif
> }
> EXPORT_SYMBOL_GPL(platform_get_irq);
> --
> 2.7.4
>
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] driver-core: platform: Avoid to return IRQ 0 in platform_get_irq()
2017-12-05 18:20 ` Dmitry Torokhov
@ 2017-12-06 6:28 ` Arvind Yadav
0 siblings, 0 replies; 3+ messages in thread
From: Arvind Yadav @ 2017-12-06 6:28 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: gregkh, davem, linus.walleij, linux-kernel
Hi Dmitry,
On Tuesday 05 December 2017 11:50 PM, Dmitry Torokhov wrote:
> On Tue, Dec 05, 2017 at 11:41:52PM +0530, Arvind Yadav wrote:
>> Function platform_get_irq() can return 0. Which means NO_IRQ.
>> So this change will not allow to return 0.
>>
>> This change is help to use platform_get_irq() without this,
>>
>> val = platform_get_irq();
>> if (val <= 0)
>> ret = val ? val : -ENODEV;
>>
>> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> You need to audit the drivers and make sure you are not breaking them
> with this. I believe at least i2c designware controller on certain
> boards has DEFINE_RES_IRQ(0) which will be broken by this patch.
Yes, you are right. Few driver is using DEFINE_RES_IRQ(0).
Example:
drivers/mfd/intel-lpss.c
static const struct resource intel_lpss_dev_resources[] = {
DEFINE_RES_MEM_NAMED(LPSS_DEV_OFFSET, LPSS_DEV_SIZE, "lpss_dev"),
DEFINE_RES_MEM_NAMED(LPSS_PRIV_OFFSET, LPSS_PRIV_SIZE,
"lpss_priv"),
DEFINE_RES_IRQ(0),
};
There's a bunch of platforms in the kernel that still use IRQ0. They can
suffer because
of this change. I should have mark this patch for testing.
>
>> ---
>> drivers/base/platform.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
>> index c203fb9..7b3079c 100644
>> --- a/drivers/base/platform.c
>> +++ b/drivers/base/platform.c
>> @@ -127,7 +127,7 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
>> irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
>> }
>>
>> - return r ? r->start : -ENXIO;
>> + return r && r->start ? r->start : -ENXIO;
>> #endif
>> }
>> EXPORT_SYMBOL_GPL(platform_get_irq);
>> --
>> 2.7.4
>>
> Thanks.
>
Thanks,
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-06 6:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-05 18:11 [PATCH] driver-core: platform: Avoid to return IRQ 0 in platform_get_irq() Arvind Yadav
2017-12-05 18:20 ` Dmitry Torokhov
2017-12-06 6:28 ` Arvind Yadav
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).