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.c331
1 files changed, 209 insertions, 122 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c
index ab6982056518..da38d97a51b1 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -10,9 +10,11 @@
10 * the Free Software Foundation. 10 * the Free Software Foundation.
11 */ 11 */
12 12
13#define pr_fmt(fmt) KBUILD_BASENAME ": " fmt
14
13#include <linux/init.h> 15#include <linux/init.h>
14#include <linux/types.h> 16#include <linux/types.h>
15#include <linux/input.h> 17#include <linux/input/mt.h>
16#include <linux/module.h> 18#include <linux/module.h>
17#include <linux/slab.h> 19#include <linux/slab.h>
18#include <linux/random.h> 20#include <linux/random.h>
@@ -24,7 +26,6 @@
24#include <linux/device.h> 26#include <linux/device.h>
25#include <linux/mutex.h> 27#include <linux/mutex.h>
26#include <linux/rcupdate.h> 28#include <linux/rcupdate.h>
27#include <linux/smp_lock.h>
28#include "input-compat.h" 29#include "input-compat.h"
29 30
30MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); 31MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
@@ -171,7 +172,7 @@ static int input_handle_abs_event(struct input_dev *dev,
171 if (code == ABS_MT_SLOT) { 172 if (code == ABS_MT_SLOT) {
172 /* 173 /*
173 * "Stage" the event; we'll flush it later, when we 174 * "Stage" the event; we'll flush it later, when we
174 * get actiual touch data. 175 * get actual touch data.
175 */ 176 */
176 if (*pval >= 0 && *pval < dev->mtsize) 177 if (*pval >= 0 && *pval < dev->mtsize)
177 dev->slot = *pval; 178 dev->slot = *pval;
@@ -188,7 +189,7 @@ static int input_handle_abs_event(struct input_dev *dev,
188 pold = &mtslot->abs[code - ABS_MT_FIRST]; 189 pold = &mtslot->abs[code - ABS_MT_FIRST];
189 } else { 190 } else {
190 /* 191 /*
191 * Bypass filtering for multitouch events when 192 * Bypass filtering for multi-touch events when
192 * not employing slots. 193 * not employing slots.
193 */ 194 */
194 pold = NULL; 195 pold = NULL;
@@ -450,7 +451,6 @@ int input_grab_device(struct input_handle *handle)
450 } 451 }
451 452
452 rcu_assign_pointer(dev->grab, handle); 453 rcu_assign_pointer(dev->grab, handle);
453 synchronize_rcu();
454 454
455 out: 455 out:
456 mutex_unlock(&dev->mutex); 456 mutex_unlock(&dev->mutex);
@@ -634,78 +634,141 @@ static void input_disconnect_device(struct input_dev *dev)
634 spin_unlock_irq(&dev->event_lock); 634 spin_unlock_irq(&dev->event_lock);
635} 635}
636 636
637static int input_fetch_keycode(struct input_dev *dev, int scancode) 637/**
638 * input_scancode_to_scalar() - converts scancode in &struct input_keymap_entry
639 * @ke: keymap entry containing scancode to be converted.
640 * @scancode: pointer to the location where converted scancode should
641 * be stored.
642 *
643 * This function is used to convert scancode stored in &struct keymap_entry
644 * into scalar form understood by legacy keymap handling methods. These
645 * methods expect scancodes to be represented as 'unsigned int'.
646 */
647int input_scancode_to_scalar(const struct input_keymap_entry *ke,
648 unsigned int *scancode)
649{
650 switch (ke->len) {
651 case 1:
652 *scancode = *((u8 *)ke->scancode);
653 break;
654
655 case 2:
656 *scancode = *((u16 *)ke->scancode);
657 break;
658
659 case 4:
660 *scancode = *((u32 *)ke->scancode);
661 break;
662
663 default:
664 return -EINVAL;
665 }
666
667 return 0;
668}
669EXPORT_SYMBOL(input_scancode_to_scalar);
670
671/*
672 * Those routines handle the default case where no [gs]etkeycode() is
673 * defined. In this case, an array indexed by the scancode is used.
674 */
675
676static unsigned int input_fetch_keycode(struct input_dev *dev,
677 unsigned int index)
638{ 678{
639 switch (dev->keycodesize) { 679 switch (dev->keycodesize) {
640 case 1: 680 case 1:
641 return ((u8 *)dev->keycode)[scancode]; 681 return ((u8 *)dev->keycode)[index];
642 682
643 case 2: 683 case 2:
644 return ((u16 *)dev->keycode)[scancode]; 684 return ((u16 *)dev->keycode)[index];
645 685
646 default: 686 default:
647 return ((u32 *)dev->keycode)[scancode]; 687 return ((u32 *)dev->keycode)[index];
648 } 688 }
649} 689}
650 690
651static int input_default_getkeycode(struct input_dev *dev, 691static int input_default_getkeycode(struct input_dev *dev,
652 unsigned int scancode, 692 struct input_keymap_entry *ke)
653 unsigned int *keycode)
654{ 693{
694 unsigned int index;
695 int error;
696
655 if (!dev->keycodesize) 697 if (!dev->keycodesize)
656 return -EINVAL; 698 return -EINVAL;
657 699
658 if (scancode >= dev->keycodemax) 700 if (ke->flags & INPUT_KEYMAP_BY_INDEX)
701 index = ke->index;
702 else {
703 error = input_scancode_to_scalar(ke, &index);
704 if (error)
705 return error;
706 }
707
708 if (index >= dev->keycodemax)
659 return -EINVAL; 709 return -EINVAL;
660 710
661 *keycode = input_fetch_keycode(dev, scancode); 711 ke->keycode = input_fetch_keycode(dev, index);
712 ke->index = index;
713 ke->len = sizeof(index);
714 memcpy(ke->scancode, &index, sizeof(index));
662 715
663 return 0; 716 return 0;
664} 717}
665 718
666static int input_default_setkeycode(struct input_dev *dev, 719static int input_default_setkeycode(struct input_dev *dev,
667 unsigned int scancode, 720 const struct input_keymap_entry *ke,
668 unsigned int keycode) 721 unsigned int *old_keycode)
669{ 722{
670 int old_keycode; 723 unsigned int index;
724 int error;
671 int i; 725 int i;
672 726
673 if (scancode >= dev->keycodemax) 727 if (!dev->keycodesize)
674 return -EINVAL; 728 return -EINVAL;
675 729
676 if (!dev->keycodesize) 730 if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
731 index = ke->index;
732 } else {
733 error = input_scancode_to_scalar(ke, &index);
734 if (error)
735 return error;
736 }
737
738 if (index >= dev->keycodemax)
677 return -EINVAL; 739 return -EINVAL;
678 740
679 if (dev->keycodesize < sizeof(keycode) && (keycode >> (dev->keycodesize * 8))) 741 if (dev->keycodesize < sizeof(ke->keycode) &&
742 (ke->keycode >> (dev->keycodesize * 8)))
680 return -EINVAL; 743 return -EINVAL;
681 744
682 switch (dev->keycodesize) { 745 switch (dev->keycodesize) {
683 case 1: { 746 case 1: {
684 u8 *k = (u8 *)dev->keycode; 747 u8 *k = (u8 *)dev->keycode;
685 old_keycode = k[scancode]; 748 *old_keycode = k[index];
686 k[scancode] = keycode; 749 k[index] = ke->keycode;
687 break; 750 break;
688 } 751 }
689 case 2: { 752 case 2: {
690 u16 *k = (u16 *)dev->keycode; 753 u16 *k = (u16 *)dev->keycode;
691 old_keycode = k[scancode]; 754 *old_keycode = k[index];
692 k[scancode] = keycode; 755 k[index] = ke->keycode;
693 break; 756 break;
694 } 757 }
695 default: { 758 default: {
696 u32 *k = (u32 *)dev->keycode; 759 u32 *k = (u32 *)dev->keycode;
697 old_keycode = k[scancode]; 760 *old_keycode = k[index];
698 k[scancode] = keycode; 761 k[index] = ke->keycode;
699 break; 762 break;
700 } 763 }
701 } 764 }
702 765
703 __clear_bit(old_keycode, dev->keybit); 766 __clear_bit(*old_keycode, dev->keybit);
704 __set_bit(keycode, dev->keybit); 767 __set_bit(ke->keycode, dev->keybit);
705 768
706 for (i = 0; i < dev->keycodemax; i++) { 769 for (i = 0; i < dev->keycodemax; i++) {
707 if (input_fetch_keycode(dev, i) == old_keycode) { 770 if (input_fetch_keycode(dev, i) == *old_keycode) {
708 __set_bit(old_keycode, dev->keybit); 771 __set_bit(*old_keycode, dev->keybit);
709 break; /* Setting the bit twice is useless, so break */ 772 break; /* Setting the bit twice is useless, so break */
710 } 773 }
711 } 774 }
@@ -716,21 +779,18 @@ static int input_default_setkeycode(struct input_dev *dev,
716/** 779/**
717 * input_get_keycode - retrieve keycode currently mapped to a given scancode 780 * input_get_keycode - retrieve keycode currently mapped to a given scancode
718 * @dev: input device which keymap is being queried 781 * @dev: input device which keymap is being queried
719 * @scancode: scancode (or its equivalent for device in question) for which 782 * @ke: keymap entry
720 * keycode is needed
721 * @keycode: result
722 * 783 *
723 * This function should be called by anyone interested in retrieving current 784 * This function should be called by anyone interested in retrieving current
724 * keymap. Presently keyboard and evdev handlers use it. 785 * keymap. Presently evdev handlers use it.
725 */ 786 */
726int input_get_keycode(struct input_dev *dev, 787int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke)
727 unsigned int scancode, unsigned int *keycode)
728{ 788{
729 unsigned long flags; 789 unsigned long flags;
730 int retval; 790 int retval;
731 791
732 spin_lock_irqsave(&dev->event_lock, flags); 792 spin_lock_irqsave(&dev->event_lock, flags);
733 retval = dev->getkeycode(dev, scancode, keycode); 793 retval = dev->getkeycode(dev, ke);
734 spin_unlock_irqrestore(&dev->event_lock, flags); 794 spin_unlock_irqrestore(&dev->event_lock, flags);
735 795
736 return retval; 796 return retval;
@@ -738,31 +798,26 @@ int input_get_keycode(struct input_dev *dev,
738EXPORT_SYMBOL(input_get_keycode); 798EXPORT_SYMBOL(input_get_keycode);
739 799
740/** 800/**
741 * input_get_keycode - assign new keycode to a given scancode 801 * input_set_keycode - attribute a keycode to a given scancode
742 * @dev: input device which keymap is being updated 802 * @dev: input device which keymap is being updated
743 * @scancode: scancode (or its equivalent for device in question) 803 * @ke: new keymap entry
744 * @keycode: new keycode to be assigned to the scancode
745 * 804 *
746 * This function should be called by anyone needing to update current 805 * This function should be called by anyone needing to update current
747 * keymap. Presently keyboard and evdev handlers use it. 806 * keymap. Presently keyboard and evdev handlers use it.
748 */ 807 */
749int input_set_keycode(struct input_dev *dev, 808int input_set_keycode(struct input_dev *dev,
750 unsigned int scancode, unsigned int keycode) 809 const struct input_keymap_entry *ke)
751{ 810{
752 unsigned long flags; 811 unsigned long flags;
753 unsigned int old_keycode; 812 unsigned int old_keycode;
754 int retval; 813 int retval;
755 814
756 if (keycode > KEY_MAX) 815 if (ke->keycode > KEY_MAX)
757 return -EINVAL; 816 return -EINVAL;
758 817
759 spin_lock_irqsave(&dev->event_lock, flags); 818 spin_lock_irqsave(&dev->event_lock, flags);
760 819
761 retval = dev->getkeycode(dev, scancode, &old_keycode); 820 retval = dev->setkeycode(dev, ke, &old_keycode);
762 if (retval)
763 goto out;
764
765 retval = dev->setkeycode(dev, scancode, keycode);
766 if (retval) 821 if (retval)
767 goto out; 822 goto out;
768 823
@@ -848,10 +903,8 @@ static int input_attach_handler(struct input_dev *dev, struct input_handler *han
848 903
849 error = handler->connect(handler, dev, id); 904 error = handler->connect(handler, dev, id);
850 if (error && error != -ENODEV) 905 if (error && error != -ENODEV)
851 printk(KERN_ERR 906 pr_err("failed to attach handler %s to device %s, error: %d\n",
852 "input: failed to attach handler %s to device %s, " 907 handler->name, kobject_name(&dev->dev.kobj), error);
853 "error: %d\n",
854 handler->name, kobject_name(&dev->dev.kobj), error);
855 908
856 return error; 909 return error;
857} 910}
@@ -999,6 +1052,8 @@ static int input_devices_seq_show(struct seq_file *seq, void *v)
999 seq_printf(seq, "%s ", handle->name); 1052 seq_printf(seq, "%s ", handle->name);
1000 seq_putc(seq, '\n'); 1053 seq_putc(seq, '\n');
1001 1054
1055 input_seq_print_bitmap(seq, "PROP", dev->propbit, INPUT_PROP_MAX);
1056
1002 input_seq_print_bitmap(seq, "EV", dev->evbit, EV_MAX); 1057 input_seq_print_bitmap(seq, "EV", dev->evbit, EV_MAX);
1003 if (test_bit(EV_KEY, dev->evbit)) 1058 if (test_bit(EV_KEY, dev->evbit))
1004 input_seq_print_bitmap(seq, "KEY", dev->keybit, KEY_MAX); 1059 input_seq_print_bitmap(seq, "KEY", dev->keybit, KEY_MAX);
@@ -1222,11 +1277,26 @@ static ssize_t input_dev_show_modalias(struct device *dev,
1222} 1277}
1223static DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL); 1278static DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL);
1224 1279
1280static int input_print_bitmap(char *buf, int buf_size, unsigned long *bitmap,
1281 int max, int add_cr);
1282
1283static ssize_t input_dev_show_properties(struct device *dev,
1284 struct device_attribute *attr,
1285 char *buf)
1286{
1287 struct input_dev *input_dev = to_input_dev(dev);
1288 int len = input_print_bitmap(buf, PAGE_SIZE, input_dev->propbit,
1289 INPUT_PROP_MAX, true);
1290 return min_t(int, len, PAGE_SIZE);
1291}
1292static DEVICE_ATTR(properties, S_IRUGO, input_dev_show_properties, NULL);
1293
1225static struct attribute *input_dev_attrs[] = { 1294static struct attribute *input_dev_attrs[] = {
1226 &dev_attr_name.attr, 1295 &dev_attr_name.attr,
1227 &dev_attr_phys.attr, 1296 &dev_attr_phys.attr,
1228 &dev_attr_uniq.attr, 1297 &dev_attr_uniq.attr,
1229 &dev_attr_modalias.attr, 1298 &dev_attr_modalias.attr,
1299 &dev_attr_properties.attr,
1230 NULL 1300 NULL
1231}; 1301};
1232 1302
@@ -1360,7 +1430,7 @@ static int input_add_uevent_bm_var(struct kobj_uevent_env *env,
1360{ 1430{
1361 int len; 1431 int len;
1362 1432
1363 if (add_uevent_var(env, "%s=", name)) 1433 if (add_uevent_var(env, "%s", name))
1364 return -ENOMEM; 1434 return -ENOMEM;
1365 1435
1366 len = input_print_bitmap(&env->buf[env->buflen - 1], 1436 len = input_print_bitmap(&env->buf[env->buflen - 1],
@@ -1426,6 +1496,8 @@ static int input_dev_uevent(struct device *device, struct kobj_uevent_env *env)
1426 if (dev->uniq) 1496 if (dev->uniq)
1427 INPUT_ADD_HOTPLUG_VAR("UNIQ=\"%s\"", dev->uniq); 1497 INPUT_ADD_HOTPLUG_VAR("UNIQ=\"%s\"", dev->uniq);
1428 1498
1499 INPUT_ADD_HOTPLUG_BM_VAR("PROP=", dev->propbit, INPUT_PROP_MAX);
1500
1429 INPUT_ADD_HOTPLUG_BM_VAR("EV=", dev->evbit, EV_MAX); 1501 INPUT_ADD_HOTPLUG_BM_VAR("EV=", dev->evbit, EV_MAX);
1430 if (test_bit(EV_KEY, dev->evbit)) 1502 if (test_bit(EV_KEY, dev->evbit))
1431 INPUT_ADD_HOTPLUG_BM_VAR("KEY=", dev->keybit, KEY_MAX); 1503 INPUT_ADD_HOTPLUG_BM_VAR("KEY=", dev->keybit, KEY_MAX);
@@ -1469,8 +1541,7 @@ static int input_dev_uevent(struct device *device, struct kobj_uevent_env *env)
1469 } \ 1541 } \
1470 } while (0) 1542 } while (0)
1471 1543
1472#ifdef CONFIG_PM 1544static void input_dev_toggle(struct input_dev *dev, bool activate)
1473static void input_dev_reset(struct input_dev *dev, bool activate)
1474{ 1545{
1475 if (!dev->event) 1546 if (!dev->event)
1476 return; 1547 return;
@@ -1484,12 +1555,44 @@ static void input_dev_reset(struct input_dev *dev, bool activate)
1484 } 1555 }
1485} 1556}
1486 1557
1558/**
1559 * input_reset_device() - reset/restore the state of input device
1560 * @dev: input device whose state needs to be reset
1561 *
1562 * This function tries to reset the state of an opened input device and
1563 * bring internal state and state if the hardware in sync with each other.
1564 * We mark all keys as released, restore LED state, repeat rate, etc.
1565 */
1566void input_reset_device(struct input_dev *dev)
1567{
1568 mutex_lock(&dev->mutex);
1569
1570 if (dev->users) {
1571 input_dev_toggle(dev, true);
1572
1573 /*
1574 * Keys that have been pressed at suspend time are unlikely
1575 * to be still pressed when we resume.
1576 */
1577 spin_lock_irq(&dev->event_lock);
1578 input_dev_release_keys(dev);
1579 spin_unlock_irq(&dev->event_lock);
1580 }
1581
1582 mutex_unlock(&dev->mutex);
1583}
1584EXPORT_SYMBOL(input_reset_device);
1585
1586#ifdef CONFIG_PM
1487static int input_dev_suspend(struct device *dev) 1587static int input_dev_suspend(struct device *dev)
1488{ 1588{
1489 struct input_dev *input_dev = to_input_dev(dev); 1589 struct input_dev *input_dev = to_input_dev(dev);
1490 1590
1491 mutex_lock(&input_dev->mutex); 1591 mutex_lock(&input_dev->mutex);
1492 input_dev_reset(input_dev, false); 1592
1593 if (input_dev->users)
1594 input_dev_toggle(input_dev, false);
1595
1493 mutex_unlock(&input_dev->mutex); 1596 mutex_unlock(&input_dev->mutex);
1494 1597
1495 return 0; 1598 return 0;
@@ -1499,18 +1602,7 @@ static int input_dev_resume(struct device *dev)
1499{ 1602{
1500 struct input_dev *input_dev = to_input_dev(dev); 1603 struct input_dev *input_dev = to_input_dev(dev);
1501 1604
1502 mutex_lock(&input_dev->mutex); 1605 input_reset_device(input_dev);
1503 input_dev_reset(input_dev, true);
1504
1505 /*
1506 * Keys that have been pressed at suspend time are unlikely
1507 * to be still pressed when we resume.
1508 */
1509 spin_lock_irq(&input_dev->event_lock);
1510 input_dev_release_keys(input_dev);
1511 spin_unlock_irq(&input_dev->event_lock);
1512
1513 mutex_unlock(&input_dev->mutex);
1514 1606
1515 return 0; 1607 return 0;
1516} 1608}
@@ -1595,52 +1687,6 @@ void input_free_device(struct input_dev *dev)
1595EXPORT_SYMBOL(input_free_device); 1687EXPORT_SYMBOL(input_free_device);
1596 1688
1597/** 1689/**
1598 * input_mt_create_slots() - create MT input slots
1599 * @dev: input device supporting MT events and finger tracking
1600 * @num_slots: number of slots used by the device
1601 *
1602 * This function allocates all necessary memory for MT slot handling in the
1603 * input device, and adds ABS_MT_SLOT to the device capabilities. All slots
1604 * are initially marked as unused iby setting ABS_MT_TRACKING_ID to -1.
1605 */
1606int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)
1607{
1608 int i;
1609
1610 if (!num_slots)
1611 return 0;
1612
1613 dev->mt = kcalloc(num_slots, sizeof(struct input_mt_slot), GFP_KERNEL);
1614 if (!dev->mt)
1615 return -ENOMEM;
1616
1617 dev->mtsize = num_slots;
1618 input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0);
1619
1620 /* Mark slots as 'unused' */
1621 for (i = 0; i < num_slots; i++)
1622 dev->mt[i].abs[ABS_MT_TRACKING_ID - ABS_MT_FIRST] = -1;
1623
1624 return 0;
1625}
1626EXPORT_SYMBOL(input_mt_create_slots);
1627
1628/**
1629 * input_mt_destroy_slots() - frees the MT slots of the input device
1630 * @dev: input device with allocated MT slots
1631 *
1632 * This function is only needed in error path as the input core will
1633 * automatically free the MT slots when the device is destroyed.
1634 */
1635void input_mt_destroy_slots(struct input_dev *dev)
1636{
1637 kfree(dev->mt);
1638 dev->mt = NULL;
1639 dev->mtsize = 0;
1640}
1641EXPORT_SYMBOL(input_mt_destroy_slots);
1642
1643/**
1644 * input_set_capability - mark device as capable of a certain event 1690 * input_set_capability - mark device as capable of a certain event
1645 * @dev: device that is capable of emitting or accepting event 1691 * @dev: device that is capable of emitting or accepting event
1646 * @type: type of the event (EV_KEY, EV_REL, etc...) 1692 * @type: type of the event (EV_KEY, EV_REL, etc...)
@@ -1689,9 +1735,8 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int
1689 break; 1735 break;
1690 1736
1691 default: 1737 default:
1692 printk(KERN_ERR 1738 pr_err("input_set_capability: unknown type %u (code %u)\n",
1693 "input_set_capability: unknown type %u (code %u)\n", 1739 type, code);
1694 type, code);
1695 dump_stack(); 1740 dump_stack();
1696 return; 1741 return;
1697 } 1742 }
@@ -1700,6 +1745,42 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int
1700} 1745}
1701EXPORT_SYMBOL(input_set_capability); 1746EXPORT_SYMBOL(input_set_capability);
1702 1747
1748static unsigned int input_estimate_events_per_packet(struct input_dev *dev)
1749{
1750 int mt_slots;
1751 int i;
1752 unsigned int events;
1753
1754 if (dev->mtsize) {
1755 mt_slots = dev->mtsize;
1756 } else if (test_bit(ABS_MT_TRACKING_ID, dev->absbit)) {
1757 mt_slots = dev->absinfo[ABS_MT_TRACKING_ID].maximum -
1758 dev->absinfo[ABS_MT_TRACKING_ID].minimum + 1,
1759 mt_slots = clamp(mt_slots, 2, 32);
1760 } else if (test_bit(ABS_MT_POSITION_X, dev->absbit)) {
1761 mt_slots = 2;
1762 } else {
1763 mt_slots = 0;
1764 }
1765
1766 events = mt_slots + 1; /* count SYN_MT_REPORT and SYN_REPORT */
1767
1768 for (i = 0; i < ABS_CNT; i++) {
1769 if (test_bit(i, dev->absbit)) {
1770 if (input_is_mt_axis(i))
1771 events += mt_slots;
1772 else
1773 events++;
1774 }
1775 }
1776
1777 for (i = 0; i < REL_CNT; i++)
1778 if (test_bit(i, dev->relbit))
1779 events++;
1780
1781 return events;
1782}
1783
1703#define INPUT_CLEANSE_BITMASK(dev, type, bits) \ 1784#define INPUT_CLEANSE_BITMASK(dev, type, bits) \
1704 do { \ 1785 do { \
1705 if (!test_bit(EV_##type, dev->evbit)) \ 1786 if (!test_bit(EV_##type, dev->evbit)) \
@@ -1747,6 +1828,10 @@ int input_register_device(struct input_dev *dev)
1747 /* Make sure that bitmasks not mentioned in dev->evbit are clean. */ 1828 /* Make sure that bitmasks not mentioned in dev->evbit are clean. */
1748 input_cleanse_bitmasks(dev); 1829 input_cleanse_bitmasks(dev);
1749 1830
1831 if (!dev->hint_events_per_packet)
1832 dev->hint_events_per_packet =
1833 input_estimate_events_per_packet(dev);
1834
1750 /* 1835 /*
1751 * If delay and period are pre-set by the driver, then autorepeating 1836 * If delay and period are pre-set by the driver, then autorepeating
1752 * is handled by the driver itself and we don't do it in input.c. 1837 * is handled by the driver itself and we don't do it in input.c.
@@ -1773,8 +1858,9 @@ int input_register_device(struct input_dev *dev)
1773 return error; 1858 return error;
1774 1859
1775 path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL); 1860 path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL);
1776 printk(KERN_INFO "input: %s as %s\n", 1861 pr_info("%s as %s\n",
1777 dev->name ? dev->name : "Unspecified device", path ? path : "N/A"); 1862 dev->name ? dev->name : "Unspecified device",
1863 path ? path : "N/A");
1778 kfree(path); 1864 kfree(path);
1779 1865
1780 error = mutex_lock_interruptible(&input_mutex); 1866 error = mutex_lock_interruptible(&input_mutex);
@@ -2047,6 +2133,7 @@ out:
2047static const struct file_operations input_fops = { 2133static const struct file_operations input_fops = {
2048 .owner = THIS_MODULE, 2134 .owner = THIS_MODULE,
2049 .open = input_open_file, 2135 .open = input_open_file,
2136 .llseek = noop_llseek,
2050}; 2137};
2051 2138
2052static int __init input_init(void) 2139static int __init input_init(void)
@@ -2055,7 +2142,7 @@ static int __init input_init(void)
2055 2142
2056 err = class_register(&input_class); 2143 err = class_register(&input_class);
2057 if (err) { 2144 if (err) {
2058 printk(KERN_ERR "input: unable to register input_dev class\n"); 2145 pr_err("unable to register input_dev class\n");
2059 return err; 2146 return err;
2060 } 2147 }
2061 2148
@@ -2065,7 +2152,7 @@ static int __init input_init(void)
2065 2152
2066 err = register_chrdev(INPUT_MAJOR, "input", &input_fops); 2153 err = register_chrdev(INPUT_MAJOR, "input", &input_fops);
2067 if (err) { 2154 if (err) {
2068 printk(KERN_ERR "input: unable to register char major %d", INPUT_MAJOR); 2155 pr_err("unable to register char major %d", INPUT_MAJOR);
2069 goto fail2; 2156 goto fail2;
2070 } 2157 }
2071 2158