Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7150573ybi; Mon, 8 Jul 2019 15:39:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzX5GutSon9gnxu7DNyaIItgJLYQ6Dv2zEgmBbFDWhMzZYHXmJ9SCN+AM0iQ9BZ71is7Q+K X-Received: by 2002:a17:90a:1b4a:: with SMTP id q68mr28720543pjq.61.1562625588757; Mon, 08 Jul 2019 15:39:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625588; cv=none; d=google.com; s=arc-20160816; b=HUO49u83gXKaoS/JJP8B2fuN99WGW/eKwEZxxhFWmWPBPJNoxLvq+V1CO1mSvGBieE mC+Hj0qeZ32rqfrbZk0b1Gk5SmjjjzZB0C8xob8AYBBLlf+bskcgJzEnI4cZHJ1NuIzP PwVTkblZeYz0fpyLIJHRmGUm5bXNeJo1LHCEwPWgDTXN7QprjbSfwplIjufnC6DLaEU/ wKS9waTCnozEePTGr+ZPW/LwkUuE5BOmgv76PZTu/P9hQsfJtrLQIsJvqOOgHBU4ATWZ Gn61bGcSSVPll8zwzbjcAmuGmO2ZPOXiLCxNvzY3P23TXTWOLw1rkZgseZfPfw29cla8 xydg== 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=h1BG/v08fl8rYxMntjDrZ9pRH8v3hlFP16YCDqUCYOM=; b=SAcJeVd0+XvSFgqKKJd4QpEtKr5n51oykw2pqJmJey9jlRsNsk81CyXNEPOpgu3WF6 6yN2bkLWOKrb7c0HcWTg3FHFOeKOFC+da0r2iK2fkdpSRphvfwPzZttsPYw92wKlJM4A Dhu/vh8+vgbRb/9dWRlokHAdBcRc0iP2fL5ypAktmsealgG1D42+zS0QPUQ7XGVBuQlM LUx9dipwwQkklELc4Lr3i26f6yjqkPn8ObKC4ffcKaXKaLGa2BJI07niVnNID/7b8/Cz IJ96aR5K+FfuJCAY7kfX1BjBZGMng76TkrC2Jd1xwk+UiPBg3fF2KNTP3b0bPzz4Hzsp UqlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GVWiae7Q; 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 j69si20135961pgd.589.2019.07.08.15.39.34; Mon, 08 Jul 2019 15:39:48 -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=pass header.i=@kernel.org header.s=default header.b=GVWiae7Q; 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 S1732974AbfGHPeE (ORCPT + 99 others); Mon, 8 Jul 2019 11:34:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:36070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390452AbfGHPdy (ORCPT ); Mon, 8 Jul 2019 11:33:54 -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 3273920651; Mon, 8 Jul 2019 15:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562600033; bh=lpF8smmZKzXzIFKYhBNQHTJe28GZk9w9HrrXxBl46x0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GVWiae7QBD6ICZw2epNC2xbpHXzv/sAA+zKPPeG0aUMGzLX383bNx5eBvcbbcS3dn VsKTAI340KO32Vq9zSuDl9GlGzGPlZT5CTC2Vlk08gyxBQUlEyvXikEqEj7Brzt4ot F/U2Wz8XF5lziseWWJmeE6TxDREF33ZcSajzh7Z8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathew King , Jett Rink , Mario Limonciello , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.1 45/96] platform/x86: intel-vbtn: Report switch events when event wakes device Date: Mon, 8 Jul 2019 17:13:17 +0200 Message-Id: <20190708150528.967156980@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150526.234572443@linuxfoundation.org> References: <20190708150526.234572443@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 [ Upstream commit cb1921b17adbe6509538098ac431033378cd7165 ] When a switch event, such as tablet mode/laptop mode or docked/undocked, wakes a device make sure that the value of the swich is reported. Without when a device is put in tablet mode from laptop mode when it is suspended or vice versa the device will wake up but mode will be incorrect. Tested by suspending a device in laptop mode and putting it in tablet mode, the device resumes and is in tablet mode. When suspending the device in tablet mode and putting it in laptop mode the device resumes and is in laptop mode. Signed-off-by: Mathew King Reviewed-by: Jett Rink Reviewed-by: Mario Limonciello Signed-off-by: Andy Shevchenko Signed-off-by: Sasha Levin --- drivers/platform/x86/intel-vbtn.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c index 06cd7e818ed5..a0d0cecff55f 100644 --- a/drivers/platform/x86/intel-vbtn.c +++ b/drivers/platform/x86/intel-vbtn.c @@ -76,12 +76,24 @@ static void notify_handler(acpi_handle handle, u32 event, void *context) struct platform_device *device = context; struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); unsigned int val = !(event & 1); /* Even=press, Odd=release */ - const struct key_entry *ke_rel; + const struct key_entry *ke, *ke_rel; bool autorelease; if (priv->wakeup_mode) { - if (sparse_keymap_entry_from_scancode(priv->input_dev, event)) { + ke = sparse_keymap_entry_from_scancode(priv->input_dev, event); + if (ke) { pm_wakeup_hard_event(&device->dev); + + /* + * Switch events like tablet mode will wake the device + * and report the new switch position to the input + * subsystem. + */ + if (ke->type == KE_SW) + sparse_keymap_report_event(priv->input_dev, + event, + val, + 0); return; } goto out_unknown; -- 2.20.1