aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-11-27 04:50:54 -0500
committerHenrik Rydberg <rydberg@euromail.se>2010-12-16 04:41:12 -0500
commit8cde81001626c4c60b26ef2eb5fc522885ed9fd0 (patch)
tree9e9092cae44615376c5e3de98b8b259d137eb987 /drivers
parent47c78e891323513e9909729b44033e2c6649e2b7 (diff)
input: mt: Collect slots initialization code
The MT slots devices all follow the same initialization pattern of creating slots and hinting about buffer size. Let drivers call an initialization function instead, and make sure it can be called repeatedly without side effects. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hid/hid-3m-pct.c5
-rw-r--r--drivers/input/input-mt.c19
-rw-r--r--drivers/input/misc/uinput.c3
-rw-r--r--drivers/input/tablet/wacom_wac.c2
-rw-r--r--drivers/input/touchscreen/wacom_w8001.c2
5 files changed, 17 insertions, 14 deletions
diff --git a/drivers/hid/hid-3m-pct.c b/drivers/hid/hid-3m-pct.c
index 18575a4e0d63..ea475964d05a 100644
--- a/drivers/hid/hid-3m-pct.c
+++ b/drivers/hid/hid-3m-pct.c
@@ -29,7 +29,6 @@ MODULE_LICENSE("GPL");
29 29
30#define MAX_SLOTS 60 30#define MAX_SLOTS 60
31#define MAX_TRKID USHRT_MAX 31#define MAX_TRKID USHRT_MAX
32#define MAX_EVENTS 360
33 32
34/* estimated signal-to-noise ratios */ 33/* estimated signal-to-noise ratios */
35#define SN_MOVE 2048 34#define SN_MOVE 2048
@@ -123,9 +122,7 @@ static int mmm_input_mapping(struct hid_device *hdev, struct hid_input *hi,
123 EV_ABS, ABS_MT_TRACKING_ID); 122 EV_ABS, ABS_MT_TRACKING_ID);
124 input_set_abs_params(hi->input, ABS_MT_TRACKING_ID, 123 input_set_abs_params(hi->input, ABS_MT_TRACKING_ID,
125 0, MAX_TRKID, 0, 0); 124 0, MAX_TRKID, 0, 0);
126 if (!hi->input->mt) 125 input_mt_init_slots(hi->input, MAX_SLOTS);
127 input_mt_create_slots(hi->input, MAX_SLOTS);
128 input_set_events_per_packet(hi->input, MAX_EVENTS);
129 return 1; 126 return 1;
130 } 127 }
131 /* let hid-input decide for the others */ 128 /* let hid-input decide for the others */
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index 463a4d7d54f2..f400e47092c4 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -12,20 +12,25 @@
12#include <linux/slab.h> 12#include <linux/slab.h>
13 13
14/** 14/**
15 * input_mt_create_slots() - create MT input slots 15 * input_mt_init_slots() - initialize MT input slots
16 * @dev: input device supporting MT events and finger tracking 16 * @dev: input device supporting MT events and finger tracking
17 * @num_slots: number of slots used by the device 17 * @num_slots: number of slots used by the device
18 * 18 *
19 * This function allocates all necessary memory for MT slot handling in the 19 * This function allocates all necessary memory for MT slot handling
20 * input device, and adds ABS_MT_SLOT to the device capabilities. All slots 20 * in the input device, adds ABS_MT_SLOT to the device capabilities
21 * are initially marked as unused by setting ABS_MT_TRACKING_ID to -1. 21 * and sets up appropriate event buffers. All slots are initially
22 * marked as unused by setting ABS_MT_TRACKING_ID to -1. May be called
23 * repeatedly. Returns -EINVAL if attempting to reinitialize with a
24 * different number of slots.
22 */ 25 */
23int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots) 26int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots)
24{ 27{
25 int i; 28 int i;
26 29
27 if (!num_slots) 30 if (!num_slots)
28 return 0; 31 return 0;
32 if (dev->mt)
33 return dev->mtsize != num_slots ? -EINVAL : 0;
29 34
30 dev->mt = kcalloc(num_slots, sizeof(struct input_mt_slot), GFP_KERNEL); 35 dev->mt = kcalloc(num_slots, sizeof(struct input_mt_slot), GFP_KERNEL);
31 if (!dev->mt) 36 if (!dev->mt)
@@ -33,6 +38,7 @@ int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)
33 38
34 dev->mtsize = num_slots; 39 dev->mtsize = num_slots;
35 input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0); 40 input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0);
41 input_set_events_per_packet(dev, 6 * num_slots);
36 42
37 /* Mark slots as 'unused' */ 43 /* Mark slots as 'unused' */
38 for (i = 0; i < num_slots; i++) 44 for (i = 0; i < num_slots; i++)
@@ -40,7 +46,7 @@ int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)
40 46
41 return 0; 47 return 0;
42} 48}
43EXPORT_SYMBOL(input_mt_create_slots); 49EXPORT_SYMBOL(input_mt_init_slots);
44 50
45/** 51/**
46 * input_mt_destroy_slots() - frees the MT slots of the input device 52 * input_mt_destroy_slots() - frees the MT slots of the input device
@@ -54,5 +60,6 @@ void input_mt_destroy_slots(struct input_dev *dev)
54 kfree(dev->mt); 60 kfree(dev->mt);
55 dev->mt = NULL; 61 dev->mt = NULL;
56 dev->mtsize = 0; 62 dev->mtsize = 0;
63 dev->slot = 0;
57} 64}
58EXPORT_SYMBOL(input_mt_destroy_slots); 65EXPORT_SYMBOL(input_mt_destroy_slots);
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 8f374143190e..bea89722c4e9 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -407,8 +407,7 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu
407 goto exit; 407 goto exit;
408 if (test_bit(ABS_MT_SLOT, dev->absbit)) { 408 if (test_bit(ABS_MT_SLOT, dev->absbit)) {
409 int nslot = input_abs_get_max(dev, ABS_MT_SLOT) + 1; 409 int nslot = input_abs_get_max(dev, ABS_MT_SLOT) + 1;
410 input_mt_create_slots(dev, nslot); 410 input_mt_init_slots(dev, nslot);
411 input_set_events_per_packet(dev, 6 * nslot);
412 } else if (test_bit(ABS_MT_POSITION_X, dev->absbit)) { 411 } else if (test_bit(ABS_MT_POSITION_X, dev->absbit)) {
413 input_set_events_per_packet(dev, 60); 412 input_set_events_per_packet(dev, 60);
414 } 413 }
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index bde612c6d36d..f26e2238f6ca 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -1273,7 +1273,7 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
1273 __set_bit(BTN_TOOL_FINGER, input_dev->keybit); 1273 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
1274 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); 1274 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
1275 1275
1276 input_mt_create_slots(input_dev, 2); 1276 input_mt_init_slots(input_dev, 2);
1277 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 1277 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1278 0, features->x_max, 1278 0, features->x_max,
1279 features->x_fuzz, 0); 1279 features->x_fuzz, 0);
diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c
index 5d4f50e52a28..4a2e8cf4c8ef 100644
--- a/drivers/input/touchscreen/wacom_w8001.c
+++ b/drivers/input/touchscreen/wacom_w8001.c
@@ -318,7 +318,7 @@ static int w8001_setup(struct w8001 *w8001)
318 case 5: 318 case 5:
319 w8001->pktlen = W8001_PKTLEN_TOUCH2FG; 319 w8001->pktlen = W8001_PKTLEN_TOUCH2FG;
320 320
321 input_mt_create_slots(dev, 2); 321 input_mt_init_slots(dev, 2);
322 input_set_abs_params(dev, ABS_MT_TRACKING_ID, 322 input_set_abs_params(dev, ABS_MT_TRACKING_ID,
323 0, MAX_TRACKING_ID, 0, 0); 323 0, MAX_TRACKING_ID, 0, 0);
324 input_set_abs_params(dev, ABS_MT_POSITION_X, 324 input_set_abs_params(dev, ABS_MT_POSITION_X,