From f5c67ea036be174f75cb48b8f91894bc710811dd Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 30 Jul 2015 13:40:39 -0600 Subject: 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 Reviewed-by: Bin Meng --- drivers/core/device.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers/core') diff --git a/drivers/core/device.c b/drivers/core/device.c index caaf231..bbe7a94 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; +} -- cgit v1.1