summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorFelix Held <felix-coreboot@felixheld.de>2022-01-31 15:56:14 +0100
committerFelix Held <felix-coreboot@felixheld.de>2022-02-02 18:04:20 +0000
commit7edf910d79cfefb45d4e8e0c770007c8663bb991 (patch)
treeaa4b42f037d0425bfc73810f9a46ef90a45a6aed /src/drivers
parent7a3c416ebd21a1851f3f755d752473d532e2714f (diff)
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>
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/i2c/designware/dw_i2c.c11
-rw-r--r--src/drivers/i2c/designware/dw_i2c.h5
2 files changed, 6 insertions, 10 deletions
diff --git a/src/drivers/i2c/designware/dw_i2c.c b/src/drivers/i2c/designware/dw_i2c.c
index bfb5971684..2a7c6fcc33 100644
--- a/src/drivers/i2c/designware/dw_i2c.c
+++ b/src/drivers/i2c/designware/dw_i2c.c
@@ -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. */
diff --git a/src/drivers/i2c/designware/dw_i2c.h b/src/drivers/i2c/designware/dw_i2c.h
index 3d8e66367c..464facfeed 100644
--- a/src/drivers/i2c/designware/dw_i2c.h
+++ b/src/drivers/i2c/designware/dw_i2c.h
@@ -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);