]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.34/acpi-video-refactor-and-fix-dmi_is_desktop.patch
Linux 4.14.111
[thirdparty/kernel/stable-queue.git] / releases / 4.19.34 / acpi-video-refactor-and-fix-dmi_is_desktop.patch
1 From 7eb3de3eaecae41d16b050000f58a6e79d7f07ba Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Mon, 7 Jan 2019 17:08:20 +0100
4 Subject: ACPI / video: Refactor and fix dmi_is_desktop()
5
6 [ Upstream commit cecf3e3e0803462335e25d083345682518097334 ]
7
8 This commit refactors the chassis-type detection introduced by
9 commit 53fa1f6e8a59 ("ACPI / video: Only default only_lcd to true on
10 Win8-ready _desktops_") (where desktop means anything without a builtin
11 screen).
12
13 The DMI chassis_type is an unsigned integer, so rather then doing a
14 whole bunch of string-compares on it, convert it to an int and feed
15 the result to a switch case.
16
17 Note the switch case uses hex values, this is done because the spec
18 uses hex values too. This changes the check for "Main Server Chassis"
19 from checking for 11 decimal to 11 hexadecimal, this is a bug fix,
20 the original check for 11 decimal was wrong.
21
22 Fixes: 53fa1f6e8a59 ("ACPI / video: Only default only_lcd to true ...")
23 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
24 [ rjw: Drop redundant return statements ]
25 Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
26 Signed-off-by: Sasha Levin <sashal@kernel.org>
27 ---
28 drivers/acpi/acpi_video.c | 19 +++++++++++++------
29 1 file changed, 13 insertions(+), 6 deletions(-)
30
31 diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
32 index f0b52266b3ac..1ab1460c4a4e 100644
33 --- a/drivers/acpi/acpi_video.c
34 +++ b/drivers/acpi/acpi_video.c
35 @@ -2124,21 +2124,28 @@ static int __init intel_opregion_present(void)
36 return opregion;
37 }
38
39 +/* Check if the chassis-type indicates there is no builtin LCD panel */
40 static bool dmi_is_desktop(void)
41 {
42 const char *chassis_type;
43 + unsigned long type;
44
45 chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE);
46 if (!chassis_type)
47 return false;
48
49 - if (!strcmp(chassis_type, "3") || /* 3: Desktop */
50 - !strcmp(chassis_type, "4") || /* 4: Low Profile Desktop */
51 - !strcmp(chassis_type, "5") || /* 5: Pizza Box */
52 - !strcmp(chassis_type, "6") || /* 6: Mini Tower */
53 - !strcmp(chassis_type, "7") || /* 7: Tower */
54 - !strcmp(chassis_type, "11")) /* 11: Main Server Chassis */
55 + if (kstrtoul(chassis_type, 10, &type) != 0)
56 + return false;
57 +
58 + switch (type) {
59 + case 0x03: /* Desktop */
60 + case 0x04: /* Low Profile Desktop */
61 + case 0x05: /* Pizza Box */
62 + case 0x06: /* Mini Tower */
63 + case 0x07: /* Tower */
64 + case 0x11: /* Main Server Chassis */
65 return true;
66 + }
67
68 return false;
69 }
70 --
71 2.19.1
72