示例#1
0
static int i2c_lpc2k_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
	int msg_num)
{
	int ret, i;
	unsigned long stat;
	struct lpc2k_i2c *i2c = adap->algo_data;

	/* Check for bus idle condition */
	stat = i2c_readl(i2c->reg_base + LPC24XX_I2STAT);
	if (stat != m_i2c_idle) {
		/* Something is holding the bus, try to clear it */
		ret = i2c_lpc2k_clear_arb(i2c);
		if (ret) {
			dev_err(&i2c->adap.dev, "Bus is not idle\n");
			return ret;
		}
	}

	dev_dbg(&i2c->adap.dev, "Processing total messages = %d\n", msg_num);

	/* Process a single message at a time */
	for (i = 0; i < msg_num; i++) {
		/* Save message pointer and current message data index */
		i2c->msg = &msgs[i];
		i2c->msg_idx = 0;
		i2c->msg_status = -EBUSY;
		i2c->is_last = (i == (msg_num - 1));

		ret = lpc2k_process_msg(i2c, i);
		if (ret)
			return ret;
	}

	return msg_num;
}
示例#2
0
static int i2c_lpc2k_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
			  int msg_num)
{
	struct lpc2k_i2c *i2c = i2c_get_adapdata(adap);
	int ret, i;
	u32 stat;

	/* Check for bus idle condition */
	stat = readl(i2c->base + LPC24XX_I2STAT);
	if (stat != M_I2C_IDLE) {
		/* Something is holding the bus, try to clear it */
		return i2c_lpc2k_clear_arb(i2c);
	}

	/* Process a single message at a time */
	for (i = 0; i < msg_num; i++) {
		/* Save message pointer and current message data index */
		i2c->msg = &msgs[i];
		i2c->msg_idx = 0;
		i2c->msg_status = -EBUSY;
		i2c->is_last = (i == (msg_num - 1));

		ret = lpc2k_process_msg(i2c, i);
		if (ret)
			return ret;
	}

	return msg_num;
}