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

devicetree: add helper inline for retrieving a node's full name

The pattern (np ? np->full_name : "<none>") is rather common in the
kernel, but can also make for quite long lines. This patch adds a new
inline function, of_node_full_name() so that the test for a valid node
pointer doesn't need to be open coded at all call sites.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>

authored by

Grant Likely and committed by
Rob Herring
74a7f084 1af4c7f1

+25 -21
+2 -4
arch/microblaze/pci/pci-common.c
··· 249 249 } else { 250 250 pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n", 251 251 oirq.size, oirq.specifier[0], oirq.specifier[1], 252 - oirq.controller ? oirq.controller->full_name : 253 - "<default>"); 252 + of_node_full_name(oirq.controller)); 254 253 255 254 virq = irq_create_of_mapping(oirq.controller, oirq.specifier, 256 255 oirq.size); ··· 1492 1493 struct pci_bus *bus; 1493 1494 struct device_node *node = hose->dn; 1494 1495 1495 - pr_debug("PCI: Scanning PHB %s\n", 1496 - node ? node->full_name : "<NO NAME>"); 1496 + pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node)); 1497 1497 1498 1498 pcibios_setup_phb_resources(hose, &resources); 1499 1499
+2 -4
arch/powerpc/kernel/pci-common.c
··· 248 248 } else { 249 249 pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n", 250 250 oirq.size, oirq.specifier[0], oirq.specifier[1], 251 - oirq.controller ? oirq.controller->full_name : 252 - "<default>"); 251 + of_node_full_name(oirq.controller)); 253 252 254 253 virq = irq_create_of_mapping(oirq.controller, oirq.specifier, 255 254 oirq.size); ··· 1627 1628 struct device_node *node = hose->dn; 1628 1629 int mode; 1629 1630 1630 - pr_debug("PCI: Scanning PHB %s\n", 1631 - node ? node->full_name : "<NO NAME>"); 1631 + pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node)); 1632 1632 1633 1633 /* Get some IO space for the new PHB */ 1634 1634 pcibios_setup_phb_io_space(hose);
+2 -3
arch/powerpc/kernel/vio.c
··· 1296 1296 struct iommu_table *tbl = get_iommu_table_base(dev); 1297 1297 1298 1298 if (tbl) 1299 - iommu_free_table(tbl, dev->of_node ? 1300 - dev->of_node->full_name : dev_name(dev)); 1299 + iommu_free_table(tbl, of_node_full_name(dev->of_node)); 1301 1300 of_node_put(dev->of_node); 1302 1301 kfree(to_vio_dev(dev)); 1303 1302 } ··· 1508 1509 { 1509 1510 struct device_node *of_node = dev->of_node; 1510 1511 1511 - return sprintf(buf, "%s\n", of_node ? of_node->full_name : "none"); 1512 + return sprintf(buf, "%s\n", of_node_full_name(of_node)); 1512 1513 } 1513 1514 1514 1515 static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
+1 -2
arch/powerpc/platforms/cell/iommu.c
··· 552 552 iommu = cell_iommu_for_node(dev_to_node(dev)); 553 553 if (iommu == NULL || list_empty(&iommu->windows)) { 554 554 printk(KERN_ERR "iommu: missing iommu for %s (node %d)\n", 555 - dev->of_node ? dev->of_node->full_name : "?", 556 - dev_to_node(dev)); 555 + of_node_full_name(dev->of_node), dev_to_node(dev)); 557 556 return NULL; 558 557 } 559 558 window = list_entry(iommu->windows.next, struct iommu_window, list);
+1 -1
arch/powerpc/platforms/pseries/iommu.c
··· 1051 1051 if (!pdn || !PCI_DN(pdn)) { 1052 1052 printk(KERN_WARNING "pci_dma_dev_setup_pSeriesLP: " 1053 1053 "no DMA window found for pci dev=%s dn=%s\n", 1054 - pci_name(dev), dn? dn->full_name : "<null>"); 1054 + pci_name(dev), of_node_full_name(dn)); 1055 1055 return; 1056 1056 } 1057 1057 pr_debug(" parent is %s\n", pdn->full_name);
+1 -1
arch/sparc/kernel/of_device_64.c
··· 580 580 printk("%s: Apply [%s:%x] imap --> [%s:%x]\n", 581 581 op->dev.of_node->full_name, 582 582 pp->full_name, this_orig_irq, 583 - (iret ? iret->full_name : "NULL"), irq); 583 + of_node_full_name(iret), irq); 584 584 585 585 if (!iret) 586 586 break;
+1 -1
drivers/of/base.c
··· 1173 1173 ap->stem[stem_len] = 0; 1174 1174 list_add_tail(&ap->link, &aliases_lookup); 1175 1175 pr_debug("adding DT alias:%s: stem=%s id=%i node=%s\n", 1176 - ap->alias, ap->stem, ap->id, np ? np->full_name : NULL); 1176 + ap->alias, ap->stem, ap->id, of_node_full_name(np)); 1177 1177 } 1178 1178 1179 1179 /**
+1 -1
drivers/of/irq.c
··· 255 255 256 256 skiplevel: 257 257 /* Iterate again with new parent */ 258 - pr_debug(" -> new parent: %s\n", newpar ? newpar->full_name : "<>"); 258 + pr_debug(" -> new parent: %s\n", of_node_full_name(newpar)); 259 259 of_node_put(ipar); 260 260 ipar = newpar; 261 261 newpar = NULL;
+10
include/linux/of.h
··· 163 163 #define of_node_to_nid of_node_to_nid 164 164 #endif 165 165 166 + static inline const char* of_node_full_name(struct device_node *np) 167 + { 168 + return np ? np->full_name : "<no-node>"; 169 + } 170 + 166 171 extern struct device_node *of_find_node_by_name(struct device_node *from, 167 172 const char *name); 168 173 #define for_each_node_by_name(dn, name) \ ··· 307 302 s = of_prop_next_string(prop, s)) 308 303 309 304 #else /* CONFIG_OF */ 305 + 306 + static inline const char* of_node_full_name(struct device_node *np) 307 + { 308 + return "<no-node>"; 309 + } 310 310 311 311 static inline bool of_have_populated_dt(void) 312 312 {
+4 -4
kernel/irq/irqdomain.c
··· 448 448 } 449 449 450 450 pr_debug("irq %lu on domain %s mapped to virtual irq %u\n", 451 - hwirq, domain->of_node ? domain->of_node->full_name : "null", virq); 451 + hwirq, of_node_full_name(domain->of_node), virq); 452 452 453 453 return virq; 454 454 } ··· 477 477 return intspec[0]; 478 478 #endif 479 479 pr_warning("no irq domain found for %s !\n", 480 - controller->full_name); 480 + of_node_full_name(controller)); 481 481 return 0; 482 482 } 483 483 ··· 725 725 data = irq_desc_get_chip_data(desc); 726 726 seq_printf(m, data ? "0x%p " : " %p ", data); 727 727 728 - if (desc->irq_data.domain && desc->irq_data.domain->of_node) 729 - p = desc->irq_data.domain->of_node->full_name; 728 + if (desc->irq_data.domain) 729 + p = of_node_full_name(desc->irq_data.domain->of_node); 730 730 else 731 731 p = none; 732 732 seq_printf(m, "%s\n", p);