Skip to content

Commit a613b26

Browse files
committed
of: Convert to using %pOFn instead of device_node.name
In preparation to remove the node name pointer from struct device_node, convert printf users to use the %pOFn format specifier. Reviewed-by: Frank Rowand <frank.rowand@sony.com> Cc: Andrew Lunn <andrew@lunn.ch> Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: netdev@vger.kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
1 parent 6901378 commit a613b26

File tree

6 files changed

+23
-22
lines changed

6 files changed

+23
-22
lines changed

drivers/of/device.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ static ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len
219219
return -ENODEV;
220220

221221
/* Name & Type */
222-
csize = snprintf(str, len, "of:N%sT%s", dev->of_node->name,
222+
/* %p eats all alphanum characters, so %c must be used here */
223+
csize = snprintf(str, len, "of:N%pOFn%c%s", dev->of_node, 'T',
223224
dev->of_node->type);
224225
tsize = csize;
225226
len -= csize;
@@ -298,7 +299,7 @@ void of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
298299
if ((!dev) || (!dev->of_node))
299300
return;
300301

301-
add_uevent_var(env, "OF_NAME=%s", dev->of_node->name);
302+
add_uevent_var(env, "OF_NAME=%pOFn", dev->of_node);
302303
add_uevent_var(env, "OF_FULLNAME=%pOF", dev->of_node);
303304
if (dev->of_node->type && strcmp("<NULL>", dev->of_node->type) != 0)
304305
add_uevent_var(env, "OF_TYPE=%s", dev->of_node->type);

drivers/of/of_mdio.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
9797
return rc;
9898
}
9999

100-
dev_dbg(&mdio->dev, "registered phy %s at address %i\n",
101-
child->name, addr);
100+
dev_dbg(&mdio->dev, "registered phy %pOFn at address %i\n",
101+
child, addr);
102102
return 0;
103103
}
104104

@@ -127,8 +127,8 @@ static int of_mdiobus_register_device(struct mii_bus *mdio,
127127
return rc;
128128
}
129129

130-
dev_dbg(&mdio->dev, "registered mdio device %s at address %i\n",
131-
child->name, addr);
130+
dev_dbg(&mdio->dev, "registered mdio device %pOFn at address %i\n",
131+
child, addr);
132132
return 0;
133133
}
134134

@@ -263,8 +263,8 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
263263
continue;
264264

265265
/* be noisy to encourage people to set reg property */
266-
dev_info(&mdio->dev, "scan phy %s at address %i\n",
267-
child->name, addr);
266+
dev_info(&mdio->dev, "scan phy %pOFn at address %i\n",
267+
child, addr);
268268

269269
if (of_mdiobus_child_is_phy(child)) {
270270
rc = of_mdiobus_register_phy(mdio, child, addr);

drivers/of/of_numa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ int of_node_to_nid(struct device_node *device)
163163
np = of_get_next_parent(np);
164164
}
165165
if (np && r)
166-
pr_warn("Invalid \"numa-node-id\" property in node %s\n",
167-
np->name);
166+
pr_warn("Invalid \"numa-node-id\" property in node %pOFn\n",
167+
np);
168168
of_node_put(np);
169169

170170
/*

drivers/of/overlay.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ static int build_changeset_next_level(struct overlay_changeset *ovcs,
425425
for_each_child_of_node(overlay_node, child) {
426426
ret = add_changeset_node(ovcs, target_node, child);
427427
if (ret) {
428-
pr_debug("Failed to apply node @%pOF/%s, err=%d\n",
429-
target_node, child->name, ret);
428+
pr_debug("Failed to apply node @%pOF/%pOFn, err=%d\n",
429+
target_node, child, ret);
430430
of_node_put(child);
431431
return ret;
432432
}

drivers/of/platform.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ static void of_device_make_bus_id(struct device *dev)
9191
*/
9292
reg = of_get_property(node, "reg", NULL);
9393
if (reg && (addr = of_translate_address(node, reg)) != OF_BAD_ADDR) {
94-
dev_set_name(dev, dev_name(dev) ? "%llx.%s:%s" : "%llx.%s",
95-
(unsigned long long)addr, node->name,
94+
dev_set_name(dev, dev_name(dev) ? "%llx.%pOFn:%s" : "%llx.%pOFn",
95+
(unsigned long long)addr, node,
9696
dev_name(dev));
9797
return;
9898
}
@@ -142,8 +142,8 @@ struct platform_device *of_device_alloc(struct device_node *np,
142142
WARN_ON(rc);
143143
}
144144
if (of_irq_to_resource_table(np, res, num_irq) != num_irq)
145-
pr_debug("not all legacy IRQ resources mapped for %s\n",
146-
np->name);
145+
pr_debug("not all legacy IRQ resources mapped for %pOFn\n",
146+
np);
147147
}
148148

149149
dev->dev.of_node = of_node_get(np);

drivers/of/unittest.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ static int __init of_unittest_check_node_linkage(struct device_node *np)
212212

213213
for_each_child_of_node(np, child) {
214214
if (child->parent != np) {
215-
pr_err("Child node %s links to wrong parent %s\n",
216-
child->name, np->name);
215+
pr_err("Child node %pOFn links to wrong parent %pOFn\n",
216+
child, np);
217217
rc = -EINVAL;
218218
goto put_child;
219219
}
@@ -1040,16 +1040,16 @@ static void __init of_unittest_platform_populate(void)
10401040
for_each_child_of_node(np, child) {
10411041
for_each_child_of_node(child, grandchild)
10421042
unittest(of_find_device_by_node(grandchild),
1043-
"Could not create device for node '%s'\n",
1044-
grandchild->name);
1043+
"Could not create device for node '%pOFn'\n",
1044+
grandchild);
10451045
}
10461046

10471047
of_platform_depopulate(&test_bus->dev);
10481048
for_each_child_of_node(np, child) {
10491049
for_each_child_of_node(child, grandchild)
10501050
unittest(!of_find_device_by_node(grandchild),
1051-
"device didn't get destroyed '%s'\n",
1052-
grandchild->name);
1051+
"device didn't get destroyed '%pOFn'\n",
1052+
grandchild);
10531053
}
10541054

10551055
platform_device_unregister(test_bus);

0 commit comments

Comments
 (0)