Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp992877ybt; Fri, 19 Jun 2020 20:53:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzv4glSHAEbr9eNtUe4u2anK1DG0uq3btZfdks/5hPVEz2fb1B9q8s0WS7oRLqsFvoOYhOt X-Received: by 2002:aa7:da8c:: with SMTP id q12mr6503146eds.385.1592625201435; Fri, 19 Jun 2020 20:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592625201; cv=none; d=google.com; s=arc-20160816; b=pTTximn/svh9Xb7EO6nIJiZ1C+dC7sLdkrXmsHBUzE6/UMOQqQKBE2zlBi49gjhd/s uy1mdTCCUk2ydhORpf9RObECJdWE5ZBFDccFbKgwZS0nJK+9ba5SN3NxapkMtLyTbjxY hURVc27vriAh5PuElpq517uuSMGTpb7efO7ZLctEh5wZc+62ONgiRv8RsbY/z3xOi73W 6XIpsONSLVIQ5XuxTFscARzwJEo1tA9VOiqbC5XlO7y/juyYIAkGqGt0+g5r+FjnWTAo cjFmObsE6cNXGBiIFvkVdJxQ7mkHOvyiTCRyK8sfNyJwVWxp9gpu2XyuDubcLU+ymOpX Hfmw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aiwCVFDTc3RjtOc45LetBwmJgBR3AP1x8KHLekdsYfk=; b=WwXow47J72AKXUKM1xIdBx5RXkoU+GyKLdxi+dAiUT3MpOCg/DbJHVR1ZiRcUvZ3UU 7m6jfIZhjkjJe93bm66z+gy0WH4KLENwNj0v1nd9G8D07fqdC5NTckaSEHTSjSMYvtR6 UfzlpQ42OrkmtuJeLup+PtomlpduvWBiv7kvRHt1QXlHLk2SeQNYjPpUbIo0+8T69m8M Y0R1oy3FsOonPVtQ503w2NYeMoYDaXKMwhX5YA840LZQebFZ6e09n/qQ8AKn3fCoLRz2 szBxlNT9TVp4cde8lk4H2rG4NT0d0UXjqFGKOjKWQMbS3KHp6WPXPJGXn8/AfRZM1g4M AK8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yr9VCgoj; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id do5si6941185ejc.105.2020.06.19.20.52.59; Fri, 19 Jun 2020 20:53:21 -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=Yr9VCgoj; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394446AbgFSQXN (ORCPT + 99 others); Fri, 19 Jun 2020 12:23:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:55776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390536AbgFSO7g (ORCPT ); Fri, 19 Jun 2020 10:59:36 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9734321973; Fri, 19 Jun 2020 14:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578775; bh=duFMSxH9LLHFznCxFrz5SCLi4Onawnsd+0BCsQHec3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yr9VCgojJYyIE9PKvZ8+U94baC3QDOOiWT0eaHKaoQbSw8RmEWDayAyFV9rfiGWtl 5sVNiPbqSywKlbCYSawXPm1NLBOzNytr7fBQxVfBvbPxZNs1vUzjfprJpRIkIdqaBu SVrixKdf1cXobgOPE1IEUlJ99jJvq+9UKumvaoco= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Andy Shevchenko , Sasha Levin Subject: [PATCH 4.19 150/267] platform/x86: intel-vbtn: Split keymap into buttons and switches parts Date: Fri, 19 Jun 2020 16:32:15 +0200 Message-Id: <20200619141656.025785903@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 0bcfa20dd614..e42203776727 100644 --- a/drivers/platform/x86/intel-vbtn.c +++ b/drivers/platform/x86/intel-vbtn.c @@ -39,14 +39,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; }; @@ -54,13 +60,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