From patchwork Thu Jan 20 08:56:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 491321 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0K8uiKa014520 for ; Thu, 20 Jan 2011 08:57:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754259Ab1ATI5G (ORCPT ); Thu, 20 Jan 2011 03:57:06 -0500 Received: from mail-pz0-f46.google.com ([209.85.210.46]:43359 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753118Ab1ATI5F (ORCPT ); Thu, 20 Jan 2011 03:57:05 -0500 Received: by pzk35 with SMTP id 35so59268pzk.19 for ; Thu, 20 Jan 2011 00:57:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=eTprHg7tNxYiTnhw2AVzn/twpn5M4LNWJYYEQGdr9Ho=; b=wwgu4QDMTLLWcTupjrerq86FNOTH9c5HA/mi/PO++rUqv3d5+EA0XrE+bmh6/SGCWM 905xYuu/1d75byj5OX5zLMgL2mVfNMOm6kYfQr/s3UUtBC/oPtSGEzbUlzz9VZ9fCrny 1YU/2vYSmQ7s7RgFx6KC7CTTkSqduJ0IpgLO8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=Hnv2gJew71l/AfV680w+mniBJKT3gHK/iHKw09GTtggBE0Ui174tkOO1aXaHvJQ05a tfxfbQpzjYp5eshZNjSgLzRGTtZZjGXrDrBBqSs3b8Z4XcAkylQyN9MaZXdKx0Ra0fmH isMzfIVp015VQ9+yWtq+avwyaSL54ZL/FNfxY= Received: by 10.142.216.1 with SMTP id o1mr1849488wfg.190.1295513824405; Thu, 20 Jan 2011 00:57:04 -0800 (PST) Received: from mailhub.coreip.homeip.net (c-98-234-113-65.hsd1.ca.comcast.net [98.234.113.65]) by mx.google.com with ESMTPS id o1sm10815406wfl.2.2011.01.20.00.56.57 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 20 Jan 2011 00:56:58 -0800 (PST) Date: Thu, 20 Jan 2011 00:56:54 -0800 From: Dmitry Torokhov To: Arjan van de Ven Cc: Kristen Carlson Accardi , linux-input@vger.kernel.org, Jason Wessel Subject: Re: [PATCH] input: move check for same handler in input_pass_event Message-ID: <20110120085654.GA19696@core.coreip.homeip.net> References: <1294352688-29564-1-git-send-email-kristen@linux.intel.com> <20110107060456.GA29038@core.coreip.homeip.net> <20110107102434.7776091d@kcaccard-MOBL3> <20110107192938.GB28875@core.coreip.homeip.net> <4D276A51.5030102@linux.intel.com> <20110107194313.GC28875@core.coreip.homeip.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110107194313.GC28875@core.coreip.homeip.net> User-Agent: Mutt/1.5.21 (2010-09-15) 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.6 (demeter1.kernel.org [140.211.167.41]); Thu, 20 Jan 2011 08:57:08 +0000 (UTC) diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index c556ed9..ef3a983 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -571,6 +571,7 @@ struct sysrq_state { unsigned int alt_use; bool active; bool need_reinject; + bool reinjecting; }; static void sysrq_reinject_alt_sysrq(struct work_struct *work) @@ -581,6 +582,10 @@ static void sysrq_reinject_alt_sysrq(struct work_struct *work) unsigned int alt_code = sysrq->alt_use; if (sysrq->need_reinject) { + /* we do not want the assignment to be reordered */ + sysrq->reinjecting = true; + mb(); + /* Simulate press and release of Alt + SysRq */ input_inject_event(handle, EV_KEY, alt_code, 1); input_inject_event(handle, EV_KEY, KEY_SYSRQ, 1); @@ -589,6 +594,9 @@ static void sysrq_reinject_alt_sysrq(struct work_struct *work) input_inject_event(handle, EV_KEY, KEY_SYSRQ, 0); input_inject_event(handle, EV_KEY, alt_code, 0); input_inject_event(handle, EV_SYN, SYN_REPORT, 1); + + mb(); + sysrq->reinjecting = false; } } @@ -599,6 +607,13 @@ static bool sysrq_filter(struct input_handle *handle, bool was_active = sysrq->active; bool suppress; + /* + * Do not filter anything if we are in the process of re-injecting + * Alt+SysRq combination. + */ + if (sysrq->reinjecting) + return false; + switch (type) { case EV_SYN: @@ -629,7 +644,7 @@ static bool sysrq_filter(struct input_handle *handle, sysrq->alt_use = sysrq->alt; /* * If nothing else will be pressed we'll need - * to * re-inject Alt-SysRq keysroke. + * to re-inject Alt-SysRq keysroke. */ sysrq->need_reinject = true; }