driver-core: prepare for 2.6.27 api change by adding dev_set_name
authorStephen Rothwell <sfr@canb.auug.org.au>
Fri, 30 May 2008 00:16:40 +0000 (10:16 +1000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 30 May 2008 04:10:01 +0000 (21:10 -0700)
Create the dev_set_name function now so that various subsystems can
start changing over to it before other changes in 2.6.27 will make it
compulsory.

Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/core.c
include/linux/device.h

index 72eccae4904bf8685f887bcd0b9ef6a6fc19f5cb..422cfcad486d3eab10b79318caaed63997b93a24 100644 (file)
@@ -759,6 +759,21 @@ static void device_remove_class_symlinks(struct device *dev)
        sysfs_remove_link(&dev->kobj, "subsystem");
 }
 
+/**
+ * dev_set_name - set a device name
+ * @dev: device
+ */
+int dev_set_name(struct device *dev, const char *fmt, ...)
+{
+       va_list vargs;
+
+       va_start(vargs, fmt);
+       vsnprintf(dev->bus_id, sizeof(dev->bus_id), fmt, vargs);
+       va_end(vargs);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(dev_set_name);
+
 /**
  * device_add - add device to device hierarchy.
  * @dev: device.
index 14616e80213cb996947ad5f77ec17903fa495f7d..6a2d04c011bc1850e4f8191cc3749699952e2b7c 100644 (file)
@@ -385,6 +385,9 @@ static inline const char *dev_name(struct device *dev)
        return dev->bus_id;
 }
 
+extern int dev_set_name(struct device *dev, const char *name, ...)
+                       __attribute__((format(printf, 2, 3)));
+
 #ifdef CONFIG_NUMA
 static inline int dev_to_node(struct device *dev)
 {