diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-01-07 01:34:59 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-01-07 01:34:59 -0500 |
commit | 554738da71004d96e06fb75f4772dfc3b0f47810 (patch) | |
tree | 149a96ce3727025d3b9260961ec94ba8306db278 /drivers/input/input.c | |
parent | 7b4b30689d688d9ca2e5c3859db6bbe1c35e6014 (diff) | |
parent | a6d38f889750ed6290728a19d9dad577b147c6d0 (diff) |
Merge branch 'next' into for-linus
Conflicts:
include/linux/input.h
Diffstat (limited to 'drivers/input/input.c')
-rw-r--r-- | drivers/input/input.c | 91 |
1 files changed, 32 insertions, 59 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c index 5edc41aa08f8..f37da09a5e4c 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> |
@@ -959,10 +961,8 @@ static int input_attach_handler(struct input_dev *dev, struct input_handler *han | |||
959 | 961 | ||
960 | error = handler->connect(handler, dev, id); | 962 | error = handler->connect(handler, dev, id); |
961 | if (error && error != -ENODEV) | 963 | if (error && error != -ENODEV) |
962 | printk(KERN_ERR | 964 | pr_err("failed to attach handler %s to device %s, error: %d\n", |
963 | "input: failed to attach handler %s to device %s, " | 965 | handler->name, kobject_name(&dev->dev.kobj), error); |
964 | "error: %d\n", | ||
965 | handler->name, kobject_name(&dev->dev.kobj), error); | ||
966 | 966 | ||
967 | return error; | 967 | return error; |
968 | } | 968 | } |
@@ -1110,6 +1110,8 @@ static int input_devices_seq_show(struct seq_file *seq, void *v) | |||
1110 | seq_printf(seq, "%s ", handle->name); | 1110 | seq_printf(seq, "%s ", handle->name); |
1111 | seq_putc(seq, '\n'); | 1111 | seq_putc(seq, '\n'); |
1112 | 1112 | ||
1113 | input_seq_print_bitmap(seq, "PROP", dev->propbit, INPUT_PROP_MAX); | ||
1114 | |||
1113 | input_seq_print_bitmap(seq, "EV", dev->evbit, EV_MAX); | 1115 | input_seq_print_bitmap(seq, "EV", dev->evbit, EV_MAX); |
1114 | if (test_bit(EV_KEY, dev->evbit)) | 1116 | if (test_bit(EV_KEY, dev->evbit)) |
1115 | input_seq_print_bitmap(seq, "KEY", dev->keybit, KEY_MAX); | 1117 | input_seq_print_bitmap(seq, "KEY", dev->keybit, KEY_MAX); |
@@ -1333,11 +1335,26 @@ static ssize_t input_dev_show_modalias(struct device *dev, | |||
1333 | } | 1335 | } |
1334 | static DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL); | 1336 | static DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL); |
1335 | 1337 | ||
1338 | static int input_print_bitmap(char *buf, int buf_size, unsigned long *bitmap, | ||
1339 | int max, int add_cr); | ||
1340 | |||
1341 | static ssize_t input_dev_show_properties(struct device *dev, | ||
1342 | struct device_attribute *attr, | ||
1343 | char *buf) | ||
1344 | { | ||
1345 | struct input_dev *input_dev = to_input_dev(dev); | ||
1346 | int len = input_print_bitmap(buf, PAGE_SIZE, input_dev->propbit, | ||
1347 | INPUT_PROP_MAX, true); | ||
1348 | return min_t(int, len, PAGE_SIZE); | ||
1349 | } | ||
1350 | static DEVICE_ATTR(properties, S_IRUGO, input_dev_show_properties, NULL); | ||
1351 | |||
1336 | static struct attribute *input_dev_attrs[] = { | 1352 | static struct attribute *input_dev_attrs[] = { |
1337 | &dev_attr_name.attr, | 1353 | &dev_attr_name.attr, |
1338 | &dev_attr_phys.attr, | 1354 | &dev_attr_phys.attr, |
1339 | &dev_attr_uniq.attr, | 1355 | &dev_attr_uniq.attr, |
1340 | &dev_attr_modalias.attr, | 1356 | &dev_attr_modalias.attr, |
1357 | &dev_attr_properties.attr, | ||
1341 | NULL | 1358 | NULL |
1342 | }; | 1359 | }; |
1343 | 1360 | ||
@@ -1471,7 +1488,7 @@ static int input_add_uevent_bm_var(struct kobj_uevent_env *env, | |||
1471 | { | 1488 | { |
1472 | int len; | 1489 | int len; |
1473 | 1490 | ||
1474 | if (add_uevent_var(env, "%s=", name)) | 1491 | if (add_uevent_var(env, "%s", name)) |
1475 | return -ENOMEM; | 1492 | return -ENOMEM; |
1476 | 1493 | ||
1477 | len = input_print_bitmap(&env->buf[env->buflen - 1], | 1494 | len = input_print_bitmap(&env->buf[env->buflen - 1], |
@@ -1537,6 +1554,8 @@ static int input_dev_uevent(struct device *device, struct kobj_uevent_env *env) | |||
1537 | if (dev->uniq) | 1554 | if (dev->uniq) |
1538 | INPUT_ADD_HOTPLUG_VAR("UNIQ=\"%s\"", dev->uniq); | 1555 | INPUT_ADD_HOTPLUG_VAR("UNIQ=\"%s\"", dev->uniq); |
1539 | 1556 | ||
1557 | INPUT_ADD_HOTPLUG_BM_VAR("PROP=", dev->propbit, INPUT_PROP_MAX); | ||
1558 | |||
1540 | INPUT_ADD_HOTPLUG_BM_VAR("EV=", dev->evbit, EV_MAX); | 1559 | INPUT_ADD_HOTPLUG_BM_VAR("EV=", dev->evbit, EV_MAX); |
1541 | if (test_bit(EV_KEY, dev->evbit)) | 1560 | if (test_bit(EV_KEY, dev->evbit)) |
1542 | INPUT_ADD_HOTPLUG_BM_VAR("KEY=", dev->keybit, KEY_MAX); | 1561 | INPUT_ADD_HOTPLUG_BM_VAR("KEY=", dev->keybit, KEY_MAX); |
@@ -1726,52 +1745,6 @@ void input_free_device(struct input_dev *dev) | |||
1726 | EXPORT_SYMBOL(input_free_device); | 1745 | EXPORT_SYMBOL(input_free_device); |
1727 | 1746 | ||
1728 | /** | 1747 | /** |
1729 | * input_mt_create_slots() - create MT input slots | ||
1730 | * @dev: input device supporting MT events and finger tracking | ||
1731 | * @num_slots: number of slots used by the device | ||
1732 | * | ||
1733 | * This function allocates all necessary memory for MT slot handling in the | ||
1734 | * input device, and adds ABS_MT_SLOT to the device capabilities. All slots | ||
1735 | * are initially marked as unused by setting ABS_MT_TRACKING_ID to -1. | ||
1736 | */ | ||
1737 | int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots) | ||
1738 | { | ||
1739 | int i; | ||
1740 | |||
1741 | if (!num_slots) | ||
1742 | return 0; | ||
1743 | |||
1744 | dev->mt = kcalloc(num_slots, sizeof(struct input_mt_slot), GFP_KERNEL); | ||
1745 | if (!dev->mt) | ||
1746 | return -ENOMEM; | ||
1747 | |||
1748 | dev->mtsize = num_slots; | ||
1749 | input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0); | ||
1750 | |||
1751 | /* Mark slots as 'unused' */ | ||
1752 | for (i = 0; i < num_slots; i++) | ||
1753 | dev->mt[i].abs[ABS_MT_TRACKING_ID - ABS_MT_FIRST] = -1; | ||
1754 | |||
1755 | return 0; | ||
1756 | } | ||
1757 | EXPORT_SYMBOL(input_mt_create_slots); | ||
1758 | |||
1759 | /** | ||
1760 | * input_mt_destroy_slots() - frees the MT slots of the input device | ||
1761 | * @dev: input device with allocated MT slots | ||
1762 | * | ||
1763 | * This function is only needed in error path as the input core will | ||
1764 | * automatically free the MT slots when the device is destroyed. | ||
1765 | */ | ||
1766 | void input_mt_destroy_slots(struct input_dev *dev) | ||
1767 | { | ||
1768 | kfree(dev->mt); | ||
1769 | dev->mt = NULL; | ||
1770 | dev->mtsize = 0; | ||
1771 | } | ||
1772 | EXPORT_SYMBOL(input_mt_destroy_slots); | ||
1773 | |||
1774 | /** | ||
1775 | * input_set_capability - mark device as capable of a certain event | 1748 | * input_set_capability - mark device as capable of a certain event |
1776 | * @dev: device that is capable of emitting or accepting event | 1749 | * @dev: device that is capable of emitting or accepting event |
1777 | * @type: type of the event (EV_KEY, EV_REL, etc...) | 1750 | * @type: type of the event (EV_KEY, EV_REL, etc...) |
@@ -1820,9 +1793,8 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int | |||
1820 | break; | 1793 | break; |
1821 | 1794 | ||
1822 | default: | 1795 | default: |
1823 | printk(KERN_ERR | 1796 | pr_err("input_set_capability: unknown type %u (code %u)\n", |
1824 | "input_set_capability: unknown type %u (code %u)\n", | 1797 | type, code); |
1825 | type, code); | ||
1826 | dump_stack(); | 1798 | dump_stack(); |
1827 | return; | 1799 | return; |
1828 | } | 1800 | } |
@@ -1904,8 +1876,9 @@ int input_register_device(struct input_dev *dev) | |||
1904 | return error; | 1876 | return error; |
1905 | 1877 | ||
1906 | path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL); | 1878 | path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL); |
1907 | printk(KERN_INFO "input: %s as %s\n", | 1879 | pr_info("%s as %s\n", |
1908 | dev->name ? dev->name : "Unspecified device", path ? path : "N/A"); | 1880 | dev->name ? dev->name : "Unspecified device", |
1881 | path ? path : "N/A"); | ||
1909 | kfree(path); | 1882 | kfree(path); |
1910 | 1883 | ||
1911 | error = mutex_lock_interruptible(&input_mutex); | 1884 | error = mutex_lock_interruptible(&input_mutex); |
@@ -2187,7 +2160,7 @@ static int __init input_init(void) | |||
2187 | 2160 | ||
2188 | err = class_register(&input_class); | 2161 | err = class_register(&input_class); |
2189 | if (err) { | 2162 | if (err) { |
2190 | printk(KERN_ERR "input: unable to register input_dev class\n"); | 2163 | pr_err("unable to register input_dev class\n"); |
2191 | return err; | 2164 | return err; |
2192 | } | 2165 | } |
2193 | 2166 | ||
@@ -2197,7 +2170,7 @@ static int __init input_init(void) | |||
2197 | 2170 | ||
2198 | err = register_chrdev(INPUT_MAJOR, "input", &input_fops); | 2171 | err = register_chrdev(INPUT_MAJOR, "input", &input_fops); |
2199 | if (err) { | 2172 | if (err) { |
2200 | printk(KERN_ERR "input: unable to register char major %d", INPUT_MAJOR); | 2173 | pr_err("unable to register char major %d", INPUT_MAJOR); |
2201 | goto fail2; | 2174 | goto fail2; |
2202 | } | 2175 | } |
2203 | 2176 | ||