Backlight and LCD module patches [1]

From: Andrew Zabolotny
Date: Thu Jun 17 2004 - 13:40:12 EST


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@xxxxxxxxxxx>

--- 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 *);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/