Felix Held has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/61512 )
Change subject: drivers/i2c/designware/dw_i2c: use cb_err for dw_i2c_gen_speed_config ......................................................................
drivers/i2c/designware/dw_i2c: use cb_err for dw_i2c_gen_speed_config
Using enum cb_err as return type instead of int improves the readability of the code.
Signed-off-by: Felix Held felix-coreboot@felixheld.de Change-Id: I8d96e5f72a8b3552ab39c1d298bafcc224bf9e55 --- M src/drivers/i2c/designware/dw_i2c.c M src/drivers/i2c/designware/dw_i2c.h 2 files changed, 4 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/12/61512/1
diff --git a/src/drivers/i2c/designware/dw_i2c.c b/src/drivers/i2c/designware/dw_i2c.c index e29d54f..1f73d5c 100644 --- a/src/drivers/i2c/designware/dw_i2c.c +++ b/src/drivers/i2c/designware/dw_i2c.c @@ -615,7 +615,7 @@ return CB_SUCCESS; }
-int dw_i2c_gen_speed_config(uintptr_t dw_i2c_addr, +enum cb_err dw_i2c_gen_speed_config(uintptr_t dw_i2c_addr, enum i2c_speed speed, const struct dw_i2c_bus_config *bcfg, struct dw_i2c_speed_config *config) @@ -669,7 +669,7 @@ }
/* Generate speed config based on clock */ - if (dw_i2c_gen_speed_config((uintptr_t)regs, speed, bcfg, &config) < 0) + if (dw_i2c_gen_speed_config((uintptr_t)regs, speed, bcfg, &config) != CB_SUCCESS) return CB_ERR;
/* Select this speed in the control register */ @@ -830,7 +830,7 @@
/* Report currently used timing values for the OS driver */ acpigen_write_scope(path); - if (dw_i2c_gen_speed_config(dw_i2c_addr, speed, bcfg, &sgen) >= 0) { + if (dw_i2c_gen_speed_config(dw_i2c_addr, speed, bcfg, &sgen) == CB_SUCCESS) { dw_i2c_acpi_write_speed_config(&sgen); } /* Now check if there are more speed settings available and report them as well. */ diff --git a/src/drivers/i2c/designware/dw_i2c.h b/src/drivers/i2c/designware/dw_i2c.h index 64e27c0..2d255ee 100644 --- a/src/drivers/i2c/designware/dw_i2c.h +++ b/src/drivers/i2c/designware/dw_i2c.h @@ -100,11 +100,8 @@
/* * Generate speed config based on clock - * Return value: - * -1 = failure - * 0 = success */ -int dw_i2c_gen_speed_config(uintptr_t dw_i2c_addr, +enum cb_err dw_i2c_gen_speed_config(uintptr_t dw_i2c_addr, enum i2c_speed speed, const struct dw_i2c_bus_config *bcfg, struct dw_i2c_speed_config *config);