Commit 74a7f084 authored by Grant Likely's avatar Grant Likely Committed by Rob Herring

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: default avatarGrant 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: default avatarRob Herring <rob.herring@calxeda.com>
parent 1af4c7f1
...@@ -249,8 +249,7 @@ int pci_read_irq_line(struct pci_dev *pci_dev) ...@@ -249,8 +249,7 @@ int pci_read_irq_line(struct pci_dev *pci_dev)
} else { } else {
pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n", pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n",
oirq.size, oirq.specifier[0], oirq.specifier[1], oirq.size, oirq.specifier[0], oirq.specifier[1],
oirq.controller ? oirq.controller->full_name : of_node_full_name(oirq.controller));
"<default>");
virq = irq_create_of_mapping(oirq.controller, oirq.specifier, virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
oirq.size); oirq.size);
...@@ -1493,8 +1492,7 @@ static void __devinit pcibios_scan_phb(struct pci_controller *hose) ...@@ -1493,8 +1492,7 @@ static void __devinit pcibios_scan_phb(struct pci_controller *hose)
struct pci_bus *bus; struct pci_bus *bus;
struct device_node *node = hose->dn; struct device_node *node = hose->dn;
pr_debug("PCI: Scanning PHB %s\n", pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node));
node ? node->full_name : "<NO NAME>");
pcibios_setup_phb_resources(hose, &resources); pcibios_setup_phb_resources(hose, &resources);
......
...@@ -248,8 +248,7 @@ static int pci_read_irq_line(struct pci_dev *pci_dev) ...@@ -248,8 +248,7 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)
} else { } else {
pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n", pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n",
oirq.size, oirq.specifier[0], oirq.specifier[1], oirq.size, oirq.specifier[0], oirq.specifier[1],
oirq.controller ? oirq.controller->full_name : of_node_full_name(oirq.controller));
"<default>");
virq = irq_create_of_mapping(oirq.controller, oirq.specifier, virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
oirq.size); oirq.size);
...@@ -1628,8 +1627,7 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose) ...@@ -1628,8 +1627,7 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose)
struct device_node *node = hose->dn; struct device_node *node = hose->dn;
int mode; int mode;
pr_debug("PCI: Scanning PHB %s\n", pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node));
node ? node->full_name : "<NO NAME>");
/* Get some IO space for the new PHB */ /* Get some IO space for the new PHB */
pcibios_setup_phb_io_space(hose); pcibios_setup_phb_io_space(hose);
......
...@@ -1296,8 +1296,7 @@ static void __devinit vio_dev_release(struct device *dev) ...@@ -1296,8 +1296,7 @@ static void __devinit vio_dev_release(struct device *dev)
struct iommu_table *tbl = get_iommu_table_base(dev); struct iommu_table *tbl = get_iommu_table_base(dev);
if (tbl) if (tbl)
iommu_free_table(tbl, dev->of_node ? iommu_free_table(tbl, of_node_full_name(dev->of_node));
dev->of_node->full_name : dev_name(dev));
of_node_put(dev->of_node); of_node_put(dev->of_node);
kfree(to_vio_dev(dev)); kfree(to_vio_dev(dev));
} }
...@@ -1509,7 +1508,7 @@ static ssize_t devspec_show(struct device *dev, ...@@ -1509,7 +1508,7 @@ static ssize_t devspec_show(struct device *dev,
{ {
struct device_node *of_node = dev->of_node; struct device_node *of_node = dev->of_node;
return sprintf(buf, "%s\n", of_node ? of_node->full_name : "none"); return sprintf(buf, "%s\n", of_node_full_name(of_node));
} }
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
......
...@@ -552,8 +552,7 @@ static struct iommu_table *cell_get_iommu_table(struct device *dev) ...@@ -552,8 +552,7 @@ static struct iommu_table *cell_get_iommu_table(struct device *dev)
iommu = cell_iommu_for_node(dev_to_node(dev)); iommu = cell_iommu_for_node(dev_to_node(dev));
if (iommu == NULL || list_empty(&iommu->windows)) { if (iommu == NULL || list_empty(&iommu->windows)) {
printk(KERN_ERR "iommu: missing iommu for %s (node %d)\n", printk(KERN_ERR "iommu: missing iommu for %s (node %d)\n",
dev->of_node ? dev->of_node->full_name : "?", of_node_full_name(dev->of_node), dev_to_node(dev));
dev_to_node(dev));
return NULL; return NULL;
} }
window = list_entry(iommu->windows.next, struct iommu_window, list); window = list_entry(iommu->windows.next, struct iommu_window, list);
......
...@@ -1051,7 +1051,7 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev) ...@@ -1051,7 +1051,7 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
if (!pdn || !PCI_DN(pdn)) { if (!pdn || !PCI_DN(pdn)) {
printk(KERN_WARNING "pci_dma_dev_setup_pSeriesLP: " printk(KERN_WARNING "pci_dma_dev_setup_pSeriesLP: "
"no DMA window found for pci dev=%s dn=%s\n", "no DMA window found for pci dev=%s dn=%s\n",
pci_name(dev), dn? dn->full_name : "<null>"); pci_name(dev), of_node_full_name(dn));
return; return;
} }
pr_debug(" parent is %s\n", pdn->full_name); pr_debug(" parent is %s\n", pdn->full_name);
......
...@@ -580,7 +580,7 @@ static unsigned int __init build_one_device_irq(struct platform_device *op, ...@@ -580,7 +580,7 @@ static unsigned int __init build_one_device_irq(struct platform_device *op,
printk("%s: Apply [%s:%x] imap --> [%s:%x]\n", printk("%s: Apply [%s:%x] imap --> [%s:%x]\n",
op->dev.of_node->full_name, op->dev.of_node->full_name,
pp->full_name, this_orig_irq, pp->full_name, this_orig_irq,
(iret ? iret->full_name : "NULL"), irq); of_node_full_name(iret), irq);
if (!iret) if (!iret)
break; break;
......
...@@ -1173,7 +1173,7 @@ static void of_alias_add(struct alias_prop *ap, struct device_node *np, ...@@ -1173,7 +1173,7 @@ static void of_alias_add(struct alias_prop *ap, struct device_node *np,
ap->stem[stem_len] = 0; ap->stem[stem_len] = 0;
list_add_tail(&ap->link, &aliases_lookup); list_add_tail(&ap->link, &aliases_lookup);
pr_debug("adding DT alias:%s: stem=%s id=%i node=%s\n", pr_debug("adding DT alias:%s: stem=%s id=%i node=%s\n",
ap->alias, ap->stem, ap->id, np ? np->full_name : NULL); ap->alias, ap->stem, ap->id, of_node_full_name(np));
} }
/** /**
......
...@@ -255,7 +255,7 @@ int of_irq_map_raw(struct device_node *parent, const __be32 *intspec, ...@@ -255,7 +255,7 @@ int of_irq_map_raw(struct device_node *parent, const __be32 *intspec,
skiplevel: skiplevel:
/* Iterate again with new parent */ /* Iterate again with new parent */
pr_debug(" -> new parent: %s\n", newpar ? newpar->full_name : "<>"); pr_debug(" -> new parent: %s\n", of_node_full_name(newpar));
of_node_put(ipar); of_node_put(ipar);
ipar = newpar; ipar = newpar;
newpar = NULL; newpar = NULL;
......
...@@ -163,6 +163,11 @@ static inline int of_node_to_nid(struct device_node *np) { return -1; } ...@@ -163,6 +163,11 @@ static inline int of_node_to_nid(struct device_node *np) { return -1; }
#define of_node_to_nid of_node_to_nid #define of_node_to_nid of_node_to_nid
#endif #endif
static inline const char* of_node_full_name(struct device_node *np)
{
return np ? np->full_name : "<no-node>";
}
extern struct device_node *of_find_node_by_name(struct device_node *from, extern struct device_node *of_find_node_by_name(struct device_node *from,
const char *name); const char *name);
#define for_each_node_by_name(dn, name) \ #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,6 +308,11 @@ const char *of_prop_next_string(struct property *prop, const char *cur);
#else /* CONFIG_OF */ #else /* CONFIG_OF */
static inline const char* of_node_full_name(struct device_node *np)
{
return "<no-node>";
}
static inline bool of_have_populated_dt(void) static inline bool of_have_populated_dt(void)
{ {
return false; return false;
......
...@@ -448,7 +448,7 @@ unsigned int irq_create_mapping(struct irq_domain *domain, ...@@ -448,7 +448,7 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
} }
pr_debug("irq %lu on domain %s mapped to virtual irq %u\n", pr_debug("irq %lu on domain %s mapped to virtual irq %u\n",
hwirq, domain->of_node ? domain->of_node->full_name : "null", virq); hwirq, of_node_full_name(domain->of_node), virq);
return virq; return virq;
} }
...@@ -477,7 +477,7 @@ unsigned int irq_create_of_mapping(struct device_node *controller, ...@@ -477,7 +477,7 @@ unsigned int irq_create_of_mapping(struct device_node *controller,
return intspec[0]; return intspec[0];
#endif #endif
pr_warning("no irq domain found for %s !\n", pr_warning("no irq domain found for %s !\n",
controller->full_name); of_node_full_name(controller));
return 0; return 0;
} }
...@@ -725,8 +725,8 @@ static int virq_debug_show(struct seq_file *m, void *private) ...@@ -725,8 +725,8 @@ static int virq_debug_show(struct seq_file *m, void *private)
data = irq_desc_get_chip_data(desc); data = irq_desc_get_chip_data(desc);
seq_printf(m, data ? "0x%p " : " %p ", data); seq_printf(m, data ? "0x%p " : " %p ", data);
if (desc->irq_data.domain && desc->irq_data.domain->of_node) if (desc->irq_data.domain)
p = desc->irq_data.domain->of_node->full_name; p = of_node_full_name(desc->irq_data.domain->of_node);
else else
p = none; p = none;
seq_printf(m, "%s\n", p); seq_printf(m, "%s\n", p);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment