summaryrefslogtreecommitdiffstats
path: root/drivers/core
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-07-30 13:40:39 -0600
committerSimon Glass <sjg@chromium.org>2015-08-06 07:44:29 -0600
commitf5c67ea036be174f75cb48b8f91894bc710811dd (patch)
tree15877db8c32f59a6457f89db7f9367210392401f /drivers/core
parentc3e6847bb33c061ce248d0178d8ca8daf1104aef (diff)
downloadblackbird-obmc-uboot-f5c67ea036be174f75cb48b8f91894bc710811dd.tar.gz
blackbird-obmc-uboot-f5c67ea036be174f75cb48b8f91894bc710811dd.zip
dm: core: Add a way to set a device name
Some devices are bound entirely by probing and do not have the benefit of a device tree to give them a name. This is very common with PCI and USB. In most cases this is fine, but we should add an official way to set a device name. This should be called in the device's bind() method. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/device.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index caaf231921..bbe7a94f2a 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -603,3 +603,13 @@ bool device_is_last_sibling(struct udevice *dev)
return false;
return list_is_last(&dev->sibling_node, &parent->child_head);
}
+
+int device_set_name(struct udevice *dev, const char *name)
+{
+ name = strdup(name);
+ if (!name)
+ return -ENOMEM;
+ dev->name = name;
+
+ return 0;
+}
OpenPOWER on IntegriCloud