for (i = 1; i <= msg[0].len; i++) 
for (i = 1; i < msg[0].len; i++) 
static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,                                    unsigned short flags,                                   char read_write, u8 command, int size,                                    union i2c_smbus_data * data){	/* So we need to generate a series of msgs. In the case of writing, we	  need to use only one message; when reading, we need two. We initialize	  most things with sane defaults, to keep the code below somewhat	  simpler. */	unsigned char msgbuf0[34];	unsigned char msgbuf1[34];	int num = read_write == I2C_SMBUS_READ?2:1;	struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, 	                          { addr, flags | I2C_M_RD, 0, msgbuf1 }	                        };	int i;	msgbuf0[0] = command;	switch(size) {	case I2C_SMBUS_QUICK:		msg[0].len = 0;		/* Special case: The read/write field is used as data */		msg[0].flags = flags | (read_write==I2C_SMBUS_READ)?I2C_M_RD:0;		num = 1;		break;	case I2C_SMBUS_BYTE:		if (read_write == I2C_SMBUS_READ) {			/* Special case: only a read! */			msg[0].flags = I2C_M_RD | flags;			num = 1;		}		break;	case I2C_SMBUS_BYTE_DATA:		if (read_write == I2C_SMBUS_READ)			msg[1].len = 1;		else {			msg[0].len = 2;			msgbuf0[1] = data->byte;		}		break;	case I2C_SMBUS_WORD_DATA:		if (read_write == I2C_SMBUS_READ)			msg[1].len = 2;		else {			msg[0].len=3;			msgbuf0[1] = data->word & 0xff;			msgbuf0[2] = (data->word >> 8) & 0xff;		}		break;	case I2C_SMBUS_PROC_CALL:		num = 2; /* Special case */		read_write = I2C_SMBUS_READ;		msg[0].len = 3;		msg[1].len = 2;		msgbuf0[1] = data->word & 0xff;		msgbuf0[2] = (data->word >> 8) & 0xff;		break;	case I2C_SMBUS_BLOCK_DATA:	case I2C_SMBUS_BLOCK_DATA_PEC:		if (read_write == I2C_SMBUS_READ) {			dev_err(&adapter->dev, "Block read not supported "			       "under I2C emulation!\n");			return -1;		} else {			msg[0].len = data->block[0] + 2;			if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 2) {				dev_err(&adapter->dev, "smbus_access called with "				       "invalid block write size (%d)\n",				       data->block[0]);				return -1;			}			if(size == I2C_SMBUS_BLOCK_DATA_PEC)				(msg[0].len)++;			for (i = 1; i <= msg[0].len; i++)				msgbuf0[i] = data->block[i-1];		}		break;	case I2C_SMBUS_BLOCK_PROC_CALL:	case I2C_SMBUS_BLOCK_PROC_CALL_PEC:		dev_dbg(&adapter->dev, "Block process call not supported "		       "under I2C emulation!\n");		return -1;	case I2C_SMBUS_I2C_BLOCK_DATA:		if (read_write == I2C_SMBUS_READ) {			msg[1].len = I2C_SMBUS_I2C_BLOCK_MAX;		} else {			msg[0].len = data->block[0] + 1;			if (msg[0].len > I2C_SMBUS_I2C_BLOCK_MAX + 1) {				dev_err(&adapter->dev, "i2c_smbus_xfer_emulated called with "				       "invalid block write size (%d)\n",				       data->block[0]);				return -1;			}			for (i = 1; i <= data->block[0]; i++)				msgbuf0[i] = data->block[i];		}		break;	default:		dev_err(&adapter->dev, "smbus_access called with invalid size (%d)\n",		       size);		return -1;	}	if (i2c_transfer(adapter, msg, num) < 0)		return -1;	if (read_write == I2C_SMBUS_READ)		switch(size) {			case I2C_SMBUS_BYTE:				data->byte = msgbuf0[0];				break;			case I2C_SMBUS_BYTE_DATA:				data->byte = msgbuf1[0];				break;			case I2C_SMBUS_WORD_DATA: 			case I2C_SMBUS_PROC_CALL:				data->word = msgbuf1[0] | (msgbuf1[1] << 8);				break;			case I2C_SMBUS_I2C_BLOCK_DATA:				/* fixed at 32 for now */				data->block[0] = I2C_SMBUS_I2C_BLOCK_MAX;				for (i = 0; i < I2C_SMBUS_I2C_BLOCK_MAX; i++)					data->block[i+1] = msgbuf1[i];				break;		}	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/5c50d1885981537ff3b8df6433951de6c9cb72cb/i2c-core.c/buggy/drivers/i2c/i2c-core.c