aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/input.c
diff options
context:
space:
mode:
authorDaniel Mack <daniel@caiaq.de>2010-08-02 23:18:21 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-08-02 23:30:04 -0400
commitd31b2865a4e8a9dd02f39e56c8fadb824c5e187b (patch)
treecbe062757aa54c88c8e9ae2bf6ff87f791313c60 /drivers/input/input.c
parent987a6c0298260b7aa40702b349282554d6180e4b (diff)
Input: dynamically allocate ABS information
As all callers are now changed to only use the input_abs_*() access helpers, switching over to dynamically allocated ABS information is easy. This reduces size of struct input_dev from 3152 to 1640 on 64 bit architectures. Signed-off-by: Daniel Mack <daniel@caiaq.de> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/input.c')
-rw-r--r--drivers/input/input.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 7259adb8619d..a9b025f4147a 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -182,7 +182,7 @@ static int input_handle_abs_event(struct input_dev *dev,
182 is_mt_event = code >= ABS_MT_FIRST && code <= ABS_MT_LAST; 182 is_mt_event = code >= ABS_MT_FIRST && code <= ABS_MT_LAST;
183 183
184 if (!is_mt_event) { 184 if (!is_mt_event) {
185 pold = &dev->abs[code]; 185 pold = &dev->absinfo[code].value;
186 } else if (dev->mt) { 186 } else if (dev->mt) {
187 struct input_mt_slot *mtslot = &dev->mt[dev->slot]; 187 struct input_mt_slot *mtslot = &dev->mt[dev->slot];
188 pold = &mtslot->abs[code - ABS_MT_FIRST]; 188 pold = &mtslot->abs[code - ABS_MT_FIRST];
@@ -196,7 +196,7 @@ static int input_handle_abs_event(struct input_dev *dev,
196 196
197 if (pold) { 197 if (pold) {
198 *pval = input_defuzz_abs_event(*pval, *pold, 198 *pval = input_defuzz_abs_event(*pval, *pold,
199 dev->absfuzz[code]); 199 dev->absinfo[code].fuzz);
200 if (*pold == *pval) 200 if (*pold == *pval)
201 return INPUT_IGNORE_EVENT; 201 return INPUT_IGNORE_EVENT;
202 202
@@ -391,6 +391,43 @@ void input_inject_event(struct input_handle *handle,
391EXPORT_SYMBOL(input_inject_event); 391EXPORT_SYMBOL(input_inject_event);
392 392
393/** 393/**
394 * input_alloc_absinfo - allocates array of input_absinfo structs
395 * @dev: the input device emitting absolute events
396 *
397 * If the absinfo struct the caller asked for is already allocated, this
398 * functions will not do anything.
399 */
400void input_alloc_absinfo(struct input_dev *dev)
401{
402 if (!dev->absinfo)
403 dev->absinfo = kcalloc(ABS_CNT, sizeof(struct input_absinfo),
404 GFP_KERNEL);
405
406 WARN(!dev->absinfo, "%s(): kcalloc() failed?\n", __func__);
407}
408EXPORT_SYMBOL(input_alloc_absinfo);
409
410void input_set_abs_params(struct input_dev *dev, unsigned int axis,
411 int min, int max, int fuzz, int flat)
412{
413 struct input_absinfo *absinfo;
414
415 input_alloc_absinfo(dev);
416 if (!dev->absinfo)
417 return;
418
419 absinfo = &dev->absinfo[axis];
420 absinfo->minimum = min;
421 absinfo->maximum = max;
422 absinfo->fuzz = fuzz;
423 absinfo->flat = flat;
424
425 dev->absbit[BIT_WORD(axis)] |= BIT_MASK(axis);
426}
427EXPORT_SYMBOL(input_set_abs_params);
428
429
430/**
394 * input_grab_device - grabs device for exclusive use 431 * input_grab_device - grabs device for exclusive use
395 * @handle: input handle that wants to own the device 432 * @handle: input handle that wants to own the device
396 * 433 *
@@ -1308,6 +1345,7 @@ static void input_dev_release(struct device *device)
1308 1345
1309 input_ff_destroy(dev); 1346 input_ff_destroy(dev);
1310 input_mt_destroy_slots(dev); 1347 input_mt_destroy_slots(dev);
1348 kfree(dev->absinfo);
1311 kfree(dev); 1349 kfree(dev);
1312 1350
1313 module_put(THIS_MODULE); 1351 module_put(THIS_MODULE);