Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp55156ybg; Mon, 8 Jun 2020 16:16:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhtyMMiG8iav6Nl71AJ8v/SYrP0bcydModoipCy+Hhlr5dN3lrmWA3OTLffvVxVff6V6T8 X-Received: by 2002:a05:6402:2070:: with SMTP id bd16mr23609801edb.35.1591658177359; Mon, 08 Jun 2020 16:16:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591658177; cv=none; d=google.com; s=arc-20160816; b=opCdaZYWzzRzKRZPSM2BpRApYsU8d5D58E3vFQwfZD2ICq0tcFVPUGhHQvkRv88xSK Ahk2CeUa8MVRrg8tJYQhwinmBkzZ80QHCMKDWjJqqYkHPH6QVMr7q9ICkQrZUPR16eIj Unp0aVl0DbLBZcOfTDgPx+5KCzUbWGpX4a4zQGVXMalTAa1AimmlRRe5L0uKhhVtEieK qpDqK3IyvGN7HFHHjTIDMOsbZbhA98HDMUfNDO0rrr3fLSqtuLANqXbv3qPaTabX6r2t UGij8b/MpAsaIKzaWORfoQQv/GOD0CXoH9fkhA+uipXPnAxcL6pgUwL4U35lQLTstCez YE6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=huYyKytFqtSfN6wTRXYnnMHMaeIu5DkF2xNMH5giwCw=; b=BTYrKDqfaPJuz5V2YoeUpS0pNkAK6xno4yHIwFnKTA/S3A/wr6ad3qKNYYVtsjkMBm PMZnchkjZwetRBv12a6BcbTt8vDHF+Oq4A+hGd+kPfhGyj4ahtoT36QoK0F9wgKRTpRq UIi8k6FJVzQlpzBQXq4cZfWDBfhn8oCqi1bIJkD95CTwGBoUI53TbhVaHZzO8NvBgdG/ kZSXIMpJf4rUKyd7o2PugkRxh1esBsygwAQY75/4AGRuS565Bbka11IzOeM8RiTcxcKx PrfYGOiNR8bo4esusEPJir7VZgP58NHD3kifMMy+HjOeIBWu7CMp84IixHx5wW0EdIFS WD7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tY22pXf9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q21si9471365edw.46.2020.06.08.16.15.54; Mon, 08 Jun 2020 16:16:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tY22pXf9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726943AbgFHXLZ (ORCPT + 99 others); Mon, 8 Jun 2020 19:11:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:55956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727865AbgFHXJ6 (ORCPT ); Mon, 8 Jun 2020 19:09:58 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 661CB20897; Mon, 8 Jun 2020 23:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657798; bh=3ojo2VBVuawBc4HDxLn8sIbL+mr/RC4gim2D8Fr8+Hs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tY22pXf9UTv5KXGUzRcd0zZY72CmCxzSjqKrE7L9qbMLS9A2CE90HUrF4nr74Eypo HGXiRTg+U13s2OifWYRlEaNE8c5+LulAjFjzm21VFNmzU/k/GJ7pqevUsbR3s6TyIr YhQG4EYEQTAiVeHIEcKOExFA9ubHLrS0XhtV9vW8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hans de Goede , Andy Shevchenko , Sasha Levin , platform-driver-x86@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 176/274] platform/x86: intel-vbtn: Split keymap into buttons and switches parts Date: Mon, 8 Jun 2020 19:04:29 -0400 Message-Id: <20200608230607.3361041-176-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans de Goede [ Upstream commit f6ba524970c4b73b234bf41ecd6628f5803b1559 ] Split the sparse keymap into 2 separate keymaps, a buttons and a switches keymap and combine the 2 to a single map again in intel_vbtn_input_setup(). This is a preparation patch for not telling userspace that we have switches when we do not have them (and for doing the same for the buttons). Fixes: de9647efeaa9 ("platform/x86: intel-vbtn: Only activate tablet mode switch on 2-in-1's") Signed-off-by: Hans de Goede Signed-off-by: Andy Shevchenko Signed-off-by: Sasha Levin --- drivers/platform/x86/intel-vbtn.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c index 191894d648bb..634096cef21a 100644 --- a/drivers/platform/x86/intel-vbtn.c +++ b/drivers/platform/x86/intel-vbtn.c @@ -40,14 +40,20 @@ static const struct key_entry intel_vbtn_keymap[] = { { KE_IGNORE, 0xC7, { KEY_VOLUMEDOWN } }, /* volume-down key release */ { KE_KEY, 0xC8, { KEY_ROTATE_LOCK_TOGGLE } }, /* rotate-lock key press */ { KE_KEY, 0xC9, { KEY_ROTATE_LOCK_TOGGLE } }, /* rotate-lock key release */ +}; + +static const struct key_entry intel_vbtn_switchmap[] = { { KE_SW, 0xCA, { .sw = { SW_DOCK, 1 } } }, /* Docked */ { KE_SW, 0xCB, { .sw = { SW_DOCK, 0 } } }, /* Undocked */ { KE_SW, 0xCC, { .sw = { SW_TABLET_MODE, 1 } } }, /* Tablet */ { KE_SW, 0xCD, { .sw = { SW_TABLET_MODE, 0 } } }, /* Laptop */ - { KE_END }, }; +#define KEYMAP_LEN \ + (ARRAY_SIZE(intel_vbtn_keymap) + ARRAY_SIZE(intel_vbtn_switchmap) + 1) + struct intel_vbtn_priv { + struct key_entry keymap[KEYMAP_LEN]; struct input_dev *input_dev; bool wakeup_mode; }; @@ -55,13 +61,29 @@ struct intel_vbtn_priv { static int intel_vbtn_input_setup(struct platform_device *device) { struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); - int ret; + int ret, keymap_len = 0; + + if (true) { + memcpy(&priv->keymap[keymap_len], intel_vbtn_keymap, + ARRAY_SIZE(intel_vbtn_keymap) * + sizeof(struct key_entry)); + keymap_len += ARRAY_SIZE(intel_vbtn_keymap); + } + + if (true) { + memcpy(&priv->keymap[keymap_len], intel_vbtn_switchmap, + ARRAY_SIZE(intel_vbtn_switchmap) * + sizeof(struct key_entry)); + keymap_len += ARRAY_SIZE(intel_vbtn_switchmap); + } + + priv->keymap[keymap_len].type = KE_END; priv->input_dev = devm_input_allocate_device(&device->dev); if (!priv->input_dev) return -ENOMEM; - ret = sparse_keymap_setup(priv->input_dev, intel_vbtn_keymap, NULL); + ret = sparse_keymap_setup(priv->input_dev, priv->keymap, NULL); if (ret) return ret; -- 2.25.1