summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-07-30 19:40:39 (GMT)
committerSimon Glass <sjg@chromium.org>2015-08-06 13:44:29 (GMT)
commitf5c67ea036be174f75cb48b8f91894bc710811dd (patch)
tree15877db8c32f59a6457f89db7f9367210392401f /include
parentc3e6847bb33c061ce248d0178d8ca8daf1104aef (diff)
downloadu-boot-fsl-qoriq-f5c67ea036be174f75cb48b8f91894bc710811dd.tar.xz
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 'include')
-rw-r--r--include/dm/device.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/dm/device.h b/include/dm/device.h
index 53773a8..1f78963 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -470,6 +470,21 @@ bool device_has_active_children(struct udevice *dev);
*/
bool device_is_last_sibling(struct udevice *dev);
+/**
+ * device_set_name() - set the name of a device
+ *
+ * This must be called in the device's bind() method and no later. Normally
+ * this is unnecessary but for probed devices which don't get a useful name
+ * this function can be helpful.
+ *
+ * @dev: Device to update
+ * @name: New name (this string is allocated new memory and attached to
+ * the device)
+ * @return 0 if OK, -ENOMEM if there is not enough memory to allocate the
+ * string
+ */
+int device_set_name(struct udevice *dev, const char *name);
+
/* device resource management */
typedef void (*dr_release_t)(struct udevice *dev, void *res);
typedef int (*dr_match_t)(struct udevice *dev, void *res, void *match_data);