Commit f9a4c2da authored by Simon Glass's avatar Simon Glass

dm: i2c: Rename driver model I2C functions to permit compatibility

Add a dm_ prefix to driver model I2C functions so that we can keep the old
ones around.

This is a little unfortunate, but on reflection it is too difficult to
change the API. We can undo this rename when most boards and drivers are
converted to use driver model for I2C.
Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
parent a08d643d
......@@ -60,7 +60,7 @@ void pmu_write(uchar reg, uchar data)
debug("%s: Cannot find PMIC I2C chip\n", __func__);
return;
}
i2c_write(dev, reg, &data, 1);
dm_i2c_write(dev, reg, &data, 1);
}
/*
......
......@@ -57,7 +57,7 @@ void board_sdmmc_voltage_init(void)
reg = 0x32;
for (i = 0; i < MAX_I2C_RETRY; ++i) {
if (i2c_write(dev, reg, data_buffer, 1))
if (dm_i2c_write(dev, reg, data_buffer, 1))
udelay(100);
}
......@@ -66,7 +66,7 @@ void board_sdmmc_voltage_init(void)
reg = 0x67;
for (i = 0; i < MAX_I2C_RETRY; ++i) {
if (i2c_write(dev, reg, data_buffer, 1))
if (dm_i2c_write(dev, reg, data_buffer, 1))
udelay(100);
}
}
......@@ -104,7 +104,7 @@ int tegra_pcie_board_init(void)
data[0] = 0x15;
addr = 0x30;
err = i2c_write(dev, addr, data, 1);
err = dm_i2c_write(dev, addr, data, 1);
if (err) {
debug("failed to set VDD supply\n");
return err;
......@@ -121,7 +121,7 @@ int tegra_pcie_board_init(void)
data[0] = 0x15;
addr = 0x31;
err = i2c_write(dev, addr, data, 1);
err = dm_i2c_write(dev, addr, data, 1);
if (err) {
debug("failed to set AVDD supply\n");
return err;
......
......@@ -65,7 +65,7 @@ void board_sdmmc_voltage_init(void)
data_buffer[0] = 0x31;
reg = 0x61;
ret = i2c_write(dev, reg, data_buffer, 1);
ret = dm_i2c_write(dev, reg, data_buffer, 1);
if (ret)
printf("%s: PMU i2c_write %02X<-%02X returned %d\n",
__func__, reg, data_buffer[0], ret);
......@@ -74,7 +74,7 @@ void board_sdmmc_voltage_init(void)
data_buffer[0] = 0x01;
reg = 0x60;
ret = i2c_write(dev, reg, data_buffer, 1);
ret = dm_i2c_write(dev, reg, data_buffer, 1);
if (ret)
printf("%s: PMU i2c_write %02X<-%02X returned %d\n",
__func__, reg, data_buffer[0], ret);
......@@ -88,7 +88,7 @@ void board_sdmmc_voltage_init(void)
debug("%s: Cannot find charger I2C chip\n", __func__);
return;
}
ret = i2c_write(dev, reg, data_buffer, 1);
ret = dm_i2c_write(dev, reg, data_buffer, 1);
if (ret)
printf("%s: BAT i2c_write %02X<-%02X returned %d\n",
__func__, reg, data_buffer[0], ret);
......
......@@ -33,15 +33,15 @@ void pin_mux_mmc(void)
return;
}
val = 0x29;
ret = i2c_write(dev, 0x46, &val, 1);
ret = dm_i2c_write(dev, 0x46, &val, 1);
if (ret)
printf("i2c_write 0 0x3c 0x46 failed: %d\n", ret);
val = 0x00;
ret = i2c_write(dev, 0x45, &val, 1);
ret = dm_i2c_write(dev, 0x45, &val, 1);
if (ret)
printf("i2c_write 0 0x3c 0x45 failed: %d\n", ret);
val = 0x1f;
ret = i2c_write(dev, 0x44, &val, 1);
ret = dm_i2c_write(dev, 0x44, &val, 1);
if (ret)
printf("i2c_write 0 0x3c 0x44 failed: %d\n", ret);
......@@ -70,11 +70,11 @@ void pin_mux_usb(void)
return;
}
val = 0x03;
ret = i2c_write(dev, 2, &val, 1);
ret = dm_i2c_write(dev, 2, &val, 1);
if (ret)
printf("i2c_write 0 0x20 2 failed: %d\n", ret);
val = 0xfc;
ret = i2c_write(dev, 6, &val, 1);
ret = dm_i2c_write(dev, 6, &val, 1);
if (ret)
printf("i2c_write 0 0x20 6 failed: %d\n", ret);
}
......@@ -51,7 +51,7 @@ int tegra_pcie_board_init(void)
data[0] = 0x27;
addr = 0x25;
err = i2c_write(dev, addr, data, 1);
err = dm_i2c_write(dev, addr, data, 1);
if (err) {
debug("failed to set VDD supply\n");
return err;
......@@ -61,7 +61,7 @@ int tegra_pcie_board_init(void)
data[0] = 0x0D;
addr = 0x24;
err = i2c_write(dev, addr, data, 1);
err = dm_i2c_write(dev, addr, data, 1);
if (err) {
debug("failed to enable VDD supply\n");
return err;
......@@ -71,7 +71,7 @@ int tegra_pcie_board_init(void)
data[0] = 0x0D;
addr = 0x35;
err = i2c_write(dev, addr, data, 1);
err = dm_i2c_write(dev, addr, data, 1);
if (err) {
debug("failed to set AVDD supply\n");
return err;
......
......@@ -133,7 +133,7 @@ static uchar i2c_no_probes[] = CONFIG_SYS_I2C_NOPROBES;
#ifdef CONFIG_DM_I2C
static struct udevice *i2c_cur_bus;
static int i2c_set_bus_num(unsigned int busnum)
static int cmd_i2c_set_bus_num(unsigned int busnum)
{
struct udevice *bus;
int ret;
......@@ -323,7 +323,7 @@ static int do_i2c_read ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
if (!ret && alen != -1)
ret = i2c_set_chip_offset_len(dev, alen);
if (!ret)
ret = i2c_read(dev, devaddr, memaddr, length);
ret = dm_i2c_read(dev, devaddr, memaddr, length);
#else
ret = i2c_read(chip, devaddr, alen, memaddr, length);
#endif
......@@ -381,7 +381,7 @@ static int do_i2c_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
while (length-- > 0) {
#ifdef CONFIG_DM_I2C
ret = i2c_write(dev, devaddr++, memaddr++, 1);
ret = dm_i2c_write(dev, devaddr++, memaddr++, 1);
#else
ret = i2c_write(chip, devaddr++, alen, memaddr++, 1);
#endif
......@@ -513,7 +513,7 @@ static int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes;
#ifdef CONFIG_DM_I2C
ret = i2c_read(dev, addr, linebuf, linebytes);
ret = dm_i2c_read(dev, addr, linebuf, linebytes);
#else
ret = i2c_read(chip, addr, alen, linebuf, linebytes);
#endif
......@@ -611,7 +611,7 @@ static int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
while (count-- > 0) {
#ifdef CONFIG_DM_I2C
ret = i2c_write(dev, addr++, &byte, 1);
ret = dm_i2c_write(dev, addr++, &byte, 1);
#else
ret = i2c_write(chip, addr++, alen, &byte, 1);
#endif
......@@ -698,7 +698,7 @@ static int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
err = 0;
while (count-- > 0) {
#ifdef CONFIG_DM_I2C
ret = i2c_read(dev, addr, &byte, 1);
ret = dm_i2c_read(dev, addr, &byte, 1);
#else
ret = i2c_read(chip, addr, alen, &byte, 1);
#endif
......@@ -793,7 +793,7 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg
do {
printf("%08lx:", addr);
#ifdef CONFIG_DM_I2C
ret = i2c_read(dev, addr, (uchar *)&data, size);
ret = dm_i2c_read(dev, addr, (uchar *)&data, size);
#else
ret = i2c_read(chip, addr, alen, (uchar *)&data, size);
#endif
......@@ -841,8 +841,8 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg
*/
bootretry_reset_cmd_timeout();
#ifdef CONFIG_DM_I2C
ret = i2c_write(dev, addr, (uchar *)&data,
size);
ret = dm_i2c_write(dev, addr, (uchar *)&data,
size);
#else
ret = i2c_write(chip, addr, alen,
(uchar *)&data, size);
......@@ -917,7 +917,7 @@ static int do_i2c_probe (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
continue;
#endif
#ifdef CONFIG_DM_I2C
ret = i2c_probe(bus, j, 0, &dev);
ret = dm_i2c_probe(bus, j, 0, &dev);
#else
ret = i2c_probe(j);
#endif
......@@ -1010,7 +1010,7 @@ static int do_i2c_loop(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
*/
while (1) {
#ifdef CONFIG_DM_I2C
ret = i2c_read(dev, addr, bytes, length);
ret = dm_i2c_read(dev, addr, bytes, length);
#else
ret = i2c_read(chip, addr, alen, bytes, length);
#endif
......@@ -1579,7 +1579,7 @@ int do_edid(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
#ifdef CONFIG_DM_I2C
ret = i2c_get_cur_bus_chip(chip, &dev);
if (!ret)
ret = i2c_read(dev, 0, (uchar *)&edid, sizeof(edid));
ret = dm_i2c_read(dev, 0, (uchar *)&edid, sizeof(edid));
#else
ret = i2c_read(chip, 0, 1, (uchar *)&edid, sizeof(edid));
#endif
......@@ -1696,7 +1696,11 @@ static int do_i2c_bus_num(cmd_tbl_t *cmdtp, int flag, int argc,
}
#endif
printf("Setting bus to %d\n", bus_no);
#ifdef CONFIG_DM_I2C
ret = cmd_i2c_set_bus_num(bus_no);
#else
ret = i2c_set_bus_num(bus_no);
#endif
if (ret)
printf("Failure changing bus number (%d)\n", ret);
}
......
......@@ -23,7 +23,8 @@ unsigned long get_version(void)
# define install_hdlr irq_install_handler
# define free_hdlr irq_free_handler
#endif
#ifndef CONFIG_CMD_I2C
#if !defined(CONFIG_CMD_I2C) || \
(defined(CONFIG_DM_I2C) && !defined(CONFIG_DM_I2C_COMPAT))
# define i2c_write dummy
# define i2c_read dummy
#endif
......
......@@ -100,7 +100,7 @@ static int i2c_write_bytewise(struct udevice *dev, uint offset,
return 0;
}
int i2c_read(struct udevice *dev, uint offset, uint8_t *buffer, int len)
int dm_i2c_read(struct udevice *dev, uint offset, uint8_t *buffer, int len)
{
struct dm_i2c_chip *chip = dev_get_parentdata(dev);
struct udevice *bus = dev_get_parent(dev);
......@@ -130,7 +130,8 @@ int i2c_read(struct udevice *dev, uint offset, uint8_t *buffer, int len)
return ops->xfer(bus, msg, msg_count);
}
int i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer, int len)
int dm_i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer,
int len)
{
struct dm_i2c_chip *chip = dev_get_parentdata(dev);
struct udevice *bus = dev_get_parent(dev);
......@@ -303,8 +304,8 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, struct udevice **devp)
return 0;
}
int i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags,
struct udevice **devp)
int dm_i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags,
struct udevice **devp)
{
int ret;
......
......@@ -31,7 +31,7 @@ static int as3722_read(struct udevice *pmic, u8 reg, u8 *value)
{
int err;
err = i2c_read(pmic, reg, value, 1);
err = dm_i2c_read(pmic, reg, value, 1);
if (err < 0)
return err;
......@@ -42,7 +42,7 @@ static int as3722_write(struct udevice *pmic, u8 reg, u8 value)
{
int err;
err = i2c_write(pmic, reg, &value, 1);
err = dm_i2c_write(pmic, reg, &value, 1);
if (err < 0)
return err;
......
......@@ -37,7 +37,7 @@ static int tps6586x_read(int reg)
int retval = -1;
for (i = 0; i < MAX_I2C_RETRY; ++i) {
if (!i2c_read(tps6586x_dev, reg, &data, 1)) {
if (!dm_i2c_read(tps6586x_dev, reg, &data, 1)) {
retval = (int)data;
goto exit;
}
......@@ -60,7 +60,7 @@ static int tps6586x_write(int reg, uchar *data, uint len)
int retval = -1;
for (i = 0; i < MAX_I2C_RETRY; ++i) {
if (!i2c_write(tps6586x_dev, reg, data, len)) {
if (!dm_i2c_write(tps6586x_dev, reg, data, len)) {
retval = 0;
goto exit;
}
......
......@@ -75,7 +75,7 @@ struct dm_i2c_bus {
};
/**
* i2c_read() - read bytes from an I2C chip
* dm_i2c_read() - read bytes from an I2C chip
*
* To obtain an I2C device (called a 'chip') given the I2C bus address you
* can use i2c_get_chip(). To obtain a bus by bus number use
......@@ -91,13 +91,12 @@ struct dm_i2c_bus {
*
* @return 0 on success, -ve on failure
*/
int i2c_read(struct udevice *dev, uint offset, uint8_t *buffer,
int len);
int dm_i2c_read(struct udevice *dev, uint offset, uint8_t *buffer, int len);
/**
* i2c_write() - write bytes to an I2C chip
* dm_i2c_write() - write bytes to an I2C chip
*
* See notes for i2c_read() above.
* See notes for dm_i2c_read() above.
*
* @dev: Chip to write to
* @offset: Offset within chip to start writing
......@@ -106,11 +105,11 @@ int i2c_read(struct udevice *dev, uint offset, uint8_t *buffer,
*
* @return 0 on success, -ve on failure
*/
int i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer,
int len);
int dm_i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer,
int len);
/**
* i2c_probe() - probe a particular chip address
* dm_i2c_probe() - probe a particular chip address
*
* This can be useful to check for the existence of a chip on the bus.
* It is typically implemented by writing the chip address to the bus
......@@ -122,8 +121,8 @@ int i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer,
* @devp: Returns the device found, or NULL if none
* @return 0 if a chip was found at that address, -ve if not
*/
int i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags,
struct udevice **devp);
int dm_i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags,
struct udevice **devp);
/**
* i2c_set_bus_speed() - set the speed of a bus
......
......@@ -35,8 +35,8 @@ static int dm_test_i2c_find(struct dm_test_state *dms)
* remove the emulation and the slave device.
*/
ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus));
ut_assertok(i2c_probe(bus, chip, 0, &dev));
ut_asserteq(-ENODEV, i2c_probe(bus, no_chip, 0, &dev));
ut_assertok(dm_i2c_probe(bus, chip, 0, &dev));
ut_asserteq(-ENODEV, dm_i2c_probe(bus, no_chip, 0, &dev));
ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_I2C, 1, &bus));
return 0;
......@@ -50,10 +50,10 @@ static int dm_test_i2c_read_write(struct dm_test_state *dms)
ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus));
ut_assertok(i2c_get_chip(bus, chip, &dev));
ut_assertok(i2c_read(dev, 0, buf, 5));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
ut_assertok(memcmp(buf, "\0\0\0\0\0", sizeof(buf)));
ut_assertok(i2c_write(dev, 2, (uint8_t *)"AB", 2));
ut_assertok(i2c_read(dev, 0, buf, 5));
ut_assertok(dm_i2c_write(dev, 2, (uint8_t *)"AB", 2));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
ut_assertok(memcmp(buf, "\0\0AB\0", sizeof(buf)));
return 0;
......@@ -68,11 +68,11 @@ static int dm_test_i2c_speed(struct dm_test_state *dms)
ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus));
ut_assertok(i2c_get_chip(bus, chip, &dev));
ut_assertok(i2c_set_bus_speed(bus, 100000));
ut_assertok(i2c_read(dev, 0, buf, 5));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
ut_assertok(i2c_set_bus_speed(bus, 400000));
ut_asserteq(400000, i2c_get_bus_speed(bus));
ut_assertok(i2c_read(dev, 0, buf, 5));
ut_asserteq(-EINVAL, i2c_write(dev, 0, buf, 5));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
ut_asserteq(-EINVAL, dm_i2c_write(dev, 0, buf, 5));
return 0;
}
......@@ -86,7 +86,7 @@ static int dm_test_i2c_offset_len(struct dm_test_state *dms)
ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus));
ut_assertok(i2c_get_chip(bus, chip, &dev));
ut_assertok(i2c_set_chip_offset_len(dev, 1));
ut_assertok(i2c_read(dev, 0, buf, 5));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
/* This is not supported by the uclass */
ut_asserteq(-EINVAL, i2c_set_chip_offset_len(dev, 5));
......@@ -100,7 +100,7 @@ static int dm_test_i2c_probe_empty(struct dm_test_state *dms)
struct udevice *bus, *dev;
ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus));
ut_assertok(i2c_probe(bus, SANDBOX_I2C_TEST_ADDR, 0, &dev));
ut_assertok(dm_i2c_probe(bus, SANDBOX_I2C_TEST_ADDR, 0, &dev));
return 0;
}
......@@ -114,7 +114,7 @@ static int dm_test_i2c_bytewise(struct dm_test_state *dms)
ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus));
ut_assertok(i2c_get_chip(bus, chip, &dev));
ut_assertok(i2c_read(dev, 0, buf, 5));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
ut_assertok(memcmp(buf, "\0\0\0\0\0", sizeof(buf)));
/* Tell the EEPROM to only read/write one register at a time */
......@@ -123,34 +123,34 @@ static int dm_test_i2c_bytewise(struct dm_test_state *dms)
sandbox_i2c_eeprom_set_test_mode(eeprom, SIE_TEST_MODE_SINGLE_BYTE);
/* Now we only get the first byte - the rest will be 0xff */
ut_assertok(i2c_read(dev, 0, buf, 5));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
ut_assertok(memcmp(buf, "\0\xff\xff\xff\xff", sizeof(buf)));
/* If we do a separate transaction for each byte, it works */
ut_assertok(i2c_set_chip_flags(dev, DM_I2C_CHIP_RD_ADDRESS));
ut_assertok(i2c_read(dev, 0, buf, 5));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
ut_assertok(memcmp(buf, "\0\0\0\0\0", sizeof(buf)));
/* This will only write A */
ut_assertok(i2c_set_chip_flags(dev, 0));
ut_assertok(i2c_write(dev, 2, (uint8_t *)"AB", 2));
ut_assertok(i2c_read(dev, 0, buf, 5));
ut_assertok(dm_i2c_write(dev, 2, (uint8_t *)"AB", 2));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
ut_assertok(memcmp(buf, "\0\xff\xff\xff\xff", sizeof(buf)));
/* Check that the B was ignored */
ut_assertok(i2c_set_chip_flags(dev, DM_I2C_CHIP_RD_ADDRESS));
ut_assertok(i2c_read(dev, 0, buf, 5));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
ut_assertok(memcmp(buf, "\0\0A\0\0\0", sizeof(buf)));
/* Now write it again with the new flags, it should work */
ut_assertok(i2c_set_chip_flags(dev, DM_I2C_CHIP_WR_ADDRESS));
ut_assertok(i2c_write(dev, 2, (uint8_t *)"AB", 2));
ut_assertok(i2c_read(dev, 0, buf, 5));
ut_assertok(dm_i2c_write(dev, 2, (uint8_t *)"AB", 2));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
ut_assertok(memcmp(buf, "\0\xff\xff\xff\xff", sizeof(buf)));
ut_assertok(i2c_set_chip_flags(dev, DM_I2C_CHIP_WR_ADDRESS |
DM_I2C_CHIP_RD_ADDRESS));
ut_assertok(i2c_read(dev, 0, buf, 5));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
ut_assertok(memcmp(buf, "\0\0AB\0\0", sizeof(buf)));
/* Restore defaults */
......@@ -170,42 +170,42 @@ static int dm_test_i2c_offset(struct dm_test_state *dms)
ut_assertok(i2c_get_chip_for_busnum(busnum, chip, &dev));
/* Do a transfer so we can find the emulator */
ut_assertok(i2c_read(dev, 0, buf, 5));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
ut_assertok(uclass_first_device(UCLASS_I2C_EMUL, &eeprom));
/* Offset length 0 */
sandbox_i2c_eeprom_set_offset_len(eeprom, 0);
ut_assertok(i2c_set_chip_offset_len(dev, 0));
ut_assertok(i2c_write(dev, 10 /* ignored */, (uint8_t *)"AB", 2));
ut_assertok(i2c_read(dev, 0, buf, 5));
ut_assertok(dm_i2c_write(dev, 10 /* ignored */, (uint8_t *)"AB", 2));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
ut_assertok(memcmp(buf, "AB\0\0\0\0", sizeof(buf)));
/* Offset length 1 */
sandbox_i2c_eeprom_set_offset_len(eeprom, 1);
ut_assertok(i2c_set_chip_offset_len(dev, 1));
ut_assertok(i2c_write(dev, 2, (uint8_t *)"AB", 2));
ut_assertok(i2c_read(dev, 0, buf, 5));
ut_assertok(dm_i2c_write(dev, 2, (uint8_t *)"AB", 2));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
ut_assertok(memcmp(buf, "ABAB\0", sizeof(buf)));
/* Offset length 2 */
sandbox_i2c_eeprom_set_offset_len(eeprom, 2);
ut_assertok(i2c_set_chip_offset_len(dev, 2));
ut_assertok(i2c_write(dev, 0x210, (uint8_t *)"AB", 2));
ut_assertok(i2c_read(dev, 0x210, buf, 5));
ut_assertok(dm_i2c_write(dev, 0x210, (uint8_t *)"AB", 2));
ut_assertok(dm_i2c_read(dev, 0x210, buf, 5));
ut_assertok(memcmp(buf, "AB\0\0\0", sizeof(buf)));
/* Offset length 3 */
sandbox_i2c_eeprom_set_offset_len(eeprom, 2);
ut_assertok(i2c_set_chip_offset_len(dev, 2));
ut_assertok(i2c_write(dev, 0x410, (uint8_t *)"AB", 2));
ut_assertok(i2c_read(dev, 0x410, buf, 5));
ut_assertok(dm_i2c_write(dev, 0x410, (uint8_t *)"AB", 2));
ut_assertok(dm_i2c_read(dev, 0x410, buf, 5));
ut_assertok(memcmp(buf, "AB\0\0\0", sizeof(buf)));
/* Offset length 4 */
sandbox_i2c_eeprom_set_offset_len(eeprom, 2);
ut_assertok(i2c_set_chip_offset_len(dev, 2));
ut_assertok(i2c_write(dev, 0x420, (uint8_t *)"AB", 2));
ut_assertok(i2c_read(dev, 0x420, buf, 5));
ut_assertok(dm_i2c_write(dev, 0x420, (uint8_t *)"AB", 2));
ut_assertok(dm_i2c_read(dev, 0x420, buf, 5));
ut_assertok(memcmp(buf, "AB\0\0\0", sizeof(buf)));
/* Restore defaults */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment