Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 202201
b: refs/heads/master
c: 866d7d7
h: refs/heads/master
i:
  202199: ccd1a30
v: v3
  • Loading branch information
Oliver Neukum authored and Dmitry Torokhov committed Jul 3, 2010
1 parent 675b5a1 commit 390c707
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3eac5c7e44f35eb07f0ecb28ce60f15b2dda1932
refs/heads/master: 866d7d7b4a4e1d502b136bcc8af605091fe4c7b5
39 changes: 29 additions & 10 deletions trunk/drivers/input/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,13 +527,31 @@ void input_close_device(struct input_handle *handle)
}
EXPORT_SYMBOL(input_close_device);

/*
* Simulate keyup events for all keys that are marked as pressed.
* The function must be called with dev->event_lock held.
*/
static void input_dev_release_keys(struct input_dev *dev)
{
int code;

if (is_event_supported(EV_KEY, dev->evbit, EV_MAX)) {
for (code = 0; code <= KEY_MAX; code++) {
if (is_event_supported(code, dev->keybit, KEY_MAX) &&
__test_and_clear_bit(code, dev->key)) {
input_pass_event(dev, EV_KEY, code, 0);
}
}
input_pass_event(dev, EV_SYN, SYN_REPORT, 1);
}
}

/*
* Prepare device for unregistering
*/
static void input_disconnect_device(struct input_dev *dev)
{
struct input_handle *handle;
int code;

/*
* Mark device as going away. Note that we take dev->mutex here
Expand All @@ -552,15 +570,7 @@ static void input_disconnect_device(struct input_dev *dev)
* generate events even after we done here but they will not
* reach any handlers.
*/
if (is_event_supported(EV_KEY, dev->evbit, EV_MAX)) {
for (code = 0; code <= KEY_MAX; code++) {
if (is_event_supported(code, dev->keybit, KEY_MAX) &&
__test_and_clear_bit(code, dev->key)) {
input_pass_event(dev, EV_KEY, code, 0);
}
}
input_pass_event(dev, EV_SYN, SYN_REPORT, 1);
}
input_dev_release_keys(dev);

list_for_each_entry(handle, &dev->h_list, d_node)
handle->open = 0;
Expand Down Expand Up @@ -1433,6 +1443,15 @@ static int input_dev_resume(struct device *dev)

mutex_lock(&input_dev->mutex);
input_dev_reset(input_dev, true);

/*
* Keys that have been pressed at suspend time are unlikely
* to be still pressed when we resume.
*/
spin_lock_irq(&input_dev->event_lock);
input_dev_release_keys(input_dev);
spin_unlock_irq(&input_dev->event_lock);

mutex_unlock(&input_dev->mutex);

return 0;
Expand Down

0 comments on commit 390c707

Please sign in to comment.