]> git.neil.brown.name Git - history.git/commitdiff
input layer update:
authorPatrick Mochel <mochel@osdl.org>
Mon, 26 Aug 2002 10:00:59 +0000 (03:00 -0700)
committerPatrick Mochel <mochel@osdl.org>
Mon, 26 Aug 2002 10:00:59 +0000 (03:00 -0700)
- Remove struct input_dev * input_dev; replace with static LIST_HEAD(input_dev_list).
- Change all list manipulation from manual to using generic list helpers.

drivers/input/input.c
include/linux/input.h

index 5ac97d500f72bd1d677e3ad49001e752519b9122..266189bce7602cb53ebc796a3ddc5ae7df1ad5b8 100644 (file)
@@ -58,8 +58,11 @@ EXPORT_SYMBOL(input_event);
 #define INPUT_MAJOR    13
 #define INPUT_DEVICES  256
 
-static struct input_dev *input_dev;
+static LIST_HEAD(input_dev_list);
+static LIST_HEAD(input_handler_list);
+
 static struct input_handler *input_handler;
+
 static struct input_handler *input_table[8];
 static devfs_handle_t input_devfs_handle;
 
@@ -465,9 +468,7 @@ void input_register_device(struct input_dev *dev)
 /*
  * Add the device.
  */
-
-       dev->next = input_dev;  
-       input_dev = dev;
+       list_add_tail(&dev->node,&input_dev_list);
 
 /*
  * Notify handlers.
@@ -539,7 +540,7 @@ void input_unregister_device(struct input_dev *dev)
 /*
  * Remove the device.
  */
-       input_find_and_remove(struct input_dev, input_dev, dev, next);
+       list_del_init(&dev->node);
 
 /*
  * Notify /proc.
@@ -553,7 +554,7 @@ void input_unregister_device(struct input_dev *dev)
 
 void input_register_handler(struct input_handler *handler)
 {
-       struct input_dev *dev = input_dev;
+       struct list_head * node;
        struct input_handle *handle;
        struct input_device_id *id;
 
@@ -577,11 +578,11 @@ void input_register_handler(struct input_handler *handler)
  * Notify it about all existing devices.
  */
 
-       while (dev) {
+       list_for_each(node,&input_dev_list) {
+               struct input_dev *dev = container_of(node,struct input_dev,node);
                if ((id = input_match_device(handler->id_table, dev)))
                        if ((handle = handler->connect(handler, dev, id)))
                                input_link_handle(handle);
-               dev = dev->next;
        }
 
 /*
@@ -715,13 +716,14 @@ static unsigned int input_devices_poll(struct file *file, poll_table *wait)
 
 static int input_devices_read(char *buf, char **start, off_t pos, int count, int *eof, void *data)
 {
-       struct input_dev *dev = input_dev;
+       struct list_head * node;
        struct input_handle *handle;
 
        off_t at = 0;
        int i, len, cnt = 0;
 
-       while (dev) {
+       list_for_each(node,&input_dev_list) {
+               struct input_dev *dev = container_of(node,struct input_dev,node);
 
                len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n",
                        dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version);
@@ -761,11 +763,10 @@ static int input_devices_read(char *buf, char **start, off_t pos, int count, int
                        if (cnt >= count)
                                break;
                }
-
-               dev = dev->next;
        }
 
-       if (!dev) *eof = 1;
+       if (node == &input_dev_list)
+               *eof = 1;
 
        return (count > cnt) ? cnt : count;
 }
index 002e82ebb49487ff01b66d04313a6f2d3be33101..fa2c3b3b09db918ac4dea52b3b7251c3f4006d10 100644 (file)
@@ -812,7 +812,7 @@ struct input_dev {
        int (*erase_effect)(struct input_dev *dev, int effect_id);
 
        struct input_handle *handle;
-       struct input_dev *next;
+       struct list_head        node;
 };
 
 /*