Subject: Driver core: add class_device_create_v()

From: "Mark M. Hoffman" <[email-masked]>
Date: Wed, 1 Jun 2005 23:34:31 -0400

This patch adds a va_args version of the class_device_create function.

Signed-off-by: Mark M. Hoffman <[email-masked]>
Signed-off-by: Greg Kroah-Hartman <[email-masked]>

---
 drivers/base/class.c   |   25 +++++++++++++++++++++++--
 include/linux/device.h |    7 ++++++-
 2 files changed, 29 insertions(+), 3 deletions(-)

--- gregkh-2.6.orig/drivers/base/class.c	2005-06-01 17:11:56.000000000 -0700
+++ gregkh-2.6/drivers/base/class.c	2005-06-01 22:35:26.000000000 -0700
@@ -543,7 +543,29 @@
 struct class_device *class_device_create(struct class *cls, dev_t devt,
 					 struct device *device, char *fmt, ...)
 {
+	struct class_device *class_dev = NULL;
 	va_list args;
+
+	va_start(args, fmt);
+	class_dev = class_device_create_v(cls, devt, device, fmt, args);
+	va_end(args);
+
+	return class_dev;
+}
+
+/**
+ * class_device_create_v - creates a class device and registers it with sysfs
+ * @cs: pointer to the struct class that this device should be registered to.
+ * @dev: the dev_t for the char device to be added.
+ * @device: a pointer to a struct device that is assiociated with this class device.
+ * @fmt: string for the class device's name
+ *
+ * this function is to class_device_create as (e.g.) vprintf is to printf
+ */
+struct class_device *class_device_create_v(struct class *cls, dev_t devt,
+					   struct device *device, char *fmt,
+					   va_list args)
+{
 	struct class_device *class_dev = NULL;
 	int retval = -ENODEV;
 
@@ -561,9 +583,7 @@
 	class_dev->dev = device;
 	class_dev->class = cls;
 
-	va_start(args, fmt);
 	vsnprintf(class_dev->class_id, BUS_ID_SIZE, fmt, args);
-	va_end(args);
 	retval = class_device_register(class_dev);
 	if (retval)
 		goto error;
@@ -749,6 +769,7 @@
 EXPORT_SYMBOL_GPL(class_device_get);
 EXPORT_SYMBOL_GPL(class_device_put);
 EXPORT_SYMBOL_GPL(class_device_create);
+EXPORT_SYMBOL_GPL(class_device_create_v);
 EXPORT_SYMBOL_GPL(class_device_destroy);
 EXPORT_SYMBOL_GPL(class_device_create_file);
 EXPORT_SYMBOL_GPL(class_device_remove_file);
--- gregkh-2.6.orig/include/linux/device.h	2005-06-01 17:13:42.000000000 -0700
+++ gregkh-2.6/include/linux/device.h	2005-06-01 22:35:26.000000000 -0700
@@ -256,8 +256,13 @@
 extern struct class *class_create(struct module *owner, char *name);
 extern void class_destroy(struct class *cls);
 extern struct class_device *class_device_create(struct class *cls, dev_t devt,
-						struct device *device, char *fmt, ...)
+						struct device *device,
+						char *fmt, ...)
 					__attribute__((format(printf,4,5)));
+extern struct class_device *class_device_create_v(struct class *cls, dev_t devt,
+						  struct device *device,
+						  char *fmt, va_list args)
+					__attribute__((format(printf,4,0)));
 extern void class_device_destroy(struct class *cls, dev_t devt);