Merge branch 'next' into for-linus
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Sat, 19 Mar 2011 06:38:50 +0000 (23:38 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sat, 19 Mar 2011 06:38:50 +0000 (23:38 -0700)
1  2 
drivers/input/gameport/gameport.c
drivers/input/input.c
drivers/input/mouse/bcm5974.c
drivers/input/tablet/wacom_sys.c
drivers/input/touchscreen/ads7846.c
drivers/tty/sysrq.c
include/linux/input/matrix_keypad.h

@@@ -121,7 -121,7 +121,7 @@@ static int gameport_measure_speed(struc
        }
  
        gameport_close(gameport);
-       return (cpu_data(raw_smp_processor_id()).loops_per_jiffy *
+       return (this_cpu_read(cpu_info.loops_per_jiffy) *
                (unsigned long)HZ / (1000 / 50)) / (tx < 1 ? 1 : tx);
  
  #else
@@@ -360,7 -360,7 +360,7 @@@ static int gameport_queue_event(void *o
        event->owner = owner;
  
        list_add_tail(&event->node, &gameport_event_list);
 -      schedule_work(&gameport_event_work);
 +      queue_work(system_long_wq, &gameport_event_work);
  
  out:
        spin_unlock_irqrestore(&gameport_event_lock, flags);
diff --combined drivers/input/input.c
@@@ -26,7 -26,6 +26,6 @@@
  #include <linux/device.h>
  #include <linux/mutex.h>
  #include <linux/rcupdate.h>
- #include <linux/smp_lock.h>
  #include "input-compat.h"
  
  MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
@@@ -76,6 -75,7 +75,6 @@@ static int input_defuzz_abs_event(int v
   * dev->event_lock held and interrupts disabled.
   */
  static void input_pass_event(struct input_dev *dev,
 -                           struct input_handler *src_handler,
                             unsigned int type, unsigned int code, int value)
  {
        struct input_handler *handler;
                                continue;
  
                        handler = handle->handler;
 -
 -                      /*
 -                       * If this is the handler that injected this
 -                       * particular event we want to skip it to avoid
 -                       * filters firing again and again.
 -                       */
 -                      if (handler == src_handler)
 -                              continue;
 -
                        if (!handler->filter) {
                                if (filtered)
                                        break;
@@@ -123,7 -132,7 +122,7 @@@ static void input_repeat_key(unsigned l
        if (test_bit(dev->repeat_key, dev->key) &&
            is_event_supported(dev->repeat_key, dev->keybit, KEY_MAX)) {
  
 -              input_pass_event(dev, NULL, EV_KEY, dev->repeat_key, 2);
 +              input_pass_event(dev, EV_KEY, dev->repeat_key, 2);
  
                if (dev->sync) {
                        /*
                         * Otherwise assume that the driver will send
                         * SYN_REPORT once it's done.
                         */
 -                      input_pass_event(dev, NULL, EV_SYN, SYN_REPORT, 1);
 +                      input_pass_event(dev, EV_SYN, SYN_REPORT, 1);
                }
  
                if (dev->rep[REP_PERIOD])
@@@ -165,6 -174,7 +164,6 @@@ static void input_stop_autorepeat(struc
  #define INPUT_PASS_TO_ALL     (INPUT_PASS_TO_HANDLERS | INPUT_PASS_TO_DEVICE)
  
  static int input_handle_abs_event(struct input_dev *dev,
 -                                struct input_handler *src_handler,
                                  unsigned int code, int *pval)
  {
        bool is_mt_event;
        /* Flush pending "slot" event */
        if (is_mt_event && dev->slot != input_abs_get_val(dev, ABS_MT_SLOT)) {
                input_abs_set_val(dev, ABS_MT_SLOT, dev->slot);
 -              input_pass_event(dev, src_handler,
 -                               EV_ABS, ABS_MT_SLOT, dev->slot);
 +              input_pass_event(dev, EV_ABS, ABS_MT_SLOT, dev->slot);
        }
  
        return INPUT_PASS_TO_HANDLERS;
  }
  
  static void input_handle_event(struct input_dev *dev,
 -                             struct input_handler *src_handler,
                               unsigned int type, unsigned int code, int value)
  {
        int disposition = INPUT_IGNORE_EVENT;
  
        case EV_ABS:
                if (is_event_supported(code, dev->absbit, ABS_MAX))
 -                      disposition = input_handle_abs_event(dev, src_handler,
 -                                                           code, &value);
 +                      disposition = input_handle_abs_event(dev, code, &value);
  
                break;
  
                dev->event(dev, type, code, value);
  
        if (disposition & INPUT_PASS_TO_HANDLERS)
 -              input_pass_event(dev, src_handler, type, code, value);
 +              input_pass_event(dev, type, code, value);
  }
  
  /**
@@@ -354,7 -367,7 +353,7 @@@ void input_event(struct input_dev *dev
  
                spin_lock_irqsave(&dev->event_lock, flags);
                add_input_randomness(type, code, value);
 -              input_handle_event(dev, NULL, type, code, value);
 +              input_handle_event(dev, type, code, value);
                spin_unlock_irqrestore(&dev->event_lock, flags);
        }
  }
@@@ -384,7 -397,8 +383,7 @@@ void input_inject_event(struct input_ha
                rcu_read_lock();
                grab = rcu_dereference(dev->grab);
                if (!grab || grab == handle)
 -                      input_handle_event(dev, handle->handler,
 -                                         type, code, value);
 +                      input_handle_event(dev, type, code, value);
                rcu_read_unlock();
  
                spin_unlock_irqrestore(&dev->event_lock, flags);
@@@ -597,10 -611,10 +596,10 @@@ static void input_dev_release_keys(stru
                for (code = 0; code <= KEY_MAX; code++) {
                        if (is_event_supported(code, dev->keybit, KEY_MAX) &&
                            __test_and_clear_bit(code, dev->key)) {
 -                              input_pass_event(dev, NULL, EV_KEY, code, 0);
 +                              input_pass_event(dev, EV_KEY, code, 0);
                        }
                }
 -              input_pass_event(dev, NULL, EV_SYN, SYN_REPORT, 1);
 +              input_pass_event(dev, EV_SYN, SYN_REPORT, 1);
        }
  }
  
@@@ -792,22 -806,9 +791,9 @@@ int input_get_keycode(struct input_dev 
        int retval;
  
        spin_lock_irqsave(&dev->event_lock, flags);
-       if (dev->getkeycode) {
-               /*
-                * Support for legacy drivers, that don't implement the new
-                * ioctls
-                */
-               u32 scancode = ke->index;
-               memcpy(ke->scancode, &scancode, sizeof(scancode));
-               ke->len = sizeof(scancode);
-               retval = dev->getkeycode(dev, scancode, &ke->keycode);
-       } else {
-               retval = dev->getkeycode_new(dev, ke);
-       }
+       retval = dev->getkeycode(dev, ke);
        spin_unlock_irqrestore(&dev->event_lock, flags);
        return retval;
  }
  EXPORT_SYMBOL(input_get_keycode);
@@@ -832,35 -833,7 +818,7 @@@ int input_set_keycode(struct input_dev 
  
        spin_lock_irqsave(&dev->event_lock, flags);
  
-       if (dev->setkeycode) {
-               /*
-                * Support for legacy drivers, that don't implement the new
-                * ioctls
-                */
-               unsigned int scancode;
-               retval = input_scancode_to_scalar(ke, &scancode);
-               if (retval)
-                       goto out;
-               /*
-                * We need to know the old scancode, in order to generate a
-                * keyup effect, if the set operation happens successfully
-                */
-               if (!dev->getkeycode) {
-                       retval = -EINVAL;
-                       goto out;
-               }
-               retval = dev->getkeycode(dev, scancode, &old_keycode);
-               if (retval)
-                       goto out;
-               retval = dev->setkeycode(dev, scancode, ke->keycode);
-       } else {
-               retval = dev->setkeycode_new(dev, ke, &old_keycode);
-       }
+       retval = dev->setkeycode(dev, ke, &old_keycode);
        if (retval)
                goto out;
  
            !is_event_supported(old_keycode, dev->keybit, KEY_MAX) &&
            __test_and_clear_bit(old_keycode, dev->key)) {
  
 -              input_pass_event(dev, NULL, EV_KEY, old_keycode, 0);
 +              input_pass_event(dev, EV_KEY, old_keycode, 0);
                if (dev->sync)
 -                      input_pass_event(dev, NULL, EV_SYN, SYN_REPORT, 1);
 +                      input_pass_event(dev, EV_SYN, SYN_REPORT, 1);
        }
  
   out:
@@@ -1847,11 -1820,11 +1805,11 @@@ int input_register_device(struct input_
                dev->rep[REP_PERIOD] = 33;
        }
  
-       if (!dev->getkeycode && !dev->getkeycode_new)
-               dev->getkeycode_new = input_default_getkeycode;
+       if (!dev->getkeycode)
+               dev->getkeycode = input_default_getkeycode;
  
-       if (!dev->setkeycode && !dev->setkeycode_new)
-               dev->setkeycode_new = input_default_setkeycode;
+       if (!dev->setkeycode)
+               dev->setkeycode = input_default_setkeycode;
  
        dev_set_name(&dev->dev, "input%ld",
                     (unsigned long) atomic_inc_return(&input_no) - 1);
  #define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI  0x0236
  #define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO   0x0237
  #define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS   0x0238
+ /* MacbookAir3,2 (unibody), aka wellspring5 */
+ #define USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI  0x023f
+ #define USB_DEVICE_ID_APPLE_WELLSPRING4_ISO   0x0240
+ #define USB_DEVICE_ID_APPLE_WELLSPRING4_JIS   0x0241
+ /* MacbookAir3,1 (unibody), aka wellspring4 */
+ #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242
+ #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO  0x0243
+ #define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS  0x0244
+ /* Macbook8 (unibody, March 2011) */
+ #define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI  0x0245
+ #define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO   0x0246
+ #define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS   0x0247
  
  #define BCM5974_DEVICE(prod) {                                        \
        .match_flags = (USB_DEVICE_ID_MATCH_DEVICE |            \
@@@ -80,6 -92,18 +92,18 @@@ static const struct usb_device_id bcm59
        BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI),
        BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ISO),
        BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
+       /* MacbookAir3,2 */
+       BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI),
+       BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_ISO),
+       BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_JIS),
+       /* MacbookAir3,1 */
+       BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI),
+       BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO),
+       BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS),
+       /* MacbookPro8 */
+       BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI),
+       BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_ISO),
+       BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
        /* Terminating entry */
        {}
  };
