diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2007-03-07 23:20:26 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2007-03-07 23:20:26 -0500 |
commit | cb9def4dff9fe7e3d3114eba4e2d89f52265e22c (patch) | |
tree | c1b70080ee3c1f1b621c6f4573d9fe451e6c9c30 /drivers | |
parent | 15e03ae811475c2beebfde18717935ee9ce64617 (diff) |
Input: let driver core create class device attribute groups
Rely on device core to create attribute groups for input devices
instead of open-coding it.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/input/input.c | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c index 9b3bfceff72c..4486402fbf5d 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -754,6 +754,13 @@ static struct attribute_group input_dev_caps_attr_group = { | |||
754 | .attrs = input_dev_caps_attrs, | 754 | .attrs = input_dev_caps_attrs, |
755 | }; | 755 | }; |
756 | 756 | ||
757 | static struct attribute_group *input_dev_attr_groups[] = { | ||
758 | &input_dev_attr_group, | ||
759 | &input_dev_id_attr_group, | ||
760 | &input_dev_caps_attr_group, | ||
761 | NULL | ||
762 | }; | ||
763 | |||
757 | static void input_dev_release(struct class_device *class_dev) | 764 | static void input_dev_release(struct class_device *class_dev) |
758 | { | 765 | { |
759 | struct input_dev *dev = to_input_dev(class_dev); | 766 | struct input_dev *dev = to_input_dev(class_dev); |
@@ -907,6 +914,7 @@ struct input_dev *input_allocate_device(void) | |||
907 | dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL); | 914 | dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL); |
908 | if (dev) { | 915 | if (dev) { |
909 | dev->cdev.class = &input_class; | 916 | dev->cdev.class = &input_class; |
917 | dev->cdev.groups = input_dev_attr_groups; | ||
910 | class_device_initialize(&dev->cdev); | 918 | class_device_initialize(&dev->cdev); |
911 | mutex_init(&dev->mutex); | 919 | mutex_init(&dev->mutex); |
912 | INIT_LIST_HEAD(&dev->h_list); | 920 | INIT_LIST_HEAD(&dev->h_list); |
@@ -979,18 +987,6 @@ int input_register_device(struct input_dev *dev) | |||
979 | if (error) | 987 | if (error) |
980 | return error; | 988 | return error; |
981 | 989 | ||
982 | error = sysfs_create_group(&dev->cdev.kobj, &input_dev_attr_group); | ||
983 | if (error) | ||
984 | goto fail1; | ||
985 | |||
986 | error = sysfs_create_group(&dev->cdev.kobj, &input_dev_id_attr_group); | ||
987 | if (error) | ||
988 | goto fail2; | ||
989 | |||
990 | error = sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group); | ||
991 | if (error) | ||
992 | goto fail3; | ||
993 | |||
994 | path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL); | 990 | path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL); |
995 | printk(KERN_INFO "input: %s as %s\n", | 991 | printk(KERN_INFO "input: %s as %s\n", |
996 | dev->name ? dev->name : "Unspecified device", path ? path : "N/A"); | 992 | dev->name ? dev->name : "Unspecified device", path ? path : "N/A"); |
@@ -1008,11 +1004,6 @@ int input_register_device(struct input_dev *dev) | |||
1008 | input_wakeup_procfs_readers(); | 1004 | input_wakeup_procfs_readers(); |
1009 | 1005 | ||
1010 | return 0; | 1006 | return 0; |
1011 | |||
1012 | fail3: sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group); | ||
1013 | fail2: sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group); | ||
1014 | fail1: class_device_del(&dev->cdev); | ||
1015 | return error; | ||
1016 | } | 1007 | } |
1017 | EXPORT_SYMBOL(input_register_device); | 1008 | EXPORT_SYMBOL(input_register_device); |
1018 | 1009 | ||
@@ -1037,10 +1028,6 @@ void input_unregister_device(struct input_dev *dev) | |||
1037 | 1028 | ||
1038 | list_del_init(&dev->node); | 1029 | list_del_init(&dev->node); |
1039 | 1030 | ||
1040 | sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group); | ||
1041 | sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group); | ||
1042 | sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group); | ||
1043 | |||
1044 | class_device_unregister(&dev->cdev); | 1031 | class_device_unregister(&dev->cdev); |
1045 | 1032 | ||
1046 | input_wakeup_procfs_readers(); | 1033 | input_wakeup_procfs_readers(); |