linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / input / tsdev.c
index 00e3929..ca15479 100644 (file)
@@ -35,7 +35,7 @@
  * e-mail - mail your message to <jsimmons@infradead.org>.
  */
 
-#define TSDEV_MINOR_BASE       128
+#define TSDEV_MINOR_BASE       128
 #define TSDEV_MINORS           32
 /* First 16 devices are h3600_ts compatible; second 16 are h3600_tsraw */
 #define TSDEV_MINOR_MASK       15
@@ -48,6 +48,7 @@
 #include <linux/init.h>
 #include <linux/input.h>
 #include <linux/major.h>
+#include <linux/config.h>
 #include <linux/smp_lock.h>
 #include <linux/random.h>
 #include <linux/time.h>
@@ -156,8 +157,9 @@ static int tsdev_open(struct inode *inode, struct file *file)
        if (i >= TSDEV_MINORS || !tsdev_table[i & TSDEV_MINOR_MASK])
                return -ENODEV;
 
-       if (!(list = kzalloc(sizeof(struct tsdev_list), GFP_KERNEL)))
+       if (!(list = kmalloc(sizeof(struct tsdev_list), GFP_KERNEL)))
                return -ENOMEM;
+       memset(list, 0, sizeof(struct tsdev_list));
 
        list->raw = (i >= TSDEV_MINORS/2) ? 1 : 0;
 
@@ -229,7 +231,6 @@ static ssize_t tsdev_read(struct file *file, char __user *buffer, size_t count,
 static unsigned int tsdev_poll(struct file *file, poll_table * wait)
 {
        struct tsdev_list *list = file->private_data;
-
        poll_wait(file, &list->tsdev->wait, wait);
        return ((list->head == list->tail) ? 0 : (POLLIN | POLLRDNORM)) |
                (list->tsdev->exist ? 0 : (POLLHUP | POLLERR));
@@ -248,13 +249,11 @@ static int tsdev_ioctl(struct inode *inode, struct file *file,
                                  sizeof (struct ts_calibration)))
                        retval = -EFAULT;
                break;
-
        case TS_SET_CAL:
                if (copy_from_user (&tsdev->cal, (void __user *)arg,
                                    sizeof (struct ts_calibration)))
                        retval = -EFAULT;
                break;
-
        default:
                retval = -EINVAL;
                break;
@@ -286,11 +285,9 @@ static void tsdev_event(struct input_handle *handle, unsigned int type,
                case ABS_X:
                        tsdev->x = value;
                        break;
-
                case ABS_Y:
                        tsdev->y = value;
                        break;
-
                case ABS_PRESSURE:
                        if (value > handle->dev->absmax[ABS_PRESSURE])
                                value = handle->dev->absmax[ABS_PRESSURE];
@@ -311,7 +308,6 @@ static void tsdev_event(struct input_handle *handle, unsigned int type,
                        else if (tsdev->x > xres)
                                tsdev->x = xres;
                        break;
-
                case REL_Y:
                        tsdev->y += value;
                        if (tsdev->y < 0)
@@ -328,7 +324,6 @@ static void tsdev_event(struct input_handle *handle, unsigned int type,
                        case 0:
                                tsdev->pressure = 0;
                                break;
-
                        case 1:
                                if (!tsdev->pressure)
                                        tsdev->pressure = 1;
@@ -376,15 +371,17 @@ static struct input_handle *tsdev_connect(struct input_handler *handler,
        struct class_device *cdev;
        int minor, delta;
 
-       for (minor = 0; minor < TSDEV_MINORS / 2 && tsdev_table[minor]; minor++);
-       if (minor >= TSDEV_MINORS / 2) {
+       for (minor = 0; minor < TSDEV_MINORS/2 && tsdev_table[minor];
+            minor++);
+       if (minor >= TSDEV_MINORS/2) {
                printk(KERN_ERR
                       "tsdev: You have way too many touchscreens\n");
                return NULL;
        }
 
-       if (!(tsdev = kzalloc(sizeof(struct tsdev), GFP_KERNEL)))
+       if (!(tsdev = kmalloc(sizeof(struct tsdev), GFP_KERNEL)))
                return NULL;
+       memset(tsdev, 0, sizeof(struct tsdev));
 
        INIT_LIST_HEAD(&tsdev->list);
        init_waitqueue_head(&tsdev->wait);
@@ -449,22 +446,22 @@ static struct input_device_id tsdev_ids[] = {
              .evbit    = { BIT(EV_KEY) | BIT(EV_REL) },
              .keybit   = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) },
              .relbit   = { BIT(REL_X) | BIT(REL_Y) },
-       }, /* A mouse like device, at least one button, two relative axes */
+        },/* A mouse like device, at least one button, two relative axes */
 
        {
              .flags    = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
              .evbit    = { BIT(EV_KEY) | BIT(EV_ABS) },
              .keybit   = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) },
              .absbit   = { BIT(ABS_X) | BIT(ABS_Y) },
-       }, /* A tablet like device, at least touch detection, two absolute axes */
+        },/* A tablet like device, at least touch detection, two absolute axes */
 
        {
              .flags    = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
              .evbit    = { BIT(EV_ABS) },
              .absbit   = { BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) },
-       }, /* A tablet like device with several gradations of pressure */
+        },/* A tablet like device with several gradations of pressure */
 
-       {} /* Terminating entry */
+       {},/* Terminating entry */
 };
 
 MODULE_DEVICE_TABLE(input, tsdev_ids);