From patchwork Sat Jan 29 07:33:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 516321 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 p0T7Xsla014853 for ; Sat, 29 Jan 2011 07:33:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752416Ab1A2Hdh (ORCPT ); Sat, 29 Jan 2011 02:33:37 -0500 Received: from mail-pv0-f174.google.com ([74.125.83.174]:58574 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750765Ab1A2Hdg (ORCPT ); Sat, 29 Jan 2011 02:33:36 -0500 Received: by pva4 with SMTP id 4so562477pva.19 for ; Fri, 28 Jan 2011 23:33:35 -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:mime-version :content-type:content-disposition:user-agent; bh=7PXHGA8Q8T2BzOIh/z5Jo/8Rl+Wf36/8tQkvgUWnxas=; b=okQDSH1fHF9aJp1XypIIAL6kvWmF86WcUnI7xtifHCXOR75H8EqHXNv8xqXNhLvRkx l0AYO3tXm1NaWvzrZ0RGpOm2qRwp6DWUYe3EIwYeK2nHz5m/xMF9y9/BCr27hW2lFrMQ 1UisfMx4fR2RsXeUCtCfTjhgBr7b1XgHtEejk= 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=UpBkjm61OvNMvCu5kOVi26thQhq266hzAdPpfr6K0C15s8vacSqw/ZogQ2XyDP5C9O 6iyQG08OYermSQvgqAuhu5qLA0/qmhRLSpDCWe5mxwcfcU62w+ACsfWbDkNkevZD/SCg dpBzOqu1oo/b+Jbl0aKSgv4HI26bFI6zrI2sg= Received: by 10.142.221.7 with SMTP id t7mr3950918wfg.440.1296286415695; Fri, 28 Jan 2011 23:33:35 -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 e14sm24499994wfg.20.2011.01.28.23.33.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 28 Jan 2011 23:33:34 -0800 (PST) Date: Fri, 28 Jan 2011 23:33:29 -0800 From: Dmitry Torokhov To: Linus Torvalds Cc: Mauro Carvalho Chehab , Mark Lord , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH] Input: rc-keymap - return KEY_RESERVED for unknown mappings Message-ID: <20110129073329.GB26915@core.coreip.homeip.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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]); Sat, 29 Jan 2011 07:33:54 +0000 (UTC) diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 72be8a0..512a2f4 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -458,21 +458,27 @@ static int ir_getkeycode(struct input_dev *idev, index = ir_lookup_by_scancode(rc_map, scancode); } - if (index >= rc_map->len) { - if (!(ke->flags & INPUT_KEYMAP_BY_INDEX)) - IR_dprintk(1, "unknown key for scancode 0x%04x\n", - scancode); + if (index < rc_map->len) { + entry = &rc_map->scan[index]; + + ke->index = index; + ke->keycode = entry->keycode; + ke->len = sizeof(entry->scancode); + memcpy(ke->scancode, &entry->scancode, sizeof(entry->scancode)); + + } else if (!(ke->flags & INPUT_KEYMAP_BY_INDEX)) { + /* + * We do not really know the valid range of scancodes + * so let's respond with KEY_RESERVED to anything we + * do not have mapping for [yet]. + */ + ke->index = index; + ke->keycode = KEY_RESERVED; + } else { retval = -EINVAL; goto out; } - entry = &rc_map->scan[index]; - - ke->index = index; - ke->keycode = entry->keycode; - ke->len = sizeof(entry->scancode); - memcpy(ke->scancode, &entry->scancode, sizeof(entry->scancode)); - retval = 0; out: