public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Backlight and LCD module patches [1]
@ 2004-06-17 18:35 Andrew Zabolotny
  2004-06-17 19:47 ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Zabolotny @ 2004-06-17 18:35 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

Hello!

I've tried to fulfill all the requirements that various people presented to
the previous version of this patch; this and the following letter contains
the fixed version of the patch that is proposed to be included into the
mainstream kernel.

--
Greetings,
   Andrew

This patch adds the class_device_find() function, which can be used
to find a class_device by its name. The function was originally
written by Greg Kroah-Hartman.

Also it fixes the class_rename() function to accept 'const char *'
argument as the new class device name.

Signed-off-by: Andrew Zabolotny <zap@homelink.ru>

--- linux-2.6.7-rc3/drivers/base/class.c	2004-06-11 02:39:19.000000000 +0400
+++ linux/drivers/base/class.c	2004-06-17 21:51:11.000000000 +0400
@@ -359,7 +359,7 @@
 	class_device_put(class_dev);
 }
 
-int class_device_rename(struct class_device *class_dev, char *new_name)
+int class_device_rename(struct class_device *class_dev, const char *new_name)
 {
 	int error = 0;
 
@@ -379,6 +379,33 @@
 	return error;
 }
 
+/**
+ * class_device_find - find a struct class_device in a specific class
+ * @class: the class to search
+ * @class_id: the class_id to search for
+ *
+ * Iterates through the list of all class devices registered to a class. If
+ * the class_id is found, its reference count is incremented and returned to
+ * the caller. If the class_id does not match any existing struct class_device
+ * registered to this struct class, then NULL is returned.
+ */
+struct class_device * class_device_find(struct class *class, const char *class_id)
+{
+	struct class_device *class_dev;
+	struct class_device *found = NULL;
+
+	down_read(&class->subsys.rwsem);
+	list_for_each_entry(class_dev, &class->children, node) {
+		if (strcmp(class_dev->class_id, class_id) == 0) {
+			found = class_device_get(class_dev);
+			break;
+		}
+	}
+	up_read(&class->subsys.rwsem);
+
+	return found;
+}
+
 struct class_device * class_device_get(struct class_device *class_dev)
 {
 	if (class_dev)
@@ -391,7 +418,6 @@
 	kobject_put(&class_dev->kobj);
 }
 
-
 int class_interface_register(struct class_interface *class_intf)
 {
 	struct class * parent;
@@ -470,6 +496,8 @@
 EXPORT_SYMBOL(class_device_put);
 EXPORT_SYMBOL(class_device_create_file);
 EXPORT_SYMBOL(class_device_remove_file);
+EXPORT_SYMBOL(class_device_rename);
+EXPORT_SYMBOL(class_device_find);
 
 EXPORT_SYMBOL(class_interface_register);
 EXPORT_SYMBOL(class_interface_unregister);
--- linux-2.6.7-rc3/include/linux/device.h	2004-06-11 02:39:37.000000000 +0400
+++ linux/include/linux/device.h	2004-06-17 21:52:32.000000000 +0400
@@ -212,8 +212,9 @@
 extern int class_device_add(struct class_device *);
 extern void class_device_del(struct class_device *);
 
-extern int class_device_rename(struct class_device *, char *);
+extern int class_device_rename(struct class_device *, const char *);
 
+extern struct class_device * class_device_find(struct class *class, const char *class_id);
 extern struct class_device * class_device_get(struct class_device *);
 extern void class_device_put(struct class_device *);
 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-07-14 19:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-17 18:35 Backlight and LCD module patches [1] Andrew Zabolotny
2004-06-17 19:47 ` Greg KH
2004-06-17 21:55   ` Andrew Zabolotny
2004-06-17 22:05     ` Greg KH
2004-06-18  5:55       ` Andrew Zabolotny
2004-06-24 21:34         ` Greg KH
2004-06-26 20:21           ` Andrew Zabolotny
2004-07-14  6:11             ` Greg KH
2004-07-14 19:14               ` Andrew Zabolotny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox