aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/core.c15
-rw-r--r--include/linux/device.h3
2 files changed, 18 insertions, 0 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 72eccae4904b..422cfcad486d 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -760,6 +760,21 @@ static void device_remove_class_symlinks(struct device *dev)
760} 760}
761 761
762/** 762/**
763 * dev_set_name - set a device name
764 * @dev: device
765 */
766int dev_set_name(struct device *dev, const char *fmt, ...)
767{
768 va_list vargs;
769
770 va_start(vargs, fmt);
771 vsnprintf(dev->bus_id, sizeof(dev->bus_id), fmt, vargs);
772 va_end(vargs);
773 return 0;
774}
775EXPORT_SYMBOL_GPL(dev_set_name);
776
777/**
763 * device_add - add device to device hierarchy. 778 * device_add - add device to device hierarchy.
764 * @dev: device. 779 * @dev: device.
765 * 780 *
diff --git a/include/linux/device.h b/include/linux/device.h
index 14616e80213c..6a2d04c011bc 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -385,6 +385,9 @@ static inline const char *dev_name(struct device *dev)
385 return dev->bus_id; 385 return dev->bus_id;
386} 386}
387 387
388extern int dev_set_name(struct device *dev, const char *name, ...)
389 __attribute__((format(printf, 2, 3)));
390
388#ifdef CONFIG_NUMA 391#ifdef CONFIG_NUMA
389static inline int dev_to_node(struct device *dev) 392static inline int dev_to_node(struct device *dev)
390{ 393{