Received: by 10.213.65.68 with SMTP id h4csp55674imn; Thu, 22 Mar 2018 22:19:28 -0700 (PDT) X-Google-Smtp-Source: AG47ELs7fNwcshLymufDhuSB5U1wfwsPHPR+tJkn62/wKxC0iGP2jMJJJUgc5AbAOrVUmS4OMSRM X-Received: by 10.101.73.2 with SMTP id p2mr5877725pgs.397.1521782368140; Thu, 22 Mar 2018 22:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521782368; cv=none; d=google.com; s=arc-20160816; b=DClL3N1Cp0xtg6piAALs1/2fG+RGxw0YLQoM+hIzeSEoAHl0OzvYLrce0VhxwttROh 9ooJ+0u5qwQNkUccZyPPUmnR26arA3cVjIx3GvLOBIzNVn5zONG65FmBBI38MJYCdPLb Dsk2T1bscjZQs1pE8oTkHmyhmmKMHsQvhNdiA9Mey4MALy4RD9ODC7TMKY+buV+BLgjb IcjIYNndgwoEpTYgmffAbkYUwfj60Iw5W5B2aVSkwCJZr2OqPTXZTqLchT8YcJShNZAo GoU3mQTJ28KAWFTWlNSrqFKAL8FqEfua2a986Rw7N9+MXdpYNds/LwBZtMGA2tROq807 12wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=8Iy1Uo1nJn41cuc2YjpxaHQ0rouu/fuGc1edcFxvQ3w=; b=h88roisAoJ6howgl2nOPLQ+tQM738vY5kE1cDmq+/RUxXEDImwn+kelCAIX+eqLGRo TKvE4hYSqd2bptfZJvqCrND7FoQb9unn+pnDxx75+i3qAn8Y8xKvHtMxp0Il7b2WJWDY oB5XeouoWb0RroKDBKUjHCw0Zu2JrNNb4sy75h9yLjWcuTsxuedRzz0gjJa+ymmrHzlp ai3fxVNCFVE9RyWBWRTlLqzs1ttrwS8RQuw80RoB0dpnd5Zccuse/Aar1xThmkkfUD4D GvTAOrhtmvNGCdAQRe9PmVyKiuyEiIqOtoNhSl9h9DZds2Qhe9nNEtxbS0Kn3YsIxBQy KTag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2-v6si7892257pli.242.2018.03.22.22.19.13; Thu, 22 Mar 2018 22:19:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752025AbeCWFSL (ORCPT + 99 others); Fri, 23 Mar 2018 01:18:11 -0400 Received: from server.atrad.com.au ([150.101.241.2]:36082 "EHLO server.atrad.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751935AbeCWFSK (ORCPT ); Fri, 23 Mar 2018 01:18:10 -0400 Received: from marvin.atrad.com.au (IDENT:1008@marvin.atrad.com.au [192.168.0.2]) by server.atrad.com.au (8.15.2/8.14.9) with ESMTPS id w2N5HHrW029336 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 23 Mar 2018 15:47:19 +1030 Date: Fri, 23 Mar 2018 15:47:17 +1030 From: Jonathan Woithe To: "Darren Hart (VMware)" Cc: LKML , platform-driver-x86@vger.kernel.org, Jan-Marek Glogowski , Micha?? K??pie?? Subject: Re: [PATCH] platform/x86: fujitsu-laptop: Simplify soft key handling Message-ID: <20180323051717.GI10580@marvin.atrad.com.au> References: <2721b2f93063dd6d5586e151ec6cc14fcd39ec1b.1521768118.git.dvhart@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2721b2f93063dd6d5586e151ec6cc14fcd39ec1b.1521768118.git.dvhart@infradead.org> User-Agent: Mutt/1.6.1 (2016-04-27) X-MIMEDefang-action: accept X-Scanned-By: MIMEDefang 2.79 on 192.168.0.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 22, 2018 at 06:27:16PM -0700, Darren Hart (VMware) wrote: > The hardcoded BIT(X) used in the soft key handling can be confusing and > prone to errors. > > Instead, use the status FLAG_* defines for the sparse keymap index. > Rather than check for each known bit, use a bitmask to filter for all > known soft keys, and use the for_each_set_bit iterator. I agree. Reviewed-by: Jonathan Woithe Regards jonathan > Cc: Jan-Marek Glogowski > Cc: Micha?? K??pie?? > Cc: Jonathan Woithe > Signed-off-by: Darren Hart (VMware) > --- > > Note: this applies on top of Jan-Marek's recent RFKILL and MICMUTE hotkey patch. > I'd really appreciate a Tested-by from Jan-Marek in particular. You can get the > entire series ready for testing here: > > http://git.infradead.org/linux-platform-drivers-x86.git/shortlog/refs/heads/review-dvhart-fujitsu > > Also wondering if LID and DOCK might benefit from an input event... > > drivers/platform/x86/fujitsu-laptop.c | 47 ++++++++++++++++++----------------- > 1 file changed, 24 insertions(+), 23 deletions(-) > > diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c > index cd95b6f3a064..6afeaece2f50 100644 > --- a/drivers/platform/x86/fujitsu-laptop.c > +++ b/drivers/platform/x86/fujitsu-laptop.c > @@ -91,6 +91,9 @@ > #define FLAG_RFKILL BIT(5) > #define FLAG_LID BIT(8) > #define FLAG_DOCK BIT(9) > +#define FLAG_TOUCHPAD_TOGGLE BIT(26) > +#define FLAG_MICMUTE BIT(29) > +#define FLAG_SOFTKEYS (FLAG_RFKILL | FLAG_TOUCHPAD_TOGGLE | FLAG_MICMUTE) > > /* FUNC interface - LED control */ > #define FUNC_LED_OFF BIT(0) > @@ -456,14 +459,15 @@ static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event) > /* ACPI device for hotkey handling */ > > static const struct key_entry keymap_default[] = { > - { KE_KEY, KEY1_CODE, { KEY_PROG1 } }, > - { KE_KEY, KEY2_CODE, { KEY_PROG2 } }, > - { KE_KEY, KEY3_CODE, { KEY_PROG3 } }, > - { KE_KEY, KEY4_CODE, { KEY_PROG4 } }, > - { KE_KEY, KEY5_CODE, { KEY_RFKILL } }, > - { KE_KEY, BIT(5), { KEY_RFKILL } }, > - { KE_KEY, BIT(26), { KEY_TOUCHPAD_TOGGLE } }, > - { KE_KEY, BIT(29), { KEY_MICMUTE } }, > + { KE_KEY, KEY1_CODE, { KEY_PROG1 } }, > + { KE_KEY, KEY2_CODE, { KEY_PROG2 } }, > + { KE_KEY, KEY3_CODE, { KEY_PROG3 } }, > + { KE_KEY, KEY4_CODE, { KEY_PROG4 } }, > + { KE_KEY, KEY5_CODE, { KEY_RFKILL } }, > + /* Soft keys read from status flags */ > + { KE_KEY, FLAG_RFKILL, { KEY_RFKILL } }, > + { KE_KEY, FLAG_TOUCHPAD_TOGGLE, { KEY_TOUCHPAD_TOGGLE } }, > + { KE_KEY, FLAG_MICMUTE, { KEY_MICMUTE } }, > { KE_END, 0 } > }; > > @@ -903,7 +907,8 @@ static void acpi_fujitsu_laptop_release(struct acpi_device *device) > static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event) > { > struct fujitsu_laptop *priv = acpi_driver_data(device); > - int scancode, i = 0, ret; > + unsigned long flags; > + int scancode, i = 0; > unsigned int irb; > > if (event != ACPI_FUJITSU_NOTIFY_CODE) { > @@ -930,21 +935,17 @@ static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event) > "Unknown GIRB result [%x]\n", irb); > } > > - /* On some models (first seen on the Skylake-based Lifebook > - * E736/E746/E756), the touchpad toggle hotkey (Fn+F4) is > - * handled in software; its state is queried using FUNC_FLAGS > + /* > + * First seen on the Skylake-based Lifebook E736/E746/E756), the > + * touchpad toggle hotkey (Fn+F4) is handled in software. Other models > + * have since added additional "soft keys". These are reported in the > + * status flags queried using FUNC_FLAGS. > */ > - if (priv->flags_supported & (BIT(5) | BIT(26) | BIT(29))) { > - ret = call_fext_func(device, FUNC_FLAGS, 0x1, 0x0, 0x0); > - if (ret & BIT(5)) > - sparse_keymap_report_event(priv->input, > - BIT(5), 1, true); > - if (ret & BIT(26)) > - sparse_keymap_report_event(priv->input, > - BIT(26), 1, true); > - if (ret & BIT(29)) > - sparse_keymap_report_event(priv->input, > - BIT(29), 1, true); > + if (priv->flags_supported & (FLAG_SOFTKEYS)) { > + flags = call_fext_func(device, FUNC_FLAGS, 0x1, 0x0, 0x0); > + flags &= (FLAG_SOFTKEYS); > + for_each_set_bit(i, &flags, BITS_PER_LONG) > + sparse_keymap_report_event(priv->input, BIT(i), 1, true); > } > } > > -- > 2.14.3 > > > -- > Darren Hart > VMware Open Source Technology Center --