[PATCH] INPUT: Fix oops when accessing sysfs files of nested input devices

From: Greg KH
Date: Fri Oct 28 2005 - 01:49:22 EST


[PATCH] INPUT: Fix oops when accessing sysfs files of nested input devices

Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
commit 706d2a7c95014882307f31cd0f3c2a95b0544819
tree d13cecf9467ec8812058bad516c451e1d2c7263e
parent ae2ea92c4fa1b32ab686bf48243b3671b3aa7c3a
author Greg Kroah-Hartman <gregkh@xxxxxxx> Thu, 27 Oct 2005 22:25:43 -0700
committer Greg Kroah-Hartman <gregkh@xxxxxxx> Thu, 27 Oct 2005 22:48:06 -0700

drivers/input/input.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index b0ede4c..0d570cf 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -642,17 +642,22 @@ static ssize_t input_dev_show_##name(str
up(&input_dev->sem); \
\
return retval; \
-}
+} \
+static CLASS_DEVICE_ATTR(name, S_IRUGO, input_dev_show_##name, NULL);

INPUT_DEV_STRING_ATTR_SHOW(name);
INPUT_DEV_STRING_ATTR_SHOW(phys);
INPUT_DEV_STRING_ATTR_SHOW(uniq);

-static struct class_device_attribute input_dev_attrs[] = {
- __ATTR(name, S_IRUGO, input_dev_show_name, NULL),
- __ATTR(phys, S_IRUGO, input_dev_show_phys, NULL),
- __ATTR(uniq, S_IRUGO, input_dev_show_uniq, NULL),
- __ATTR_NULL
+static struct attribute *input_dev_attrs[] = {
+ &class_device_attr_name.attr,
+ &class_device_attr_phys.attr,
+ &class_device_attr_uniq.attr,
+ NULL
+};
+
+static struct attribute_group input_dev_group = {
+ .attrs = input_dev_attrs,
};

#define INPUT_DEV_ID_ATTR(name) \
@@ -728,7 +733,6 @@ static void input_dev_release(struct cla
struct class input_dev_class = {
.name = "input_dev",
.release = input_dev_release,
- .class_dev_attrs = input_dev_attrs,
};

struct input_dev *input_allocate_device(void)
@@ -766,6 +770,7 @@ static void input_register_classdevice(s
kfree(path);

class_device_add(&dev->cdev);
+ sysfs_create_group(&dev->cdev.kobj, &input_dev_group);
sysfs_create_group(&dev->cdev.kobj, &input_dev_id_attr_group);
sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
}

-
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/