lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220429211418.4546-3-lyude@redhat.com>
Date:   Fri, 29 Apr 2022 17:14:18 -0400
From:   Lyude Paul <lyude@...hat.com>
To:     ibm-acpi-devel@...ts.sourceforge.net,
        platform-driver-x86@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org, linux-hwmon@...r.kernel.org,
        Hans de Goede <hdegoede@...hat.com>,
        Mark Pearson <markpearson@...ovo.com>,
        Henrique de Moraes Holschuh <hmh@....eng.br>,
        Mark Gross <markgross@...nel.org>
Subject: [PATCH 2/2] platform/x86: thinkpad_acpi: Don't probe 2nd fan if enabled by quirk

If we already know that the system in question has a quirk telling us that
the system has a second fan, there's no purpose in probing the second fan -
especially when probing the second fan may not work properly with systems
relying on quirks.

Also, convert all of the conditionals here into a single group of if/else
statements. This is because there's no situations where there's more then
one quirk on a device.

Signed-off-by: Lyude Paul <lyude@...hat.com>
Fixes: bf779aaf56ea ("platform/x86: thinkpad_acpi: Add dual fan probe")
Cc: Mark Pearson <markpearson@...ovo.com>
Cc: Hans de Goede <hdegoede@...hat.com>
Cc: Henrique de Moraes Holschuh <hmh@....eng.br>
Cc: Mark Gross <markgross@...nel.org>
Cc: ibm-acpi-devel@...ts.sourceforge.net
Cc: platform-driver-x86@...r.kernel.org
---
 drivers/platform/x86/thinkpad_acpi.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 9067fd0a945c..677822b5d4b4 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -8747,26 +8747,25 @@ static int __init fan_init(struct ibm_init_struct *iibm)
 			unsigned int speed;
 
 			fan_status_access_mode = TPACPI_FAN_RD_TPEC;
-			if (quirks & TPACPI_FAN_Q1)
+			if (quirks & TPACPI_FAN_Q1) {
 				fan_quirk1_setup();
-			if (quirks & TPACPI_FAN_2FAN) {
+			} else if (quirks & TPACPI_FAN_2FAN) {
 				tp_features.second_fan = 1;
 				pr_info("secondary fan support enabled\n");
-			}
-			if (quirks & TPACPI_FAN_2CTL) {
+			} else if (quirks & TPACPI_FAN_2CTL) {
 				tp_features.second_fan = 1;
 				tp_features.second_fan_ctl = 1;
 				pr_info("secondary fan control enabled\n");
+			} else {
+				/* 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");
+				}
 			}
-			/* 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;
-- 
2.35.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