Received: by 10.213.65.68 with SMTP id h4csp1197944imn; Thu, 22 Mar 2018 18:28:58 -0700 (PDT) X-Google-Smtp-Source: AG47ELuK2nHxB0/OaGqaBqCIKzc62eUBONix5VvtlNzK0hVi0+Zhs1f7tntKfWad5f5mgJqQ4kz+ X-Received: by 10.98.220.86 with SMTP id t83mr11039707pfg.60.1521768537972; Thu, 22 Mar 2018 18:28:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521768537; cv=none; d=google.com; s=arc-20160816; b=buDPz8xLk2qQPC14EGyp3Hq7wT85nkzpzZ85V1OX7JZCns823FtaARGBq76lJAPwHQ zcMFbyqjjKkvX2zfqb7+yZZAN4TkHKIR6zJOMV3R3kAvcCn2HNX+WnIQ6KnUUGnSJX3H fc0MWh+XxXypUe7eefgSMhrowvSJiWD660DJuWGIybeu4bS0y+JGZN2coM3OPosoPFcy Emm4md/i4K9Mzchvn6Uk1zSkkoun3uBOgEyCVENgb+8Bd5KlN67ear/SLK5yexT2dci/ AlUUgsaAkCkG+jBSumFc0AdikwJ+dyf7Ej3A/QbR0k6c32bV7JUQTrkmuPdcqZlgFsKx B+nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=gnQ++0mJc60fT3uf26qdXYN48ZvmKwIi2UQ1fP+Jeog=; b=J8YFzVi+TVqM5mXAeseGMgaNRkpb/x1gkj6bqAtUDnkWR+U5epcEUxp11ul+G+OjOc f3Q4RxcpYlBfkTOSFJYOCJolOJge+ixwayooCGvPF7RJdkJggX+WTSIEn7L7KJY9iyAg wvvuPsmWQ14fi+6f82M/CGUjYBTNszSRVEIex1SvgU0RpcriKkEV8Cjv/e6w20xKcWby TDEq2GapfF2c7zDY/opqlQ/fYCQ8Xb7RB9K13B5m/IKcfaQ4SSgf98NCj66qYFZMKQlC Glt3oLeeqJKYYSZcHXCBQxMpPPNZOFo1vm0Un/o3YyeB6UlCn3v+hkpkP7YHkLYtqI0D zANQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Yai4a/zj; 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 z67si5826841pfd.257.2018.03.22.18.28.42; Thu, 22 Mar 2018 18:28:57 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Yai4a/zj; 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 S1751666AbeCWB1W (ORCPT + 99 others); Thu, 22 Mar 2018 21:27:22 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:44978 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751303AbeCWB1V (ORCPT ); Thu, 22 Mar 2018 21:27:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:MIME-Version:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=gnQ++0mJc60fT3uf26qdXYN48ZvmKwIi2UQ1fP+Jeog=; b=Yai4a/zjakCzDOCUCff25CHgq u+7a8PEOQlAu0sSmEc+1OakTT8dwvugVBBrrkCDf/QEMErj9vd+T9n6tPT1eBE17WH0RCUs1bkOK+ cUmyHiYnFgcAFVE9iXwRPfXUP5VkjG0mcFKRorgo894K7jD5N7SPzi7bX2YYiMirNSdUHKjTJbW3v h+0iyQeTtHfLGDbxc43hsYPL2uApl6X5sk+rvKofCH3U6Kr5XPqwiXOHr05duglxRrFLC6GjNCDKH MOH2yibtgQO5pOINTJLFSleBSByuXJFr6VdsyOJ4+Yx15So7qhFyBsU4uoreulvnqW1JqimV7CMqZ sXmxV+8zA==; Received: from dvhart by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1ezBUE-0003BL-Jc; Fri, 23 Mar 2018 01:27:18 +0000 Date: Thu, 22 Mar 2018 18:27:16 -0700 From: "Darren Hart (VMware)" To: LKML , platform-driver-x86@vger.kernel.org Cc: Jan-Marek Glogowski , =?utf-8?B?TWljaGHFgiBLxJlwaWXFhA==?= , Jonathan Woithe Subject: [PATCH] platform/x86: fujitsu-laptop: Simplify soft key handling Message-ID: <2721b2f93063dd6d5586e151ec6cc14fcd39ec1b.1521768118.git.dvhart@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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