]> git.hungrycats.org Git - linux/commitdiff
Make SET_INPUT_KEYCODE return the old value, and clean up
authorLinus Torvalds <torvalds@home.osdl.org>
Sun, 8 Feb 2004 11:02:20 +0000 (03:02 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Sun, 8 Feb 2004 11:02:20 +0000 (03:02 -0800)
users of this that were very confused indeed.

drivers/char/keyboard.c
drivers/input/evdev.c
include/linux/input.h

index 643014bf8c4c1d0b66f504c320ded8ad7ccab717..010bff6e144995208b5263319e4eefbe0c41d5c6 100644 (file)
@@ -201,8 +201,7 @@ int setkeycode(unsigned int scancode, unsigned int keycode)
        if (scancode < 0 || scancode >= dev->keycodemax)
                return -EINVAL;
 
-       oldkey = INPUT_KEYCODE(dev, scancode);
-       SET_INPUT_KEYCODE(dev, scancode, oldkey);
+       oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode);
 
        clear_bit(oldkey, dev->keybit);
        set_bit(keycode, dev->keybit);
index 0e16eeeb9e55e2fdc0b368e2ae25411450891cc9..9b26ff99a414f7ca5ecc0308450414298bb5e9af 100644 (file)
@@ -209,7 +209,7 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
        struct evdev *evdev = list->evdev;
        struct input_dev *dev = evdev->handle.dev;
        struct input_absinfo abs;
-       int i, t, u, v;
+       int t, u, v;
 
        if (!evdev->exist) return -ENODEV;
 
@@ -231,10 +231,8 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                        if (get_user(t, ((int *) arg) + 0)) return -EFAULT;
                        if (t < 0 || t > dev->keycodemax || !dev->keycodesize) return -EINVAL;
                        if (get_user(v, ((int *) arg) + 1)) return -EFAULT;
-                       u = INPUT_KEYCODE(dev, t);
-                       SET_INPUT_KEYCODE(dev, t, v);
-                       for (i = 0; i < dev->keycodemax; i++) if (v == u) break;
-                       if (i == dev->keycodemax) clear_bit(u, dev->keybit);
+                       u = SET_INPUT_KEYCODE(dev, t, v);
+                       clear_bit(u, dev->keybit);
                        set_bit(v, dev->keybit);
                        return 0;
 
index 59afa63abbb397cf6ea823200603c3bf6b6901a0..77ba731cfb3a39a8ec943f8a4f64255c3891ed8e 100644 (file)
@@ -752,25 +752,28 @@ struct ff_effect {
 #define init_input_dev(dev)    do { INIT_LIST_HEAD(&((dev)->h_list)); INIT_LIST_HEAD(&((dev)->node)); } while (0)
 
 #define SET_INPUT_KEYCODE(dev, scancode, val)                  \
-       do {                                                    \
+               ({      unsigned __old;                         \
                switch (dev->keycodesize) {                     \
                        case 1: {                               \
                                u8 *k = (u8 *)dev->keycode;     \
+                               __old = k[scancode];            \
                                k[scancode] = val;              \
                                break;                          \
                        }                                       \
                        case 2: {                               \
                                u16 *k = (u16 *)dev->keycode;   \
+                               __old = k[scancode];            \
                                k[scancode] = val;              \
                                break;                          \
                        }                                       \
-                       case 4: {                               \
+                       default: {                              \
                                u32 *k = (u32 *)dev->keycode;   \
+                               __old = k[scancode];            \
                                k[scancode] = val;              \
                                break;                          \
                        }                                       \
                }                                               \
-       } while (0)
+               __old; })
 
 struct input_dev {