aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/input.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-01-07 17:45:47 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-07 17:45:47 -0500
commit31b6ca0af758a88e5e769b48cc6dde037ee37b96 (patch)
treee1968d7168affb25e33e2be2d1d102f94af98af0 /drivers/input/input.c
parent56b85f32d530d09d6805488ad00775d4e0e3baab (diff)
parent554738da71004d96e06fb75f4772dfc3b0f47810 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (58 commits) Input: wacom_w8001 - support pen or touch only devices Input: wacom_w8001 - use __set_bit to set keybits Input: bu21013_ts - fix misuse of logical operation in place of bitop Input: i8042 - add Acer Aspire 5100 to the Dritek list Input: wacom - add support for digitizer in Lenovo W700 Input: psmouse - disable the synaptics extension on OLPC machines Input: psmouse - fix up Synaptics comment Input: synaptics - ignore bogus mt packet Input: synaptics - add multi-finger and semi-mt support Input: synaptics - report clickpad property input: mt: Document interface updates Input: fix double equality sign in uevent Input: introduce device properties hid: egalax: Add support for Wetab (726b) Input: include MT library as source for kerneldoc MAINTAINERS: Update input-mt entry hid: egalax: Add support for Samsung NB30 netbook hid: egalax: Document the new devices in Kconfig hid: egalax: Add support for Wetab hid: egalax: Convert to MT slots ... Fixed up trivial conflict in drivers/input/keyboard/Kconfig
Diffstat (limited to 'drivers/input/input.c')
-rw-r--r--drivers/input/input.c91
1 files changed, 32 insertions, 59 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c
index db409d6bd5d2..7985114beac7 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>
@@ -958,10 +960,8 @@ static int input_attach_handler(struct input_dev *dev, struct input_handler *han
958 960
959 error = handler->connect(handler, dev, id); 961 error = handler->connect(handler, dev, id);
960 if (error && error != -ENODEV) 962 if (error && error != -ENODEV)
961 printk(KERN_ERR 963 pr_err("failed to attach handler %s to device %s, error: %d\n",
962 "input: failed to attach handler %s to device %s, " 964 handler->name, kobject_name(&dev->dev.kobj), error);
963 "error: %d\n",
964 handler->name, kobject_name(&dev->dev.kobj), error);
965 965
966 return error; 966 return error;
967} 967}
@@ -1109,6 +1109,8 @@ static int input_devices_seq_show(struct seq_file *seq, void *v)
1109 seq_printf(seq, "%s ", handle->name); 1109 seq_printf(seq, "%s ", handle->name);
1110 seq_putc(seq, '\n'); 1110 seq_putc(seq, '\n');
1111 1111
1112 input_seq_print_bitmap(seq, "PROP", dev->propbit, INPUT_PROP_MAX);
1113
1112 input_seq_print_bitmap(seq, "EV", dev->evbit, EV_MAX); 1114 input_seq_print_bitmap(seq, "EV", dev->evbit, EV_MAX);
1113 if (test_bit(EV_KEY, dev->evbit)) 1115 if (test_bit(EV_KEY, dev->evbit))
1114 input_seq_print_bitmap(seq, "KEY", dev->keybit, KEY_MAX); 1116 input_seq_print_bitmap(seq, "KEY", dev->keybit, KEY_MAX);
@@ -1332,11 +1334,26 @@ static ssize_t input_dev_show_modalias(struct device *dev,
1332} 1334}
1333static DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL); 1335static DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL);
1334 1336
1337static int input_print_bitmap(char *buf, int buf_size, unsigned long *bitmap,
1338 int max, int add_cr);
1339
1340static ssize_t input_dev_show_properties(struct device *dev,
1341 struct device_attribute *attr,
1342 char *buf)
1343{
1344 struct input_dev *input_dev = to_input_dev(dev);
1345 int len = input_print_bitmap(buf, PAGE_SIZE, input_dev->propbit,
1346 INPUT_PROP_MAX, true);
1347 return min_t(int, len, PAGE_SIZE);
1348}
1349static DEVICE_ATTR(properties, S_IRUGO, input_dev_show_properties, NULL);
1350
1335static struct attribute *input_dev_attrs[] = { 1351static struct attribute *input_dev_attrs[] = {
1336 &dev_attr_name.attr, 1352 &dev_attr_name.attr,
1337 &dev_attr_phys.attr, 1353 &dev_attr_phys.attr,
1338 &dev_attr_uniq.attr, 1354 &dev_attr_uniq.attr,
1339 &dev_attr_modalias.attr, 1355 &dev_attr_modalias.attr,
1356 &dev_attr_properties.attr,
1340 NULL 1357 NULL
1341}; 1358};
1342 1359
@@ -1470,7 +1487,7 @@ static int input_add_uevent_bm_var(struct kobj_uevent_env *env,
1470{ 1487{
1471 int len; 1488 int len;
1472 1489
1473 if (add_uevent_var(env, "%s=", name)) 1490 if (add_uevent_var(env, "%s", name))
1474 return -ENOMEM; 1491 return -ENOMEM;
1475 1492
1476 len = input_print_bitmap(&env->buf[env->buflen - 1], 1493 len = input_print_bitmap(&env->buf[env->buflen - 1],
@@ -1536,6 +1553,8 @@ static int input_dev_uevent(struct device *device, struct kobj_uevent_env *env)
1536 if (dev->uniq) 1553 if (dev->uniq)
1537 INPUT_ADD_HOTPLUG_VAR("UNIQ=\"%s\"", dev->uniq); 1554 INPUT_ADD_HOTPLUG_VAR("UNIQ=\"%s\"", dev->uniq);
1538 1555
1556 INPUT_ADD_HOTPLUG_BM_VAR("PROP=", dev->propbit, INPUT_PROP_MAX);
1557
1539 INPUT_ADD_HOTPLUG_BM_VAR("EV=", dev->evbit, EV_MAX); 1558 INPUT_ADD_HOTPLUG_BM_VAR("EV=", dev->evbit, EV_MAX);
1540 if (test_bit(EV_KEY, dev->evbit)) 1559 if (test_bit(EV_KEY, dev->evbit))
1541 INPUT_ADD_HOTPLUG_BM_VAR("KEY=", dev->keybit, KEY_MAX); 1560 INPUT_ADD_HOTPLUG_BM_VAR("KEY=", dev->keybit, KEY_MAX);
@@ -1725,52 +1744,6 @@ void input_free_device(struct input_dev *dev)
1725EXPORT_SYMBOL(input_free_device); 1744EXPORT_SYMBOL(input_free_device);
1726 1745
1727/** 1746/**
1728 * input_mt_create_slots() - create MT input slots
1729 * @dev: input device supporting MT events and finger tracking
1730 * @num_slots: number of slots used by the device
1731 *
1732 * This function allocates all necessary memory for MT slot handling in the
1733 * input device, and adds ABS_MT_SLOT to the device capabilities. All slots
1734 * are initially marked as unused by setting ABS_MT_TRACKING_ID to -1.
1735 */
1736int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)
1737{
1738 int i;
1739
1740 if (!num_slots)
1741 return 0;
1742
1743 dev->mt = kcalloc(num_slots, sizeof(struct input_mt_slot), GFP_KERNEL);
1744 if (!dev->mt)
1745 return -ENOMEM;
1746
1747 dev->mtsize = num_slots;
1748 input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0);
1749
1750 /* Mark slots as 'unused' */
1751 for (i = 0; i < num_slots; i++)
1752 dev->mt[i].abs[ABS_MT_TRACKING_ID - ABS_MT_FIRST] = -1;
1753
1754 return 0;
1755}
1756EXPORT_SYMBOL(input_mt_create_slots);
1757
1758/**
1759 * input_mt_destroy_slots() - frees the MT slots of the input device
1760 * @dev: input device with allocated MT slots
1761 *
1762 * This function is only needed in error path as the input core will
1763 * automatically free the MT slots when the device is destroyed.
1764 */
1765void input_mt_destroy_slots(struct input_dev *dev)
1766{
1767 kfree(dev->mt);
1768 dev->mt = NULL;
1769 dev->mtsize = 0;
1770}
1771EXPORT_SYMBOL(input_mt_destroy_slots);
1772
1773/**
1774 * input_set_capability - mark device as capable of a certain event 1747 * input_set_capability - mark device as capable of a certain event
1775 * @dev: device that is capable of emitting or accepting event 1748 * @dev: device that is capable of emitting or accepting event
1776 * @type: type of the event (EV_KEY, EV_REL, etc...) 1749 * @type: type of the event (EV_KEY, EV_REL, etc...)
@@ -1819,9 +1792,8 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int
1819 break; 1792 break;
1820 1793
1821 default: 1794 default:
1822 printk(KERN_ERR 1795 pr_err("input_set_capability: unknown type %u (code %u)\n",
1823 "input_set_capability: unknown type %u (code %u)\n", 1796 type, code);
1824 type, code);
1825 dump_stack(); 1797 dump_stack();
1826 return; 1798 return;
1827 } 1799 }
@@ -1903,8 +1875,9 @@ int input_register_device(struct input_dev *dev)
1903 return error; 1875 return error;
1904 1876
1905 path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL); 1877 path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL);
1906 printk(KERN_INFO "input: %s as %s\n", 1878 pr_info("%s as %s\n",
1907 dev->name ? dev->name : "Unspecified device", path ? path : "N/A"); 1879 dev->name ? dev->name : "Unspecified device",
1880 path ? path : "N/A");
1908 kfree(path); 1881 kfree(path);
1909 1882
1910 error = mutex_lock_interruptible(&input_mutex); 1883 error = mutex_lock_interruptible(&input_mutex);
@@ -2186,7 +2159,7 @@ static int __init input_init(void)
2186 2159
2187 err = class_register(&input_class); 2160 err = class_register(&input_class);
2188 if (err) { 2161 if (err) {
2189 printk(KERN_ERR "input: unable to register input_dev class\n"); 2162 pr_err("unable to register input_dev class\n");
2190 return err; 2163 return err;
2191 } 2164 }
2192 2165
@@ -2196,7 +2169,7 @@ static int __init input_init(void)
2196 2169
2197 err = register_chrdev(INPUT_MAJOR, "input", &input_fops); 2170 err = register_chrdev(INPUT_MAJOR, "input", &input_fops);
2198 if (err) { 2171 if (err) {
2199 printk(KERN_ERR "input: unable to register char major %d", INPUT_MAJOR); 2172 pr_err("unable to register char major %d", INPUT_MAJOR);
2200 goto fail2; 2173 goto fail2;
2201 } 2174 }
2202 2175