Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irqdomain: Introduce irq_domain_create_simple() API

Linus Walleij pointed out that ird_domain_add_simple() gained
additional functionality and can't be anymore replaced with
a simple conditional. In preparation to upgrade GPIO library
to use fwnode, introduce irq_domain_create_simple() API which is
functional equivalent to the existing irq_domain_add_simple(),
but takes a pointer to the struct fwnode_handle as a parameter.

While at it, amend documentation to mention irq_domain_create_*()
functions where it makes sense.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

authored by

Andy Shevchenko and committed by
Bartosz Golaszewski
67196fea 3fd19d4b

+36 -25
+12 -10
Documentation/core-api/irq/irq-domain.rst
··· 42 42 ================ 43 43 44 44 An interrupt controller driver creates and registers an irq_domain by 45 - calling one of the irq_domain_add_*() functions (each mapping method 46 - has a different allocator function, more on that later). The function 47 - will return a pointer to the irq_domain on success. The caller must 48 - provide the allocator function with an irq_domain_ops structure. 45 + calling one of the irq_domain_add_*() or irq_domain_create_*() functions 46 + (each mapping method has a different allocator function, more on that later). 47 + The function will return a pointer to the irq_domain on success. The caller 48 + must provide the allocator function with an irq_domain_ops structure. 49 49 50 50 In most cases, the irq_domain will begin empty without any mappings 51 51 between hwirq and IRQ numbers. Mappings are added to the irq_domain ··· 147 147 irq_domain_add_simple() 148 148 irq_domain_add_legacy() 149 149 irq_domain_add_legacy_isa() 150 + irq_domain_create_simple() 150 151 irq_domain_create_legacy() 151 152 152 153 The Legacy mapping is a special case for drivers that already have a ··· 170 169 mapping Linux IRQs 0-15 so that existing ISA drivers get the correct IRQ 171 170 numbers. 172 171 173 - Most users of legacy mappings should use irq_domain_add_simple() which 174 - will use a legacy domain only if an IRQ range is supplied by the 175 - system and will otherwise use a linear domain mapping. The semantics 176 - of this call are such that if an IRQ range is specified then 172 + Most users of legacy mappings should use irq_domain_add_simple() or 173 + irq_domain_create_simple() which will use a legacy domain only if an IRQ range 174 + is supplied by the system and will otherwise use a linear domain mapping. 175 + The semantics of this call are such that if an IRQ range is specified then 177 176 descriptors will be allocated on-the-fly for it, and if no range is 178 - specified it will fall through to irq_domain_add_linear() which means 179 - *no* irq descriptors will be allocated. 177 + specified it will fall through to irq_domain_add_linear() or 178 + irq_domain_create_linear() which means *no* irq descriptors will be allocated. 180 179 181 180 A typical use case for simple domains is where an irqchip provider 182 181 is supporting both dynamic and static IRQ assignments. ··· 187 186 before any irq_find_mapping() since the latter will actually work 188 187 for the static IRQ assignment case. 189 188 189 + irq_domain_add_simple() and irq_domain_create_simple() as well as 190 190 irq_domain_add_legacy() and irq_domain_create_legacy() are functionally 191 191 equivalent, except for the first argument is different - the former 192 192 accepts an Open Firmware specific 'struct device_node', while the latter
+14 -5
include/linux/irqdomain.h
··· 256 256 irq_hw_number_t hwirq_max, int direct_max, 257 257 const struct irq_domain_ops *ops, 258 258 void *host_data); 259 - struct irq_domain *irq_domain_add_simple(struct device_node *of_node, 260 - unsigned int size, 261 - unsigned int first_irq, 262 - const struct irq_domain_ops *ops, 263 - void *host_data); 259 + struct irq_domain *irq_domain_create_simple(struct fwnode_handle *fwnode, 260 + unsigned int size, 261 + unsigned int first_irq, 262 + const struct irq_domain_ops *ops, 263 + void *host_data); 264 264 struct irq_domain *irq_domain_add_legacy(struct device_node *of_node, 265 265 unsigned int size, 266 266 unsigned int first_irq, ··· 323 323 d = irq_find_matching_host(node, DOMAIN_BUS_ANY); 324 324 325 325 return d; 326 + } 327 + 328 + static inline struct irq_domain *irq_domain_add_simple(struct device_node *of_node, 329 + unsigned int size, 330 + unsigned int first_irq, 331 + const struct irq_domain_ops *ops, 332 + void *host_data) 333 + { 334 + return irq_domain_create_simple(of_node_to_fwnode(of_node), size, first_irq, ops, host_data); 326 335 } 327 336 328 337 /**
+10 -10
kernel/irq/irqdomain.c
··· 295 295 EXPORT_SYMBOL_GPL(irq_domain_update_bus_token); 296 296 297 297 /** 298 - * irq_domain_add_simple() - Register an irq_domain and optionally map a range of irqs 299 - * @of_node: pointer to interrupt controller's device tree node. 298 + * irq_domain_create_simple() - Register an irq_domain and optionally map a range of irqs 299 + * @fwnode: firmware node for the interrupt controller 300 300 * @size: total number of irqs in mapping 301 301 * @first_irq: first number of irq block assigned to the domain, 302 302 * pass zero to assign irqs on-the-fly. If first_irq is non-zero, then ··· 312 312 * irqs get mapped dynamically on the fly. However, if the controller requires 313 313 * static virq assignments (non-DT boot) then it will set that up correctly. 314 314 */ 315 - struct irq_domain *irq_domain_add_simple(struct device_node *of_node, 316 - unsigned int size, 317 - unsigned int first_irq, 318 - const struct irq_domain_ops *ops, 319 - void *host_data) 315 + struct irq_domain *irq_domain_create_simple(struct fwnode_handle *fwnode, 316 + unsigned int size, 317 + unsigned int first_irq, 318 + const struct irq_domain_ops *ops, 319 + void *host_data) 320 320 { 321 321 struct irq_domain *domain; 322 322 323 - domain = __irq_domain_add(of_node_to_fwnode(of_node), size, size, 0, ops, host_data); 323 + domain = __irq_domain_add(fwnode, size, size, 0, ops, host_data); 324 324 if (!domain) 325 325 return NULL; 326 326 ··· 328 328 if (IS_ENABLED(CONFIG_SPARSE_IRQ)) { 329 329 /* attempt to allocated irq_descs */ 330 330 int rc = irq_alloc_descs(first_irq, first_irq, size, 331 - of_node_to_nid(of_node)); 331 + of_node_to_nid(to_of_node(fwnode))); 332 332 if (rc < 0) 333 333 pr_info("Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n", 334 334 first_irq); ··· 338 338 339 339 return domain; 340 340 } 341 - EXPORT_SYMBOL_GPL(irq_domain_add_simple); 341 + EXPORT_SYMBOL_GPL(irq_domain_create_simple); 342 342 343 343 /** 344 344 * irq_domain_add_legacy() - Allocate and register a legacy revmap irq_domain.