diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2012-01-26 14:12:14 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2012-02-16 08:11:24 -0500 |
commit | a18dc81bf58258ac0920bec26b91656cb0140d2a (patch) | |
tree | 7e11dd40b11ffa281c3ecb902994b94250fbf916 /kernel/irq | |
parent | 16b2e6e2f31dda41f114aa0acade04f7e10f67c9 (diff) |
irq_domain: constify irq_domain_ops
Make irq_domain_ops pointer a constant to make it safer for multiple
instances to share the same ops pointer and change the irq_domain code
so that it does not modify the ops.
v4: Fix mismatched type reference in powerpc code
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Milton Miller <miltonm@bga.com>
Tested-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'kernel/irq')
-rw-r--r-- | kernel/irq/irqdomain.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 456e3fc8387f..25a498eb98a3 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c | |||
@@ -26,11 +26,6 @@ static DEFINE_MUTEX(revmap_trees_mutex); | |||
26 | static unsigned int irq_virq_count = NR_IRQS; | 26 | static unsigned int irq_virq_count = NR_IRQS; |
27 | static struct irq_domain *irq_default_domain; | 27 | static struct irq_domain *irq_default_domain; |
28 | 28 | ||
29 | static int default_irq_domain_match(struct irq_domain *d, struct device_node *np) | ||
30 | { | ||
31 | return d->of_node != NULL && d->of_node == np; | ||
32 | } | ||
33 | |||
34 | /** | 29 | /** |
35 | * irq_domain_alloc() - Allocate a new irq_domain data structure | 30 | * irq_domain_alloc() - Allocate a new irq_domain data structure |
36 | * @of_node: optional device-tree node of the interrupt controller | 31 | * @of_node: optional device-tree node of the interrupt controller |
@@ -44,7 +39,7 @@ static int default_irq_domain_match(struct irq_domain *d, struct device_node *np | |||
44 | */ | 39 | */ |
45 | static struct irq_domain *irq_domain_alloc(struct device_node *of_node, | 40 | static struct irq_domain *irq_domain_alloc(struct device_node *of_node, |
46 | unsigned int revmap_type, | 41 | unsigned int revmap_type, |
47 | struct irq_domain_ops *ops, | 42 | const struct irq_domain_ops *ops, |
48 | void *host_data) | 43 | void *host_data) |
49 | { | 44 | { |
50 | struct irq_domain *domain; | 45 | struct irq_domain *domain; |
@@ -59,9 +54,6 @@ static struct irq_domain *irq_domain_alloc(struct device_node *of_node, | |||
59 | domain->host_data = host_data; | 54 | domain->host_data = host_data; |
60 | domain->of_node = of_node_get(of_node); | 55 | domain->of_node = of_node_get(of_node); |
61 | 56 | ||
62 | if (domain->ops->match == NULL) | ||
63 | domain->ops->match = default_irq_domain_match; | ||
64 | |||
65 | return domain; | 57 | return domain; |
66 | } | 58 | } |
67 | 59 | ||
@@ -104,7 +96,7 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node, | |||
104 | unsigned int size, | 96 | unsigned int size, |
105 | unsigned int first_irq, | 97 | unsigned int first_irq, |
106 | irq_hw_number_t first_hwirq, | 98 | irq_hw_number_t first_hwirq, |
107 | struct irq_domain_ops *ops, | 99 | const struct irq_domain_ops *ops, |
108 | void *host_data) | 100 | void *host_data) |
109 | { | 101 | { |
110 | struct irq_domain *domain; | 102 | struct irq_domain *domain; |
@@ -170,7 +162,7 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node, | |||
170 | */ | 162 | */ |
171 | struct irq_domain *irq_domain_add_linear(struct device_node *of_node, | 163 | struct irq_domain *irq_domain_add_linear(struct device_node *of_node, |
172 | unsigned int size, | 164 | unsigned int size, |
173 | struct irq_domain_ops *ops, | 165 | const struct irq_domain_ops *ops, |
174 | void *host_data) | 166 | void *host_data) |
175 | { | 167 | { |
176 | struct irq_domain *domain; | 168 | struct irq_domain *domain; |
@@ -192,7 +184,7 @@ struct irq_domain *irq_domain_add_linear(struct device_node *of_node, | |||
192 | } | 184 | } |
193 | 185 | ||
194 | struct irq_domain *irq_domain_add_nomap(struct device_node *of_node, | 186 | struct irq_domain *irq_domain_add_nomap(struct device_node *of_node, |
195 | struct irq_domain_ops *ops, | 187 | const struct irq_domain_ops *ops, |
196 | void *host_data) | 188 | void *host_data) |
197 | { | 189 | { |
198 | struct irq_domain *domain = irq_domain_alloc(of_node, | 190 | struct irq_domain *domain = irq_domain_alloc(of_node, |
@@ -211,7 +203,7 @@ struct irq_domain *irq_domain_add_nomap(struct device_node *of_node, | |||
211 | * (the reverse mapping will use the slow path until that happens). | 203 | * (the reverse mapping will use the slow path until that happens). |
212 | */ | 204 | */ |
213 | struct irq_domain *irq_domain_add_tree(struct device_node *of_node, | 205 | struct irq_domain *irq_domain_add_tree(struct device_node *of_node, |
214 | struct irq_domain_ops *ops, | 206 | const struct irq_domain_ops *ops, |
215 | void *host_data) | 207 | void *host_data) |
216 | { | 208 | { |
217 | struct irq_domain *domain = irq_domain_alloc(of_node, | 209 | struct irq_domain *domain = irq_domain_alloc(of_node, |
@@ -230,6 +222,7 @@ struct irq_domain *irq_domain_add_tree(struct device_node *of_node, | |||
230 | struct irq_domain *irq_find_host(struct device_node *node) | 222 | struct irq_domain *irq_find_host(struct device_node *node) |
231 | { | 223 | { |
232 | struct irq_domain *h, *found = NULL; | 224 | struct irq_domain *h, *found = NULL; |
225 | int rc; | ||
233 | 226 | ||
234 | /* We might want to match the legacy controller last since | 227 | /* We might want to match the legacy controller last since |
235 | * it might potentially be set to match all interrupts in | 228 | * it might potentially be set to match all interrupts in |
@@ -237,11 +230,17 @@ struct irq_domain *irq_find_host(struct device_node *node) | |||
237 | * yet though... | 230 | * yet though... |
238 | */ | 231 | */ |
239 | mutex_lock(&irq_domain_mutex); | 232 | mutex_lock(&irq_domain_mutex); |
240 | list_for_each_entry(h, &irq_domain_list, link) | 233 | list_for_each_entry(h, &irq_domain_list, link) { |
241 | if (h->ops->match(h, node)) { | 234 | if (h->ops->match) |
235 | rc = h->ops->match(h, node); | ||
236 | else | ||
237 | rc = (h->of_node != NULL) && (h->of_node == node); | ||
238 | |||
239 | if (rc) { | ||
242 | found = h; | 240 | found = h; |
243 | break; | 241 | break; |
244 | } | 242 | } |
243 | } | ||
245 | mutex_unlock(&irq_domain_mutex); | 244 | mutex_unlock(&irq_domain_mutex); |
246 | return found; | 245 | return found; |
247 | } | 246 | } |
@@ -760,7 +759,7 @@ int irq_domain_xlate_onetwocell(struct irq_domain *d, | |||
760 | } | 759 | } |
761 | EXPORT_SYMBOL_GPL(irq_domain_xlate_onetwocell); | 760 | EXPORT_SYMBOL_GPL(irq_domain_xlate_onetwocell); |
762 | 761 | ||
763 | struct irq_domain_ops irq_domain_simple_ops = { | 762 | const struct irq_domain_ops irq_domain_simple_ops = { |
764 | .map = irq_domain_simple_map, | 763 | .map = irq_domain_simple_map, |
765 | .xlate = irq_domain_xlate_onetwocell, | 764 | .xlate = irq_domain_xlate_onetwocell, |
766 | }; | 765 | }; |