Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp250138ybd; Tue, 25 Jun 2019 20:44:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzV1HcDyNPsFG5pda1QgcXf5iWTqx1uOOSdJkVBlHYWPoKsrzVUQ6OBP8ygMx28js3iyX51 X-Received: by 2002:a17:902:4a:: with SMTP id 68mr2575128pla.235.1561520670096; Tue, 25 Jun 2019 20:44:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561520670; cv=none; d=google.com; s=arc-20160816; b=ul/zesaDKpLRE7qPDPyZ/IXnb23tCaX3xGon8sJCw5roJFd398bBs7YvA0KdDlmZIN e+Ljeqz0LjVH4UQrN/Dp4b+4kJFFVEvgchPRGRMCTfsoxysLj0pIN8o1A/OMTykyKbPc oC2mDv+o8y39OKPFQw8ZWcTNJ2pQDh/SSvh/x4kgegf+KgifTnIWVcBnzEPEiiJTBDcm leimoVAFktWycmvRDq7/tx/BIv4aUV2/yPjAPFnwwUP8XMZ3hqTE28y0qR+pf23CHH4a 2uDSF4BaJRTjUWrZCabS+3CAV9dShBVa0NCGbWtExJVBJlzlsLqE+m1bFGV6iQtIeV/t Y1iQ== 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=QTc5cKWp9Ap1hlrBi4JGPUX5xWMZP31wLdtpuo001V0=; b=cO8/IAvWdw9zkxaRBMcobBRyV6dVTYO++3cfp6UBAxieqIQnHALxmAEuhFcThSEo7j 1f6omvIOTW6+4jmlFnkm8mYmJlCz2qqAkumumaVkBAjQK9imIDg/cxwVO3P0nMbQ2i7R cLY04dwzdEnud39q1SGf0rcSaUWblVZPcS6GBKyqaQBax6DMd/s5xRuSbneV3VCe+89x XwAa5Ig/ufBfK/J0kCnJq/O8m9TKk6W/KWo9OXj1ibCl5BlQ3k0VPBEQ4kCJN9OjwM2U I0iab3ju6fktOJVGhlZD0GqLIB0hhkXq5Ni5E8cR39nkr3O3Oi10Al6PTMEEWNwESzoC eo2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="p/s0ISrp"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a24si14767807pgw.395.2019.06.25.20.44.14; Tue, 25 Jun 2019 20:44:30 -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="p/s0ISrp"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727307AbfFZDnW (ORCPT + 99 others); Tue, 25 Jun 2019 23:43:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:54360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727268AbfFZDnM (ORCPT ); Tue, 25 Jun 2019 23:43:12 -0400 Received: from sasha-vm.mshome.net (mobile-107-77-172-74.mobile.att.net [107.77.172.74]) (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 7B73E20883; Wed, 26 Jun 2019 03:43:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561520591; bh=5rFNYZyvNdwrIOYTJ/UqqG+fqyrkLzHd4QdCCujhBts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p/s0ISrpG/npDrHlgob0d9wpyxB2TYpKyqC1p5/abdJ9ELcFzkcqZfHCOfHeAjNsa 5h+Oc+anlVfG97izM3YtCkR9fKBAP4cPTLRwcN4nYoW1eLUBtrTZOpPZI3m5A8ruuN 3I78PmhaTUVNOgjeCMQOXoPEGZu6spB0ncoZAzxc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mathew King , Jett Rink , Mario Limonciello , Andy Shevchenko , Sasha Levin , platform-driver-x86@vger.kernel.org Subject: [PATCH AUTOSEL 5.1 41/51] platform/x86: intel-vbtn: Report switch events when event wakes device Date: Tue, 25 Jun 2019 23:40:57 -0400 Message-Id: <20190626034117.23247-41-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190626034117.23247-1-sashal@kernel.org> References: <20190626034117.23247-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: Mathew King [ 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