Remove i2c_has_device, as the same functionality is essentially available through the subsequent i2c_start

This commit is contained in:
RichardG867
2020-12-07 21:33:09 -03:00
parent 1d3c6c55da
commit 0617037f9a
4 changed files with 6 additions and 21 deletions

View File

@@ -213,20 +213,6 @@ i2c_handler(int set, void *bus_handle, uint8_t base, int size,
}
uint8_t
i2c_has_device(void *bus_handle, uint8_t addr)
{
i2c_bus_t *bus = (i2c_bus_t *) bus_handle;
if (!bus)
return 0;
i2c_log("I2C: has_device(%s, %02X) = %d\n", bus->name, addr, !!bus->devices[addr]);
return(!!bus->devices[addr]);
}
uint8_t
i2c_start(void *bus_handle, uint8_t addr, uint8_t read)
{
@@ -247,7 +233,7 @@ i2c_start(void *bus_handle, uint8_t addr, uint8_t read)
}
}
i2c_log("I2C: start(%s, %02X)\n", bus->name, addr);
i2c_log("I2C %s: start(%02X) = %d\n", bus->name, addr, ret);
return(ret);
}
@@ -274,7 +260,7 @@ i2c_read(void *bus_handle, uint8_t addr)
}
}
i2c_log("I2C: read(%s, %02X) = %02X\n", bus->name, addr, ret);
i2c_log("I2C %s: read(%02X) = %02X\n", bus->name, addr, ret);
return(ret);
}
@@ -300,7 +286,7 @@ i2c_write(void *bus_handle, uint8_t addr, uint8_t data)
}
}
i2c_log("I2C: write(%s, %02X, %02X) = %d\n", bus->name, addr, data, ret);
i2c_log("I2C %s: write(%02X, %02X) = %d\n", bus->name, addr, data, ret);
return(ret);
}
@@ -325,5 +311,5 @@ i2c_stop(void *bus_handle, uint8_t addr)
}
}
i2c_log("I2C: stop(%s, %02X)\n", bus->name, addr);
i2c_log("I2C %s: stop(%02X)\n", bus->name, addr);
}

View File

@@ -125,7 +125,7 @@ i2c_gpio_set(void *dev_handle, uint8_t scl, uint8_t sda)
dev->slave_read = dev->byte & 1;
/* slave ACKs? */
dev->slave_sda = !(i2c_has_device(dev->i2c, dev->slave_addr) && i2c_start(dev->i2c, dev->slave_addr, dev->slave_read));
dev->slave_sda = !i2c_start(dev->i2c, dev->slave_addr, dev->slave_read);
i2c_gpio_log(2, "I2C GPIO %s: Slave %02X %s %sACK\n", dev->bus_name, dev->slave_addr, dev->slave_read ? "read" : "write", dev->slave_sda ? "N" : "");
if (!dev->slave_sda && dev->slave_read) /* read first byte on an ACKed read transfer */

View File

@@ -131,7 +131,7 @@ smbus_piix4_write(uint16_t addr, uint8_t val, void *priv)
smbus_piix4_log("SMBus PIIX4: addr=%02X read=%d protocol=%X cmd=%02X data0=%02X data1=%02X\n", smbus_addr, read, cmd, dev->cmd, dev->data0, dev->data1);
/* Raise DEV_ERR if no device is at this address, or if the device returned NAK when starting the transfer. */
if (!i2c_has_device(i2c_smbus, smbus_addr) || !i2c_start(i2c_smbus, smbus_addr, read)) {
if (!i2c_start(i2c_smbus, smbus_addr, read)) {
dev->next_stat = 0x04;
break;
}

View File

@@ -48,7 +48,6 @@ extern void i2c_handler(int set, void *bus_handle, uint8_t base, int size,
void (*stop)(void *bus, uint8_t addr, void *priv),
void *priv);
extern uint8_t i2c_has_device(void *bus_handle, uint8_t addr);
extern uint8_t i2c_start(void *bus_handle, uint8_t addr, uint8_t read);
extern uint8_t i2c_read(void *bus_handle, uint8_t addr);
extern uint8_t i2c_write(void *bus_handle, uint8_t addr, uint8_t data);