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>
This commit is contained in:
Felix Held 2022-01-31 15:56:14 +01:00
parent 7a3c416ebd
commit 7edf910d79
2 changed files with 6 additions and 10 deletions

View File

@ -615,7 +615,7 @@ static enum cb_err dw_i2c_gen_config_rise_fall_time(struct dw_i2c_regs *regs,
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 @@ int dw_i2c_gen_speed_config(uintptr_t dw_i2c_addr,
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 @@ static enum cb_err dw_i2c_set_speed(unsigned int bus, enum i2c_speed speed,
}
/* 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 @@ void dw_i2c_acpi_fill_ssdt(const struct device *dev)
/* 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. */

View File

@ -100,11 +100,8 @@ enum cb_err dw_i2c_init(unsigned int bus, const struct dw_i2c_bus_config *bcfg);
/*
* 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);