diff options
| author | Grant Likely <grant.likely@secretlab.ca> | 2012-06-04 01:04:33 -0400 |
|---|---|---|
| committer | Grant Likely <grant.likely@secretlab.ca> | 2012-06-15 13:44:03 -0400 |
| commit | efd68e7254503f3207805f674a1ea1d743f5dfe2 (patch) | |
| tree | d5d0dc0b2b6fdf41ff57eb4b21501fbfe3a56d64 | |
| parent | cfaf025112d3856637ff34a767ef785ef5cf2ca9 (diff) | |
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>
| -rw-r--r-- | arch/microblaze/pci/pci-common.c | 6 | ||||
| -rw-r--r-- | arch/powerpc/kernel/pci-common.c | 6 | ||||
| -rw-r--r-- | arch/powerpc/kernel/vio.c | 5 | ||||
| -rw-r--r-- | arch/powerpc/platforms/cell/iommu.c | 3 | ||||
| -rw-r--r-- | arch/powerpc/platforms/pseries/iommu.c | 2 | ||||
| -rw-r--r-- | arch/sparc/kernel/of_device_64.c | 2 | ||||
| -rw-r--r-- | drivers/of/base.c | 2 | ||||
| -rw-r--r-- | drivers/of/irq.c | 2 | ||||
| -rw-r--r-- | include/linux/of.h | 10 | ||||
| -rw-r--r-- | kernel/irq/irqdomain.c | 8 |
10 files changed, 25 insertions, 21 deletions
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c index ed22bfc5db14..ca8f6e769960 100644 --- a/arch/microblaze/pci/pci-common.c +++ b/arch/microblaze/pci/pci-common.c | |||
| @@ -249,8 +249,7 @@ int pci_read_irq_line(struct pci_dev *pci_dev) | |||
| 249 | } else { | 249 | } else { |
| 250 | pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n", | 250 | pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n", |
| 251 | oirq.size, oirq.specifier[0], oirq.specifier[1], | 251 | oirq.size, oirq.specifier[0], oirq.specifier[1], |
| 252 | oirq.controller ? oirq.controller->full_name : | 252 | of_node_full_name(oirq.controller)); |
| 253 | "<default>"); | ||
| 254 | 253 | ||
| 255 | virq = irq_create_of_mapping(oirq.controller, oirq.specifier, | 254 | virq = irq_create_of_mapping(oirq.controller, oirq.specifier, |
| 256 | oirq.size); | 255 | oirq.size); |
| @@ -1493,8 +1492,7 @@ static void __devinit pcibios_scan_phb(struct pci_controller *hose) | |||
| 1493 | struct pci_bus *bus; | 1492 | struct pci_bus *bus; |
| 1494 | struct device_node *node = hose->dn; | 1493 | struct device_node *node = hose->dn; |
| 1495 | 1494 | ||
| 1496 | pr_debug("PCI: Scanning PHB %s\n", | 1495 | pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node)); |
| 1497 | node ? node->full_name : "<NO NAME>"); | ||
| 1498 | 1496 | ||
| 1499 | pcibios_setup_phb_resources(hose, &resources); | 1497 | pcibios_setup_phb_resources(hose, &resources); |
| 1500 | 1498 | ||
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 8e78e93c8185..886c254fd565 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c | |||
| @@ -248,8 +248,7 @@ static int pci_read_irq_line(struct pci_dev *pci_dev) | |||
| 248 | } else { | 248 | } else { |
| 249 | pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n", | 249 | pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n", |
| 250 | oirq.size, oirq.specifier[0], oirq.specifier[1], | 250 | oirq.size, oirq.specifier[0], oirq.specifier[1], |
| 251 | oirq.controller ? oirq.controller->full_name : | 251 | of_node_full_name(oirq.controller)); |
| 252 | "<default>"); | ||
| 253 | 252 | ||
| 254 | virq = irq_create_of_mapping(oirq.controller, oirq.specifier, | 253 | virq = irq_create_of_mapping(oirq.controller, oirq.specifier, |
| 255 | oirq.size); | 254 | oirq.size); |
| @@ -1628,8 +1627,7 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose) | |||
| 1628 | struct device_node *node = hose->dn; | 1627 | struct device_node *node = hose->dn; |
| 1629 | int mode; | 1628 | int mode; |
| 1630 | 1629 | ||
| 1631 | pr_debug("PCI: Scanning PHB %s\n", | 1630 | pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node)); |
| 1632 | node ? node->full_name : "<NO NAME>"); | ||
| 1633 | 1631 | ||
| 1634 | /* Get some IO space for the new PHB */ | 1632 | /* Get some IO space for the new PHB */ |
| 1635 | pcibios_setup_phb_io_space(hose); | 1633 | pcibios_setup_phb_io_space(hose); |
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c index cb87301ccd55..63f72ede4341 100644 --- a/arch/powerpc/kernel/vio.c +++ b/arch/powerpc/kernel/vio.c | |||
| @@ -1296,8 +1296,7 @@ static void __devinit vio_dev_release(struct device *dev) | |||
| 1296 | struct iommu_table *tbl = get_iommu_table_base(dev); | 1296 | struct iommu_table *tbl = get_iommu_table_base(dev); |
| 1297 | 1297 | ||
| 1298 | if (tbl) | 1298 | if (tbl) |
| 1299 | iommu_free_table(tbl, dev->of_node ? | 1299 | iommu_free_table(tbl, of_node_full_name(dev->of_node)); |
| 1300 | dev->of_node->full_name : dev_name(dev)); | ||
| 1301 | of_node_put(dev->of_node); | 1300 | of_node_put(dev->of_node); |
| 1302 | kfree(to_vio_dev(dev)); | 1301 | kfree(to_vio_dev(dev)); |
| 1303 | } | 1302 | } |
| @@ -1509,7 +1508,7 @@ static ssize_t devspec_show(struct device *dev, | |||
| 1509 | { | 1508 | { |
| 1510 | struct device_node *of_node = dev->of_node; | 1509 | struct device_node *of_node = dev->of_node; |
| 1511 | 1510 | ||
| 1512 | return sprintf(buf, "%s\n", of_node ? of_node->full_name : "none"); | 1511 | return sprintf(buf, "%s\n", of_node_full_name(of_node)); |
| 1513 | } | 1512 | } |
| 1514 | 1513 | ||
| 1515 | static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, | 1514 | static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, |
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c index b9f509a34c01..b6732004c882 100644 --- a/arch/powerpc/platforms/cell/iommu.c +++ b/arch/powerpc/platforms/cell/iommu.c | |||
| @@ -552,8 +552,7 @@ static struct iommu_table *cell_get_iommu_table(struct device *dev) | |||
| 552 | iommu = cell_iommu_for_node(dev_to_node(dev)); | 552 | iommu = cell_iommu_for_node(dev_to_node(dev)); |
| 553 | if (iommu == NULL || list_empty(&iommu->windows)) { | 553 | if (iommu == NULL || list_empty(&iommu->windows)) { |
| 554 | printk(KERN_ERR "iommu: missing iommu for %s (node %d)\n", | 554 | printk(KERN_ERR "iommu: missing iommu for %s (node %d)\n", |
| 555 | dev->of_node ? dev->of_node->full_name : "?", | 555 | of_node_full_name(dev->of_node), dev_to_node(dev)); |
| 556 | dev_to_node(dev)); | ||
| 557 | return NULL; | 556 | return NULL; |
| 558 | } | 557 | } |
| 559 | window = list_entry(iommu->windows.next, struct iommu_window, list); | 558 | window = list_entry(iommu->windows.next, struct iommu_window, list); |
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 0915b1ad66ce..aab5fbc924e6 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c | |||
| @@ -1051,7 +1051,7 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev) | |||
| 1051 | if (!pdn || !PCI_DN(pdn)) { | 1051 | if (!pdn || !PCI_DN(pdn)) { |
| 1052 | printk(KERN_WARNING "pci_dma_dev_setup_pSeriesLP: " | 1052 | printk(KERN_WARNING "pci_dma_dev_setup_pSeriesLP: " |
| 1053 | "no DMA window found for pci dev=%s dn=%s\n", | 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 | return; | 1055 | return; |
| 1056 | } | 1056 | } |
| 1057 | pr_debug(" parent is %s\n", pdn->full_name); | 1057 | pr_debug(" parent is %s\n", pdn->full_name); |
diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c index 7a3be6f6737a..7bbdc26d9512 100644 --- a/arch/sparc/kernel/of_device_64.c +++ b/arch/sparc/kernel/of_device_64.c | |||
| @@ -580,7 +580,7 @@ static unsigned int __init build_one_device_irq(struct platform_device *op, | |||
| 580 | printk("%s: Apply [%s:%x] imap --> [%s:%x]\n", | 580 | printk("%s: Apply [%s:%x] imap --> [%s:%x]\n", |
| 581 | op->dev.of_node->full_name, | 581 | op->dev.of_node->full_name, |
| 582 | pp->full_name, this_orig_irq, | 582 | pp->full_name, this_orig_irq, |
| 583 | (iret ? iret->full_name : "NULL"), irq); | 583 | of_node_full_name(iret), irq); |
| 584 | 584 | ||
| 585 | if (!iret) | 585 | if (!iret) |
| 586 | break; | 586 | break; |
diff --git a/drivers/of/base.c b/drivers/of/base.c index d9bfd49b1935..9282d4cc1091 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
| @@ -1173,7 +1173,7 @@ static void of_alias_add(struct alias_prop *ap, struct device_node *np, | |||
| 1173 | ap->stem[stem_len] = 0; | 1173 | ap->stem[stem_len] = 0; |
| 1174 | list_add_tail(&ap->link, &aliases_lookup); | 1174 | list_add_tail(&ap->link, &aliases_lookup); |
| 1175 | pr_debug("adding DT alias:%s: stem=%s id=%i node=%s\n", | 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 | /** |
diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 9cf00602f566..ff8ab7b27373 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c | |||
| @@ -255,7 +255,7 @@ int of_irq_map_raw(struct device_node *parent, const __be32 *intspec, | |||
| 255 | 255 | ||
| 256 | skiplevel: | 256 | skiplevel: |
| 257 | /* Iterate again with new parent */ | 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 | of_node_put(ipar); | 259 | of_node_put(ipar); |
| 260 | ipar = newpar; | 260 | ipar = newpar; |
| 261 | newpar = NULL; | 261 | newpar = NULL; |
diff --git a/include/linux/of.h b/include/linux/of.h index 2ec1083af7ff..1012377cae92 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
| @@ -163,6 +163,11 @@ static inline int of_node_to_nid(struct device_node *np) { return -1; } | |||
| 163 | #define of_node_to_nid of_node_to_nid | 163 | #define of_node_to_nid of_node_to_nid |
| 164 | #endif | 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 | extern struct device_node *of_find_node_by_name(struct device_node *from, | 171 | extern struct device_node *of_find_node_by_name(struct device_node *from, |
| 167 | const char *name); | 172 | const char *name); |
| 168 | #define for_each_node_by_name(dn, name) \ | 173 | #define for_each_node_by_name(dn, name) \ |
| @@ -303,6 +308,11 @@ const char *of_prop_next_string(struct property *prop, const char *cur); | |||
| 303 | 308 | ||
| 304 | #else /* CONFIG_OF */ | 309 | #else /* CONFIG_OF */ |
| 305 | 310 | ||
| 311 | static inline const char* of_node_full_name(struct device_node *np) | ||
| 312 | { | ||
| 313 | return "<no-node>"; | ||
| 314 | } | ||
| 315 | |||
| 306 | static inline bool of_have_populated_dt(void) | 316 | static inline bool of_have_populated_dt(void) |
| 307 | { | 317 | { |
| 308 | return false; | 318 | return false; |
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 41c1564103f1..38c5eb839c92 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c | |||
| @@ -448,7 +448,7 @@ unsigned int irq_create_mapping(struct irq_domain *domain, | |||
| 448 | } | 448 | } |
| 449 | 449 | ||
| 450 | pr_debug("irq %lu on domain %s mapped to virtual irq %u\n", | 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 | return virq; | 453 | return virq; |
| 454 | } | 454 | } |
| @@ -477,7 +477,7 @@ unsigned int irq_create_of_mapping(struct device_node *controller, | |||
| 477 | return intspec[0]; | 477 | return intspec[0]; |
| 478 | #endif | 478 | #endif |
| 479 | pr_warning("no irq domain found for %s !\n", | 479 | pr_warning("no irq domain found for %s !\n", |
| 480 | controller->full_name); | 480 | of_node_full_name(controller)); |
| 481 | return 0; | 481 | return 0; |
| 482 | } | 482 | } |
| 483 | 483 | ||
| @@ -725,8 +725,8 @@ static int virq_debug_show(struct seq_file *m, void *private) | |||
| 725 | data = irq_desc_get_chip_data(desc); | 725 | data = irq_desc_get_chip_data(desc); |
| 726 | seq_printf(m, data ? "0x%p " : " %p ", data); | 726 | seq_printf(m, data ? "0x%p " : " %p ", data); |
| 727 | 727 | ||
| 728 | if (desc->irq_data.domain && desc->irq_data.domain->of_node) | 728 | if (desc->irq_data.domain) |
| 729 | p = desc->irq_data.domain->of_node->full_name; | 729 | p = of_node_full_name(desc->irq_data.domain->of_node); |
| 730 | else | 730 | else |
| 731 | p = none; | 731 | p = none; |
| 732 | seq_printf(m, "%s\n", p); | 732 | seq_printf(m, "%s\n", p); |
