Commit 1e0afb28 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: fix formatting to better follow CodingStyle

Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent f60d2b11
...@@ -78,14 +78,19 @@ static int evdev_fasync(int fd, struct file *file, int on) ...@@ -78,14 +78,19 @@ static int evdev_fasync(int fd, struct file *file, int on)
{ {
int retval; int retval;
struct evdev_list *list = file->private_data; struct evdev_list *list = file->private_data;
retval = fasync_helper(fd, file, on, &list->fasync); retval = fasync_helper(fd, file, on, &list->fasync);
return retval < 0 ? retval : 0; return retval < 0 ? retval : 0;
} }
static int evdev_flush(struct file * file, fl_owner_t id) static int evdev_flush(struct file *file, fl_owner_t id)
{ {
struct evdev_list *list = file->private_data; struct evdev_list *list = file->private_data;
if (!list->evdev->exist) return -ENODEV;
if (!list->evdev->exist)
return -ENODEV;
return input_flush_device(&list->evdev->handle, file); return input_flush_device(&list->evdev->handle, file);
} }
...@@ -300,6 +305,7 @@ static ssize_t evdev_read(struct file * file, char __user * buffer, size_t count ...@@ -300,6 +305,7 @@ static ssize_t evdev_read(struct file * file, char __user * buffer, size_t count
static unsigned int evdev_poll(struct file *file, poll_table *wait) static unsigned int evdev_poll(struct file *file, poll_table *wait)
{ {
struct evdev_list *list = file->private_data; struct evdev_list *list = file->private_data;
poll_wait(file, &list->evdev->wait, wait); poll_wait(file, &list->evdev->wait, wait);
return ((list->head == list->tail) ? 0 : (POLLIN | POLLRDNORM)) | return ((list->head == list->tail) ? 0 : (POLLIN | POLLRDNORM)) |
(list->evdev->exist ? 0 : (POLLHUP | POLLERR)); (list->evdev->exist ? 0 : (POLLHUP | POLLERR));
......
...@@ -64,11 +64,13 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in ...@@ -64,11 +64,13 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
case EV_SYN: case EV_SYN:
switch (code) { switch (code) {
case SYN_CONFIG: case SYN_CONFIG:
if (dev->event) dev->event(dev, type, code, value); if (dev->event)
dev->event(dev, type, code, value);
break; break;
case SYN_REPORT: case SYN_REPORT:
if (dev->sync) return; if (dev->sync)
return;
dev->sync = 1; dev->sync = 1;
break; break;
} }
...@@ -137,7 +139,8 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in ...@@ -137,7 +139,8 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
if (code > MSC_MAX || !test_bit(code, dev->mscbit)) if (code > MSC_MAX || !test_bit(code, dev->mscbit))
return; return;
if (dev->event) dev->event(dev, type, code, value); if (dev->event)
dev->event(dev, type, code, value);
break; break;
...@@ -147,7 +150,9 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in ...@@ -147,7 +150,9 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
return; return;
change_bit(code, dev->led); change_bit(code, dev->led);
if (dev->event) dev->event(dev, type, code, value);
if (dev->event)
dev->event(dev, type, code, value);
break; break;
...@@ -159,21 +164,25 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in ...@@ -159,21 +164,25 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
if (!!test_bit(code, dev->snd) != !!value) if (!!test_bit(code, dev->snd) != !!value)
change_bit(code, dev->snd); change_bit(code, dev->snd);
if (dev->event) dev->event(dev, type, code, value); if (dev->event)
dev->event(dev, type, code, value);
break; break;
case EV_REP: case EV_REP:
if (code > REP_MAX || value < 0 || dev->rep[code] == value) return; if (code > REP_MAX || value < 0 || dev->rep[code] == value)
return;
dev->rep[code] = value; dev->rep[code] = value;
if (dev->event) dev->event(dev, type, code, value); if (dev->event)
dev->event(dev, type, code, value);
break; break;
case EV_FF: case EV_FF:
if (dev->event) dev->event(dev, type, code, value); if (dev->event)
dev->event(dev, type, code, value);
break; break;
} }
...@@ -336,9 +345,11 @@ static inline void input_wakeup_procfs_readers(void) ...@@ -336,9 +345,11 @@ static inline void input_wakeup_procfs_readers(void)
static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait) static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait)
{ {
int state = input_devices_state; int state = input_devices_state;
poll_wait(file, &input_devices_poll_wait, wait); poll_wait(file, &input_devices_poll_wait, wait);
if (state != input_devices_state) if (state != input_devices_state)
return POLLIN | POLLRDNORM; return POLLIN | POLLRDNORM;
return 0; return 0;
} }
...@@ -972,9 +983,10 @@ int input_register_device(struct input_dev *dev) ...@@ -972,9 +983,10 @@ int input_register_device(struct input_dev *dev)
void input_unregister_device(struct input_dev *dev) void input_unregister_device(struct input_dev *dev)
{ {
struct list_head * node, * next; struct list_head *node, *next;
if (!dev) return; if (!dev)
return;
del_timer_sync(&dev->timer); del_timer_sync(&dev->timer);
...@@ -1005,7 +1017,8 @@ void input_register_handler(struct input_handler *handler) ...@@ -1005,7 +1017,8 @@ void input_register_handler(struct input_handler *handler)
struct input_handle *handle; struct input_handle *handle;
struct input_device_id *id; struct input_device_id *id;
if (!handler) return; if (!handler)
return;
INIT_LIST_HEAD(&handler->h_list); INIT_LIST_HEAD(&handler->h_list);
...@@ -1025,7 +1038,7 @@ void input_register_handler(struct input_handler *handler) ...@@ -1025,7 +1038,7 @@ void input_register_handler(struct input_handler *handler)
void input_unregister_handler(struct input_handler *handler) void input_unregister_handler(struct input_handler *handler)
{ {
struct list_head * node, * next; struct list_head *node, *next;
list_for_each_safe(node, next, &handler->h_list) { list_for_each_safe(node, next, &handler->h_list) {
struct input_handle * handle = to_handle_h(node); struct input_handle * handle = to_handle_h(node);
......
...@@ -81,10 +81,7 @@ static int joydev_correct(int value, struct js_corr *corr) ...@@ -81,10 +81,7 @@ static int joydev_correct(int value, struct js_corr *corr)
return 0; return 0;
} }
if (value < -32767) return -32767; return value < -32767 ? -32767 : (value > 32767 ? 32767 : value);
if (value > 32767) return 32767;
return value;
} }
static void joydev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) static void joydev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
...@@ -96,7 +93,8 @@ static void joydev_event(struct input_handle *handle, unsigned int type, unsigne ...@@ -96,7 +93,8 @@ static void joydev_event(struct input_handle *handle, unsigned int type, unsigne
switch (type) { switch (type) {
case EV_KEY: case EV_KEY:
if (code < BTN_MISC || value == 2) return; if (code < BTN_MISC || value == 2)
return;
event.type = JS_EVENT_BUTTON; event.type = JS_EVENT_BUTTON;
event.number = joydev->keymap[code - BTN_MISC]; event.number = joydev->keymap[code - BTN_MISC];
event.value = value; event.value = value;
...@@ -106,7 +104,8 @@ static void joydev_event(struct input_handle *handle, unsigned int type, unsigne ...@@ -106,7 +104,8 @@ static void joydev_event(struct input_handle *handle, unsigned int type, unsigne
event.type = JS_EVENT_AXIS; event.type = JS_EVENT_AXIS;
event.number = joydev->absmap[code]; event.number = joydev->absmap[code];
event.value = joydev_correct(value, joydev->corr + event.number); event.value = joydev_correct(value, joydev->corr + event.number);
if (event.value == joydev->abs[event.number]) return; if (event.value == joydev->abs[event.number])
return;
joydev->abs[event.number] = event.value; joydev->abs[event.number] = event.value;
break; break;
...@@ -134,7 +133,9 @@ static int joydev_fasync(int fd, struct file *file, int on) ...@@ -134,7 +133,9 @@ static int joydev_fasync(int fd, struct file *file, int on)
{ {
int retval; int retval;
struct joydev_list *list = file->private_data; struct joydev_list *list = file->private_data;
retval = fasync_helper(fd, file, on, &list->fasync); retval = fasync_helper(fd, file, on, &list->fasync);
return retval < 0 ? retval : 0; return retval < 0 ? retval : 0;
} }
...@@ -222,12 +223,12 @@ static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, lo ...@@ -222,12 +223,12 @@ static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, lo
return sizeof(struct JS_DATA_TYPE); return sizeof(struct JS_DATA_TYPE);
} }
if (list->startup == joydev->nabs + joydev->nkey if (list->startup == joydev->nabs + joydev->nkey &&
&& list->head == list->tail && (file->f_flags & O_NONBLOCK)) list->head == list->tail && (file->f_flags & O_NONBLOCK))
return -EAGAIN; return -EAGAIN;
retval = wait_event_interruptible(list->joydev->wait, retval = wait_event_interruptible(list->joydev->wait,
!list->joydev->exist || !list->joydev->exist ||
list->startup < joydev->nabs + joydev->nkey || list->startup < joydev->nabs + joydev->nkey ||
list->head != list->tail); list->head != list->tail);
...@@ -276,8 +277,9 @@ static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, lo ...@@ -276,8 +277,9 @@ static ssize_t joydev_read(struct file *file, char __user *buf, size_t count, lo
static unsigned int joydev_poll(struct file *file, poll_table *wait) static unsigned int joydev_poll(struct file *file, poll_table *wait)
{ {
struct joydev_list *list = file->private_data; struct joydev_list *list = file->private_data;
poll_wait(file, &list->joydev->wait, wait); poll_wait(file, &list->joydev->wait, wait);
return ((list->head != list->tail || list->startup < list->joydev->nabs + list->joydev->nkey) ? return ((list->head != list->tail || list->startup < list->joydev->nabs + list->joydev->nkey) ?
(POLLIN | POLLRDNORM) : 0) | (list->joydev->exist ? 0 : (POLLHUP | POLLERR)); (POLLIN | POLLRDNORM) : 0) | (list->joydev->exist ? 0 : (POLLHUP | POLLERR));
} }
...@@ -291,20 +293,26 @@ static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __u ...@@ -291,20 +293,26 @@ static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __u
case JS_SET_CAL: case JS_SET_CAL:
return copy_from_user(&joydev->glue.JS_CORR, argp, return copy_from_user(&joydev->glue.JS_CORR, argp,
sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0; sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0;
case JS_GET_CAL: case JS_GET_CAL:
return copy_to_user(argp, &joydev->glue.JS_CORR, return copy_to_user(argp, &joydev->glue.JS_CORR,
sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0; sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0;
case JS_SET_TIMEOUT: case JS_SET_TIMEOUT:
return get_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp); return get_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp);
case JS_GET_TIMEOUT: case JS_GET_TIMEOUT:
return put_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp); return put_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp);
case JSIOCGVERSION: case JSIOCGVERSION:
return put_user(JS_VERSION, (__u32 __user *) argp); return put_user(JS_VERSION, (__u32 __user *) argp);
case JSIOCGAXES: case JSIOCGAXES:
return put_user(joydev->nabs, (__u8 __user *) argp); return put_user(joydev->nabs, (__u8 __user *) argp);
case JSIOCGBUTTONS: case JSIOCGBUTTONS:
return put_user(joydev->nkey, (__u8 __user *) argp); return put_user(joydev->nkey, (__u8 __user *) argp);
case JSIOCSCORR: case JSIOCSCORR:
if (copy_from_user(joydev->corr, argp, if (copy_from_user(joydev->corr, argp,
sizeof(joydev->corr[0]) * joydev->nabs)) sizeof(joydev->corr[0]) * joydev->nabs))
...@@ -314,38 +322,49 @@ static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __u ...@@ -314,38 +322,49 @@ static int joydev_ioctl_common(struct joydev *joydev, unsigned int cmd, void __u
joydev->abs[i] = joydev_correct(dev->abs[j], joydev->corr + i); joydev->abs[i] = joydev_correct(dev->abs[j], joydev->corr + i);
} }
return 0; return 0;
case JSIOCGCORR: case JSIOCGCORR:
return copy_to_user(argp, joydev->corr, return copy_to_user(argp, joydev->corr,
sizeof(joydev->corr[0]) * joydev->nabs) ? -EFAULT : 0; sizeof(joydev->corr[0]) * joydev->nabs) ? -EFAULT : 0;
case JSIOCSAXMAP: case JSIOCSAXMAP:
if (copy_from_user(joydev->abspam, argp, sizeof(__u8) * (ABS_MAX + 1))) if (copy_from_user(joydev->abspam, argp, sizeof(__u8) * (ABS_MAX + 1)))
return -EFAULT; return -EFAULT;
for (i = 0; i < joydev->nabs; i++) { for (i = 0; i < joydev->nabs; i++) {
if (joydev->abspam[i] > ABS_MAX) return -EINVAL; if (joydev->abspam[i] > ABS_MAX)
return -EINVAL;
joydev->absmap[joydev->abspam[i]] = i; joydev->absmap[joydev->abspam[i]] = i;
} }
return 0; return 0;
case JSIOCGAXMAP: case JSIOCGAXMAP:
return copy_to_user(argp, joydev->abspam, return copy_to_user(argp, joydev->abspam,
sizeof(__u8) * (ABS_MAX + 1)) ? -EFAULT : 0; sizeof(__u8) * (ABS_MAX + 1)) ? -EFAULT : 0;
case JSIOCSBTNMAP: case JSIOCSBTNMAP:
if (copy_from_user(joydev->keypam, argp, sizeof(__u16) * (KEY_MAX - BTN_MISC + 1))) if (copy_from_user(joydev->keypam, argp, sizeof(__u16) * (KEY_MAX - BTN_MISC + 1)))
return -EFAULT; return -EFAULT;
for (i = 0; i < joydev->nkey; i++) { for (i = 0; i < joydev->nkey; i++) {
if (joydev->keypam[i] > KEY_MAX || joydev->keypam[i] < BTN_MISC) return -EINVAL; if (joydev->keypam[i] > KEY_MAX || joydev->keypam[i] < BTN_MISC)
return -EINVAL;
joydev->keymap[joydev->keypam[i] - BTN_MISC] = i; joydev->keymap[joydev->keypam[i] - BTN_MISC] = i;
} }
return 0; return 0;
case JSIOCGBTNMAP: case JSIOCGBTNMAP:
return copy_to_user(argp, joydev->keypam, return copy_to_user(argp, joydev->keypam,
sizeof(__u16) * (KEY_MAX - BTN_MISC + 1)) ? -EFAULT : 0; sizeof(__u16) * (KEY_MAX - BTN_MISC + 1)) ? -EFAULT : 0;
default: default:
if ((cmd & ~(_IOC_SIZEMASK << _IOC_SIZESHIFT)) == JSIOCGNAME(0)) { if ((cmd & ~(_IOC_SIZEMASK << _IOC_SIZESHIFT)) == JSIOCGNAME(0)) {
int len; int len;
if (!dev->name) return 0; if (!dev->name)
return 0;
len = strlen(dev->name) + 1; len = strlen(dev->name) + 1;
if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); if (len > _IOC_SIZE(cmd))
if (copy_to_user(argp, dev->name, len)) return -EFAULT; len = _IOC_SIZE(cmd);
if (copy_to_user(argp, dev->name, len))
return -EFAULT;
return len; return len;
} }
} }
...@@ -362,7 +381,9 @@ static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned lo ...@@ -362,7 +381,9 @@ static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned lo
struct JS_DATA_SAVE_TYPE_32 ds32; struct JS_DATA_SAVE_TYPE_32 ds32;
int err; int err;
if (!joydev->exist) return -ENODEV; if (!joydev->exist)
return -ENODEV;
switch(cmd) { switch(cmd) {
case JS_SET_TIMELIMIT: case JS_SET_TIMELIMIT:
err = get_user(tmp32, (s32 __user *) arg); err = get_user(tmp32, (s32 __user *) arg);
...@@ -395,8 +416,7 @@ static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned lo ...@@ -395,8 +416,7 @@ static long joydev_compat_ioctl(struct file *file, unsigned int cmd, unsigned lo
ds32.JS_SAVE = joydev->glue.JS_SAVE; ds32.JS_SAVE = joydev->glue.JS_SAVE;
ds32.JS_CORR = joydev->glue.JS_CORR; ds32.JS_CORR = joydev->glue.JS_CORR;
err = copy_to_user(argp, &ds32, err = copy_to_user(argp, &ds32, sizeof(ds32)) ? -EFAULT : 0;
sizeof(ds32)) ? -EFAULT : 0;
break; break;
default: default:
...@@ -412,7 +432,8 @@ static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd ...@@ -412,7 +432,8 @@ static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
struct joydev *joydev = list->joydev; struct joydev *joydev = list->joydev;
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
if (!joydev->exist) return -ENODEV; if (!joydev->exist)
return -ENODEV;
switch(cmd) { switch(cmd) {
case JS_SET_TIMELIMIT: case JS_SET_TIMELIMIT:
...@@ -546,8 +567,8 @@ static struct input_device_id joydev_blacklist[] = { ...@@ -546,8 +567,8 @@ static struct input_device_id joydev_blacklist[] = {
.flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT, .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT,
.evbit = { BIT(EV_KEY) }, .evbit = { BIT(EV_KEY) },
.keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) }, .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) },
}, /* Avoid itouchpads, touchscreens and tablets */ }, /* Avoid itouchpads, touchscreens and tablets */
{ }, /* Terminating entry */ { } /* Terminating entry */
}; };
static struct input_device_id joydev_ids[] = { static struct input_device_id joydev_ids[] = {
...@@ -566,7 +587,7 @@ static struct input_device_id joydev_ids[] = { ...@@ -566,7 +587,7 @@ static struct input_device_id joydev_ids[] = {
.evbit = { BIT(EV_ABS) }, .evbit = { BIT(EV_ABS) },
.absbit = { BIT(ABS_THROTTLE) }, .absbit = { BIT(ABS_THROTTLE) },
}, },
{ }, /* Terminating entry */ { } /* Terminating entry */
}; };
MODULE_DEVICE_TABLE(input, joydev_ids); MODULE_DEVICE_TABLE(input, joydev_ids);
...@@ -579,7 +600,7 @@ static struct input_handler joydev_handler = { ...@@ -579,7 +600,7 @@ static struct input_handler joydev_handler = {
.minor = JOYDEV_MINOR_BASE, .minor = JOYDEV_MINOR_BASE,
.name = "joydev", .name = "joydev",
.id_table = joydev_ids, .id_table = joydev_ids,
.blacklist = joydev_blacklist, .blacklist = joydev_blacklist,
}; };
static int __init joydev_init(void) static int __init joydev_init(void)
......
...@@ -123,7 +123,9 @@ static void mousedev_touchpad_event(struct input_dev *dev, struct mousedev *mous ...@@ -123,7 +123,9 @@ static void mousedev_touchpad_event(struct input_dev *dev, struct mousedev *mous
if (mousedev->touch) { if (mousedev->touch) {
size = dev->absmax[ABS_X] - dev->absmin[ABS_X]; size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
if (size == 0) size = 256 * 2; if (size == 0)
size = 256 * 2;
switch (code) { switch (code) {
case ABS_X: case ABS_X:
fx(0) = value; fx(0) = value;
...@@ -155,18 +157,24 @@ static void mousedev_abs_event(struct input_dev *dev, struct mousedev *mousedev, ...@@ -155,18 +157,24 @@ static void mousedev_abs_event(struct input_dev *dev, struct mousedev *mousedev,
switch (code) { switch (code) {
case ABS_X: case ABS_X:
size = dev->absmax[ABS_X] - dev->absmin[ABS_X]; size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
if (size == 0) size = xres ? : 1; if (size == 0)
if (value > dev->absmax[ABS_X]) value = dev->absmax[ABS_X]; size = xres ? : 1;
if (value < dev->absmin[ABS_X]) value = dev->absmin[ABS_X]; if (value > dev->absmax[ABS_X])
value = dev->absmax[ABS_X];
if (value < dev->absmin[ABS_X])
value = dev->absmin[ABS_X];
mousedev->packet.x = ((value - dev->absmin[ABS_X]) * xres) / size; mousedev->packet.x = ((value - dev->absmin[ABS_X]) * xres) / size;
mousedev->packet.abs_event = 1; mousedev->packet.abs_event = 1;
break; break;
case ABS_Y: case ABS_Y:
size = dev->absmax[ABS_Y] - dev->absmin[ABS_Y]; size = dev->absmax[ABS_Y] - dev->absmin[ABS_Y];
if (size == 0) size = yres ? : 1; if (size == 0)
if (value > dev->absmax[ABS_Y]) value = dev->absmax[ABS_Y]; size = yres ? : 1;
if (value < dev->absmin[ABS_Y]) value = dev->absmin[ABS_Y]; if (value > dev->absmax[ABS_Y])
value = dev->absmax[ABS_Y];
if (value < dev->absmin[ABS_Y])
value = dev->absmin[ABS_Y];
mousedev->packet.y = yres - ((value - dev->absmin[ABS_Y]) * yres) / size; mousedev->packet.y = yres - ((value - dev->absmin[ABS_Y]) * yres) / size;
mousedev->packet.abs_event = 1; mousedev->packet.abs_event = 1;
break; break;
...@@ -202,7 +210,7 @@ static void mousedev_key_event(struct mousedev *mousedev, unsigned int code, int ...@@ -202,7 +210,7 @@ static void mousedev_key_event(struct mousedev *mousedev, unsigned int code, int
case BTN_SIDE: index = 3; break; case BTN_SIDE: index = 3; break;
case BTN_4: case BTN_4:
case BTN_EXTRA: index = 4; break; case BTN_EXTRA: index = 4; break;
default: return; default: return;
} }
if (value) { if (value) {
...@@ -285,10 +293,9 @@ static void mousedev_touchpad_touch(struct mousedev *mousedev, int value) ...@@ -285,10 +293,9 @@ static void mousedev_touchpad_touch(struct mousedev *mousedev, int value)
mousedev->touch = mousedev->pkt_count = 0; mousedev->touch = mousedev->pkt_count = 0;
mousedev->frac_dx = 0; mousedev->frac_dx = 0;
mousedev->frac_dy = 0; mousedev->frac_dy = 0;
}
else } else if (!mousedev->touch)
if (!mousedev->touch) mousedev->touch = jiffies;
mousedev->touch = jiffies;
} }
static void mousedev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) static void mousedev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
...@@ -327,7 +334,7 @@ static void mousedev_event(struct input_handle *handle, unsigned int type, unsig ...@@ -327,7 +334,7 @@ static void mousedev_event(struct input_handle *handle, unsigned int type, unsig
mousedev->pkt_count++; mousedev->pkt_count++;
/* Input system eats duplicate events, but we need all of them /* Input system eats duplicate events, but we need all of them
* to do correct averaging so apply present one forward * to do correct averaging so apply present one forward
*/ */
fx(0) = fx(1); fx(0) = fx(1);
fy(0) = fy(1); fy(0) = fy(1);
} }
...@@ -346,7 +353,9 @@ static int mousedev_fasync(int fd, struct file *file, int on) ...@@ -346,7 +353,9 @@ static int mousedev_fasync(int fd, struct file *file, int on)
{ {
int retval; int retval;
struct mousedev_list *list = file->private_data; struct mousedev_list *list = file->private_data;
retval = fasync_helper(fd, file, on, &list->fasync); retval = fasync_helper(fd, file, on, &list->fasync);
return retval < 0 ? retval : 0; return retval < 0 ? retval : 0;
} }
...@@ -507,14 +516,16 @@ static ssize_t mousedev_write(struct file * file, const char __user * buffer, si ...@@ -507,14 +516,16 @@ static ssize_t mousedev_write(struct file * file, const char __user * buffer, si
list->imexseq = 0; list->imexseq = 0;
list->mode = MOUSEDEV_EMUL_EXPS; list->mode = MOUSEDEV_EMUL_EXPS;
} }
} else list->imexseq = 0; } else
list->imexseq = 0;
if (c == mousedev_imps_seq[list->impsseq]) { if (c == mousedev_imps_seq[list->impsseq]) {
if (++list->impsseq == MOUSEDEV_SEQ_LEN) { if (++list->impsseq == MOUSEDEV_SEQ_LEN) {
list->impsseq = 0; list->impsseq = 0;
list->mode = MOUSEDEV_EMUL_IMPS; list->mode = MOUSEDEV_EMUL_IMPS;
} }
} else list->impsseq = 0; } else
list->impsseq = 0;
list->ps2[0] = 0xfa; list->ps2[0] = 0xfa;
...@@ -598,6 +609,7 @@ static ssize_t mousedev_read(struct file * file, char __user * buffer, size_t co ...@@ -598,6 +609,7 @@ static ssize_t mousedev_read(struct file * file, char __user * buffer, size_t co
static unsigned int mousedev_poll(struct file *file, poll_table *wait) static unsigned int mousedev_poll(struct file *file, poll_table *wait)
{ {
struct mousedev_list *list = file->private_data; struct mousedev_list *list = file->private_data;
poll_wait(file, &list->mousedev->wait, wait); poll_wait(file, &list->mousedev->wait, wait);
return ((list->ready || list->buffer) ? (POLLIN | POLLRDNORM) : 0) | return ((list->ready || list->buffer) ? (POLLIN | POLLRDNORM) : 0) |
(list->mousedev->exist ? 0 : (POLLHUP | POLLERR)); (list->mousedev->exist ? 0 : (POLLHUP | POLLERR));
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
* e-mail - mail your message to <jsimmons@infradead.org>. * e-mail - mail your message to <jsimmons@infradead.org>.
*/ */
#define TSDEV_MINOR_BASE 128 #define TSDEV_MINOR_BASE 128
#define TSDEV_MINORS 32 #define TSDEV_MINORS 32
/* First 16 devices are h3600_ts compatible; second 16 are h3600_tsraw */ /* First 16 devices are h3600_ts compatible; second 16 are h3600_tsraw */
#define TSDEV_MINOR_MASK 15 #define TSDEV_MINOR_MASK 15
...@@ -230,6 +230,7 @@ static ssize_t tsdev_read(struct file *file, char __user *buffer, size_t count, ...@@ -230,6 +230,7 @@ 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) static unsigned int tsdev_poll(struct file *file, poll_table * wait)
{ {
struct tsdev_list *list = file->private_data; struct tsdev_list *list = file->private_data;
poll_wait(file, &list->tsdev->wait, wait); poll_wait(file, &list->tsdev->wait, wait);
return ((list->head == list->tail) ? 0 : (POLLIN | POLLRDNORM)) | return ((list->head == list->tail) ? 0 : (POLLIN | POLLRDNORM)) |
(list->tsdev->exist ? 0 : (POLLHUP | POLLERR)); (list->tsdev->exist ? 0 : (POLLHUP | POLLERR));
...@@ -248,11 +249,13 @@ static int tsdev_ioctl(struct inode *inode, struct file *file, ...@@ -248,11 +249,13 @@ static int tsdev_ioctl(struct inode *inode, struct file *file,
sizeof (struct ts_calibration))) sizeof (struct ts_calibration)))
retval = -EFAULT; retval = -EFAULT;
break; break;
case TS_SET_CAL: case TS_SET_CAL:
if (copy_from_user (&tsdev->cal, (void __user *)arg, if (copy_from_user (&tsdev->cal, (void __user *)arg,
sizeof (struct ts_calibration))) sizeof (struct ts_calibration)))
retval = -EFAULT; retval = -EFAULT;
break; break;
default: default:
retval = -EINVAL; retval = -EINVAL;
break; break;
...@@ -284,9 +287,11 @@ static void tsdev_event(struct input_handle *handle, unsigned int type, ...@@ -284,9 +287,11 @@ static void tsdev_event(struct input_handle *handle, unsigned int type,
case ABS_X: case ABS_X:
tsdev->x = value; tsdev->x = value;
break; break;
case ABS_Y: case ABS_Y:
tsdev->y = value; tsdev->y = value;
break; break;
case ABS_PRESSURE: case ABS_PRESSURE:
if (value > handle->dev->absmax[ABS_PRESSURE]) if (value > handle->dev->absmax[ABS_PRESSURE])
value = handle->dev->absmax[ABS_PRESSURE]; value = handle->dev->absmax[ABS_PRESSURE];
...@@ -307,6 +312,7 @@ static void tsdev_event(struct input_handle *handle, unsigned int type, ...@@ -307,6 +312,7 @@ static void tsdev_event(struct input_handle *handle, unsigned int type,
else if (tsdev->x > xres) else if (tsdev->x > xres)
tsdev->x = xres; tsdev->x = xres;
break; break;
case REL_Y: case REL_Y:
tsdev->y += value; tsdev->y += value;
if (tsdev->y < 0) if (tsdev->y < 0)
...@@ -323,6 +329,7 @@ static void tsdev_event(struct input_handle *handle, unsigned int type, ...@@ -323,6 +329,7 @@ static void tsdev_event(struct input_handle *handle, unsigned int type,
case 0: case 0:
tsdev->pressure = 0; tsdev->pressure = 0;
break; break;
case 1: case 1:
if (!tsdev->pressure) if (!tsdev->pressure)
tsdev->pressure = 1; tsdev->pressure = 1;
...@@ -370,9 +377,8 @@ static struct input_handle *tsdev_connect(struct input_handler *handler, ...@@ -370,9 +377,8 @@ static struct input_handle *tsdev_connect(struct input_handler *handler,
struct class_device *cdev; struct class_device *cdev;
int minor, delta; int minor, delta;
for (minor = 0; minor < TSDEV_MINORS/2 && tsdev_table[minor]; for (minor = 0; minor < TSDEV_MINORS / 2 && tsdev_table[minor]; minor++);
minor++); if (minor >= TSDEV_MINORS / 2) {
if (minor >= TSDEV_MINORS/2) {
printk(KERN_ERR printk(KERN_ERR
"tsdev: You have way too many touchscreens\n"); "tsdev: You have way too many touchscreens\n");
return NULL; return NULL;
...@@ -444,22 +450,22 @@ static struct input_device_id tsdev_ids[] = { ...@@ -444,22 +450,22 @@ static struct input_device_id tsdev_ids[] = {
.evbit = { BIT(EV_KEY) | BIT(EV_REL) }, .evbit = { BIT(EV_KEY) | BIT(EV_REL) },
.keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) }, .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) },
.relbit = { BIT(REL_X) | BIT(REL_Y) }, .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, .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
.evbit = { BIT(EV_KEY) | BIT(EV_ABS) }, .evbit = { BIT(EV_KEY) | BIT(EV_ABS) },
.keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) }, .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) },
.absbit = { BIT(ABS_X) | BIT(ABS_Y) }, .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, .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
.evbit = { BIT(EV_ABS) }, .evbit = { BIT(EV_ABS) },
.absbit = { BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) }, .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); MODULE_DEVICE_TABLE(input, tsdev_ids);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment