~ubuntu-branches/ubuntu/karmic/linux-mvl-dove/karmic-updates

« back to all changes in this revision

Viewing changes to drivers/input/input.c

  • Committer: Bazaar Package Importer
  • Author(s): Andy Whitcroft, Amit Kucheria, Andy Whitcroft, Colin Watson, Tim Gardner, Ubuntu: 2.6.31-13.43, Ubuntu: 2.6.31-13.42, Ubuntu: 2.6.31-12.41, Ubuntu: 2.6.31-12.40
  • Date: 2009-10-09 14:41:22 UTC
  • Revision ID: james.westby@ubuntu.com-20091009144122-tdxnwe8yr8lbexi8
Tags: 2.6.31-207.15
[ Amit Kucheria ]

* Disable CONFIG_UEVENT_HELPER_PATH

[ Andy Whitcroft ]

* rebase to Ubuntu-2.6.31-13.42
* rebase to Ubuntu-2.6.31-13.43

[ Colin Watson ]

* Use section 'admin' rather than 'base'

[ Tim Gardner ]

* [Config] CONFIG_GFS2_FS_LOCKING_DLM=y
  - LP: #416325

[ Ubuntu: 2.6.31-13.43 ]

* Revert "[Upstream] acerhdf: Limit modalias matching to supported
  boards"
* Use section 'admin' rather than 'base'
* SAUCE: AppArmor: Set error code after structure initialization.
  - LP: #427948
* SAUCE: AppArmor: Fix off by 2 error in getprocattr mem allocation
  - LP: #446595
* SAUCE: Add sr_mod to the scsi-modules udeb for powerpc
* [Upstream] acerhdf: Limit modalias matching to supported boards
  (supersedes previous revert made by Andy Whitcroft)
  - LP: #435958

[ Ubuntu: 2.6.31-13.42 ]

* SAUCE: (drop after 2.6.31) input: Add support for filtering input
  events
  - LP: #430809
* SAUCE: (drop after 2.6.31) dell-laptop: Trigger rfkill updates on wifi
  toggle switch press
  - LP: #430809
* SAUCE: Raise the default console 'quiet' level to 2
  This supresses all but critical and emergency level messages.
  https://lists.ubuntu.com/archives/kernel-team/2009-October/007476.html
* TTY: fix typos
* Linux 2.6.31.3
* V4L/DVB (12439): cx88: add support for WinFast DTV2000H rev. J
  - LP: #433904

[ Ubuntu: 2.6.31-12.41 ]

* [Config] CONFIG_GFS2_FS_LOCKING_DLM=y
  - LP: #416325
* SAUCE: Fix MODULE_IMPORT/MODULE_EXPORT
  The original patch failed to work for amd64.
  - LP: #430694
* ALSA: hda - Add a white-list for MSI option
  Upstream cherry-pick: Infrastructure support for #445580
* ALSA: hda - Add HP Pavilion dv4t-1300 to MSI whitelist
  - LP: #445580
* ALSA: intel8x0 - Mute External Amplifier by default for Sony VAIO
  VGN-T350P
  - LP: #410933
* ALSA: intel8x0 - Mute External Amplifier by default for Sony VAIO
  VGN-B1VP
  - LP: #410933

[ Ubuntu: 2.6.31-12.40 ]

* SAUCE: Created MODULE_EXPORT/MODULE_IMPORT macros
  - LP: #430694
* SAUCE: Use MODULE_IMPORT macro to tie intel_agp to i915
  - LP: #430694
* V4L/DVB (12352): gspca - vc032x: Fix mi1310_soc preview and LED
  - LP: #310760

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
 */
89
89
static void input_pass_event(struct input_dev *dev,
90
90
                             unsigned int type, unsigned int code, int value)
91
 
