]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Input: add sysfs class support for input devices
authorGreg Kroah-Hartman <greg@kroah.com>
Mon, 19 Jan 2004 08:38:36 +0000 (00:38 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Mon, 19 Jan 2004 08:38:36 +0000 (00:38 -0800)
This patch adds sysfs support for all input devices.  It also provides
the "device" and "driver" symlink for all Input devices that specify it.

drivers/input/evdev.c
drivers/input/input.c
drivers/input/joydev.c
drivers/input/mousedev.c
drivers/input/tsdev.c
include/linux/input.h

index ab7bdedff9b6ec3d5a27aed6623af7043632da22..8a165f585f0e0aae23d39c94dfb69589707571fc 100644 (file)
@@ -92,6 +92,7 @@ static int evdev_flush(struct file * file)
 static void evdev_free(struct evdev *evdev)
 {
        devfs_remove("input/event%d", evdev->minor);
+       class_simple_device_remove(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor));
        evdev_table[evdev->minor] = NULL;
        kfree(evdev);
 }
@@ -426,6 +427,9 @@ static struct input_handle *evdev_connect(struct input_handler *handler, struct
 
        devfs_mk_cdev(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
                        S_IFCHR|S_IRUGO|S_IWUSR, "input/event%d", minor);
+       class_simple_device_add(input_class, 
+                               MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
+                               dev->dev, "event%d", minor);
 
        return &evdev->handle;
 }
index 2955af5401c084e1d08f356913ee86cf92452883..4a27267eda51e934cb9f4c15cb893b07c88121b3 100644 (file)
@@ -720,15 +720,13 @@ static int __init input_proc_init(void)
 static inline int input_proc_init(void) { return 0; }
 #endif
 
-struct class input_class = {
-       .name           = "input",
-};
+struct class_simple *input_class;
 
 static int __init input_init(void)
 {
        int retval = -ENOMEM;
 
-       class_register(&input_class);
+       input_class = class_simple_create(THIS_MODULE, "input");
        input_proc_init();
        retval = register_chrdev(INPUT_MAJOR, "input", &input_fops);
        if (retval) {
@@ -757,7 +755,7 @@ static void __exit input_exit(void)
 
        devfs_remove("input");
        unregister_chrdev(INPUT_MAJOR, "input");
-       class_unregister(&input_class);
+       class_simple_destroy(input_class);
 }
 
 subsys_initcall(input_init);
index 822ae5473b3f5b264caa9ba64a324c6abd733e8d..26f601905ebb0888dc3406768ea091f13c0aa2b4 100644 (file)
@@ -145,6 +145,7 @@ static void joydev_free(struct joydev *joydev)
 {
        devfs_remove("js%d", joydev->minor);
        joydev_table[joydev->minor] = NULL;
+       class_simple_device_remove(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor));
        kfree(joydev);
 }
 
@@ -444,6 +445,9 @@ static struct input_handle *joydev_connect(struct input_handler *handler, struct
        
        devfs_mk_cdev(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor),
                        S_IFCHR|S_IRUGO|S_IWUSR, "js%d", minor);
+       class_simple_device_add(input_class, 
+                               MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor),
+                               dev->dev, "js%d", minor);
 
        return &joydev->handle;
 }
index c9e96e4913557d7ae275a808aefb0c686c36baa7..a2ac08ad8e96dd7f8429f5e6d0ed9a39bc4680f2 100644 (file)
@@ -225,6 +225,7 @@ static int mousedev_fasync(int fd, struct file *file, int on)
 static void mousedev_free(struct mousedev *mousedev)
 {
        devfs_remove("input/mouse%d", mousedev->minor);
+       class_simple_device_remove(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor));
        mousedev_table[mousedev->minor] = NULL;
        kfree(mousedev);
 }
@@ -486,6 +487,9 @@ static struct input_handle *mousedev_connect(struct input_handler *handler, stru
 
        devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
                        S_IFCHR|S_IRUGO|S_IWUSR, "input/mouse%d", minor);
+       class_simple_device_add(input_class, 
+                               MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
+                               dev->dev, "mouse%d", minor);
 
        return &mousedev->handle;
 }
@@ -564,7 +568,8 @@ static int __init mousedev_init(void)
 
        devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX),
                        S_IFCHR|S_IRUGO|S_IWUSR, "input/mice");
-
+       class_simple_device_add(input_class, MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX),
+                               NULL, "mice");
 
 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
        if (!(mousedev_mix.misc = !misc_register(&psaux_mouse)))
@@ -583,6 +588,7 @@ static void __exit mousedev_exit(void)
                misc_deregister(&psaux_mouse);
 #endif
        devfs_remove("input/mice");
+       class_simple_device_remove(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX));
        input_unregister_handler(&mousedev_handler);
 }
 
index 679f42f81c6c2ceb66dc763d1b08a3ecb8a5dfab..7958ae8578cab50a2ffe83ace31b0126071e827c 100644 (file)
@@ -129,6 +129,7 @@ static int tsdev_open(struct inode *inode, struct file *file)
 static void tsdev_free(struct tsdev *tsdev)
 {
        devfs_remove("input/ts%d", tsdev->minor);
+       class_simple_device_remove(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor));
        tsdev_table[tsdev->minor] = NULL;
        kfree(tsdev);
 }
@@ -343,6 +344,9 @@ static struct input_handle *tsdev_connect(struct input_handler *handler,
        
        devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor),
                        S_IFCHR|S_IRUGO|S_IWUSR, "input/ts%d", minor);
+       class_simple_device_add(input_class, 
+                               MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor),
+                               dev->dev, "ts%d", minor);
 
        return &tsdev->handle;
 }
index eff36f445c255d6810d931ca35b606e87a9fa401..4cb08d4fbd5ebaa0175c49ad0161623c81270c82 100644 (file)
@@ -809,6 +809,7 @@ struct input_dev {
        int (*erase_effect)(struct input_dev *dev, int effect_id);
 
        struct input_handle *grab;
+       struct device *dev;
 
        struct list_head        h_list;
        struct list_head        node;
@@ -921,7 +922,7 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
 #define input_regs(a,b)                do { (a)->regs = (b); } while (0)
 #define input_sync(a)          do { input_event(a, EV_SYN, SYN_REPORT, 0); (a)->regs = NULL; } while (0)
 
-extern struct class input_class;
+extern struct class_simple *input_class;
 
 #endif
 #endif