/* Prepare controller for a transaction and call i2c_davinci_xfer_msg  */
static int i2c_davinci_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], int num)
/* Prepare controller for a transaction and call i2c_davinci_xfer_msg  */
static int i2c_davinci_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], int num)
{
    struct davinci_i2c_dev *dev = bus->priv;
    int i;
    int ret;
    i2c_dbg("%s: msgs: %d\n", __func__, num);
    ret = i2c_davinci_wait_bus_not_busy(dev, 1);
    if (ret < 0)
    {
        i2c_dbg("timeout waiting for bus ready\n");
        return ret;
    }
    for (i = 0; i < num; i++)
    {
        ret = i2c_davinci_xfer_msg(bus, &msgs[i], (i == (num - 1)));
        i2c_dbg("%s [%d/%d] ret: %d\n", __func__, i + 1, num,
            ret);
        if (ret < 0)
            return ret;
    }
    return num;
}