X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=drivers%2Fi2c%2Fi2c-dev.c;h=5a15e50748de11076202b2c91bc8c0afc9974701;hb=32c15bb978c0e6ff65b3012a6af5a14c899005ce;hp=e7a7097105923296482dcc37acef6a8bc53fddb9;hpb=e63340ae6b6205fef26b40a75673d1c9c0c8bb90;p=linux-2.6-omap-h63xx.git diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index e7a70971059..5a15e50748d 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -226,8 +226,10 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, res = 0; for( i=0; i 8192) { + /* Limit the size of the message to a sane amount; + * and don't let length change either. */ + if ((rdwr_pa[i].len > 8192) || + (rdwr_pa[i].flags & I2C_M_RECV_LEN)) { res = -EINVAL; break; } @@ -283,6 +285,7 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, (data_arg.size != I2C_SMBUS_WORD_DATA) && (data_arg.size != I2C_SMBUS_PROC_CALL) && (data_arg.size != I2C_SMBUS_BLOCK_DATA) && + (data_arg.size != I2C_SMBUS_I2C_BLOCK_BROKEN) && (data_arg.size != I2C_SMBUS_I2C_BLOCK_DATA) && (data_arg.size != I2C_SMBUS_BLOCK_PROC_CALL)) { dev_dbg(&client->adapter->dev, @@ -329,10 +332,18 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, if ((data_arg.size == I2C_SMBUS_PROC_CALL) || (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || + (data_arg.size == I2C_SMBUS_I2C_BLOCK_DATA) || (data_arg.read_write == I2C_SMBUS_WRITE)) { if (copy_from_user(&temp, data_arg.data, datasize)) return -EFAULT; } + if (data_arg.size == I2C_SMBUS_I2C_BLOCK_BROKEN) { + /* Convert old I2C block commands to the new + convention. This preserves binary compatibility. */ + data_arg.size = I2C_SMBUS_I2C_BLOCK_DATA; + if (data_arg.read_write == I2C_SMBUS_READ) + temp.block[0] = I2C_SMBUS_BLOCK_MAX; + } res = i2c_smbus_xfer(client->adapter,client->addr,client->flags, data_arg.read_write, data_arg.command,data_arg.size,&temp); @@ -343,9 +354,19 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, return -EFAULT; } return res; - + case I2C_RETRIES: + client->adapter->retries = arg; + break; + case I2C_TIMEOUT: + client->adapter->timeout = arg; + break; default: - return i2c_control(client,cmd,arg); + /* NOTE: returning a fault code here could cause trouble + * in buggy userspace code. Some old kernel bugs returned + * zero in this case, and userspace code might accidentally + * have depended on that bug. + */ + return -ENOTTY; } return 0; }