diff options
author | Marc Zyngier <marc.zyngier@arm.com> | 2015-10-13 07:51:35 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2015-10-13 13:01:24 -0400 |
commit | 1bf4ddc46c5d6123897a54cea4ffe3e90f30600b (patch) | |
tree | 6a14bb9d75d3f6dc90fdfd032fcabfa8aa9823c6 | |
parent | c0131f09de8c2d301814cac86d78f643b8ee0574 (diff) |
irqdomain: Introduce irq_domain_create_{linear, tree}
Just like we have irq_domain_add_{linear,tree} to create a irq domain
identified by an of_node, introduce irq_domain_create_{linear,tree}
that do the same thing, except that they take a struct fwnode_handle.
Existing functions get rewritten in terms of the new ones so that
everything keeps working as before (and __irq_domain_add is now
fwnode_handle based as well).
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-and-tested-by: Hanjun Guo <hanjun.guo@linaro.org>
Tested-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: <linux-arm-kernel@lists.infradead.org>
Cc: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Cc: Graeme Gregory <graeme@xora.org.uk>
Cc: Jake Oshins <jakeo@microsoft.com>
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
Link: http://lkml.kernel.org/r/1444737105-31573-8-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | include/linux/irqdomain.h | 31 | ||||
-rw-r--r-- | kernel/irq/irqdomain.c | 11 |
2 files changed, 31 insertions, 11 deletions
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index 7e7842e90d40..995d4c5100d3 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h | |||
@@ -188,7 +188,7 @@ static inline struct device_node *irq_domain_get_of_node(struct irq_domain *d) | |||
188 | } | 188 | } |
189 | 189 | ||
190 | #ifdef CONFIG_IRQ_DOMAIN | 190 | #ifdef CONFIG_IRQ_DOMAIN |
191 | struct irq_domain *__irq_domain_add(struct device_node *of_node, int size, | 191 | struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size, |
192 | irq_hw_number_t hwirq_max, int direct_max, | 192 | irq_hw_number_t hwirq_max, int direct_max, |
193 | const struct irq_domain_ops *ops, | 193 | const struct irq_domain_ops *ops, |
194 | void *host_data); | 194 | void *host_data); |
@@ -207,11 +207,15 @@ extern struct irq_domain *irq_find_matching_fwnode(struct fwnode_handle *fwnode, | |||
207 | enum irq_domain_bus_token bus_token); | 207 | enum irq_domain_bus_token bus_token); |
208 | extern void irq_set_default_host(struct irq_domain *host); | 208 | extern void irq_set_default_host(struct irq_domain *host); |
209 | 209 | ||
210 | static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *node) | ||
211 | { | ||
212 | return node ? &node->fwnode : NULL; | ||
213 | } | ||
214 | |||
210 | static inline struct irq_domain *irq_find_matching_host(struct device_node *node, | 215 | static inline struct irq_domain *irq_find_matching_host(struct device_node *node, |
211 | enum irq_domain_bus_token bus_token) | 216 | enum irq_domain_bus_token bus_token) |
212 | { | 217 | { |
213 | return irq_find_matching_fwnode(node ? &node->fwnode : NULL, | 218 | return irq_find_matching_fwnode(of_node_to_fwnode(node), bus_token); |
214 | bus_token); | ||
215 | } | 219 | } |
216 | 220 | ||
217 | static inline struct irq_domain *irq_find_host(struct device_node *node) | 221 | static inline struct irq_domain *irq_find_host(struct device_node *node) |
@@ -231,14 +235,14 @@ static inline struct irq_domain *irq_domain_add_linear(struct device_node *of_no | |||
231 | const struct irq_domain_ops *ops, | 235 | const struct irq_domain_ops *ops, |
232 | void *host_data) | 236 | void *host_data) |
233 | { | 237 | { |
234 | return __irq_domain_add(of_node, size, size, 0, ops, host_data); | 238 | return __irq_domain_add(of_node_to_fwnode(of_node), size, size, 0, ops, host_data); |
235 | } | 239 | } |
236 | static inline struct irq_domain *irq_domain_add_nomap(struct device_node *of_node, | 240 | static inline struct irq_domain *irq_domain_add_nomap(struct device_node *of_node, |
237 | unsigned int max_irq, | 241 | unsigned int max_irq, |
238 | const struct irq_domain_ops *ops, | 242 | const struct irq_domain_ops *ops, |
239 | void *host_data) | 243 | void *host_data) |
240 | { | 244 | { |
241 | return __irq_domain_add(of_node, 0, max_irq, max_irq, ops, host_data); | 245 | return __irq_domain_add(of_node_to_fwnode(of_node), 0, max_irq, max_irq, ops, host_data); |
242 | } | 246 | } |
243 | static inline struct irq_domain *irq_domain_add_legacy_isa( | 247 | static inline struct irq_domain *irq_domain_add_legacy_isa( |
244 | struct device_node *of_node, | 248 | struct device_node *of_node, |
@@ -252,7 +256,22 @@ static inline struct irq_domain *irq_domain_add_tree(struct device_node *of_node | |||
252 | const struct irq_domain_ops *ops, | 256 | const struct irq_domain_ops *ops, |
253 | void *host_data) | 257 | void *host_data) |
254 | { | 258 | { |
255 | return __irq_domain_add(of_node, 0, ~0, 0, ops, host_data); | 259 | return __irq_domain_add(of_node_to_fwnode(of_node), 0, ~0, 0, ops, host_data); |
260 | } | ||
261 | |||
262 | static inline struct irq_domain *irq_domain_create_linear(struct fwnode_handle *fwnode, | ||
263 | unsigned int size, | ||
264 | const struct irq_domain_ops *ops, | ||
265 | void *host_data) | ||
266 | { | ||
267 | return __irq_domain_add(fwnode, size, size, 0, ops, host_data); | ||
268 | } | ||
269 | |||
270 | static inline struct irq_domain *irq_domain_create_tree(struct fwnode_handle *fwnode, | ||
271 | const struct irq_domain_ops *ops, | ||
272 | void *host_data) | ||
273 | { | ||
274 | return __irq_domain_add(fwnode, 0, ~0, 0, ops, host_data); | ||
256 | } | 275 | } |
257 | 276 | ||
258 | extern void irq_domain_remove(struct irq_domain *host); | 277 | extern void irq_domain_remove(struct irq_domain *host); |
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index b1fda6dad467..de6d7493190b 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c | |||
@@ -40,13 +40,15 @@ static void irq_domain_check_hierarchy(struct irq_domain *domain); | |||
40 | * Allocates and initialize and irq_domain structure. | 40 | * Allocates and initialize and irq_domain structure. |
41 | * Returns pointer to IRQ domain, or NULL on failure. | 41 | * Returns pointer to IRQ domain, or NULL on failure. |
42 | */ | 42 | */ |
43 | struct irq_domain *__irq_domain_add(struct device_node *of_node, int size, | 43 | struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size, |
44 | irq_hw_number_t hwirq_max, int direct_max, | 44 | irq_hw_number_t hwirq_max, int direct_max, |
45 | const struct irq_domain_ops *ops, | 45 | const struct irq_domain_ops *ops, |
46 | void *host_data) | 46 | void *host_data) |
47 | { | 47 | { |
48 | struct irq_domain *domain; | 48 | struct irq_domain *domain; |
49 | struct fwnode_handle *fwnode; | 49 | struct device_node *of_node; |
50 | |||
51 | of_node = to_of_node(fwnode); | ||
50 | 52 | ||
51 | domain = kzalloc_node(sizeof(*domain) + (sizeof(unsigned int) * size), | 53 | domain = kzalloc_node(sizeof(*domain) + (sizeof(unsigned int) * size), |
52 | GFP_KERNEL, of_node_to_nid(of_node)); | 54 | GFP_KERNEL, of_node_to_nid(of_node)); |
@@ -54,7 +56,6 @@ struct irq_domain *__irq_domain_add(struct device_node *of_node, int size, | |||
54 | return NULL; | 56 | return NULL; |
55 | 57 | ||
56 | of_node_get(of_node); | 58 | of_node_get(of_node); |
57 | fwnode = of_node ? &of_node->fwnode : NULL; | ||
58 | 59 | ||
59 | /* Fill structure */ | 60 | /* Fill structure */ |
60 | INIT_RADIX_TREE(&domain->revmap_tree, GFP_KERNEL); | 61 | INIT_RADIX_TREE(&domain->revmap_tree, GFP_KERNEL); |
@@ -137,7 +138,7 @@ struct irq_domain *irq_domain_add_simple(struct device_node *of_node, | |||
137 | { | 138 | { |
138 | struct irq_domain *domain; | 139 | struct irq_domain *domain; |
139 | 140 | ||
140 | domain = __irq_domain_add(of_node, size, size, 0, ops, host_data); | 141 | domain = __irq_domain_add(of_node_to_fwnode(of_node), size, size, 0, ops, host_data); |
141 | if (!domain) | 142 | if (!domain) |
142 | return NULL; | 143 | return NULL; |
143 | 144 | ||
@@ -181,7 +182,7 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node, | |||
181 | { | 182 | { |
182 | struct irq_domain *domain; | 183 | struct irq_domain *domain; |
183 | 184 | ||
184 | domain = __irq_domain_add(of_node, first_hwirq + size, | 185 | domain = __irq_domain_add(of_node_to_fwnode(of_node), first_hwirq + size, |
185 | first_hwirq + size, 0, ops, host_data); | 186 | first_hwirq + size, 0, ops, host_data); |
186 | if (domain) | 187 | if (domain) |
187 | irq_domain_associate_many(domain, first_irq, first_hwirq, size); | 188 | irq_domain_associate_many(domain, first_irq, first_hwirq, size); |