Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp997806yba; Thu, 4 Apr 2019 02:04:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+oRDzfTndw1p036OBy6u74FgxKg8KjJNjiQvNafylloxygbOvYLCFOUJzwVPoObQa85K4 X-Received: by 2002:a17:902:2bab:: with SMTP id l40mr5136231plb.273.1554368661052; Thu, 04 Apr 2019 02:04:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554368661; cv=none; d=google.com; s=arc-20160816; b=kSrCXuHejGPdt78RJilMdk56fLzdUkCFMd3kGtNLQeBpt+AUwnnZsu+f80Z6L7wyrZ RV10vrfZh5qDXV4LMx5BwAjA0k8cIHExAyeJ6d+VlzBtiXDWA43YTm4bMIFN/yK2G+Mm uFk8a7Ro2yFuH0WJIbs6osnx2Z8xduRd/6QqnH4GTc3zmTSKqHPjlPY93w+S4G0Oz8DK ruq8Lz+o58en51EUs3KvSNIboMta0MgG3eDIIsy0r6e3+djTckGA9zSDGzjyLXZQ/kei YkXMbBw6i91IwU6bZJNAq5yh1zGQSjfn+qi7khhk6wBWBlTtC3RRdikoMSiEkKsMCBAq W2sg== 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=SP8FUl+GnsNr+upweCqVkBXCeZfBR3xvYMn4iiwMv6Y=; b=ZdkusyAJwN+yJWB+F5+silljX9yFln86SiWLLkcFBgFAnLmoUBogaT3Mws+yvjj2RD wpAeFvGOHDLtzkG/JQpIfBpS0kzPwovub1xD12p+n0NLxlvy4JQWNklyAwQZZ4SGbr6J 9mDIE7VwzaxVH3fHTZ9+Q2w1SbVoXZT6yV1HaCM15TOKPNdi1xGwp8ESB05AzRHxjBKn YPQJqrr8D8E5yJR9Wb6xbnApouhLxm+YsslkN9D4RP95GgsaTutUlZ/V2tAVQtV+EbWn M/58XzWVQJJMUiE1Wj02hZ5amf2wpHdew/Tx/gY2Q21MnaBFsmadoFUgLgPJu4jaDH5n rp+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QjfeWf2N; 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 i69si12574612pge.560.2019.04.04.02.04.06; Thu, 04 Apr 2019 02:04:21 -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=QjfeWf2N; 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 S1731803AbfDDJD3 (ORCPT + 99 others); Thu, 4 Apr 2019 05:03:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:41028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731303AbfDDJDX (ORCPT ); Thu, 4 Apr 2019 05:03:23 -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 3B3332147C; Thu, 4 Apr 2019 09:03:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368602; bh=elv6NIoqgrgPpCqh12/eXqjjhOjZCu7JZazTljH8OOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QjfeWf2N6On8Z7EkFGcZsR0RdBNQePXnFBRdZNmK++khOfEnmHyf7UDgr2sr0pGnK eW7abkgB8sscUQuVBzsglWS4C95FZCgxBJ+mYdJdJRZ/yjz+IHNWtm1vesq/9Hxcjf EFLtjflQ4o6V+Jcmg4nIyU4bNDn4a5qSCdyBgzXk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 4.19 100/187] ACPI / video: Refactor and fix dmi_is_desktop() Date: Thu, 4 Apr 2019 10:47:17 +0200 Message-Id: <20190404084607.893561951@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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