@@@ -234,6 -258,42 +258,42 @@@ static const struct bcm5974_config bcm5
                { DIM_X, DIM_X / SN_COORD, -4460, 5166 },
                { DIM_Y, DIM_Y / SN_COORD, -75, 6700 }
        },
+       {
+               USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI,
+               USB_DEVICE_ID_APPLE_WELLSPRING4_ISO,
+               USB_DEVICE_ID_APPLE_WELLSPRING4_JIS,
+               HAS_INTEGRATED_BUTTON,
+               0x84, sizeof(struct bt_data),
+               0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
+               { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
+               { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
+               { DIM_X, DIM_X / SN_COORD, -4620, 5140 },
+               { DIM_Y, DIM_Y / SN_COORD, -150, 6600 }
+       },
+       {
+               USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI,
+               USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO,
+               USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS,
+               HAS_INTEGRATED_BUTTON,
+               0x84, sizeof(struct bt_data),
+               0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
+               { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
+               { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
+               { DIM_X, DIM_X / SN_COORD, -4616, 5112 },
+               { DIM_Y, DIM_Y / SN_COORD, -142, 5234 }
+       },
+       {
+               USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI,
+               USB_DEVICE_ID_APPLE_WELLSPRING5_ISO,
+               USB_DEVICE_ID_APPLE_WELLSPRING5_JIS,
+               HAS_INTEGRATED_BUTTON,
+               0x84, sizeof(struct bt_data),
+               0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
+               { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
+               { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
+               { DIM_X, DIM_X / SN_COORD, -4415, 5050 },
+               { DIM_Y, DIM_Y / SN_COORD, -55, 6680 }
+       },
        {}
  };
  
@@@ -390,6 -450,10 +450,6 @@@ static int report_tp_state(struct bcm59
                ptest = int2bound(&c->p, raw_p);
                origin = raw2int(f->origin);
  
 -              /* set the integrated button if applicable */
 -              if (c->tp_type == TYPE2)
 -                      ibt = raw2int(dev->tp_data[BUTTON_TYPE2]);
 -
                /* while tracking finger still valid, count all fingers */
                if (ptest > PRESSURE_LOW && origin) {
                        abs_p = ptest;
                }
        }
  
 +      /* set the integrated button if applicable */
 +      if (c->tp_type == TYPE2)
 +              ibt = raw2int(dev->tp_data[BUTTON_TYPE2]);
 +
        if (dev->fingers < nmin)
                dev->fingers = nmin;
        if (dev->fingers > nmax)
@@@ -193,16 -193,16 +193,16 @@@ static int wacom_parse_hid(struct usb_i
                        case HID_USAGE_X:
                                if (usage == WCM_DESKTOP) {
                                        if (finger) {
-                                               features->device_type = BTN_TOOL_DOUBLETAP;
+                                               features->device_type = BTN_TOOL_FINGER;
                                                if (features->type == TABLETPC2FG) {
                                                        /* need to reset back */
                                                        features->pktlen = WACOM_PKGLEN_TPC2FG;
-                                                       features->device_type = BTN_TOOL_TRIPLETAP;
+                                                       features->device_type = BTN_TOOL_DOUBLETAP;
                                                }
                                                if (features->type == BAMBOO_PT) {
                                                        /* need to reset back */
                                                        features->pktlen = WACOM_PKGLEN_BBTOUCH;
-                                                       features->device_type = BTN_TOOL_TRIPLETAP;
+                                                       features->device_type = BTN_TOOL_DOUBLETAP;
                                                        features->x_phy =
                                                                get_unaligned_le16(&report[i + 5]);
                                                        features->x_max =
                        case HID_USAGE_Y:
                                if (usage == WCM_DESKTOP) {
                                        if (finger) {
-                                               features->device_type = BTN_TOOL_DOUBLETAP;
+                                               features->device_type = BTN_TOOL_FINGER;
                                                if (features->type == TABLETPC2FG) {
                                                        /* need to reset back */
                                                        features->pktlen = WACOM_PKGLEN_TPC2FG;
-                                                       features->device_type = BTN_TOOL_TRIPLETAP;
+                                                       features->device_type = BTN_TOOL_DOUBLETAP;
                                                        features->y_max =
                                                                get_unaligned_le16(&report[i + 3]);
                                                        features->y_phy =
                                                } else if (features->type == BAMBOO_PT) {
                                                        /* need to reset back */
                                                        features->pktlen = WACOM_PKGLEN_BBTOUCH;
-                                                       features->device_type = BTN_TOOL_TRIPLETAP;
+                                                       features->device_type = BTN_TOOL_DOUBLETAP;
                                                        features->y_phy =
                                                                get_unaligned_le16(&report[i + 3]);
                                                        features->y_max =
@@@ -519,7 -519,7 +519,7 @@@ static int wacom_probe(struct usb_inter
        /* Retrieve the physical and logical size for OEM devices */
        error = wacom_retrieve_hid_descriptor(intf, features);
        if (error)
 -              goto fail2;
 +              goto fail3;
  
        wacom_setup_device_quirks(features);
  
@@@ -26,6 -26,7 +26,7 @@@
  #include <linux/input.h>
  #include <linux/interrupt.h>
  #include <linux/slab.h>
+ #include <linux/pm.h>
  #include <linux/gpio.h>
  #include <linux/spi/spi.h>
  #include <linux/spi/ads7846.h>
@@@ -892,9 -893,10 +893,10 @@@ static irqreturn_t ads7846_irq(int irq
        return IRQ_HANDLED;
  }
  
- static int ads7846_suspend(struct spi_device *spi, pm_message_t message)
+ #ifdef CONFIG_PM_SLEEP
+ static int ads7846_suspend(struct device *dev)
  {
-       struct ads7846 *ts = dev_get_drvdata(&spi->dev);
+       struct ads7846 *ts = dev_get_drvdata(dev);
  
        mutex_lock(&ts->lock);
  
        return 0;
  }
  
- static int ads7846_resume(struct spi_device *spi)
+ static int ads7846_resume(struct device *dev)
  {
-       struct ads7846 *ts = dev_get_drvdata(&spi->dev);
+       struct ads7846 *ts = dev_get_drvdata(dev);
  
        mutex_lock(&ts->lock);
  
  
        return 0;
  }
+ #endif
+ static SIMPLE_DEV_PM_OPS(ads7846_pm, ads7846_suspend, ads7846_resume);
  
  static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads7846 *ts)
  {
        struct ads7846_platform_data *pdata = spi->dev.platform_data;
        int err;
  
 -      /* REVISIT when the irq can be triggered active-low, or if for some
 +      /*
 +       * REVISIT when the irq can be triggered active-low, or if for some
         * reason the touchscreen isn't hooked up, we don't need to access
         * the pendown state.
         */
 -      if (!pdata->get_pendown_state && !gpio_is_valid(pdata->gpio_pendown)) {
 -              dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
 -              return -EINVAL;
 -      }
  
        if (pdata->get_pendown_state) {
                ts->get_pendown_state = pdata->get_pendown_state;
 -              return 0;
 -      }
 +      } else if (gpio_is_valid(pdata->gpio_pendown)) {
  
 -      err = gpio_request(pdata->gpio_pendown, "ads7846_pendown");
 -      if (err) {
 -              dev_err(&spi->dev, "failed to request pendown GPIO%d\n",
 -                      pdata->gpio_pendown);
 -              return err;
 -      }
 +              err = gpio_request(pdata->gpio_pendown, "ads7846_pendown");
 +              if (err) {
 +                      dev_err(&spi->dev, "failed to request pendown GPIO%d\n",
 +                              pdata->gpio_pendown);
 +                      return err;
 +              }
  
 -      ts->gpio_pendown = pdata->gpio_pendown;
 +              ts->gpio_pendown = pdata->gpio_pendown;
 +
 +      } else {
 +              dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
 +              return -EINVAL;
 +      }
  
        return 0;
  }
@@@ -1354,7 -1358,7 +1359,7 @@@ static int __devinit ads7846_probe(stru
   err_put_regulator:
        regulator_put(ts->reg);
   err_free_gpio:
 -      if (ts->gpio_pendown != -1)
 +      if (!ts->get_pendown_state)
                gpio_free(ts->gpio_pendown);
   err_cleanup_filter:
        if (ts->filter_cleanup)
@@@ -1384,13 -1388,8 +1389,13 @@@ static int __devexit ads7846_remove(str
        regulator_disable(ts->reg);
        regulator_put(ts->reg);
  
 -      if (ts->gpio_pendown != -1)
 +      if (!ts->get_pendown_state) {
 +              /*
 +               * If we are not using specialized pendown method we must
 +               * have been relying on gpio we set up ourselves.
 +               */
                gpio_free(ts->gpio_pendown);
 +      }
  
        if (ts->filter_cleanup)
                ts->filter_cleanup(ts->filter_data);
@@@ -1408,11 -1407,10 +1413,10 @@@ static struct spi_driver ads7846_drive
                .name   = "ads7846",
                .bus    = &spi_bus_type,
                .owner  = THIS_MODULE,
+               .pm     = &ads7846_pm,
        },
        .probe          = ads7846_probe,
        .remove         = __devexit_p(ads7846_remove),
-       .suspend        = ads7846_suspend,
-       .resume         = ads7846_resume,
  };
  
  static int __init ads7846_init(void)
diff --combined drivers/tty/sysrq.c
@@@ -571,7 -571,6 +571,7 @@@ struct sysrq_state 
        unsigned int alt_use;
        bool active;
        bool need_reinject;
 +      bool reinjecting;
  };
  
  static void sysrq_reinject_alt_sysrq(struct work_struct *work)
        unsigned int alt_code = sysrq->alt_use;
  
        if (sysrq->need_reinject) {
 +              /* we do not want the assignment to be reordered */
 +              sysrq->reinjecting = true;
 +              mb();
 +
                /* Simulate press and release of Alt + SysRq */
                input_inject_event(handle, EV_KEY, alt_code, 1);
                input_inject_event(handle, EV_KEY, KEY_SYSRQ, 1);
                input_inject_event(handle, EV_KEY, KEY_SYSRQ, 0);
                input_inject_event(handle, EV_KEY, alt_code, 0);
                input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
 +
 +              mb();
 +              sysrq->reinjecting = false;
        }
  }
  
@@@ -607,13 -599,6 +607,13 @@@ static bool sysrq_filter(struct input_h
        bool was_active = sysrq->active;
        bool suppress;
  
 +      /*
 +       * Do not filter anything if we are in the process of re-injecting
 +       * Alt+SysRq combination.
 +       */
 +      if (sysrq->reinjecting)
 +              return false;
 +
        switch (type) {
  
        case EV_SYN:
                                sysrq->alt_use = sysrq->alt;
                                /*
                                 * If nothing else will be pressed we'll need
 -                               * to re-inject Alt-SysRq keysroke.
 +                               * to re-inject Alt-SysRq keysroke.
                                 */
                                sysrq->need_reinject = true;
                        }
@@@ -4,12 -4,12 +4,12 @@@
  #include <linux/types.h>
  #include <linux/input.h>
  
 -#define MATRIX_MAX_ROWS               16
 -#define MATRIX_MAX_COLS               16
 +#define MATRIX_MAX_ROWS               32
 +#define MATRIX_MAX_COLS               32
  
  #define KEY(row, col, val)    ((((row) & (MATRIX_MAX_ROWS - 1)) << 24) |\
                                 (((col) & (MATRIX_MAX_COLS - 1)) << 16) |\
-                                (val & 0xffff))
+                                ((val) & 0xffff))
  
  #define KEY_ROW(k)            (((k) >> 24) & 0xff)
  #define KEY_COL(k)            (((k) >> 16) & 0xff)