From 0617037f9a67fa992ab811b31d61e871c6adde38 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Mon, 7 Dec 2020 21:33:09 -0300 Subject: [PATCH] Remove i2c_has_device, as the same functionality is essentially available through the subsequent i2c_start --- src/device/i2c.c | 22 ++++------------------ src/device/i2c_gpio.c | 2 +- src/device/smbus_piix4.c | 2 +- src/include/86box/i2c.h | 1 - 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/device/i2c.c b/src/device/i2c.c index c17f3487c..ac0e5ee83 100644 --- a/src/device/i2c.c +++ b/src/device/i2c.c @@ -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); } diff --git a/src/device/i2c_gpio.c b/src/device/i2c_gpio.c index 8d219b67d..91c2d370b 100644 --- a/src/device/i2c_gpio.c +++ b/src/device/i2c_gpio.c @@ -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 */ diff --git a/src/device/smbus_piix4.c b/src/device/smbus_piix4.c index 9a544832c..e9156bf62 100644 --- a/src/device/smbus_piix4.c +++ b/src/device/smbus_piix4.c @@ -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; } diff --git a/src/include/86box/i2c.h b/src/include/86box/i2c.h index 58ef23bd1..b47754d64 100644 --- a/src/include/86box/i2c.h +++ b/src/include/86box/i2c.h @@ -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);