[PATCH] class.c: added class_create_attrs() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

this is a patch based on linux 2.6.18-rc6.
It adds a class_create_attrs() function in
drivers/base/class.c .
This new function works similar to class_create(),
but also allows to create the class attribute files
(if any) during class creation.

-Thomas Maier


diff -urpN linux-2.6.18-rc6/drivers/base/class.c patch/drivers/base/class.c
--- linux-2.6.18-rc6/drivers/base/class.c	2006-09-11 21:45:12.000000000 +0200
+++ patch/drivers/base/class.c	2006-09-11 21:52:06.000000000 +0200
@@ -199,6 +199,18 @@ static int class_device_create_uevent(st
   */
  struct class *class_create(struct module *owner, char *name)
  {
+	return class_create_attrs(owner, name, NULL);
+}
+/**
+ * class_create_attrs - similar to class_create(), but can also
+ * create class attribute files on class creation.
+ * @owner: pointer to the module that is to "own" this struct class
+ * @name: pointer to a string for the name of this class.
+ * @cls_attrs: pointer to a class_attribute array.
+ */
+struct class *class_create_attrs(struct module *owner, char *name,
+				struct class_attribute *cls_attrs)
+{
  	struct class *cls;
  	int retval;

@@ -212,6 +224,7 @@ struct class *class_create(struct module
  	cls->owner = owner;
  	cls->class_release = class_create_release;
  	cls->release = class_device_create_release;
+	cls->class_attrs = cls_attrs;

  	retval = class_register(cls);
  	if (retval)
@@ -900,6 +913,7 @@ EXPORT_SYMBOL_GPL(class_remove_file);
  EXPORT_SYMBOL_GPL(class_register);
  EXPORT_SYMBOL_GPL(class_unregister);
  EXPORT_SYMBOL_GPL(class_create);
+EXPORT_SYMBOL_GPL(class_create_attrs);
  EXPORT_SYMBOL_GPL(class_destroy);

  EXPORT_SYMBOL_GPL(class_device_register);
diff -urpN linux-2.6.18-rc6/include/linux/device.h patch/include/linux/device.h
--- linux-2.6.18-rc6/include/linux/device.h	2006-09-11 21:53:10.000000000 +0200
+++ patch/include/linux/device.h	2006-09-11 21:54:21.000000000 +0200
@@ -272,6 +272,8 @@ extern int class_interface_register(stru
  extern void class_interface_unregister(struct class_interface *);

  extern struct class *class_create(struct module *owner, char *name);
+extern struct class *class_create_attrs(struct module *owner, char *name,
+					struct class_attribute *cls_attrs);
  extern void class_destroy(struct class *cls);
  extern struct class_device *class_device_create(struct class *cls,
  						struct class_device *parent,
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux