Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp592504ybt; Fri, 19 Jun 2020 08:54:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAu5ystDu/cpJDgPdiZTqe7NDUcfnHvooYCHlHPrWm19Cs3Dr0R1okFqOfU6uYbyCRM0GV X-Received: by 2002:a17:906:7ad7:: with SMTP id k23mr4397783ejo.439.1592582087360; Fri, 19 Jun 2020 08:54:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592582087; cv=none; d=google.com; s=arc-20160816; b=LYFl0/AOc9x0z0WMtB8W1wRjeBIlJZ8RS5Kk0rAFwEkzYxrnEnCAYRw4FmYaThwfud ciUY0QYOozxctJkpt3SjLYklzTwRiarBMKd9ux5JfC/0MDkYpoOsT9cfTCI93VVj+d6p Ea/twHLcKsPhD022IV3vNxVxCn05Zcnc5eTWQkF7PsenreonGobM/MRsWU//71ZPmSjw N5Ef0rc/RQc4rnoQ+NDbiw5yi8zS6HKojFQGmSqXmMhn6M7RSLCfitOXCabafQbzJJzm KsZbvbje+Ue2Gmn9xba/uX6VqwDPpH+x8QtialdNSyQH6QIHCAqIGW1jivZLV49nkGmo E1Xg== 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=VoD+EiqYkKiKTw3la7zwjD2gtscdA+XrMHVf7OkgXfM=; b=WG7xgH8fwoJY/7QuQkjVNCrksP9G652AOYFEvrKaXRB+ZpziiYXE20ens6tJt1HlkA tNnMpjtLiyeD7nVxDSMXzYVg/giXDTOnOv7tkEUi/Pxf0XH6aweKPku6+I9mNPm/OTtT hBuI4jvChbfVi3VG0wRDIiczOCF4n58VJjKiKBMcmBmiRMeIxaDRgUNgjigdMqy+1siI kf1H+g8DicmAetFZHmiZp12y1SLv+OzOwH6R+AMnugpFcdePk/lUX6PUtivJcCtitNmx h56+G6fuMlkpk7MKXPteszEdnTsbHYyh9jFAtTNmKhcAZAs3coj+Lw5lzkPJhZXMOn5g fFNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xSP17StT; 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 cx3si4066970edb.547.2020.06.19.08.54.24; Fri, 19 Jun 2020 08:54:47 -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=xSP17StT; 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 S2405302AbgFSPvz (ORCPT + 99 others); Fri, 19 Jun 2020 11:51:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:55216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393198AbgFSPXj (ORCPT ); Fri, 19 Jun 2020 11:23:39 -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 9B6E120B80; Fri, 19 Jun 2020 15:23:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592580218; bh=SK1nZ2hTcSnnnyugJKyjqisJYC5D/yJd2Et368taQwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xSP17StTTlF5PGr+RiXixpjRLzmA+Eq1vMMFWuwFhmDD45gtJvmcnVE7MlmOccwJk 2OltZ2/rf9GY/+Xeb6xoP7yW/JzWO9WhSBboKsqHTV3G5ZnLp+McnamDDAejBCdoZS 7dcCkAd0lruLU9H7E+4ljI+p101bsiv9N3DhCD0c= 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 5.7 166/376] platform/x86: intel-vbtn: Do not advertise switches to userspace if they are not there Date: Fri, 19 Jun 2020 16:31:24 +0200 Message-Id: <20200619141718.182019036@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141710.350494719@linuxfoundation.org> References: <20200619141710.350494719@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 990fbb48067bf8cfa34b7d1e6e1674eaaef2f450 ] Commit de9647efeaa9 ("platform/x86: intel-vbtn: Only activate tablet mode switch on 2-in-1's") added a DMI chassis-type check to avoid accidentally reporting SW_TABLET_MODE = 1 to userspace on laptops (specifically on the Dell XPS 9360), to avoid e.g. userspace ignoring touchpad events because userspace thought the device was in tablet-mode. But if we are not getting the initial status of the switch because the device does not have a tablet mode, then we really should not advertise the presence of a tablet-mode switch to userspace at all, as userspace may use the mere presence of this switch for certain heuristics. 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 | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c index 634096cef21a..500fae82e12c 100644 --- a/drivers/platform/x86/intel-vbtn.c +++ b/drivers/platform/x86/intel-vbtn.c @@ -55,6 +55,7 @@ static const struct key_entry intel_vbtn_switchmap[] = { struct intel_vbtn_priv { struct key_entry keymap[KEYMAP_LEN]; struct input_dev *input_dev; + bool has_switches; bool wakeup_mode; }; @@ -70,7 +71,7 @@ static int intel_vbtn_input_setup(struct platform_device *device) keymap_len += ARRAY_SIZE(intel_vbtn_keymap); } - if (true) { + if (priv->has_switches) { memcpy(&priv->keymap[keymap_len], intel_vbtn_switchmap, ARRAY_SIZE(intel_vbtn_switchmap) * sizeof(struct key_entry)); @@ -138,16 +139,12 @@ out_unknown: static void detect_tablet_mode(struct platform_device *device) { - const char *chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE); struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); acpi_handle handle = ACPI_HANDLE(&device->dev); unsigned long long vgbs; acpi_status status; int m; - if (!(chassis_type && strcmp(chassis_type, "31") == 0)) - return; - status = acpi_evaluate_integer(handle, "VGBS", NULL, &vgbs); if (ACPI_FAILURE(status)) return; @@ -158,6 +155,19 @@ static void detect_tablet_mode(struct platform_device *device) input_report_switch(priv->input_dev, SW_DOCK, m); } +static bool intel_vbtn_has_switches(acpi_handle handle) +{ + const char *chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE); + unsigned long long vgbs; + acpi_status status; + + if (!(chassis_type && strcmp(chassis_type, "31") == 0)) + return false; + + status = acpi_evaluate_integer(handle, "VGBS", NULL, &vgbs); + return ACPI_SUCCESS(status); +} + static int intel_vbtn_probe(struct platform_device *device) { acpi_handle handle = ACPI_HANDLE(&device->dev); @@ -176,13 +186,16 @@ static int intel_vbtn_probe(struct platform_device *device) return -ENOMEM; dev_set_drvdata(&device->dev, priv); + priv->has_switches = intel_vbtn_has_switches(handle); + err = intel_vbtn_input_setup(device); if (err) { pr_err("Failed to setup Intel Virtual Button\n"); return err; } - detect_tablet_mode(device); + if (priv->has_switches) + detect_tablet_mode(device); status = acpi_install_notify_handler(handle, ACPI_DEVICE_NOTIFY, -- 2.25.1