Skip to content

Commit cecf3e3

Browse files
jwrdegoederafaeljw
authored andcommitted
ACPI / video: Refactor and fix dmi_is_desktop()
This commit refactors the chassis-type detection introduced by commit 53fa1f6 ("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: 53fa1f6 ("ACPI / video: Only default only_lcd to true ...") Signed-off-by: Hans de Goede <hdegoede@redhat.com> [ rjw: Drop redundant return statements ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent d139371 commit cecf3e3

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

drivers/acpi/acpi_video.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,21 +2124,28 @@ static int __init intel_opregion_present(void)
21242124
return opregion;
21252125
}
21262126

2127+
/* Check if the chassis-type indicates there is no builtin LCD panel */
21272128
static bool dmi_is_desktop(void)
21282129
{
21292130
const char *chassis_type;
2131+
unsigned long type;
21302132

21312133
chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE);
21322134
if (!chassis_type)
21332135
return false;
21342136

2135-
if (!strcmp(chassis_type, "3") || /* 3: Desktop */
2136-
!strcmp(chassis_type, "4") || /* 4: Low Profile Desktop */
2137-
!strcmp(chassis_type, "5") || /* 5: Pizza Box */
2138-
!strcmp(chassis_type, "6") || /* 6: Mini Tower */
2139-
!strcmp(chassis_type, "7") || /* 7: Tower */
2140-
!strcmp(chassis_type, "11")) /* 11: Main Server Chassis */
2137+
if (kstrtoul(chassis_type, 10, &type) != 0)
2138+
return false;
2139+
2140+
switch (type) {
2141+
case 0x03: /* Desktop */
2142+
case 0x04: /* Low Profile Desktop */
2143+
case 0x05: /* Pizza Box */
2144+
case 0x06: /* Mini Tower */
2145+
case 0x07: /* Tower */
2146+
case 0x11: /* Main Server Chassis */
21412147
return true;
2148+
}
21422149

21432150
return false;
21442151
}

0 commit comments

Comments
 (0)