Commit d30f0c9d authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

I2C: sparse cleanups for drivers/i2c/*

Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 3499c9eb
...@@ -170,8 +170,11 @@ static inline u8 FAN_TO_REG(long rpm, int div) ...@@ -170,8 +170,11 @@ static inline u8 FAN_TO_REG(long rpm, int div)
static int DIV_TO_REG(int val) static int DIV_TO_REG(int val)
{ {
int answer = 0; int answer = 0;
while ((val >>= 1)) val >>= 1;
while (val) {
answer++; answer++;
val >>= 1;
}
return answer; return answer;
} }
#define DIV_FROM_REG(val) (1 << (val)) #define DIV_FROM_REG(val) (1 << (val))
......
...@@ -181,7 +181,7 @@ int i2cdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd, ...@@ -181,7 +181,7 @@ int i2cdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd,
struct i2c_smbus_ioctl_data data_arg; struct i2c_smbus_ioctl_data data_arg;
union i2c_smbus_data temp; union i2c_smbus_data temp;
struct i2c_msg *rdwr_pa; struct i2c_msg *rdwr_pa;
u8 **data_ptrs; u8 __user **data_ptrs;
int i,datasize,res; int i,datasize,res;
unsigned long funcs; unsigned long funcs;
...@@ -238,8 +238,7 @@ int i2cdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd, ...@@ -238,8 +238,7 @@ int i2cdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
} }
data_ptrs = (u8 **) kmalloc(rdwr_arg.nmsgs * sizeof(u8 *), data_ptrs = kmalloc(rdwr_arg.nmsgs * sizeof(u8 __user *), GFP_KERNEL);
GFP_KERNEL);
if (data_ptrs == NULL) { if (data_ptrs == NULL) {
kfree(rdwr_pa); kfree(rdwr_pa);
return -ENOMEM; return -ENOMEM;
...@@ -252,7 +251,7 @@ int i2cdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd, ...@@ -252,7 +251,7 @@ int i2cdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd,
res = -EINVAL; res = -EINVAL;
break; break;
} }
data_ptrs[i] = rdwr_pa[i].buf; data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
rdwr_pa[i].buf = kmalloc(rdwr_pa[i].len, GFP_KERNEL); rdwr_pa[i].buf = kmalloc(rdwr_pa[i].len, GFP_KERNEL);
if(rdwr_pa[i].buf == NULL) { if(rdwr_pa[i].buf == NULL) {
res = -ENOMEM; res = -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment