lkml.org 
[lkml]   [2024]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 5/5] genirq/irqdomain: Clean up for irq_domain_xlate_*
Date
As irq_domain_xlate_onecell() and irq_domain_xlate_onetwocell() have
almost the same logic, introduce irq_domain_xlate_common() to do it and
use a new xlate_type enum variable to distinguish them.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
kernel/irq/irqdomain.c | 40 +++++++++++++++++++++++++++-------------
1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 2ef53697d877..4dd53d76f7ef 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -985,6 +985,29 @@ struct irq_desc *__irq_resolve_mapping(struct irq_domain *domain,
}
EXPORT_SYMBOL_GPL(__irq_resolve_mapping);

+enum xlate_type {
+ ONE_CELL = 0,
+ ONE_TWO_CELL,
+};
+
+static inline int irq_domain_xlate_common(const u32 *intspec,
+ unsigned int intsize,
+ unsigned long *out_hwirq,
+ unsigned int *out_type,
+ enum xlate_type type)
+{
+ if (WARN_ON(intsize < 1))
+ return -EINVAL;
+
+ *out_hwirq = intspec[0];
+ *out_type = IRQ_TYPE_NONE;
+
+ if (type == ONE_TWO_CELL && intsize > 1)
+ *out_type = intspec[1] & IRQ_TYPE_SENSE_MASK;
+
+ return 0;
+}
+
/**
* irq_domain_xlate_onecell() - Generic xlate for direct one cell bindings
*
@@ -995,11 +1018,8 @@ int irq_domain_xlate_onecell(struct irq_domain *d, struct device_node *ctrlr,
const u32 *intspec, unsigned int intsize,
unsigned long *out_hwirq, unsigned int *out_type)
{
- if (WARN_ON(intsize < 1))
- return -EINVAL;
- *out_hwirq = intspec[0];
- *out_type = IRQ_TYPE_NONE;
- return 0;
+ return irq_domain_xlate_common(intspec, intsize, out_hwirq,
+ out_type, ONE_CELL);
}
EXPORT_SYMBOL_GPL(irq_domain_xlate_onecell);

@@ -1037,14 +1057,8 @@ int irq_domain_xlate_onetwocell(struct irq_domain *d,
const u32 *intspec, unsigned int intsize,
unsigned long *out_hwirq, unsigned int *out_type)
{
- if (WARN_ON(intsize < 1))
- return -EINVAL;
- *out_hwirq = intspec[0];
- if (intsize > 1)
- *out_type = intspec[1] & IRQ_TYPE_SENSE_MASK;
- else
- *out_type = IRQ_TYPE_NONE;
- return 0;
+ return irq_domain_xlate_common(intspec, intsize, out_hwirq,
+ out_type, ONE_TWO_CELL);
}
EXPORT_SYMBOL_GPL(irq_domain_xlate_onetwocell);

--
2.34.1

\
 
 \ /
  Last update: 2024-05-06 15:04    [W:0.021 / U:0.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site