diff options
| author | Grant Likely <grant.likely@linaro.org> | 2013-06-08 07:57:40 -0400 |
|---|---|---|
| committer | Grant Likely <grant.likely@linaro.org> | 2013-06-10 06:52:09 -0400 |
| commit | fa40f377577752b83252b9d2b3165d4acee0eb7c (patch) | |
| tree | 81314980dfd943e07cadd7415a6c092cf91e4b19 /kernel | |
| parent | 1aa0dd94ca07df818cf14588c9031ab1d7fd84d3 (diff) | |
irqdomain: Clean up aftermath of irq_domain refactoring
After refactoring the irqdomain code, there are a number of API
functions that are merely empty wrappers around core code. Drop those
wrappers out of the C file and replace them with static inlines in the
header.
Signed-off-by: Grant Likely <grant.likely@linaro.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/irq/irqdomain.c | 127 |
1 files changed, 36 insertions, 91 deletions
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index c38be78fceb4..e0db59e2eef6 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c | |||
| @@ -23,8 +23,11 @@ static DEFINE_MUTEX(revmap_trees_mutex); | |||
| 23 | static struct irq_domain *irq_default_domain; | 23 | static struct irq_domain *irq_default_domain; |
| 24 | 24 | ||
| 25 | /** | 25 | /** |
| 26 | * irq_domain_alloc() - Allocate a new irq_domain data structure | 26 | * __irq_domain_add() - Allocate a new irq_domain data structure |
| 27 | * @of_node: optional device-tree node of the interrupt controller | 27 | * @of_node: optional device-tree node of the interrupt controller |
| 28 | * @size: Size of linear map; 0 for radix mapping only | ||
| 29 | * @direct_max: Maximum value of direct maps; Use ~0 for no limit; 0 for no | ||
| 30 | * direct mapping | ||
| 28 | * @ops: map/unmap domain callbacks | 31 | * @ops: map/unmap domain callbacks |
| 29 | * @host_data: Controller private data pointer | 32 | * @host_data: Controller private data pointer |
| 30 | * | 33 | * |
| @@ -32,10 +35,10 @@ static struct irq_domain *irq_default_domain; | |||
| 32 | * register allocated irq_domain with irq_domain_register(). Returns pointer | 35 | * register allocated irq_domain with irq_domain_register(). Returns pointer |
| 33 | * to IRQ domain, or NULL on failure. | 36 | * to IRQ domain, or NULL on failure. |
| 34 | */ | 37 | */ |
| 35 | static struct irq_domain *irq_domain_alloc(struct device_node *of_node, | 38 | struct irq_domain *__irq_domain_add(struct device_node *of_node, |
| 36 | int size, | 39 | int size, int direct_max, |
| 37 | const struct irq_domain_ops *ops, | 40 | const struct irq_domain_ops *ops, |
| 38 | void *host_data) | 41 | void *host_data) |
| 39 | { | 42 | { |
| 40 | struct irq_domain *domain; | 43 | struct irq_domain *domain; |
| 41 | 44 | ||
| @@ -50,23 +53,16 @@ static struct irq_domain *irq_domain_alloc(struct device_node *of_node, | |||
| 50 | domain->host_data = host_data; | 53 | domain->host_data = host_data; |
| 51 | domain->of_node = of_node_get(of_node); | 54 | domain->of_node = of_node_get(of_node); |
| 52 | domain->revmap_size = size; | 55 | domain->revmap_size = size; |
| 56 | domain->revmap_direct_max_irq = direct_max; | ||
| 53 | 57 | ||
| 54 | return domain; | ||
| 55 | } | ||
| 56 | |||
| 57 | static void irq_domain_free(struct irq_domain *domain) | ||
| 58 | { | ||
| 59 | of_node_put(domain->of_node); | ||
| 60 | kfree(domain); | ||
| 61 | } | ||
| 62 | |||
| 63 | static void irq_domain_add(struct irq_domain *domain) | ||
| 64 | { | ||
| 65 | mutex_lock(&irq_domain_mutex); | 58 | mutex_lock(&irq_domain_mutex); |
| 66 | list_add(&domain->link, &irq_domain_list); | 59 | list_add(&domain->link, &irq_domain_list); |
| 67 | mutex_unlock(&irq_domain_mutex); | 60 | mutex_unlock(&irq_domain_mutex); |
| 61 | |||
| 68 | pr_debug("Added domain %s\n", domain->name); | 62 | pr_debug("Added domain %s\n", domain->name); |
| 63 | return domain; | ||
| 69 | } | 64 | } |
| 65 | EXPORT_SYMBOL_GPL(__irq_domain_add); | ||
| 70 | 66 | ||
| 71 | /** | 67 | /** |
| 72 | * irq_domain_remove() - Remove an irq domain. | 68 | * irq_domain_remove() - Remove an irq domain. |
| @@ -99,30 +95,28 @@ void irq_domain_remove(struct irq_domain *domain) | |||
| 99 | 95 | ||
| 100 | pr_debug("Removed domain %s\n", domain->name); | 96 | pr_debug("Removed domain %s\n", domain->name); |
| 101 | 97 | ||
| 102 | irq_domain_free(domain); | 98 | of_node_put(domain->of_node); |
| 99 | kfree(domain); | ||
| 103 | } | 100 | } |
| 104 | EXPORT_SYMBOL_GPL(irq_domain_remove); | 101 | EXPORT_SYMBOL_GPL(irq_domain_remove); |
| 105 | 102 | ||
| 106 | /** | 103 | /** |
| 107 | * irq_domain_add_simple() - Allocate and register a simple irq_domain. | 104 | * irq_domain_add_simple() - Register an irq_domain and optionally map a range of irqs |
| 108 | * @of_node: pointer to interrupt controller's device tree node. | 105 | * @of_node: pointer to interrupt controller's device tree node. |
| 109 | * @size: total number of irqs in mapping | 106 | * @size: total number of irqs in mapping |
| 110 | * @first_irq: first number of irq block assigned to the domain, | 107 | * @first_irq: first number of irq block assigned to the domain, |
| 111 | * pass zero to assign irqs on-the-fly. This will result in a | 108 | * pass zero to assign irqs on-the-fly. If first_irq is non-zero, then |
| 112 | * linear IRQ domain so it is important to use irq_create_mapping() | 109 | * pre-map all of the irqs in the domain to virqs starting at first_irq. |
| 113 | * for each used IRQ, especially when SPARSE_IRQ is enabled. | ||
| 114 | * @ops: map/unmap domain callbacks | 110 | * @ops: map/unmap domain callbacks |
| 115 | * @host_data: Controller private data pointer | 111 | * @host_data: Controller private data pointer |
| 116 | * | 112 | * |
| 117 | * Allocates a legacy irq_domain if irq_base is positive or a linear | 113 | * Allocates an irq_domain, and optionally if first_irq is positive then also |
| 118 | * domain otherwise. For the legacy domain, IRQ descriptors will also | 114 | * allocate irq_descs and map all of the hwirqs to virqs starting at first_irq. |
| 119 | * be allocated. | ||
| 120 | * | 115 | * |
| 121 | * This is intended to implement the expected behaviour for most | 116 | * This is intended to implement the expected behaviour for most |
| 122 | * interrupt controllers which is that a linear mapping should | 117 | * interrupt controllers. If device tree is used, then first_irq will be 0 and |
| 123 | * normally be used unless the system requires a legacy mapping in | 118 | * irqs get mapped dynamically on the fly. However, if the controller requires |
| 124 | * order to support supplying interrupt numbers during non-DT | 119 | * static virq assignments (non-DT boot) then it will set that up correctly. |
| 125 | * registration of devices. | ||
| 126 | */ | 120 | */ |
| 127 | struct irq_domain *irq_domain_add_simple(struct device_node *of_node, | 121 | struct irq_domain *irq_domain_add_simple(struct device_node *of_node, |
| 128 | unsigned int size, | 122 | unsigned int size, |
| @@ -130,33 +124,25 @@ struct irq_domain *irq_domain_add_simple(struct device_node *of_node, | |||
| 130 | const struct irq_domain_ops *ops, | 124 | const struct irq_domain_ops *ops, |
| 131 | void *host_data) | 125 | void *host_data) |
| 132 | { | 126 | { |
| 133 | if (first_irq > 0) { | 127 | struct irq_domain *domain; |
| 134 | int irq_base; | 128 | |
| 129 | domain = __irq_domain_add(of_node, size, 0, ops, host_data); | ||
| 130 | if (!domain) | ||
| 131 | return NULL; | ||
| 135 | 132 | ||
| 133 | if (first_irq > 0) { | ||
| 136 | if (IS_ENABLED(CONFIG_SPARSE_IRQ)) { | 134 | if (IS_ENABLED(CONFIG_SPARSE_IRQ)) { |
| 137 | /* | 135 | /* attempt to allocated irq_descs */ |
| 138 | * Set the descriptor allocator to search for a | 136 | int rc = irq_alloc_descs(first_irq, first_irq, size, |
| 139 | * 1-to-1 mapping, such as irq_alloc_desc_at(). | 137 | of_node_to_nid(of_node)); |
| 140 | * Use of_node_to_nid() which is defined to | 138 | if (rc < 0) |
| 141 | * numa_node_id() on platforms that have no custom | ||
| 142 | * implementation. | ||
| 143 | */ | ||
| 144 | irq_base = irq_alloc_descs(first_irq, first_irq, size, | ||
| 145 | of_node_to_nid(of_node)); | ||
| 146 | if (irq_base < 0) { | ||
| 147 | pr_info("Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n", | 139 | pr_info("Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n", |
| 148 | first_irq); | 140 | first_irq); |
| 149 | irq_base = first_irq; | 141 | } |
| 150 | } | 142 | WARN_ON(irq_domain_associate_many(domain, first_irq, 0, size)); |
| 151 | } else | ||
| 152 | irq_base = first_irq; | ||
| 153 | |||
| 154 | return irq_domain_add_legacy(of_node, size, irq_base, 0, | ||
| 155 | ops, host_data); | ||
| 156 | } | 143 | } |
| 157 | 144 | ||
| 158 | /* A linear domain is the default */ | 145 | return domain; |
| 159 | return irq_domain_add_linear(of_node, size, ops, host_data); | ||
| 160 | } | 146 | } |
| 161 | EXPORT_SYMBOL_GPL(irq_domain_add_simple); | 147 | EXPORT_SYMBOL_GPL(irq_domain_add_simple); |
| 162 | 148 | ||
| @@ -184,11 +170,7 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node, | |||
| 184 | { | 170 | { |
| 185 | struct irq_domain *domain; | 171 | struct irq_domain *domain; |
| 186 | 172 | ||
| 187 | pr_debug("Setting up legacy domain virq[%i:%i] ==> hwirq[%i:%i]\n", | 173 | domain = __irq_domain_add(of_node, first_hwirq + size, 0, ops, host_data); |
| 188 | first_irq, first_irq + size - 1, | ||
| 189 | (int)first_hwirq, (int)first_hwirq + size -1); | ||
| 190 | |||
| 191 | domain = irq_domain_add_linear(of_node, first_hwirq + size, ops, host_data); | ||
| 192 | if (!domain) | 174 | if (!domain) |
| 193 | return NULL; | 175 | return NULL; |
| 194 | 176 | ||
| @@ -199,43 +181,6 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node, | |||
| 199 | EXPORT_SYMBOL_GPL(irq_domain_add_legacy); | 181 | EXPORT_SYMBOL_GPL(irq_domain_add_legacy); |
| 200 | 182 | ||
| 201 | /** | 183 | /** |
| 202 | * irq_domain_add_linear() - Allocate and register a linear revmap irq_domain. | ||
| 203 | * @of_node: pointer to interrupt controller's device tree node. | ||
| 204 | * @size: Number of interrupts in the domain. | ||
| 205 | * @ops: map/unmap domain callbacks | ||
| 206 | * @host_data: Controller private data pointer | ||
| 207 | */ | ||
| 208 | struct irq_domain *irq_domain_add_linear(struct device_node *of_node, | ||
| 209 | unsigned int size, | ||
| 210 | const struct irq_domain_ops *ops, | ||
| 211 | void *host_data) | ||
| 212 | { | ||
| 213 | struct irq_domain *domain; | ||
| 214 | |||
| 215 | domain = irq_domain_alloc(of_node, size, ops, host_data); | ||
| 216 | if (!domain) | ||
| 217 | return NULL; | ||
| 218 | |||
| 219 | irq_domain_add(domain); | ||
| 220 | return domain; | ||
| 221 | } | ||
| 222 | EXPORT_SYMBOL_GPL(irq_domain_add_linear); | ||
| 223 | |||
| 224 | struct irq_domain *irq_domain_add_nomap(struct device_node *of_node, | ||
| 225 | unsigned int max_irq, | ||
| 226 | const struct irq_domain_ops *ops, | ||
| 227 | void *host_data) | ||
| 228 | { | ||
| 229 | struct irq_domain *domain = irq_domain_alloc(of_node, 0, ops, host_data); | ||
| 230 | if (domain) { | ||
| 231 | domain->revmap_direct_max_irq = max_irq ? max_irq : ~0; | ||
| 232 | irq_domain_add(domain); | ||
| 233 | } | ||
| 234 | return domain; | ||
| 235 | } | ||
| 236 | EXPORT_SYMBOL_GPL(irq_domain_add_nomap); | ||
| 237 | |||
| 238 | /** | ||
| 239 | * irq_find_host() - Locates a domain for a given device node | 184 | * irq_find_host() - Locates a domain for a given device node |
| 240 | * @node: device-tree node of the interrupt controller | 185 | * @node: device-tree node of the interrupt controller |
| 241 | */ | 186 | */ |
