platform/x86: thinkpad_acpi: Don't report non-present second fan on models with quirk
Subsystems (3)
PATCH 1/1 platform/x86: thinkpad_acpi: Don't report non-present second fan on models with quirk
Some models report a second-fan with speed 65535 indicating that this fan is not present.
A previous fix (a10d50983f7be) disabled these fans.
However, the else branch still enables the fan on some models with a quirk enabled.
Namely the P15v Gen 1 has such a quirk, introduced in e8637dfca15e0.
Although it appears the P15 Gen 1 does have a second fan, the P15v Gen 1 does not (reporting speed 65535).
I think in all cases, this can be solved by never enabling the fan if it is detected and the reported speed reads 65535.
To do so, we only run the else branch if no fan was detected.
--- drivers/platform/x86/lenovo/thinkpad_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/lenovo/thinkpad_acpi.c +1 -1
@@ -8948,7 +8948,7 @@ static int __init fan_init(struct ibm_init_struct *iibm)/* fan control not currently available for ns ECFW */ tp_features.second_fan_ctl = !fan_with_ns_addr;pr_info ("secondary fan control detected & enabled\n" ); - }else { + }else if (res <0 ) {/* Fan not auto-detected */ tp_features.second_fan =0 ;if (quirks &TPACPI_FAN_2FAN ) {
Signature · 1 line
2.53.0
Ilpo Järvinen
maintainerQuoted 3 lines · LevitatingBusinessMan (Rein Fernhout)
Some models report a second-fan with speed 65535 indicating that this fan is not present.
A previous fix (
a10d50983f7be) disabled these fans.
Please see Documentation/process/submitting-patches.rst how to format commit references correctly.
Quoted 10 lines
However, the else branch still enables the fan on some models with a quirk enabled.
Namely the P15v Gen 1 has such a quirk, introduced in
e8637dfca15e0.Although it appears the P15 Gen 1 does have a second fan, the P15v Gen 1 does not (reporting speed 65535).
I think in all cases, this can be solved by never enabling the fan if it is detected and the reported speed reads 65535.
To do so, we only run the else branch if no fan was detected.
Please fold the changelog paragraphs at 72 chars.
This change should have a Fixes tag.
I cannot apply patches without sign off, again, please see Documentation/process/submitting-patches.rst.
Quoted 9 lines
--- drivers/platform/x86/lenovo/thinkpad_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/platform/x86/lenovo/thinkpad_acpi.c +0
-0
drivers/platform/x86/lenovo/thinkpad_acpi.c static int __init fan_init(struct ibm_init_struct *iibm) · line 8951
Quoted 5 lines
drivers/platform/x86/lenovo/thinkpad_acpi.c +1
-1@@ -8948,7 +8948,7 @@ static int __init fan_init(struct ibm_init_struct *iibm)/* fan control not currently available for ns ECFW */ tp_features.second_fan_ctl = !fan_with_ns_addr;pr_info ("secondary fan control detected & enabled\n" ); - }else { + }else if (res <0 ) {
As this is now clearly an error handling block, it should be the first one to follow the call so you should switch to order of the code blocks.
drivers/platform/x86/lenovo/thinkpad_acpi.c static int __init fan_init(struct ibm_init_struct *iibm) · line 8953
Quoted 2 lines
drivers/platform/x86/lenovo/thinkpad_acpi.c +0
-0/* Fan not auto-detected */ tp_features.second_fan =0 ;
Unrelated to this patch, I don't know why is this line necessary at all. It was cleared earlier in the same function (and even that clearing is probably not considering the default initial value which implies it should already be 0).
drivers/platform/x86/lenovo/thinkpad_acpi.c static int __init fan_init(struct ibm_init_struct *iibm) · line 8954
Quoted 1 line
drivers/platform/x86/lenovo/thinkpad_acpi.c +0
-0if (quirks &TPACPI_FAN_2FAN ) {
It might be cleaner to put this entire 2nd fan init to own function as could return early from it when no 2nd fan is detected.
Signature · 1 line
i.