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

irqdomain: Use irq_domain_get_of_node() instead of direct field access

The struct irq_domain contains a "struct device_node *" field
(of_node) that is almost the only link between the irqdomain
and the device tree infrastructure.

In order to prepare for the removal of that field, convert all
users to use irq_domain_get_of_node() instead.

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-2-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Marc Zyngier and committed by
Thomas Gleixner
5d4c9bc7 e50226b4

+75 -52
+2 -2
arch/arm/mach-exynos/suspend.c
··· 184 184 unsigned long *out_hwirq, 185 185 unsigned int *out_type) 186 186 { 187 - if (domain->of_node != controller) 187 + if (irq_domain_get_of_node(domain) != controller) 188 188 return -EINVAL; /* Shouldn't happen, really... */ 189 189 if (intsize != 3) 190 190 return -EINVAL; /* Not GIC compliant */ ··· 217 217 &exynos_pmu_chip, NULL); 218 218 219 219 parent_args = *args; 220 - parent_args.np = domain->parent->of_node; 220 + parent_args.np = irq_domain_get_of_node(domain->parent); 221 221 return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, &parent_args); 222 222 } 223 223
+2 -2
arch/arm/mach-imx/gpc.c
··· 188 188 unsigned long *out_hwirq, 189 189 unsigned int *out_type) 190 190 { 191 - if (domain->of_node != controller) 191 + if (irq_domain_get_of_node(domain) != controller) 192 192 return -EINVAL; /* Shouldn't happen, really... */ 193 193 if (intsize != 3) 194 194 return -EINVAL; /* Not GIC compliant */ ··· 223 223 &imx_gpc_chip, NULL); 224 224 225 225 parent_args = *args; 226 - parent_args.np = domain->parent->of_node; 226 + parent_args.np = irq_domain_get_of_node(domain->parent); 227 227 return irq_domain_alloc_irqs_parent(domain, irq, nr_irqs, &parent_args); 228 228 } 229 229
+2 -2
arch/arm/mach-omap2/omap-wakeupgen.c
··· 406 406 unsigned long *out_hwirq, 407 407 unsigned int *out_type) 408 408 { 409 - if (domain->of_node != controller) 409 + if (irq_domain_get_of_node(domain) != controller) 410 410 return -EINVAL; /* Shouldn't happen, really... */ 411 411 if (intsize != 3) 412 412 return -EINVAL; /* Not GIC compliant */ ··· 441 441 &wakeupgen_chip, NULL); 442 442 443 443 parent_args = *args; 444 - parent_args.np = domain->parent->of_node; 444 + parent_args.np = irq_domain_get_of_node(domain->parent); 445 445 return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, &parent_args); 446 446 } 447 447
+1 -1
arch/c6x/platforms/megamod-pic.c
··· 178 178 static void __init parse_priority_map(struct megamod_pic *pic, 179 179 int *mapping, int size) 180 180 { 181 - struct device_node *np = pic->irqhost->of_node; 181 + struct device_node *np = irq_domain_get_of_node(pic->irqhost); 182 182 const __be32 *map; 183 183 int i, maplen; 184 184 u32 val;
+2 -2
arch/mips/cavium-octeon/octeon-irq.c
··· 1094 1094 unsigned int pin; 1095 1095 unsigned int trigger; 1096 1096 1097 - if (d->of_node != node) 1097 + if (irq_domain_get_of_node(d) != node) 1098 1098 return -EINVAL; 1099 1099 1100 1100 if (intsize < 2) ··· 2163 2163 2164 2164 if (hw >= host_data->max_bits) { 2165 2165 pr_err("ERROR: %s mapping %u is to big!\n", 2166 - d->of_node->name, (unsigned)hw); 2166 + irq_domain_get_of_node(d)->name, (unsigned)hw); 2167 2167 return -EINVAL; 2168 2168 } 2169 2169
+1 -1
arch/powerpc/platforms/cell/axon_msi.c
··· 327 327 u32 tmp; 328 328 329 329 pr_devel("axon_msi: disabling %s\n", 330 - msic->irq_domain->of_node->full_name); 330 + irq_domain_get_of_node(msic->irq_domain)->full_name); 331 331 tmp = dcr_read(msic->dcr_host, MSIC_CTRL_REG); 332 332 tmp &= ~MSIC_CTRL_ENABLE & ~MSIC_CTRL_IRQ_ENABLE; 333 333 msic_dcr_write(msic, MSIC_CTRL_REG, tmp);
+6 -3
arch/powerpc/platforms/cell/spider-pic.c
··· 231 231 const u32 *imap, *tmp; 232 232 int imaplen, intsize, unit; 233 233 struct device_node *iic; 234 + struct device_node *of_node; 235 + 236 + of_node = irq_domain_get_of_node(pic->host); 234 237 235 238 /* First, we check whether we have a real "interrupts" in the device 236 239 * tree in case the device-tree is ever fixed 237 240 */ 238 - virq = irq_of_parse_and_map(pic->host->of_node, 0); 241 + virq = irq_of_parse_and_map(of_node, 0); 239 242 if (virq) 240 243 return virq; 241 244 242 245 /* Now do the horrible hacks */ 243 - tmp = of_get_property(pic->host->of_node, "#interrupt-cells", NULL); 246 + tmp = of_get_property(of_node, "#interrupt-cells", NULL); 244 247 if (tmp == NULL) 245 248 return NO_IRQ; 246 249 intsize = *tmp; 247 - imap = of_get_property(pic->host->of_node, "interrupt-map", &imaplen); 250 + imap = of_get_property(of_node, "interrupt-map", &imaplen); 248 251 if (imap == NULL || imaplen < (intsize + 1)) 249 252 return NO_IRQ; 250 253 iic = of_find_node_by_phandle(imap[intsize]);
+4 -2
arch/powerpc/platforms/pasemi/msi.c
··· 144 144 { 145 145 int rc; 146 146 struct pci_controller *phb; 147 + struct device_node *of_node; 147 148 148 - if (!mpic->irqhost->of_node || 149 - !of_device_is_compatible(mpic->irqhost->of_node, 149 + of_node = irq_domain_get_of_node(mpic->irqhost); 150 + if (!of_node || 151 + !of_device_is_compatible(of_node, 150 152 "pasemi,pwrficient-openpic")) 151 153 return -ENODEV; 152 154
+1 -1
arch/powerpc/platforms/powernv/opal-irqchip.c
··· 137 137 static int opal_event_match(struct irq_domain *h, struct device_node *node, 138 138 enum irq_domain_bus_token bus_token) 139 139 { 140 - return h->of_node == node; 140 + return irq_domain_get_of_node(h) == node; 141 141 } 142 142 143 143 static int opal_event_xlate(struct irq_domain *h, struct device_node *np,
+2 -1
arch/powerpc/sysdev/ehv_pic.c
··· 181 181 enum irq_domain_bus_token bus_token) 182 182 { 183 183 /* Exact match, unless ehv_pic node is NULL */ 184 - return h->of_node == NULL || h->of_node == node; 184 + struct device_node *of_node = irq_domain_get_of_node(h); 185 + return of_node == NULL || of_node == node; 185 186 } 186 187 187 188 static int ehv_pic_host_map(struct irq_domain *h, unsigned int virq,
+1 -1
arch/powerpc/sysdev/fsl_msi.c
··· 110 110 int rc, hwirq; 111 111 112 112 rc = msi_bitmap_alloc(&msi_data->bitmap, NR_MSI_IRQS_MAX, 113 - msi_data->irqhost->of_node); 113 + irq_domain_get_of_node(msi_data->irqhost)); 114 114 if (rc) 115 115 return rc; 116 116
+2 -1
arch/powerpc/sysdev/i8259.c
··· 165 165 static int i8259_host_match(struct irq_domain *h, struct device_node *node, 166 166 enum irq_domain_bus_token bus_token) 167 167 { 168 - return h->of_node == NULL || h->of_node == node; 168 + struct device_node *of_node = irq_domain_get_of_node(h); 169 + return of_node == NULL || of_node == node; 169 170 } 170 171 171 172 static int i8259_host_map(struct irq_domain *h, unsigned int virq,
+2 -1
arch/powerpc/sysdev/ipic.c
··· 675 675 enum irq_domain_bus_token bus_token) 676 676 { 677 677 /* Exact match, unless ipic node is NULL */ 678 - return h->of_node == NULL || h->of_node == node; 678 + struct device_node *of_node = irq_domain_get_of_node(h); 679 + return of_node == NULL || of_node == node; 679 680 } 680 681 681 682 static int ipic_host_map(struct irq_domain *h, unsigned int virq,
+2 -1
arch/powerpc/sysdev/mpic.c
··· 1011 1011 enum irq_domain_bus_token bus_token) 1012 1012 { 1013 1013 /* Exact match, unless mpic node is NULL */ 1014 - return h->of_node == NULL || h->of_node == node; 1014 + struct device_node *of_node = irq_domain_get_of_node(h); 1015 + return of_node == NULL || of_node == node; 1015 1016 } 1016 1017 1017 1018 static int mpic_host_map(struct irq_domain *h, unsigned int virq,
+1 -1
arch/powerpc/sysdev/mpic_msi.c
··· 84 84 int rc; 85 85 86 86 rc = msi_bitmap_alloc(&mpic->msi_bitmap, mpic->num_sources, 87 - mpic->irqhost->of_node); 87 + irq_domain_get_of_node(mpic->irqhost)); 88 88 if (rc) 89 89 return rc; 90 90
+2 -1
arch/powerpc/sysdev/qe_lib/qe_ic.c
··· 248 248 enum irq_domain_bus_token bus_token) 249 249 { 250 250 /* Exact match, unless qe_ic node is NULL */ 251 - return h->of_node == NULL || h->of_node == node; 251 + struct device_node *of_node = irq_domain_get_of_node(h); 252 + return of_node == NULL || of_node == node; 252 253 } 253 254 254 255 static int qe_ic_host_map(struct irq_domain *h, unsigned int virq,
+1 -1
drivers/gpio/gpio-sodaville.c
··· 102 102 { 103 103 u32 line, type; 104 104 105 - if (node != h->of_node) 105 + if (node != irq_domain_get_of_node(h)) 106 106 return -EINVAL; 107 107 108 108 if (intsize < 2)
+1 -1
drivers/irqchip/exynos-combiner.c
··· 144 144 unsigned long *out_hwirq, 145 145 unsigned int *out_type) 146 146 { 147 - if (d->of_node != controller) 147 + if (irq_domain_get_of_node(d) != controller) 148 148 return -EINVAL; 149 149 150 150 if (intsize < 2)
+1 -1
drivers/irqchip/irq-atmel-aic-common.c
··· 114 114 115 115 static void __init aic_common_ext_irq_of_init(struct irq_domain *domain) 116 116 { 117 - struct device_node *node = domain->of_node; 117 + struct device_node *node = irq_domain_get_of_node(domain); 118 118 struct irq_chip_generic *gc; 119 119 struct aic_chip_data *aic; 120 120 struct property *prop;
+2 -2
drivers/irqchip/irq-crossbar.c
··· 94 94 if (i < 0) 95 95 return -ENODEV; 96 96 97 - args.np = domain->parent->of_node; 97 + args.np = irq_domain_get_of_node(domain->parent); 98 98 args.args_count = 3; 99 99 args.args[0] = 0; /* SPI */ 100 100 args.args[1] = i; ··· 172 172 unsigned long *out_hwirq, 173 173 unsigned int *out_type) 174 174 { 175 - if (d->of_node != controller) 175 + if (irq_domain_get_of_node(d) != controller) 176 176 return -EINVAL; /* Shouldn't happen, really... */ 177 177 if (intsize != 3) 178 178 return -EINVAL; /* Not GIC compliant */
+1 -1
drivers/irqchip/irq-gic-v2m.c
··· 128 128 struct irq_data *d; 129 129 int err; 130 130 131 - args.np = domain->parent->of_node; 131 + args.np = irq_domain_get_of_node(domain->parent); 132 132 args.args_count = 3; 133 133 args.args[0] = 0; 134 134 args.args[1] = hwirq - 32;
+1 -1
drivers/irqchip/irq-gic-v3-its.c
··· 1267 1267 { 1268 1268 struct of_phandle_args args; 1269 1269 1270 - args.np = domain->parent->of_node; 1270 + args.np = irq_domain_get_of_node(domain->parent); 1271 1271 args.args_count = 3; 1272 1272 args.args[0] = GIC_IRQ_TYPE_LPI; 1273 1273 args.args[1] = hwirq;
+1 -1
drivers/irqchip/irq-gic-v3.c
··· 742 742 const u32 *intspec, unsigned int intsize, 743 743 unsigned long *out_hwirq, unsigned int *out_type) 744 744 { 745 - if (d->of_node != controller) 745 + if (irq_domain_get_of_node(d) != controller) 746 746 return -EINVAL; 747 747 if (intsize < 3) 748 748 return -EINVAL;
+1 -1
drivers/irqchip/irq-gic.c
··· 923 923 { 924 924 unsigned long ret = 0; 925 925 926 - if (d->of_node != controller) 926 + if (irq_domain_get_of_node(d) != controller) 927 927 return -EINVAL; 928 928 if (intsize < 3) 929 929 return -EINVAL;
+1 -1
drivers/irqchip/irq-hip04.c
··· 325 325 { 326 326 unsigned long ret = 0; 327 327 328 - if (d->of_node != controller) 328 + if (irq_domain_get_of_node(d) != controller) 329 329 return -EINVAL; 330 330 if (intsize < 3) 331 331 return -EINVAL;
+2 -2
drivers/irqchip/irq-imx-gpcv2.c
··· 158 158 unsigned int *out_type) 159 159 { 160 160 /* Shouldn't happen, really... */ 161 - if (domain->of_node != controller) 161 + if (irq_domain_get_of_node(domain) != controller) 162 162 return -EINVAL; 163 163 164 164 /* Not GIC compliant */ ··· 202 202 } 203 203 204 204 parent_args = *args; 205 - parent_args.np = domain->parent->of_node; 205 + parent_args.np = irq_domain_get_of_node(domain->parent); 206 206 return irq_domain_alloc_irqs_parent(domain, irq, nr_irqs, &parent_args); 207 207 } 208 208
+1 -1
drivers/irqchip/irq-mtk-sysirq.c
··· 106 106 &mtk_sysirq_chip, 107 107 domain->host_data); 108 108 109 - gic_data.np = domain->parent->of_node; 109 + gic_data.np = irq_domain_get_of_node(domain->parent); 110 110 return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, &gic_data); 111 111 } 112 112
+2 -2
drivers/irqchip/irq-s3c24xx.c
··· 311 311 * and one big domain for the dt case where the subintc 312 312 * starts at hwirq number 32. 313 313 */ 314 - offset = (intc->domain->of_node) ? 32 : 0; 314 + offset = irq_domain_get_of_node(intc->domain) ? 32 : 0; 315 315 316 316 chained_irq_enter(chip, desc); 317 317 ··· 342 342 return false; 343 343 344 344 /* non-dt machines use individual domains */ 345 - if (!intc->domain->of_node) 345 + if (!irq_domain_get_of_node(intc->domain)) 346 346 intc_offset = 0; 347 347 348 348 /* We have a problem that the INTOFFSET register does not always
+2 -2
drivers/irqchip/irq-tegra.c
··· 227 227 unsigned long *out_hwirq, 228 228 unsigned int *out_type) 229 229 { 230 - if (domain->of_node != controller) 230 + if (irq_domain_get_of_node(domain) != controller) 231 231 return -EINVAL; /* Shouldn't happen, really... */ 232 232 if (intsize != 3) 233 233 return -EINVAL; /* Not GIC compliant */ ··· 267 267 } 268 268 269 269 parent_args = *args; 270 - parent_args.np = domain->parent->of_node; 270 + parent_args.np = irq_domain_get_of_node(domain->parent); 271 271 return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, &parent_args); 272 272 } 273 273
+3 -2
drivers/irqchip/irq-vf610-mscm-ir.c
··· 142 142 &vf610_mscm_ir_irq_chip, 143 143 domain->host_data); 144 144 145 - gic_data.np = domain->parent->of_node; 145 + gic_data.np = irq_domain_get_of_node(domain->parent); 146 146 147 147 if (mscm_ir_data->is_nvic) { 148 148 gic_data.args_count = 1; ··· 205 205 goto out_unmap; 206 206 } 207 207 208 - if (of_device_is_compatible(domain->parent->of_node, "arm,armv7m-nvic")) 208 + if (of_device_is_compatible(irq_domain_get_of_node(domain->parent), 209 + "arm,armv7m-nvic")) 209 210 mscm_ir_data->is_nvic = true; 210 211 211 212 cpu_pm_register_notifier(&mscm_ir_notifier_block);
+1 -1
drivers/spmi/spmi-pmic-arb.c
··· 657 657 "intspec[0] 0x%1x intspec[1] 0x%02x intspec[2] 0x%02x\n", 658 658 intspec[0], intspec[1], intspec[2]); 659 659 660 - if (d->of_node != controller) 660 + if (irq_domain_get_of_node(d) != controller) 661 661 return -EINVAL; 662 662 if (intsize != 4) 663 663 return -EINVAL;
+21 -9
kernel/irq/irqdomain.c
··· 102 102 103 103 pr_debug("Removed domain %s\n", domain->name); 104 104 105 - of_node_put(domain->of_node); 105 + of_node_put(irq_domain_get_of_node(domain)); 106 106 kfree(domain); 107 107 } 108 108 EXPORT_SYMBOL_GPL(irq_domain_remove); ··· 208 208 */ 209 209 mutex_lock(&irq_domain_mutex); 210 210 list_for_each_entry(h, &irq_domain_list, link) { 211 + struct device_node *of_node; 212 + of_node = irq_domain_get_of_node(h); 211 213 if (h->ops->match) 212 214 rc = h->ops->match(h, node, bus_token); 213 215 else 214 - rc = ((h->of_node != NULL) && (h->of_node == node) && 216 + rc = ((of_node != NULL) && (of_node == node) && 215 217 ((bus_token == DOMAIN_BUS_ANY) || 216 218 (h->bus_token == bus_token))); 217 219 ··· 338 336 void irq_domain_associate_many(struct irq_domain *domain, unsigned int irq_base, 339 337 irq_hw_number_t hwirq_base, int count) 340 338 { 339 + struct device_node *of_node; 341 340 int i; 342 341 342 + of_node = irq_domain_get_of_node(domain); 343 343 pr_debug("%s(%s, irqbase=%i, hwbase=%i, count=%i)\n", __func__, 344 - of_node_full_name(domain->of_node), irq_base, (int)hwirq_base, count); 344 + of_node_full_name(of_node), irq_base, (int)hwirq_base, count); 345 345 346 346 for (i = 0; i < count; i++) { 347 347 irq_domain_associate(domain, irq_base + i, hwirq_base + i); ··· 363 359 */ 364 360 unsigned int irq_create_direct_mapping(struct irq_domain *domain) 365 361 { 362 + struct device_node *of_node; 366 363 unsigned int virq; 367 364 368 365 if (domain == NULL) 369 366 domain = irq_default_domain; 370 367 371 - virq = irq_alloc_desc_from(1, of_node_to_nid(domain->of_node)); 368 + of_node = irq_domain_get_of_node(domain); 369 + virq = irq_alloc_desc_from(1, of_node_to_nid(of_node)); 372 370 if (!virq) { 373 371 pr_debug("create_direct virq allocation failed\n"); 374 372 return 0; ··· 405 399 unsigned int irq_create_mapping(struct irq_domain *domain, 406 400 irq_hw_number_t hwirq) 407 401 { 402 + struct device_node *of_node; 408 403 int virq; 409 404 410 405 pr_debug("irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq); ··· 419 412 } 420 413 pr_debug("-> using domain @%p\n", domain); 421 414 415 + of_node = irq_domain_get_of_node(domain); 416 + 422 417 /* Check if mapping already exists */ 423 418 virq = irq_find_mapping(domain, hwirq); 424 419 if (virq) { ··· 429 420 } 430 421 431 422 /* Allocate a virtual interrupt number */ 432 - virq = irq_domain_alloc_descs(-1, 1, hwirq, 433 - of_node_to_nid(domain->of_node)); 423 + virq = irq_domain_alloc_descs(-1, 1, hwirq, of_node_to_nid(of_node)); 434 424 if (virq <= 0) { 435 425 pr_debug("-> virq allocation failed\n"); 436 426 return 0; ··· 441 433 } 442 434 443 435 pr_debug("irq %lu on domain %s mapped to virtual irq %u\n", 444 - hwirq, of_node_full_name(domain->of_node), virq); 436 + hwirq, of_node_full_name(of_node), virq); 445 437 446 438 return virq; 447 439 } ··· 468 460 int irq_create_strict_mappings(struct irq_domain *domain, unsigned int irq_base, 469 461 irq_hw_number_t hwirq_base, int count) 470 462 { 463 + struct device_node *of_node; 471 464 int ret; 472 465 466 + of_node = irq_domain_get_of_node(domain); 473 467 ret = irq_alloc_descs(irq_base, irq_base, count, 474 - of_node_to_nid(domain->of_node)); 468 + of_node_to_nid(of_node)); 475 469 if (unlikely(ret < 0)) 476 470 return ret; 477 471 ··· 600 590 "name", "mapped", "linear-max", "direct-max", "devtree-node"); 601 591 mutex_lock(&irq_domain_mutex); 602 592 list_for_each_entry(domain, &irq_domain_list, link) { 593 + struct device_node *of_node; 603 594 int count = 0; 595 + of_node = irq_domain_get_of_node(domain); 604 596 radix_tree_for_each_slot(slot, &domain->revmap_tree, &iter, 0) 605 597 count++; 606 598 seq_printf(m, "%c%-16s %6u %10u %10u %s\n", 607 599 domain == irq_default_domain ? '*' : ' ', domain->name, 608 600 domain->revmap_size + count, domain->revmap_size, 609 601 domain->revmap_direct_max_irq, 610 - domain->of_node ? of_node_full_name(domain->of_node) : ""); 602 + of_node ? of_node_full_name(of_node) : ""); 611 603 } 612 604 mutex_unlock(&irq_domain_mutex); 613 605