Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5584646img; Wed, 27 Mar 2019 11:09:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJ+JM4tB3Tus44EGWo2LgITriU3ENhJQaN1PgJ8ahWnGeEBewHEEmHW2qz22K9B8NthkNX X-Received: by 2002:a62:e418:: with SMTP id r24mr37185690pfh.52.1553710173657; Wed, 27 Mar 2019 11:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710173; cv=none; d=google.com; s=arc-20160816; b=R7QtJ1Ekp61zXGd4gACpSlLvmdvBSIZBaxnV8KqvlqEsMNvtVNQcnJQalsUH6g/auB wEgrTqUH42o3tClLdeyOHM/QLnIocsyHlJWShJI5G2aRe01PqCNtYJ6iA3vOlacWRUuB TNeeZMAV8D/GIz9oheKlZHg7j694GPcTz3CENMyDk5a73YnrVgluwONbPkWotwdSKYIh 0QO+mMZEiHlPcpLxN8+cMnjpqQN5Nz+8WCieJ7vg/szdK0dOwhpiJKWUkK6Fd+lwtLXY QvrP1rTbYGdDRBAGo8la+ImNff0c9iPVJThO0GltzdwETqP/AoBBYxubeAGtntPRoY3W xXBA== 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=Y1j1mHeNob9s3Wuhl3X9oBN66w1iw+8VZB0VmlWNdKI=; b=iil6QjZuo/tpAcQZ1GItSqay56a4Cr8D0gBsCJVmAPLTg0OxAXD/Bh+2w/+MPlAPQg iaUO1k/Lv2BSmt+0fu7i9S16OzeJGYyo89frcWflM1STPfNix4vWfuNSyY7NfaNv7jDK M1FLBk4jsn3otvB7JyOCQD1p/4qedpZOf/gL9SJohjS5AIH0KQLSDeCH5iiC+2ouk/OS zksktw2pdg+zdqpa9W3O/v+VXAZ9yBIHb0Je/tg6ZRqgNi3d5U9Qvpyo0qx8af+C79yg +M+X6Ve4I+aphCCxv0r8UGrzuT+s3nW5QoF82jL4jnjMzCRMonGoc3rChg8E5RfviI7M Kn9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VtfQGsVt; 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 65si20227157plf.288.2019.03.27.11.09.17; Wed, 27 Mar 2019 11:09:33 -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=VtfQGsVt; 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 S2387988AbfC0SGj (ORCPT + 99 others); Wed, 27 Mar 2019 14:06:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:48134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387953AbfC0SGb (ORCPT ); Wed, 27 Mar 2019 14:06:31 -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 E73062177E; Wed, 27 Mar 2019 18:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709990; bh=v/McQ8zuyyWPuOFNT+nvSJuiC9XFfyIZCPFgJPbTjZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VtfQGsVt59cEqcP2RKlg4UfY/M0SpKVlBlLfyqjkoUTfZ29ci7zR0bxPCRHpwFBYy kuSsBIWdgJ+XDpenIwv+kT4WQsAsPj+vCmVe+lxrCxh8dqkpvVCWt6rRDLpXdoKLHb ZPMlHb0JkrTTTOSkkASinj/mn9QClxVb/VawckBw= 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 5.0 146/262] ACPI / video: Refactor and fix dmi_is_desktop() Date: Wed, 27 Mar 2019 14:00:01 -0400 Message-Id: <20190327180158.10245-146-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-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 f0b52266b3ac..1ab1460c4a4e 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -2124,21 +2124,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