platform/x86: thinkpad_acpi: skip invalid fan speed
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi,
Quoted 1 line · Jelle van der Waa
65535 is most likely an invalid read.
I wonder if it is an invalid read, or if it actually is a reserved value which means "FAN_NOT_PRESENT"
I'm tempted to add:
#define FAN_NOT_PRESENT 65535
and then change the check to:
if (res >= 0 && speed != FAN_NOT_PRESENT) {That would make the code more logical to read.
Jelle, can you make this change for v2 ? Also please Cc: [email protected] for v2.
Mark, what do you think of this change (and of adding the FAN_NOT_PRESENT define) ?
Regards,
Hans
Quoted 23 lines
Signed-off-by Jelle van der Waa <[email protected]>---
Cc Mark Pearson <[email protected]>--- drivers/platform/x86/thinkpad_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/platform/x86/thinkpad_acpi.c +1
-1@@ -8876,7 +8876,7 @@ static int __init fan_init(struct ibm_init_struct *iibm)/* 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 ) { +if (res >=0 && speed !=65535 ) {/* It responded - so let's assume it's there */ tp_features.second_fan =1 ; tp_features.second_fan_ctl =1 ;
HI Hans
Quoted 17 lines · Hans de Goede
Hi,
Quoted 1 line · Jelle van der Waa
65535 is most likely an invalid read.
I wonder if it is an invalid read, or if it actually is a reserved value which means "
FAN_NOT_PRESENT"I'm tempted to add:
#define
FAN_NOT_PRESENT65535and then change the check to:
if (res >= 0 && speed != FAN_NOT_PRESENT) {
Quoted 7 lines
That would make the code more logical to read.
Jelle, can you make this change for v2 ? Also please Cc: [email protected] for v2.
Mark, what do you think of this change (and of adding the
FAN_NOT_PRESENTdefine) ?
Looks good to me.
I've asked the FW team to see if they can confirm if this will be standard behaviour (it's not defined in the spec that I have) and will update if I get an answer. But regardless I think it makes sense.
Mark
Quoted 31 lines
Regards,
Hans
Quoted 23 lines
Signed-off-by Jelle van der Waa <[email protected]>---
Cc Mark Pearson <[email protected]>--- drivers/platform/x86/thinkpad_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/platform/x86/thinkpad_acpi.c +1
-1@@ -8876,7 +8876,7 @@ static int __init fan_init(struct ibm_init_struct *iibm)/* 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 ) { +if (res >=0 && speed !=65535 ) {/* It responded - so let's assume it's there */ tp_features.second_fan =1 ; tp_features.second_fan_ctl =1 ;
PATCH 1/1 platform/x86: thinkpad_acpi: skip invalid fan speed
In reply to a message not in the archive65535 is most likely an invalid read.
---
--- drivers/platform/x86/thinkpad_acpi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/x86/thinkpad_acpi.c +3 -1
@@ -263,6 +263,8 @@ enum tpacpi_hkey_event_t {#define TPACPI_DBG_BRGHT 0x0020#define TPACPI_DBG_MIXER 0x0040 +#define FAN_NOT_PRESENT 65535 +#define strlencmp (a, b) (strncmp((a), (b), strlen(b)))
@@ -8876,7 +8878,7 @@ static int __init fan_init(struct ibm_init_struct *iibm)/* 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 ) { +if (res >=0 && speed !=FAN_NOT_PRESENT ) {/* It responded - so let's assume it's there */ tp_features.second_fan =1 ; tp_features.second_fan_ctl =1 ;
Signature · 1 line
2.38.1
Hi,
Quoted 3 lines · Jelle van der Waa
65535 is most likely an invalid read.
Signed-off-by Jelle van der Waa <[email protected]>
Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.
Regards,
Hans
Quoted 30 lines
---
Cc Mark Pearson <[email protected]>--- drivers/platform/x86/thinkpad_acpi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/platform/x86/thinkpad_acpi.c +3
-1@@ -263,6 +263,8 @@ enum tpacpi_hkey_event_t {#define TPACPI_DBG_BRGHT 0x0020#define TPACPI_DBG_MIXER 0x0040 +#define FAN_NOT_PRESENT 65535 +#define strlencmp (a, b) (strncmp((a), (b), strlen(b)))@@ -8876,7 +8878,7 @@ static int __init fan_init(struct ibm_init_struct *iibm)/* 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 ) { +if (res >=0 && speed !=FAN_NOT_PRESENT ) {/* It responded - so let's assume it's there */ tp_features.second_fan =1 ; tp_features.second_fan_ctl =1 ;