Elyes Haouas has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/84914?usp=email )
Change subject: acpi: : Use boolean instead of int ......................................................................
acpi: : Use boolean instead of int
Moderne C provides boolean, use it instead of old style 0, -1.
Change-Id: I361d4b8827fac25d1849ad68fddc9fdeb4113c0a Signed-off-by: Elyes Haouas ehaouas@noos.fr --- M src/acpi/acpi_pm.c M src/acpi/acpigen.c M src/acpi/gnvs.c M src/acpi/pld.c M src/include/acpi/acpi_gnvs.h M src/include/acpi/acpi_pld.h M src/include/acpi/acpi_pm.h M src/soc/amd/common/block/acpi/acpi.c M src/soc/amd/common/block/acpi/pm_state.c M src/soc/amd/common/block/gpio/gpio.c M src/soc/intel/alderlake/pmutil.c M src/soc/intel/apollolake/elog.c M src/soc/intel/apollolake/pmutil.c M src/soc/intel/baytrail/elog.c M src/soc/intel/baytrail/ramstage.c M src/soc/intel/braswell/elog.c M src/soc/intel/broadwell/pch/elog.c M src/soc/intel/broadwell/pch/ramstage.c M src/soc/intel/cannonlake/pmutil.c M src/soc/intel/common/block/acpi/acpi_wake_source.c M src/soc/intel/elkhartlake/pmutil.c M src/soc/intel/jasperlake/pmutil.c M src/soc/intel/meteorlake/pmutil.c M src/soc/intel/pantherlake/pmutil.c M src/soc/intel/skylake/elog.c M src/soc/intel/tigerlake/pmutil.c 26 files changed, 44 insertions(+), 41 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/84914/1
diff --git a/src/acpi/acpi_pm.c b/src/acpi/acpi_pm.c index 722d8f6..e873277 100644 --- a/src/acpi/acpi_pm.c +++ b/src/acpi/acpi_pm.c @@ -46,7 +46,7 @@ return acpi_pm_state; }
-int acpi_fetch_pm_state(const struct chipset_power_state **ps, +bool acpi_fetch_pm_state(const struct chipset_power_state **ps, enum power_state_claimer ps_claimer) { assert(ps_claimer < PS_CLAIMER_MAX); @@ -56,9 +56,9 @@ printk(BIOS_ERR, "No CBMEM_ID_POWER_STATE entry, %s\n", ps_claimer < PS_CLAIMER_MAX ? pm_fetch_failure_msg[ps_claimer] : "unknown claimer."); - return -1; + return false; } - return 0; + return true; }
/* Not every <soc/nvs.h> exists and has required fields. */ diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c index 4049df0..8f95a1a 100644 --- a/src/acpi/acpigen.c +++ b/src/acpi/acpigen.c @@ -1792,7 +1792,7 @@ { uint8_t buf[20];
- if (acpi_pld_to_buffer(pld, buf, ARRAY_SIZE(buf)) < 0) + if (!acpi_pld_to_buffer(pld, buf, ARRAY_SIZE(buf))) return;
acpigen_write_name("_PLD"); diff --git a/src/acpi/gnvs.c b/src/acpi/gnvs.c index 1e5d746..9c29cd8 100644 --- a/src/acpi/gnvs.c +++ b/src/acpi/gnvs.c @@ -78,15 +78,15 @@ acpigen_pop_len(); }
-int acpi_reset_gnvs_for_wake(struct global_nvs **gnvs_) +bool acpi_reset_gnvs_for_wake(struct global_nvs **gnvs_) { if (!gnvs) - return -1; + return false;
/* Set unknown wake source */ gnvs->pm1i = -1; gnvs->gpei = -1;
*gnvs_ = gnvs; - return 0; + return true; } diff --git a/src/acpi/pld.c b/src/acpi/pld.c index b9c98a1..64d2342 100644 --- a/src/acpi/pld.c +++ b/src/acpi/pld.c @@ -1,15 +1,16 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <stdbool.h> #include <stdint.h> #include <string.h> #include <acpi/acpi.h> #include <acpi/acpi_pld.h>
-int acpi_pld_fill_usb(struct acpi_pld *pld, enum acpi_upc_type type, +bool acpi_pld_fill_usb(struct acpi_pld *pld, enum acpi_upc_type type, struct acpi_pld_group *group) { if (!pld) - return -1; + return false;
memset(pld, 0, sizeof(struct acpi_pld));
@@ -50,13 +51,13 @@ break; }
- return 0; + return true; }
-int acpi_pld_to_buffer(const struct acpi_pld *pld, uint8_t *buf, int buf_len) +bool acpi_pld_to_buffer(const struct acpi_pld *pld, uint8_t *buf, int buf_len) { if (!pld || !buf) - return -1; + return false;
memset(buf, 0, buf_len);
@@ -155,5 +156,5 @@ buf[19] = pld->horizontal_offset >> 8; }
- return 0; + return true; } diff --git a/src/include/acpi/acpi_gnvs.h b/src/include/acpi/acpi_gnvs.h index fe6924f..d72c571 100644 --- a/src/include/acpi/acpi_gnvs.h +++ b/src/include/acpi/acpi_gnvs.h @@ -12,10 +12,10 @@ #if CONFIG(ACPI_SOC_NVS) void *acpi_get_gnvs(void); void *acpi_get_device_nvs(void); -int acpi_reset_gnvs_for_wake(struct global_nvs **gnvs); +bool acpi_reset_gnvs_for_wake(struct global_nvs **gnvs); #else static inline void *acpi_get_gnvs(void) { return NULL; } -static inline int acpi_reset_gnvs_for_wake(struct global_nvs **gnvs) { return -1; } +static inline bool acpi_reset_gnvs_for_wake(struct global_nvs **gnvs) { return -1; } #endif
/* Return GNVS fields for USB0/1 disablement for S3/S4/S5 sleep states. */ diff --git a/src/include/acpi/acpi_pld.h b/src/include/acpi/acpi_pld.h index 98d7f9e..4657622 100644 --- a/src/include/acpi/acpi_pld.h +++ b/src/include/acpi/acpi_pld.h @@ -130,10 +130,10 @@ };
/* Fill out PLD structure with defaults based on USB port type */ -int acpi_pld_fill_usb(struct acpi_pld *pld, enum acpi_upc_type type, +bool acpi_pld_fill_usb(struct acpi_pld *pld, enum acpi_upc_type type, struct acpi_pld_group *group);
/* Turn PLD structure into a 20 byte ACPI buffer */ -int acpi_pld_to_buffer(const struct acpi_pld *pld, uint8_t *buf, int buf_len); +bool acpi_pld_to_buffer(const struct acpi_pld *pld, uint8_t *buf, int buf_len);
#endif /* __ACPI_ACPI_PLD_H__ */ diff --git a/src/include/acpi/acpi_pm.h b/src/include/acpi/acpi_pm.h index 584265e..bf338f6 100644 --- a/src/include/acpi/acpi_pm.h +++ b/src/include/acpi/acpi_pm.h @@ -3,6 +3,8 @@ #ifndef ACPI_PM_H #define ACPI_PM_H
+#include <stdbool.h> + enum power_state_claimer { PS_CLAIMER_ELOG, PS_CLAIMER_RTC, @@ -12,7 +14,7 @@
struct chipset_power_state; struct chipset_power_state *acpi_get_pm_state(void); -int acpi_fetch_pm_state(const struct chipset_power_state **ps, +bool acpi_fetch_pm_state(const struct chipset_power_state **ps, enum power_state_claimer ps_claimer);
#endif diff --git a/src/soc/amd/common/block/acpi/acpi.c b/src/soc/amd/common/block/acpi/acpi.c index 75d4adf..44432af 100644 --- a/src/soc/amd/common/block/acpi/acpi.c +++ b/src/soc/amd/common/block/acpi/acpi.c @@ -79,7 +79,7 @@ const struct chipset_power_state *ps; const struct acpi_pm_gpe_state *state;
- if (acpi_fetch_pm_state(&ps, PS_CLAIMER_ELOG) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_ELOG)) return;
state = &ps->gpe_state; diff --git a/src/soc/amd/common/block/acpi/pm_state.c b/src/soc/amd/common/block/acpi/pm_state.c index 23a7d45..2ebd279 100644 --- a/src/soc/amd/common/block/acpi/pm_state.c +++ b/src/soc/amd/common/block/acpi/pm_state.c @@ -47,9 +47,9 @@ const struct chipset_power_state *ps; struct global_nvs *gnvs;
- if (acpi_reset_gnvs_for_wake(&gnvs) < 0) + if (!acpi_reset_gnvs_for_wake(&gnvs)) return; - if (acpi_fetch_pm_state(&ps, PS_CLAIMER_WAKE) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_WAKE)) return;
pm_fill_gnvs(gnvs, &ps->gpe_state); diff --git a/src/soc/amd/common/block/gpio/gpio.c b/src/soc/amd/common/block/gpio/gpio.c index ce098d0..ead7aa8 100644 --- a/src/soc/amd/common/block/gpio/gpio.c +++ b/src/soc/amd/common/block/gpio/gpio.c @@ -385,7 +385,7 @@ unsigned int i; unsigned int end;
- if (acpi_fetch_pm_state(&ps, PS_CLAIMER_ELOG) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_ELOG)) return; state = &ps->gpio_state;
diff --git a/src/soc/intel/alderlake/pmutil.c b/src/soc/intel/alderlake/pmutil.c index 050fd5b..54057380 100644 --- a/src/soc/intel/alderlake/pmutil.c +++ b/src/soc/intel/alderlake/pmutil.c @@ -175,7 +175,7 @@ { const struct chipset_power_state *ps;
- if (acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC)) return 1;
return rtc_failed(ps->gen_pmcon_b); diff --git a/src/soc/intel/apollolake/elog.c b/src/soc/intel/apollolake/elog.c index 03ef816..d7b4cc7 100644 --- a/src/soc/intel/apollolake/elog.c +++ b/src/soc/intel/apollolake/elog.c @@ -88,7 +88,7 @@ { const struct chipset_power_state *ps;
- if (acpi_fetch_pm_state(&ps, PS_CLAIMER_ELOG) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_ELOG)) return;
/* Power and Reset */ diff --git a/src/soc/intel/apollolake/pmutil.c b/src/soc/intel/apollolake/pmutil.c index 8d9af92..83d2cf2 100644 --- a/src/soc/intel/apollolake/pmutil.c +++ b/src/soc/intel/apollolake/pmutil.c @@ -191,7 +191,7 @@ { const struct chipset_power_state *ps;
- if (acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC)) return 1;
return rtc_failed(ps->gen_pmcon1); diff --git a/src/soc/intel/baytrail/elog.c b/src/soc/intel/baytrail/elog.c index ecdbfca..5868ae4 100644 --- a/src/soc/intel/baytrail/elog.c +++ b/src/soc/intel/baytrail/elog.c @@ -77,7 +77,7 @@ { const struct chipset_power_state *ps;
- if (acpi_fetch_pm_state(&ps, PS_CLAIMER_ELOG) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_ELOG)) return;
log_power_and_resets(ps); diff --git a/src/soc/intel/baytrail/ramstage.c b/src/soc/intel/baytrail/ramstage.c index 4e8dc68..01044f3 100644 --- a/src/soc/intel/baytrail/ramstage.c +++ b/src/soc/intel/baytrail/ramstage.c @@ -144,9 +144,9 @@ const struct chipset_power_state *ps; struct global_nvs *gnvs;
- if (acpi_reset_gnvs_for_wake(&gnvs) < 0) + if (!acpi_reset_gnvs_for_wake(&gnvs)) return; - if (acpi_fetch_pm_state(&ps, PS_CLAIMER_WAKE) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_WAKE)) return;
pm_fill_gnvs(gnvs, ps); diff --git a/src/soc/intel/braswell/elog.c b/src/soc/intel/braswell/elog.c index ecdbfca..5868ae4 100644 --- a/src/soc/intel/braswell/elog.c +++ b/src/soc/intel/braswell/elog.c @@ -77,7 +77,7 @@ { const struct chipset_power_state *ps;
- if (acpi_fetch_pm_state(&ps, PS_CLAIMER_ELOG) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_ELOG)) return;
log_power_and_resets(ps); diff --git a/src/soc/intel/broadwell/pch/elog.c b/src/soc/intel/broadwell/pch/elog.c index e3e8c0c..db09c7e 100644 --- a/src/soc/intel/broadwell/pch/elog.c +++ b/src/soc/intel/broadwell/pch/elog.c @@ -107,7 +107,7 @@ { const struct chipset_power_state *ps;
- if (acpi_fetch_pm_state(&ps, PS_CLAIMER_ELOG) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_ELOG)) return;
/* Power and Reset */ diff --git a/src/soc/intel/broadwell/pch/ramstage.c b/src/soc/intel/broadwell/pch/ramstage.c index 027b3bb..738678d 100644 --- a/src/soc/intel/broadwell/pch/ramstage.c +++ b/src/soc/intel/broadwell/pch/ramstage.c @@ -49,9 +49,9 @@ const struct chipset_power_state *ps; struct global_nvs *gnvs;
- if (acpi_reset_gnvs_for_wake(&gnvs) < 0) + if (!acpi_reset_gnvs_for_wake(&gnvs)) return; - if (acpi_fetch_pm_state(&ps, PS_CLAIMER_WAKE) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_WAKE)) return;
pm_fill_gnvs(gnvs, ps); diff --git a/src/soc/intel/cannonlake/pmutil.c b/src/soc/intel/cannonlake/pmutil.c index ed0aece..ccc6db5 100644 --- a/src/soc/intel/cannonlake/pmutil.c +++ b/src/soc/intel/cannonlake/pmutil.c @@ -168,7 +168,7 @@ { const struct chipset_power_state *ps;
- if (acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC)) return 1;
return rtc_failed(ps->gen_pmcon_b); diff --git a/src/soc/intel/common/block/acpi/acpi_wake_source.c b/src/soc/intel/common/block/acpi/acpi_wake_source.c index d45fd96..6a82f4d 100644 --- a/src/soc/intel/common/block/acpi/acpi_wake_source.c +++ b/src/soc/intel/common/block/acpi/acpi_wake_source.c @@ -52,9 +52,9 @@ const struct chipset_power_state *ps; struct global_nvs *gnvs;
- if (acpi_reset_gnvs_for_wake(&gnvs) < 0) + if (!acpi_reset_gnvs_for_wake(&gnvs)) return; - if (acpi_fetch_pm_state(&ps, PS_CLAIMER_WAKE) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_WAKE)) return;
pm_fill_gnvs(gnvs, ps); diff --git a/src/soc/intel/elkhartlake/pmutil.c b/src/soc/intel/elkhartlake/pmutil.c index 2618798..9c8e2cb 100644 --- a/src/soc/intel/elkhartlake/pmutil.c +++ b/src/soc/intel/elkhartlake/pmutil.c @@ -184,7 +184,7 @@ { const struct chipset_power_state *ps;
- if (acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC)) return 1;
return check_rtc_failed(ps->gen_pmcon_b); diff --git a/src/soc/intel/jasperlake/pmutil.c b/src/soc/intel/jasperlake/pmutil.c index f94232a..c737157 100644 --- a/src/soc/intel/jasperlake/pmutil.c +++ b/src/soc/intel/jasperlake/pmutil.c @@ -184,7 +184,7 @@ { const struct chipset_power_state *ps;
- if (acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC)) return 1;
return check_rtc_failed(ps->gen_pmcon_b); diff --git a/src/soc/intel/meteorlake/pmutil.c b/src/soc/intel/meteorlake/pmutil.c index 09fb46b..9d79516 100644 --- a/src/soc/intel/meteorlake/pmutil.c +++ b/src/soc/intel/meteorlake/pmutil.c @@ -170,7 +170,7 @@ { const struct chipset_power_state *ps;
- if (acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC)) return 1;
return rtc_failed(ps->gen_pmcon_b); diff --git a/src/soc/intel/pantherlake/pmutil.c b/src/soc/intel/pantherlake/pmutil.c index 892972c..e7ff855 100644 --- a/src/soc/intel/pantherlake/pmutil.c +++ b/src/soc/intel/pantherlake/pmutil.c @@ -168,7 +168,7 @@ { const struct chipset_power_state *ps;
- if (acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC)) return 1;
return rtc_failed(ps->gen_pmcon_b); diff --git a/src/soc/intel/skylake/elog.c b/src/soc/intel/skylake/elog.c index 325bacb..9210cfe 100644 --- a/src/soc/intel/skylake/elog.c +++ b/src/soc/intel/skylake/elog.c @@ -232,7 +232,7 @@ { const struct chipset_power_state *ps;
- if (acpi_fetch_pm_state(&ps, PS_CLAIMER_ELOG) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_ELOG)) return;
/* Power and Reset */ diff --git a/src/soc/intel/tigerlake/pmutil.c b/src/soc/intel/tigerlake/pmutil.c index ba33e49..c060786 100644 --- a/src/soc/intel/tigerlake/pmutil.c +++ b/src/soc/intel/tigerlake/pmutil.c @@ -189,7 +189,7 @@ { const struct chipset_power_state *ps;
- if (acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC) < 0) + if (!acpi_fetch_pm_state(&ps, PS_CLAIMER_RTC)) return 1;
return check_rtc_failed(ps->gen_pmcon_b);