{
92
 
        struct input_handle *handle;
 
91
 
 
92
{       struct input_handle *handle;
93
93
 
94
94
        rcu_read_lock();
95
95
 
96
96
        handle = rcu_dereference(dev->grab);
97
 
        if (handle)
 
97
        if (handle) {
98
98
                handle->handler->event(handle, type, code, value);
99
 
        else
100
 
                list_for_each_entry_rcu(handle, &dev->h_list, d_node)
101
 
                        if (handle->open)
102
 
                                handle->handler->event(handle,
103
 
                                                        type, code, value);
 
99
                goto out;
 
100
        }
 
101
 
 
102
        handle = rcu_dereference(dev->filter);
 
103
        if (handle && handle->handler->filter(handle, type, code, value))
 
104
                goto out;
 
105
 
 
106
        list_for_each_entry_rcu(handle, &dev->h_list, d_node)
 
107
                if (handle->open)
 
108
                        handle->handler->event(handle,
 
109
                                               type, code, value);
 
110
out:
104
111
        rcu_read_unlock();
105
112
}
106
113
 
375
382
}
376
383
EXPORT_SYMBOL(input_grab_device);
377
384
 
378
 
static void __input_release_device(struct input_handle *handle)
 
385
static void __input_release_device(struct input_handle *handle, bool filter)
379
386
{
380
387
        struct input_dev *dev = handle->dev;
381
388
 
382
 
        if (dev->grab == handle) {
383
 
                rcu_assign_pointer(dev->grab, NULL);
 
389
        if (handle == (filter ? dev->filter : dev->grab)) {
 
390
                if (filter)
 
391
                        rcu_assign_pointer(dev->filter, NULL);
 
392
                else
 
393
                        rcu_assign_pointer(dev->grab, NULL);
384
394
                /* Make sure input_pass_event() notices that grab is gone */
385
395
                synchronize_rcu();
386
396
 
404
414
        struct input_dev *dev = handle->dev;
405
415
 
406
416
        mutex_lock(&dev->mutex);
407
 
        __input_release_device(handle);
 
417
        __input_release_device(handle, false);
408
418
        mutex_unlock(&dev->mutex);
409
419
}
410
420
EXPORT_SYMBOL(input_release_device);
411
421
 
412
422
/**
 
423
 * input_filter_device - allow input events to be filtered from higher layers
 
424
 * @handle: input handle that wants to filter the device
 
425
 *
 
426
 * When a device is filtered by an input handle all events generated by
 
427
 * the device are to this handle. If the filter function returns true then
 
428
 * the event is discarded rather than being passed to any other input handles,
 
429
 * otherwise it is passed to them as normal. Grabs will be handled before
 
430
 * filters, so a grabbed device will not deliver events to a filter function.
 
431
 */
 
432
int input_filter_device(struct input_handle *handle)
 
433
{
 
434
        struct input_dev *dev = handle->dev;
 
435
        int retval;
 
436
 
 
437
        retval = mutex_lock_interruptible(&dev->mutex);
 
438
        if (retval)
 
439
                return retval;
 
440
 
 
441
        if (dev->filter) {
 
442
                retval = -EBUSY;
 
443
                goto out;
 
444
        }
 
445
 
 
446
        rcu_assign_pointer(dev->filter, handle);
 
447
        synchronize_rcu();
 
448
 
 
449
 out:
 
450
        mutex_unlock(&dev->mutex);
 
451
        return retval;
 
452
}
 
453
EXPORT_SYMBOL(input_filter_device);
 
454
 
 
455
/**
 
456
 * input_unfilter_device - removes a filter from a device
 
457
 * @handle: input handle that owns the device
 
458
 *
 
459
 * Removes the filter from a device so that other input handles can
 
460
 * start receiving unfiltered input events. Upon release all handlers
 
461
 * attached to the device have their start() method called so they
 
462
 * have a change to synchronize device state with the rest of the
 
463
 * system.
 
464
 */
 
465
void input_unfilter_device(struct input_handle *handle)
 
466
{
 
467
        struct input_dev *dev = handle->dev;
 
468
 
 
469
        mutex_lock(&dev->mutex);
 
470
        __input_release_device(handle, true);
 
471
        mutex_unlock(&dev->mutex);
 
472
}
 
473
EXPORT_SYMBOL(input_unfilter_device);
 
474
 
 
475
/**
413
476
 * input_open_device - open input device
414
477
 * @handle: handle through which device is being accessed
415
478
 *
482
545
 
483
546
        mutex_lock(&dev->mutex);
484
547
 
485
 
        __input_release_device(handle);
 
548
        /* Release both grabs and filters */
 
549
        __input_release_device(handle, false);
 
550
        __input_release_device(handle, true);
486
551
 
487
552
        if (!--dev->users && dev->close)
488
553
                dev->close(dev);