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: Simon Glass <sjg@chromium.org>
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index f65ab61..1e500fb 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -133,7 +133,7 @@
#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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
*/
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 @@
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 @@
*/
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 @@
#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 @@
}
#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);
}