* [PATCH] clocksource/drivers/sh_mtu2: Do not loop using platform_get_irq_by_name()
@ 2019-10-16 14:30 Geert Uytterhoeven
2019-10-16 15:06 ` Daniel Lezcano
2019-11-04 17:48 ` [tip: timers/urgent] " tip-bot2 for Geert Uytterhoeven
0 siblings, 2 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2019-10-16 14:30 UTC (permalink / raw)
To: Daniel Lezcano, Thomas Gleixner
Cc: Stephen Boyd, linux-renesas-soc, linux-kernel, Geert Uytterhoeven
As platform_get_irq_by_name() now prints an error when the interrupt
does not exist, looping over possibly non-existing interrupts causes the
printing of scary messages like:
sh_mtu2 fcff0000.timer: IRQ tgi1a not found
sh_mtu2 fcff0000.timer: IRQ tgi2a not found
Fix this by using the platform_irq_count() helper, to avoid touching
non-existent interrupts. Limit the returned number of interrupts to the
maximum number of channels currently supported by the driver in a
future-proof way, i.e. using ARRAY_SIZE() instead of a hardcoded number.
Fixes: 7723f4c5ecdb8d83 ("driver core: platform: Add an error message to platform_get_irq*()")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
This is a fix for v5.4.
---
drivers/clocksource/sh_mtu2.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index 354b27d14a19bfce..62812f80b5cc0916 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -328,12 +328,13 @@ static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name)
return 0;
}
+static const unsigned int sh_mtu2_channel_offsets[] = {
+ 0x300, 0x380, 0x000,
+};
+
static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index,
struct sh_mtu2_device *mtu)
{
- static const unsigned int channel_offsets[] = {
- 0x300, 0x380, 0x000,
- };
char name[6];
int irq;
int ret;
@@ -356,7 +357,7 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index,
return ret;
}
- ch->base = mtu->mapbase + channel_offsets[index];
+ ch->base = mtu->mapbase + sh_mtu2_channel_offsets[index];
ch->index = index;
return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev));
@@ -408,7 +409,12 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
}
/* Allocate and setup the channels. */
- mtu->num_channels = 3;
+ ret = platform_irq_count(pdev);
+ if (ret < 0)
+ goto err_unmap;
+
+ mtu->num_channels = min_t(unsigned int, ret,
+ ARRAY_SIZE(sh_mtu2_channel_offsets));
mtu->channels = kcalloc(mtu->num_channels, sizeof(*mtu->channels),
GFP_KERNEL);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] clocksource/drivers/sh_mtu2: Do not loop using platform_get_irq_by_name()
2019-10-16 14:30 [PATCH] clocksource/drivers/sh_mtu2: Do not loop using platform_get_irq_by_name() Geert Uytterhoeven
@ 2019-10-16 15:06 ` Daniel Lezcano
2019-11-04 17:48 ` [tip: timers/urgent] " tip-bot2 for Geert Uytterhoeven
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Lezcano @ 2019-10-16 15:06 UTC (permalink / raw)
To: Geert Uytterhoeven, Thomas Gleixner
Cc: Stephen Boyd, linux-renesas-soc, linux-kernel
On 16/10/2019 16:30, Geert Uytterhoeven wrote:
> As platform_get_irq_by_name() now prints an error when the interrupt
> does not exist, looping over possibly non-existing interrupts causes the
> printing of scary messages like:
>
> sh_mtu2 fcff0000.timer: IRQ tgi1a not found
> sh_mtu2 fcff0000.timer: IRQ tgi2a not found
>
> Fix this by using the platform_irq_count() helper, to avoid touching
> non-existent interrupts. Limit the returned number of interrupts to the
> maximum number of channels currently supported by the driver in a
> future-proof way, i.e. using ARRAY_SIZE() instead of a hardcoded number.
>
> Fixes: 7723f4c5ecdb8d83 ("driver core: platform: Add an error message to platform_get_irq*()")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> This is a fix for v5.4.
> ---
Applied, thanks!
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip: timers/urgent] clocksource/drivers/sh_mtu2: Do not loop using platform_get_irq_by_name()
2019-10-16 14:30 [PATCH] clocksource/drivers/sh_mtu2: Do not loop using platform_get_irq_by_name() Geert Uytterhoeven
2019-10-16 15:06 ` Daniel Lezcano
@ 2019-11-04 17:48 ` tip-bot2 for Geert Uytterhoeven
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Geert Uytterhoeven @ 2019-11-04 17:48 UTC (permalink / raw)
To: linux-tip-commits
Cc: Geert Uytterhoeven, Daniel Lezcano, Ingo Molnar, Borislav Petkov,
linux-kernel
The following commit has been merged into the timers/urgent branch of tip:
Commit-ID: 7693de9f7aa4e2993fbd7094863304be6a4bbe16
Gitweb: https://git.kernel.org/tip/7693de9f7aa4e2993fbd7094863304be6a4bbe16
Author: Geert Uytterhoeven <geert+renesas@glider.be>
AuthorDate: Wed, 16 Oct 2019 16:30:03 +02:00
Committer: Daniel Lezcano <daniel.lezcano@linaro.org>
CommitterDate: Fri, 18 Oct 2019 07:55:16 +02:00
clocksource/drivers/sh_mtu2: Do not loop using platform_get_irq_by_name()
As platform_get_irq_by_name() now prints an error when the interrupt
does not exist, looping over possibly non-existing interrupts causes the
printing of scary messages like:
sh_mtu2 fcff0000.timer: IRQ tgi1a not found
sh_mtu2 fcff0000.timer: IRQ tgi2a not found
Fix this by using the platform_irq_count() helper, to avoid touching
non-existent interrupts. Limit the returned number of interrupts to the
maximum number of channels currently supported by the driver in a
future-proof way, i.e. using ARRAY_SIZE() instead of a hardcoded number.
Fixes: 7723f4c5ecdb8d83 ("driver core: platform: Add an error message to platform_get_irq*()")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20191016143003.28561-1-geert+renesas@glider.be
---
drivers/clocksource/sh_mtu2.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index 354b27d..62812f8 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -328,12 +328,13 @@ static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name)
return 0;
}
+static const unsigned int sh_mtu2_channel_offsets[] = {
+ 0x300, 0x380, 0x000,
+};
+
static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index,
struct sh_mtu2_device *mtu)
{
- static const unsigned int channel_offsets[] = {
- 0x300, 0x380, 0x000,
- };
char name[6];
int irq;
int ret;
@@ -356,7 +357,7 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index,
return ret;
}
- ch->base = mtu->mapbase + channel_offsets[index];
+ ch->base = mtu->mapbase + sh_mtu2_channel_offsets[index];
ch->index = index;
return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev));
@@ -408,7 +409,12 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
}
/* Allocate and setup the channels. */
- mtu->num_channels = 3;
+ ret = platform_irq_count(pdev);
+ if (ret < 0)
+ goto err_unmap;
+
+ mtu->num_channels = min_t(unsigned int, ret,
+ ARRAY_SIZE(sh_mtu2_channel_offsets));
mtu->channels = kcalloc(mtu->num_channels, sizeof(*mtu->channels),
GFP_KERNEL);
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-11-04 17:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16 14:30 [PATCH] clocksource/drivers/sh_mtu2: Do not loop using platform_get_irq_by_name() Geert Uytterhoeven
2019-10-16 15:06 ` Daniel Lezcano
2019-11-04 17:48 ` [tip: timers/urgent] " tip-bot2 for Geert Uytterhoeven
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).