drivers/i2c/designware/dw_i2c: handle bus < 0 in dw_i2c_dev_transfer
dw_i2c_soc_dev_to_bus will return -1 if it failed to find an I2C bus number for a device. In this case return -1 instead of implicitly casting the -1 to an unsigned int and passing that as bus number to dw_i2c_transfer. The dw_i2c_base_address call inside _dw_i2c_transfer already ended up handling this error case correctly, but better handle the error more directly. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I06b6005cee0c5c43855cb5b388a9911fc286c984 Reviewed-on: https://review.coreboot.org/c/coreboot/+/70828 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com> Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
This commit is contained in:
parent
d832bda32b
commit
76364fb66b
|
@ -857,7 +857,12 @@ void dw_i2c_acpi_fill_ssdt(const struct device *dev)
|
||||||
static int dw_i2c_dev_transfer(struct device *dev,
|
static int dw_i2c_dev_transfer(struct device *dev,
|
||||||
const struct i2c_msg *msg, size_t count)
|
const struct i2c_msg *msg, size_t count)
|
||||||
{
|
{
|
||||||
return dw_i2c_transfer(dw_i2c_soc_dev_to_bus(dev), msg, count);
|
int bus = dw_i2c_soc_dev_to_bus(dev);
|
||||||
|
if (bus < 0) {
|
||||||
|
printk(BIOS_ERR, "Invalid I2C bus number.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return dw_i2c_transfer(bus, msg, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct i2c_bus_operations dw_i2c_bus_ops = {
|
const struct i2c_bus_operations dw_i2c_bus_ops = {
|
||||||
|
|
Loading…
Reference in New Issue