Felix Held has submitted this change. ( 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/61512 Reviewed-by: Raul Rangel rrangel@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/drivers/i2c/designware/dw_i2c.c M src/drivers/i2c/designware/dw_i2c.h 2 files changed, 6 insertions(+), 10 deletions(-)
Approvals: build bot (Jenkins): Verified Raul Rangel: Looks good to me, approved
diff --git a/src/drivers/i2c/designware/dw_i2c.c b/src/drivers/i2c/designware/dw_i2c.c index bfb5971..2a7c6fc 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) @@ -634,12 +634,11 @@ if (bcfg->speed_config[i].speed != speed) continue; memcpy(config, &bcfg->speed_config[i], sizeof(*config)); - return 0; + return CB_SUCCESS; }
/* Use the time calculation. */ - return dw_i2c_gen_config_rise_fall_time(regs, speed, bcfg, ic_clk, config) == - CB_SUCCESS ? 0 : -1; + return dw_i2c_gen_config_rise_fall_time(regs, speed, bcfg, ic_clk, config); }
static enum cb_err dw_i2c_set_speed(unsigned int bus, enum i2c_speed speed, @@ -669,7 +668,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 +829,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 3d8e663..464facf 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);