static int i2c_transfer(struct I2cOps *me, I2cSeg *segments, int seg_count) { Ipq806xI2c *bus = container_of(me, Ipq806xI2c, ops); I2cSeg *seg = segments; int ret = 0; if (!bus->initialized) { if (0 != i2c_init(bus->gsbi_id)) return 1; else bus->initialized = 1; } while (!ret && seg_count--) { if (seg->read) ret = i2c_read(bus->gsbi_id, seg->chip, seg->buf, seg->len); else ret = i2c_write(bus->gsbi_id, seg->chip, seg->buf, seg->len, (seg_count ? 0 : 1), !me->scan_mode); seg++; } if (QUP_SUCCESS != ret) { qup_set_state(bus->gsbi_id, QUP_STATE_RESET); return 1; } return 0; }
int platform_i2c_transfer(unsigned bus, struct i2c_seg *segments, int seg_count) { struct i2c_seg *seg = segments; int ret = 0; if (i2c_init(bus)) return 1; while (!ret && seg_count--) { if (seg->read) ret = i2c_read(bus, seg->chip, seg->buf, seg->len); else ret = i2c_write(bus, seg->chip, seg->buf, seg->len, (seg_count ? 0 : 1)); seg++; } if (ret) { qup_set_state(bus, QUP_STATE_RESET); return 1; } return 0; }