From patchwork Thu May 6 13:33:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 97349 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o46DVEdd004334 for ; Thu, 6 May 2010 13:34:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758113Ab0EFNeG (ORCPT ); Thu, 6 May 2010 09:34:06 -0400 Received: from cantor2.suse.de ([195.135.220.15]:34439 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758110Ab0EFNeF convert rfc822-to-8bit (ORCPT ); Thu, 6 May 2010 09:34:05 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id 9154F8672B; Thu, 6 May 2010 15:34:02 +0200 (CEST) From: Oliver Neukum Organization: SUSE To: Dmitry Torokhov Subject: Re: question on releasing keys Date: Thu, 6 May 2010 15:33:49 +0200 User-Agent: KMail/1.12.4 (Linux/2.6.34-rc6-0.1-default; KDE/4.3.5; x86_64; ; ) Cc: linux-input@vger.kernel.org References: <201004281053.52598.oneukum@suse.de> <201004280942.25746.dmitry.torokhov@gmail.com> In-Reply-To: <201004280942.25746.dmitry.torokhov@gmail.com> MIME-Version: 1.0 Message-Id: <201005061533.49845.oneukum@suse.de> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 06 May 2010 13:34:07 +0000 (UTC) diff --git a/drivers/input/input.c b/drivers/input/input.c index 9c79bd5..04be575 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -528,6 +528,27 @@ void input_close_device(struct input_handle *handle) EXPORT_SYMBOL(input_close_device); /* + * Simulate keyup events for all pressed keys so that handlers + * are not left with "stuck" keys. The driver may continue + * generate events even after we done here but they will not + * reach any handlers. + */ +static void 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) @@ -546,21 +567,7 @@ static void input_disconnect_device(struct input_dev *dev) spin_lock_irq(&dev->event_lock); - /* - * Simulate keyup events for all pressed keys so that handlers - * are not left with "stuck" keys. The driver may continue - * 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); - } + release_keys(dev); list_for_each_entry(handle, &dev->h_list, d_node) handle->open = 0; @@ -1433,6 +1440,9 @@ static int input_dev_resume(struct device *dev) mutex_lock(&input_dev->mutex); input_dev_reset(input_dev, true); + spin_lock_irq(&input_dev->event_lock); + release_keys(input_dev); + spin_unlock_irq(&input_dev->event_lock); mutex_unlock(&input_dev->mutex); return 0;