summaryrefslogtreecommitdiff
path: root/src/drivers/i2c/designware
diff options
context:
space:
mode:
authorFelix Held <felix-coreboot@felixheld.de>2022-01-31 15:59:17 +0100
committerFelix Held <felix-coreboot@felixheld.de>2022-02-01 17:56:29 +0000
commit8ed02de830b27be0c0c1652cf79ac5a866101423 (patch)
treeb9392a7fd390eed93709d62bdd43e9ca9f050c15 /src/drivers/i2c/designware
parent3d945890d8d22fa2669b6777c572bbe42152453e (diff)
drivers/i2c/designware/dw_i2c: return enum cb_err from dw_i2c_transfer
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: Ic1812c4d8d2b4d9ad331a787bd302a4f0707c1fe Reviewed-on: https://review.coreboot.org/c/coreboot/+/61513 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Raul Rangel <rrangel@chromium.org>
Diffstat (limited to 'src/drivers/i2c/designware')
-rw-r--r--src/drivers/i2c/designware/dw_i2c.c8
-rw-r--r--src/drivers/i2c/designware/dw_i2c.h5
2 files changed, 5 insertions, 8 deletions
diff --git a/src/drivers/i2c/designware/dw_i2c.c b/src/drivers/i2c/designware/dw_i2c.c
index e29d54f3c2..011b38b548 100644
--- a/src/drivers/i2c/designware/dw_i2c.c
+++ b/src/drivers/i2c/designware/dw_i2c.c
@@ -453,7 +453,7 @@ out:
return ret;
}
-int dw_i2c_transfer(unsigned int bus, const struct i2c_msg *msg, size_t count)
+enum cb_err dw_i2c_transfer(unsigned int bus, const struct i2c_msg *msg, size_t count)
{
const struct i2c_msg *orig_msg = msg;
size_t i;
@@ -469,19 +469,19 @@ int dw_i2c_transfer(unsigned int bus, const struct i2c_msg *msg, size_t count)
for (i = 0, start = 0; i < count; i++, msg++) {
if (addr != msg->slave) {
if (_dw_i2c_transfer(bus, &orig_msg[start], i - start) != CB_SUCCESS)
- return -1;
+ return CB_ERR;
start = i;
addr = msg->slave;
}
}
- return _dw_i2c_transfer(bus, &orig_msg[start], count - start) == CB_SUCCESS ? 0 : -1;
+ return _dw_i2c_transfer(bus, &orig_msg[start], count - start);
}
/* Global I2C bus handler, defined in include/device/i2c_simple.h */
int platform_i2c_transfer(unsigned int bus, struct i2c_msg *msg, int count)
{
- return dw_i2c_transfer(bus, msg, count < 0 ? 0 : count);
+ return dw_i2c_transfer(bus, msg, count < 0 ? 0 : count) == CB_SUCCESS ? 0 : -1;
}
static enum cb_err dw_i2c_set_speed_config(unsigned int bus,
diff --git a/src/drivers/i2c/designware/dw_i2c.h b/src/drivers/i2c/designware/dw_i2c.h
index 64e27c0a3c..847b6c3fda 100644
--- a/src/drivers/i2c/designware/dw_i2c.h
+++ b/src/drivers/i2c/designware/dw_i2c.h
@@ -111,11 +111,8 @@ int dw_i2c_gen_speed_config(uintptr_t dw_i2c_addr,
/*
* Process given I2C segments in a single transfer
- * Return value:
- * -1 = failure
- * 0 = success
*/
-int dw_i2c_transfer(unsigned int bus,
+enum cb_err dw_i2c_transfer(unsigned int bus,
const struct i2c_msg *segments,
size_t count);