diff options
author | Felix Held <felix-coreboot@felixheld.de> | 2022-01-31 15:52:36 +0100 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-02-01 17:51:42 +0000 |
commit | 3d945890d8d22fa2669b6777c572bbe42152453e (patch) | |
tree | 09675acce011dcb96f43409cce0068488ddf25b3 /src/drivers/i2c | |
parent | 2a542da89fcfb8bb0d021ce65c67bf68a00fdcc7 (diff) |
drivers/i2c/designware/dw_i2c: return enum cb_err from dw_i2c_init
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: I55e6d93ca141b687871ceaa763bbbbe966c4b4a3
Reviewed-on: https://review.coreboot.org/c/coreboot/+/61511
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
Reviewed-by: Jason Glenesk <jason.glenesk@gmail.com>
Diffstat (limited to 'src/drivers/i2c')
-rw-r--r-- | src/drivers/i2c/designware/dw_i2c.c | 14 | ||||
-rw-r--r-- | src/drivers/i2c/designware/dw_i2c.h | 5 |
2 files changed, 8 insertions, 11 deletions
diff --git a/src/drivers/i2c/designware/dw_i2c.c b/src/drivers/i2c/designware/dw_i2c.c index ec34f42cc3..e29d54f3c2 100644 --- a/src/drivers/i2c/designware/dw_i2c.c +++ b/src/drivers/i2c/designware/dw_i2c.c @@ -687,33 +687,33 @@ static enum cb_err dw_i2c_set_speed(unsigned int bus, enum i2c_speed speed, * The bus speed can be passed in Hz or using values from device/i2c.h and * will default to I2C_SPEED_FAST if it is not provided. */ -int dw_i2c_init(unsigned int bus, const struct dw_i2c_bus_config *bcfg) +enum cb_err dw_i2c_init(unsigned int bus, const struct dw_i2c_bus_config *bcfg) { struct dw_i2c_regs *regs; enum i2c_speed speed; if (!bcfg) - return -1; + return CB_ERR; speed = bcfg->speed ? : I2C_SPEED_FAST; regs = (struct dw_i2c_regs *)dw_i2c_base_address(bus); if (!regs) { printk(BIOS_ERR, "I2C bus %u base address not found\n", bus); - return -1; + return CB_ERR; } if (read32(®s->comp_type) != DW_I2C_COMP_TYPE) { printk(BIOS_ERR, "I2C bus %u has unknown type 0x%x.\n", bus, read32(®s->comp_type)); - return -1; + return CB_ERR; } printk(BIOS_DEBUG, "I2C bus %u version 0x%x\n", bus, read32(®s->comp_version)); if (dw_i2c_disable(regs) != CB_SUCCESS) { printk(BIOS_ERR, "I2C timeout disabling bus %u\n", bus); - return -1; + return CB_ERR; } /* Put controller in master mode with restart enabled */ @@ -723,7 +723,7 @@ int dw_i2c_init(unsigned int bus, const struct dw_i2c_bus_config *bcfg) /* Set bus speed to FAST by default */ if (dw_i2c_set_speed(bus, speed, bcfg) != CB_SUCCESS) { printk(BIOS_ERR, "I2C failed to set speed for bus %u\n", bus); - return -1; + return CB_ERR; } /* Set RX/TX thresholds to smallest values */ @@ -736,7 +736,7 @@ int dw_i2c_init(unsigned int bus, const struct dw_i2c_bus_config *bcfg) printk(BIOS_INFO, "DW I2C bus %u at %p (%u KHz)\n", bus, regs, speed / KHz); - return 0; + return CB_SUCCESS; } /* diff --git a/src/drivers/i2c/designware/dw_i2c.h b/src/drivers/i2c/designware/dw_i2c.h index c010b11d75..64e27c0a3c 100644 --- a/src/drivers/i2c/designware/dw_i2c.h +++ b/src/drivers/i2c/designware/dw_i2c.h @@ -95,11 +95,8 @@ uintptr_t dw_i2c_base_address(unsigned int bus); /* * Initialize this bus controller and set the speed - * Return value: - * -1 = failure - * 0 = success */ -int dw_i2c_init(unsigned int bus, const struct dw_i2c_bus_config *bcfg); +enum cb_err dw_i2c_init(unsigned int bus, const struct dw_i2c_bus_config *bcfg); /* * Generate speed config based on clock |