input.c (e676c232e670e27d8b3783e1167f34288e17c83f) | input.c (99ac48f54a91d02140c497edc31dc57d4bc5c85d) |
---|---|
1/* 2 * The input core 3 * 4 * Copyright (c) 1999-2002 Vojtech Pavlik 5 */ 6 7/* 8 * This program is free software; you can redistribute it and/or modify it --- 7 unchanged lines hidden (view full) --- 16#include <linux/input.h> 17#include <linux/module.h> 18#include <linux/random.h> 19#include <linux/major.h> 20#include <linux/proc_fs.h> 21#include <linux/interrupt.h> 22#include <linux/poll.h> 23#include <linux/device.h> | 1/* 2 * The input core 3 * 4 * Copyright (c) 1999-2002 Vojtech Pavlik 5 */ 6 7/* 8 * This program is free software; you can redistribute it and/or modify it --- 7 unchanged lines hidden (view full) --- 16#include <linux/input.h> 17#include <linux/module.h> 18#include <linux/random.h> 19#include <linux/major.h> 20#include <linux/proc_fs.h> 21#include <linux/interrupt.h> 22#include <linux/poll.h> 23#include <linux/device.h> |
24#include <linux/mutex.h> | |
25 26MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); 27MODULE_DESCRIPTION("Input core"); 28MODULE_LICENSE("GPL"); 29 30EXPORT_SYMBOL(input_allocate_device); 31EXPORT_SYMBOL(input_register_device); 32EXPORT_SYMBOL(input_unregister_device); --- 187 unchanged lines hidden (view full) --- 220 handle->dev->grab = NULL; 221} 222 223int input_open_device(struct input_handle *handle) 224{ 225 struct input_dev *dev = handle->dev; 226 int err; 227 | 24 25MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); 26MODULE_DESCRIPTION("Input core"); 27MODULE_LICENSE("GPL"); 28 29EXPORT_SYMBOL(input_allocate_device); 30EXPORT_SYMBOL(input_register_device); 31EXPORT_SYMBOL(input_unregister_device); --- 187 unchanged lines hidden (view full) --- 219 handle->dev->grab = NULL; 220} 221 222int input_open_device(struct input_handle *handle) 223{ 224 struct input_dev *dev = handle->dev; 225 int err; 226 |
228 err = mutex_lock_interruptible(&dev->mutex); | 227 err = down_interruptible(&dev->sem); |
229 if (err) 230 return err; 231 232 handle->open++; 233 234 if (!dev->users++ && dev->open) 235 err = dev->open(dev); 236 237 if (err) 238 handle->open--; 239 | 228 if (err) 229 return err; 230 231 handle->open++; 232 233 if (!dev->users++ && dev->open) 234 err = dev->open(dev); 235 236 if (err) 237 handle->open--; 238 |
240 mutex_unlock(&dev->mutex); | 239 up(&dev->sem); |
241 242 return err; 243} 244 245int input_flush_device(struct input_handle* handle, struct file* file) 246{ 247 if (handle->dev->flush) 248 return handle->dev->flush(handle->dev, file); 249 250 return 0; 251} 252 253void input_close_device(struct input_handle *handle) 254{ 255 struct input_dev *dev = handle->dev; 256 257 input_release_device(handle); 258 | 240 241 return err; 242} 243 244int input_flush_device(struct input_handle* handle, struct file* file) 245{ 246 if (handle->dev->flush) 247 return handle->dev->flush(handle->dev, file); 248 249 return 0; 250} 251 252void input_close_device(struct input_handle *handle) 253{ 254 struct input_dev *dev = handle->dev; 255 256 input_release_device(handle); 257 |
259 mutex_lock(&dev->mutex); | 258 down(&dev->sem); |
260 261 if (!--dev->users && dev->close) 262 dev->close(dev); 263 handle->open--; 264 | 259 260 if (!--dev->users && dev->close) 261 dev->close(dev); 262 handle->open--; 263 |
265 mutex_unlock(&dev->mutex); | 264 up(&dev->sem); |
266} 267 268static void input_link_handle(struct input_handle *handle) 269{ 270 list_add_tail(&handle->d_node, &handle->dev->h_list); 271 list_add_tail(&handle->h_node, &handle->handler->h_list); 272} 273 --- 234 unchanged lines hidden (view full) --- 508#endif 509 510#define INPUT_DEV_STRING_ATTR_SHOW(name) \ 511static ssize_t input_dev_show_##name(struct class_device *dev, char *buf) \ 512{ \ 513 struct input_dev *input_dev = to_input_dev(dev); \ 514 int retval; \ 515 \ | 265} 266 267static void input_link_handle(struct input_handle *handle) 268{ 269 list_add_tail(&handle->d_node, &handle->dev->h_list); 270 list_add_tail(&handle->h_node, &handle->handler->h_list); 271} 272 --- 234 unchanged lines hidden (view full) --- 507#endif 508 509#define INPUT_DEV_STRING_ATTR_SHOW(name) \ 510static ssize_t input_dev_show_##name(struct class_device *dev, char *buf) \ 511{ \ 512 struct input_dev *input_dev = to_input_dev(dev); \ 513 int retval; \ 514 \ |
516 retval = mutex_lock_interruptible(&input_dev->mutex); \ | 515 retval = down_interruptible(&input_dev->sem); \ |
517 if (retval) \ 518 return retval; \ 519 \ 520 retval = sprintf(buf, "%s\n", input_dev->name ? input_dev->name : ""); \ 521 \ | 516 if (retval) \ 517 return retval; \ 518 \ 519 retval = sprintf(buf, "%s\n", input_dev->name ? input_dev->name : ""); \ 520 \ |
522 mutex_unlock(&input_dev->mutex); \ | 521 up(&input_dev->sem); \ |
523 \ 524 return retval; \ 525} \ 526static CLASS_DEVICE_ATTR(name, S_IRUGO, input_dev_show_##name, NULL); 527 528INPUT_DEV_STRING_ATTR_SHOW(name); 529INPUT_DEV_STRING_ATTR_SHOW(phys); 530INPUT_DEV_STRING_ATTR_SHOW(uniq); --- 255 unchanged lines hidden (view full) --- 786 787 if (!dev->dynalloc) { 788 printk(KERN_WARNING "input: device %s is statically allocated, will not register\n" 789 "Please convert to input_allocate_device() or contact dtor_core@ameritech.net\n", 790 dev->name ? dev->name : "<Unknown>"); 791 return -EINVAL; 792 } 793 | 522 \ 523 return retval; \ 524} \ 525static CLASS_DEVICE_ATTR(name, S_IRUGO, input_dev_show_##name, NULL); 526 527INPUT_DEV_STRING_ATTR_SHOW(name); 528INPUT_DEV_STRING_ATTR_SHOW(phys); 529INPUT_DEV_STRING_ATTR_SHOW(uniq); --- 255 unchanged lines hidden (view full) --- 785 786 if (!dev->dynalloc) { 787 printk(KERN_WARNING "input: device %s is statically allocated, will not register\n" 788 "Please convert to input_allocate_device() or contact dtor_core@ameritech.net\n", 789 dev->name ? dev->name : "<Unknown>"); 790 return -EINVAL; 791 } 792 |
794 mutex_init(&dev->mutex); | 793 init_MUTEX(&dev->sem); |
795 set_bit(EV_SYN, dev->evbit); 796 797 /* 798 * If delay and period are pre-set by the driver, then autorepeating 799 * is handled by the driver itself and we don't do it in input.c. 800 */ 801 802 init_timer(&dev->timer); --- 116 unchanged lines hidden (view full) --- 919 input_table[handler->minor >> 5] = NULL; 920 921 input_wakeup_procfs_readers(); 922} 923 924static int input_open_file(struct inode *inode, struct file *file) 925{ 926 struct input_handler *handler = input_table[iminor(inode) >> 5]; | 794 set_bit(EV_SYN, dev->evbit); 795 796 /* 797 * If delay and period are pre-set by the driver, then autorepeating 798 * is handled by the driver itself and we don't do it in input.c. 799 */ 800 801 init_timer(&dev->timer); --- 116 unchanged lines hidden (view full) --- 918 input_table[handler->minor >> 5] = NULL; 919 920 input_wakeup_procfs_readers(); 921} 922 923static int input_open_file(struct inode *inode, struct file *file) 924{ 925 struct input_handler *handler = input_table[iminor(inode) >> 5]; |
927 struct file_operations *old_fops, *new_fops = NULL; | 926 const struct file_operations *old_fops, *new_fops = NULL; |
928 int err; 929 930 /* No load-on-demand here? */ 931 if (!handler || !(new_fops = fops_get(handler->fops))) 932 return -ENODEV; 933 934 /* 935 * That's _really_ odd. Usually NULL ->open means "nothing special", --- 60 unchanged lines hidden --- | 927 int err; 928 929 /* No load-on-demand here? */ 930 if (!handler || !(new_fops = fops_get(handler->fops))) 931 return -ENODEV; 932 933 /* 934 * That's _really_ odd. Usually NULL ->open means "nothing special", --- 60 unchanged lines hidden --- |