Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5596766img; Wed, 27 Mar 2019 11:22:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWzcY6Kh/j7A7v5xV3J+jJpFxu5utWXZgYDU4hfJmwPOwiACCVlXN8N4mTP0JwYM+w75MU X-Received: by 2002:a17:902:54f:: with SMTP id 73mr38779200plf.210.1553710973364; Wed, 27 Mar 2019 11:22:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710973; cv=none; d=google.com; s=arc-20160816; b=r8mPy+Fwetrm+5Jaj0p8/Lc5PUjgWQsUOxsmQQWKHU5ctP3ch7KQ3BgzMAocNLTmnN ExwZ/ctY6TyOnrGuG0EUi5psXGvA5IuzO5xuxaOZNQM9EBNC7rdmg+hG74QrUbdjdbly wUS+lRw5UHv0GocWnr7QP7pQMFr+S9YyM5Zqcq3c/ESY9ABNI0VvKL7iRlayGIAKcXsT V3MADsV6E7ZYCZ99yYcz8r+zaKa2fjHr1iqhRlMm62ugbOn/pQAkb20KUpcYaOl0nX5X 6yhnVNmilq0CNpgD17UFcNFW/lnz/ISW5nsGmRxeod16Gtdy67mifjIK8eJkFQyZ+28z DpiQ== 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=pZoMiHQMypjxiUoSsvu4JMI1Y4hyVO173HqY5du53xA=; b=qRT1naxgY83ktX5Ra1jL+iuen8kYLRdtYU/JU3ON1G8DoczJwQfdflZeM0IvWVqxkh IWB/SjVOrTQill1vh5Up9QWYlmnbyS2B9m4ZghyGcnet2TOTTM1Smy8Dwb+SOQdODiFa LW5xdMqRnxygCOYB53+b8mGO1gM3f4NZe25dX7MRxiIng//q9iqWNIwV6HrN0Ws093lt TmqV8Yygz3FRVEMYDPyhQxWy0NCxYvtanNI6wyWRgLVPN2T8VjGsIDNsmUYZciAAPFQS i5IqCjf//VAQrs8go4E6V/RrGbB4zt72OyIPAf6W6TOiUp53rweQJVG/9/r5LtFlxhpl rA2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AhErrvwd; 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 f89si21137330plb.20.2019.03.27.11.22.37; Wed, 27 Mar 2019 11:22:53 -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=AhErrvwd; 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 S2403817AbfC0SWF (ORCPT + 99 others); Wed, 27 Mar 2019 14:22:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:39976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403787AbfC0SWA (ORCPT ); Wed, 27 Mar 2019 14:22:00 -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 1445620651; Wed, 27 Mar 2019 18:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710919; bh=D8T0X0evmVkOPjk8PPbQlo3qzAHK2knJRFdlws3nCWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AhErrvwd3mxtUNR7uw5J/VsoVW/IVUhZxlfp6k6g955mrnNQ4ngZtrAvi0MFRGKxj /8zXXjV2Jt9WKrrtnh9wcZnbRHy0cHY4I2b6IYI0TSrdAl+MrIl/4r6w3DiElilar1 8jJhp8vL20LMLXzClqexcpVvUozHot7o0KBGoUQY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hans de Goede , "Rafael J . Wysocki" , Sasha Levin , linux-acpi@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 47/87] ACPI / video: Refactor and fix dmi_is_desktop() Date: Wed, 27 Mar 2019 14:20:00 -0400 Message-Id: <20190327182040.17444-47-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-1-sashal@kernel.org> MIME-Version: 1.0 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 cecf3e3e0803462335e25d083345682518097334 ] This commit refactors the chassis-type detection introduced by commit 53fa1f6e8a59 ("ACPI / video: Only default only_lcd to true on Win8-ready _desktops_") (where desktop means anything without a builtin screen). The DMI chassis_type is an unsigned integer, so rather then doing a whole bunch of string-compares on it, convert it to an int and feed the result to a switch case. Note the switch case uses hex values, this is done because the spec uses hex values too. This changes the check for "Main Server Chassis" from checking for 11 decimal to 11 hexadecimal, this is a bug fix, the original check for 11 decimal was wrong. Fixes: 53fa1f6e8a59 ("ACPI / video: Only default only_lcd to true ...") Signed-off-by: Hans de Goede [ rjw: Drop redundant return statements ] Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/acpi/acpi_video.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 667dc5c86fef..d79e38abd6d9 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -2069,21 +2069,28 @@ static int __init intel_opregion_present(void) return opregion; } +/* Check if the chassis-type indicates there is no builtin LCD panel */ static bool dmi_is_desktop(void) { const char *chassis_type; + unsigned long type; chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE); if (!chassis_type) return false; - if (!strcmp(chassis_type, "3") || /* 3: Desktop */ - !strcmp(chassis_type, "4") || /* 4: Low Profile Desktop */ - !strcmp(chassis_type, "5") || /* 5: Pizza Box */ - !strcmp(chassis_type, "6") || /* 6: Mini Tower */ - !strcmp(chassis_type, "7") || /* 7: Tower */ - !strcmp(chassis_type, "11")) /* 11: Main Server Chassis */ + if (kstrtoul(chassis_type, 10, &type) != 0) + return false; + + switch (type) { + case 0x03: /* Desktop */ + case 0x04: /* Low Profile Desktop */ + case 0x05: /* Pizza Box */ + case 0x06: /* Mini Tower */ + case 0x07: /* Tower */ + case 0x11: /* Main Server Chassis */ return true; + } return false; } -- 2.19.1