aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/input.c')
-rw-r--r--drivers/input/input.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 41168d5f8c1..e2aad0a5182 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -582,7 +582,8 @@ static int input_fetch_keycode(struct input_dev *dev, int scancode)
582} 582}
583 583
584static int input_default_getkeycode(struct input_dev *dev, 584static int input_default_getkeycode(struct input_dev *dev,
585 int scancode, int *keycode) 585 unsigned int scancode,
586 unsigned int *keycode)
586{ 587{
587 if (!dev->keycodesize) 588 if (!dev->keycodesize)
588 return -EINVAL; 589 return -EINVAL;
@@ -596,7 +597,8 @@ static int input_default_getkeycode(struct input_dev *dev,
596} 597}
597 598
598static int input_default_setkeycode(struct input_dev *dev, 599static int input_default_setkeycode(struct input_dev *dev,
599 int scancode, int keycode) 600 unsigned int scancode,
601 unsigned int keycode)
600{ 602{
601 int old_keycode; 603 int old_keycode;
602 int i; 604 int i;
@@ -654,11 +656,9 @@ static int input_default_setkeycode(struct input_dev *dev,
654 * This function should be called by anyone interested in retrieving current 656 * This function should be called by anyone interested in retrieving current
655 * keymap. Presently keyboard and evdev handlers use it. 657 * keymap. Presently keyboard and evdev handlers use it.
656 */ 658 */
657int input_get_keycode(struct input_dev *dev, int scancode, int *keycode) 659int input_get_keycode(struct input_dev *dev,
660 unsigned int scancode, unsigned int *keycode)
658{ 661{
659 if (scancode < 0)
660 return -EINVAL;
661
662 return dev->getkeycode(dev, scancode, keycode); 662 return dev->getkeycode(dev, scancode, keycode);
663} 663}
664EXPORT_SYMBOL(input_get_keycode); 664EXPORT_SYMBOL(input_get_keycode);
@@ -672,16 +672,14 @@ EXPORT_SYMBOL(input_get_keycode);
672 * This function should be called by anyone needing to update current 672 * This function should be called by anyone needing to update current
673 * keymap. Presently keyboard and evdev handlers use it. 673 * keymap. Presently keyboard and evdev handlers use it.
674 */ 674 */
675int input_set_keycode(struct input_dev *dev, int scancode, int keycode) 675int input_set_keycode(struct input_dev *dev,
676 unsigned int scancode, unsigned int keycode)
676{ 677{
677 unsigned long flags; 678 unsigned long flags;
678 int old_keycode; 679 int old_keycode;
679 int retval; 680 int retval;
680 681
681 if (scancode < 0) 682 if (keycode > KEY_MAX)
682 return -EINVAL;
683
684 if (keycode < 0 || keycode > KEY_MAX)
685 return -EINVAL; 683 return -EINVAL;
686 684
687 spin_lock_irqsave(&dev->event_lock, flags); 685 spin_lock_irqsave(&dev->event_lock, flags);
@@ -1881,35 +1879,37 @@ static int input_open_file(struct inode *inode, struct file *file)
1881 const struct file_operations *old_fops, *new_fops = NULL; 1879 const struct file_operations *old_fops, *new_fops = NULL;
1882 int err; 1880 int err;
1883 1881
1884 lock_kernel(); 1882 err = mutex_lock_interruptible(&input_mutex);
1883 if (err)
1884 return err;
1885
1885 /* No load-on-demand here? */ 1886 /* No load-on-demand here? */
1886 handler = input_table[iminor(inode) >> 5]; 1887 handler = input_table[iminor(inode) >> 5];
1887 if (!handler || !(new_fops = fops_get(handler->fops))) { 1888 if (handler)
1888 err = -ENODEV; 1889 new_fops = fops_get(handler->fops);
1889 goto out; 1890
1890 } 1891 mutex_unlock(&input_mutex);
1891 1892
1892 /* 1893 /*
1893 * That's _really_ odd. Usually NULL ->open means "nothing special", 1894 * That's _really_ odd. Usually NULL ->open means "nothing special",
1894 * not "no device". Oh, well... 1895 * not "no device". Oh, well...
1895 */ 1896 */
1896 if (!new_fops->open) { 1897 if (!new_fops || !new_fops->open) {
1897 fops_put(new_fops); 1898 fops_put(new_fops);
1898 err = -ENODEV; 1899 err = -ENODEV;
1899 goto out; 1900 goto out;
1900 } 1901 }
1902
1901 old_fops = file->f_op; 1903 old_fops = file->f_op;
1902 file->f_op = new_fops; 1904 file->f_op = new_fops;
1903 1905
1904 err = new_fops->open(inode, file); 1906 err = new_fops->open(inode, file);
1905
1906 if (err) { 1907 if (err) {
1907 fops_put(file->f_op); 1908 fops_put(file->f_op);
1908 file->f_op = fops_get(old_fops); 1909 file->f_op = fops_get(old_fops);
1909 } 1910 }
1910 fops_put(old_fops); 1911 fops_put(old_fops);
1911out: 1912out:
1912 unlock_kernel();
1913 return err; 1913 return err;
1914} 1914}
1915 1915