Commit aa2fef6f authored by Mark Pearson's avatar Mark Pearson Committed by Hans de Goede
Browse files

platform/x86: thinkpad_acpi: Correct dual fan probe



There was an issue with the dual fan probe whereby the probe was
failing as it assuming that second_fan support was not available.

Corrected the logic so the probe works correctly. Cleaned up so
quirks only used if 2nd fan not detected.

Tested on X1 Carbon 10 (2 fans), X1 Carbon 9 (2 fans) and T490 (1 fan)

Signed-off-by: default avatarMark Pearson <markpearson@lenovo.com>
Link: https://lore.kernel.org/r/20220502191200.63470-1-markpearson@lenovo.com


Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 455cd867
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -8880,6 +8880,17 @@ static int __init fan_init(struct ibm_init_struct *iibm)
			fan_status_access_mode = TPACPI_FAN_RD_TPEC;
			if (quirks & TPACPI_FAN_Q1)
				fan_quirk1_setup();
			/* Try and probe the 2nd fan */
			tp_features.second_fan = 1; /* needed for get_speed to work */
			res = fan2_get_speed(&speed);
			if (res >= 0) {
				/* It responded - so let's assume it's there */
				tp_features.second_fan = 1;
				tp_features.second_fan_ctl = 1;
				pr_info("secondary fan control detected & enabled\n");
			} else {
				/* Fan not auto-detected */
				tp_features.second_fan = 0;
				if (quirks & TPACPI_FAN_2FAN) {
					tp_features.second_fan = 1;
					pr_info("secondary fan support enabled\n");
@@ -8889,15 +8900,7 @@ static int __init fan_init(struct ibm_init_struct *iibm)
					tp_features.second_fan_ctl = 1;
					pr_info("secondary fan control enabled\n");
				}
			/* Try and probe the 2nd fan */
			res = fan2_get_speed(&speed);
			if (res >= 0) {
				/* It responded - so let's assume it's there */
				tp_features.second_fan = 1;
				tp_features.second_fan_ctl = 1;
				pr_info("secondary fan control detected & enabled\n");
			}

		} else {
			pr_err("ThinkPad ACPI EC access misbehaving, fan status and control unavailable\n");
			return -ENODEV;