* [PATCH, resend v1 1/1] irqdomain: Check virq for 0 before use in irq_dispose_mapping()
@ 2024-04-05 19:01 Andy Shevchenko
2024-04-08 10:18 ` [tip: irq/core] " tip-bot2 for Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2024-04-05 19:01 UTC (permalink / raw)
To: Thomas Gleixner, linux-kernel; +Cc: Andy Shevchenko
It's a bit hard to read the logic since we use virq before checking
it for 0. Rearrange the code to make it better to understand.
This, in particular, should clearly answer the question whether caller
need to perform this check or not, and we have plenty places for both
variants, confirming a confusion.
Fun fact that the new code is shorter:
Function old new delta
irq_dispose_mapping 278 271 -7
Total: Before=11625, After=11618, chg -0.06%
when compiled by GCC on Debian for x86_64.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
kernel/irq/irqdomain.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 3dd1c871e091..aadc8891cc16 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -909,10 +909,11 @@ EXPORT_SYMBOL_GPL(irq_create_of_mapping);
*/
void irq_dispose_mapping(unsigned int virq)
{
- struct irq_data *irq_data = irq_get_irq_data(virq);
+ struct irq_data *irq_data;
struct irq_domain *domain;
- if (!virq || !irq_data)
+ irq_data = virq ? irq_get_irq_data(virq) : NULL;
+ if (!irq_data)
return;
domain = irq_data->domain;
--
2.43.0.rc1.1.gbec44491f096
^ permalink raw reply [flat|nested] 2+ messages in thread* [tip: irq/core] irqdomain: Check virq for 0 before use in irq_dispose_mapping()
2024-04-05 19:01 [PATCH, resend v1 1/1] irqdomain: Check virq for 0 before use in irq_dispose_mapping() Andy Shevchenko
@ 2024-04-08 10:18 ` tip-bot2 for Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Andy Shevchenko @ 2024-04-08 10:18 UTC (permalink / raw)
To: linux-tip-commits
Cc: Andy Shevchenko, Thomas Gleixner, x86, linux-kernel, maz
The following commit has been merged into the irq/core branch of tip:
Commit-ID: a2ea3cd78317ae8995b65b52299158bbae52a77f
Gitweb: https://git.kernel.org/tip/a2ea3cd78317ae8995b65b52299158bbae52a77f
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
AuthorDate: Fri, 05 Apr 2024 22:01:05 +03:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Mon, 08 Apr 2024 12:08:58 +02:00
irqdomain: Check virq for 0 before use in irq_dispose_mapping()
It's a bit hard to read the logic since the virq is used before checking it
for 0. Rearrange the code to make it better to understand.
This, in particular, should clearly answer the question whether the caller
needs to perform this check or not, and there are plenty of places for both
variants, confirming a confusion.
Fun fact that the new code is shorter:
Function old new delta
irq_dispose_mapping 278 271 -7
Total: Before=11625, After=11618, chg -0.06%
when compiled by GCC on Debian for x86_64.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240405190105.3932034-1-andriy.shevchenko@linux.intel.com
---
kernel/irq/irqdomain.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 3dd1c87..aadc889 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -909,10 +909,11 @@ EXPORT_SYMBOL_GPL(irq_create_of_mapping);
*/
void irq_dispose_mapping(unsigned int virq)
{
- struct irq_data *irq_data = irq_get_irq_data(virq);
+ struct irq_data *irq_data;
struct irq_domain *domain;
- if (!virq || !irq_data)
+ irq_data = virq ? irq_get_irq_data(virq) : NULL;
+ if (!irq_data)
return;
domain = irq_data->domain;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-08 10:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-05 19:01 [PATCH, resend v1 1/1] irqdomain: Check virq for 0 before use in irq_dispose_mapping() Andy Shevchenko
2024-04-08 10:18 ` [tip: irq/core] " tip-bot2 for Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®