Commit 6060a75e authored by Tom Rix's avatar Tom Rix Committed by Hans de Goede

platform/x86: thinkpad_acpi: consistently check fan_get_status return.

Clang static analysis returns this false positive
thinkpad_acpi.c:8926:19: warning: The left operand
  of '!=' is a garbage value
  (status != 0) ? "enabled" : "disabled", status);
   ~~~~~~ ^

The return of fan_get_status* is checked inconsistenly.
Sometime ret < 0 is an error, sometimes !ret.
Both fan_get_status() and fan_get_status_safe() return
0 on success and return negative otherwise.  Change
the checks for error, ret < 0, into checks for
not success, !ret.
Signed-off-by: default avatarTom Rix <trix@redhat.com>
Link: https://lore.kernel.org/r/20220312145327.1398510-1-trix@redhat.comReviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 286e937e
...@@ -8285,7 +8285,7 @@ static int fan_set_enable(void) ...@@ -8285,7 +8285,7 @@ static int fan_set_enable(void)
case TPACPI_FAN_WR_ACPI_FANS: case TPACPI_FAN_WR_ACPI_FANS:
case TPACPI_FAN_WR_TPEC: case TPACPI_FAN_WR_TPEC:
rc = fan_get_status(&s); rc = fan_get_status(&s);
if (rc < 0) if (rc)
break; break;
/* Don't go out of emergency fan mode */ /* Don't go out of emergency fan mode */
...@@ -8304,7 +8304,7 @@ static int fan_set_enable(void) ...@@ -8304,7 +8304,7 @@ static int fan_set_enable(void)
case TPACPI_FAN_WR_ACPI_SFAN: case TPACPI_FAN_WR_ACPI_SFAN:
rc = fan_get_status(&s); rc = fan_get_status(&s);
if (rc < 0) if (rc)
break; break;
s &= 0x07; s &= 0x07;
...@@ -8843,7 +8843,7 @@ static void fan_suspend(void) ...@@ -8843,7 +8843,7 @@ static void fan_suspend(void)
/* Store fan status in cache */ /* Store fan status in cache */
fan_control_resume_level = 0; fan_control_resume_level = 0;
rc = fan_get_status_safe(&fan_control_resume_level); rc = fan_get_status_safe(&fan_control_resume_level);
if (rc < 0) if (rc)
pr_notice("failed to read fan level for later restore during resume: %d\n", pr_notice("failed to read fan level for later restore during resume: %d\n",
rc); rc);
...@@ -8864,7 +8864,7 @@ static void fan_resume(void) ...@@ -8864,7 +8864,7 @@ static void fan_resume(void)
if (!fan_control_allowed || if (!fan_control_allowed ||
!fan_control_resume_level || !fan_control_resume_level ||
(fan_get_status_safe(&current_level) < 0)) fan_get_status_safe(&current_level))
return; return;
switch (fan_control_access_mode) { switch (fan_control_access_mode) {
...@@ -8918,7 +8918,7 @@ static int fan_read(struct seq_file *m) ...@@ -8918,7 +8918,7 @@ static int fan_read(struct seq_file *m)
case TPACPI_FAN_RD_ACPI_GFAN: case TPACPI_FAN_RD_ACPI_GFAN:
/* 570, 600e/x, 770e, 770x */ /* 570, 600e/x, 770e, 770x */
rc = fan_get_status_safe(&status); rc = fan_get_status_safe(&status);
if (rc < 0) if (rc)
return rc; return rc;
seq_printf(m, "status:\t\t%s\n" seq_printf(m, "status:\t\t%s\n"
...@@ -8929,7 +8929,7 @@ static int fan_read(struct seq_file *m) ...@@ -8929,7 +8929,7 @@ static int fan_read(struct seq_file *m)
case TPACPI_FAN_RD_TPEC: case TPACPI_FAN_RD_TPEC:
/* all except 570, 600e/x, 770e, 770x */ /* all except 570, 600e/x, 770e, 770x */
rc = fan_get_status_safe(&status); rc = fan_get_status_safe(&status);
if (rc < 0) if (rc)
return rc; return rc;
seq_printf(m, "status:\t\t%s\n", seq_printf(m, "status:\t\t%s\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment