* [PATCH v1 1/1] irqdomain: Check virq for 0 before use in irq_dispose_mapping()
@ 2023-08-22 13:51 Andy Shevchenko
2023-09-19 19:59 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2023-08-22 13:51 UTC (permalink / raw)
To: Marc Zyngier, Johan Hovold, linux-kernel
Cc: Thomas Gleixner, Bartosz Golaszewski, 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 0bdef4fe925b..26f1be63d622 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -903,10 +903,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.40.0.1.gaa8946217a0b
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v1 1/1] irqdomain: Check virq for 0 before use in irq_dispose_mapping()
2023-08-22 13:51 [PATCH v1 1/1] irqdomain: Check virq for 0 before use in irq_dispose_mapping() Andy Shevchenko
@ 2023-09-19 19:59 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2023-09-19 19:59 UTC (permalink / raw)
To: Marc Zyngier, Johan Hovold, linux-kernel
Cc: Thomas Gleixner, Bartosz Golaszewski
On Tue, Aug 22, 2023 at 04:51:36PM +0300, Andy Shevchenko wrote:
> 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.
Any comment on this?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-19 20:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-22 13:51 [PATCH v1 1/1] irqdomain: Check virq for 0 before use in irq_dispose_mapping() Andy Shevchenko
2023-09-19 19:59 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox