From patchwork Wed Jul 3 14:12:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 11029679 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50BAD13A4 for ; Wed, 3 Jul 2019 14:12:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 406772875F for ; Wed, 3 Jul 2019 14:12:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 347D4289D7; Wed, 3 Jul 2019 14:12:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86FB32875F for ; Wed, 3 Jul 2019 14:12:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726605AbfGCOMP (ORCPT ); Wed, 3 Jul 2019 10:12:15 -0400 Received: from gofer.mess.org ([88.97.38.141]:41179 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725944AbfGCOMO (ORCPT ); Wed, 3 Jul 2019 10:12:14 -0400 Received: by gofer.mess.org (Postfix, from userid 1000) id 0B25561A6D; Wed, 3 Jul 2019 15:12:12 +0100 (BST) From: Sean Young To: linux-media@vger.kernel.org Cc: Bastien Nocera Subject: [PATCH v4l-utils 2/2] gen_keytables.pl: remove duplicate scancodes from keymap Date: Wed, 3 Jul 2019 15:12:12 +0100 Message-Id: <20190703141212.31719-2-sean@mess.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190703141212.31719-1-sean@mess.org> References: <20190703141212.31719-1-sean@mess.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP One scancode can only be mapped to one keycode. In addition, the toml is invalid so the keymap cannot be loaded. Cc: Bastien Nocera Signed-off-by: Sean Young --- utils/keytable/gen_keytables.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/utils/keytable/gen_keytables.pl b/utils/keytable/gen_keytables.pl index 8f3a87e6..c14aded3 100755 --- a/utils/keytable/gen_keytables.pl +++ b/utils/keytable/gen_keytables.pl @@ -76,6 +76,7 @@ sub parse_file($$) my $legacy = shift; my $num_tables = 0; + my %scancodes = (); $warn = 0; next if ($filename =~ m/\.mod.c/); @@ -101,6 +102,7 @@ sub parse_file($$) $keyname =~ s/_table$//; $read = 1; $num_tables++; + %scancodes = (); next; } if (m/struct\s+rc_map_list.*=\s+{/) { @@ -142,7 +144,15 @@ sub parse_file($$) if ($read) { if (m/(0x[\dA-Fa-f]+)[\s\,]+(KEY|BTN)(\_[^\s\,\}]+)/) { - $out .= "$1 = \"$2$3\"\n"; + my $scancode = hex($1); + my $keycode = "$2$3"; + + if (exists($scancodes{$scancode})) { + printf STDERR "WARNING: duplicate scancode $1 in file $filename, set to $keycode and $scancodes{$scancode}\n"; + } else { + $out .= "$1 = \"$keycode\"\n"; + $scancodes{$scancode} = $keycode; + } next; } if (m/\}/) {