From patchwork Thu Nov 19 07:13:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 61238 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAJ7DMf0031357 for ; Thu, 19 Nov 2009 07:13:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752108AbZKSHNP (ORCPT ); Thu, 19 Nov 2009 02:13:15 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752284AbZKSHNP (ORCPT ); Thu, 19 Nov 2009 02:13:15 -0500 Received: from mail-pw0-f42.google.com ([209.85.160.42]:64363 "EHLO mail-pw0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752108AbZKSHNO (ORCPT ); Thu, 19 Nov 2009 02:13:14 -0500 Received: by pwi3 with SMTP id 3so1234072pwi.21 for ; Wed, 18 Nov 2009 23:13:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=ohpcoZkDBA6HCh2diXrDsl22RAuTIhiurCQ0/vZXLFM=; b=kFYG6LHkdP1pZQ8/X234eiJ2RZWsHN7QNfClZjkPcL1TBPFKlk6BfmPnOpqA+h1cPb 4jD5B6sSx45VT96MSZTOGnrRHcUHUzdaFd4SwQiyZt8U1cimAs8Fdp0izTYXnVkOQgzA Zk0N2joykS23W2ivM5l1MlvAdd+2Z9QC6mkME= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=kUPYlvG6Rowxch0DnFXblqAhYXrcQ7v1qVJxaAfLaJLy9KFGFhV2S0FR75CWpdfI1J CSyDjEY/LA2jNS0+ZuP/KGoQ3nmD0nr9rGdKlja1Frft7QW/Dm9vlmW24GAlKSvET8lM ywkIFZISl2hfllnyJfzwyXclqWRl9nfT6YeE0= Received: by 10.114.187.3 with SMTP id k3mr6771325waf.82.1258614800293; Wed, 18 Nov 2009 23:13:20 -0800 (PST) Received: from mailhub.coreip.homeip.net (c-24-6-153-137.hsd1.ca.comcast.net [24.6.153.137]) by mx.google.com with ESMTPS id 21sm185217pzk.15.2009.11.18.23.13.18 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 18 Nov 2009 23:13:19 -0800 (PST) Date: Wed, 18 Nov 2009 23:13:15 -0800 From: Dmitry Torokhov To: Linux Input Cc: LKML Subject: [PATCH] Input: keyboard - add locking around event handling Message-ID: <20091119071315.GD3010@core.coreip.homeip.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index ce2ab67..e095ff3 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c @@ -130,6 +130,7 @@ int shift_state = 0; */ static struct input_handler kbd_handler; +static DEFINE_SPINLOCK(kbd_event_lock); static unsigned long key_down[BITS_TO_LONGS(KEY_CNT)]; /* keyboard key bitmap */ static unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */ static int dead_key_next; @@ -1304,11 +1305,16 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw) static void kbd_event(struct input_handle *handle, unsigned int event_type, unsigned int event_code, int value) { + /* We are called with interrupts disabled */ + spin_lock(&kbd_event_lock); + if (event_type == EV_MSC && event_code == MSC_RAW && HW_RAW(handle->dev)) kbd_rawcode(value); if (event_type == EV_KEY) kbd_keycode(event_code, value, HW_RAW(handle->dev)); + spin_unlock(&kbd_event_lock); + tasklet_schedule(&keyboard_tasklet); do_poke_blanked_console = 1; schedule_console_callback();