Commit 9669f541 authored by Vincent Sanders's avatar Vincent Sanders Committed by Jean Delvare

i2c: Remove big kernel lock from i2cdev_open

The BKL is held over a kmalloc so cannot protect anything beyond that.
The two calls before the kmalloc have their own locking.
Improve device open function by removing the now unnecessary ret variable
Signed-off-by: default avatarVincent Sanders <vince@simtec.co.uk>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent c2e90e9b
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c-dev.h> #include <linux/i2c-dev.h>
#include <linux/smp_lock.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -445,20 +444,14 @@ static int i2cdev_open(struct inode *inode, struct file *file) ...@@ -445,20 +444,14 @@ static int i2cdev_open(struct inode *inode, struct file *file)
struct i2c_client *client; struct i2c_client *client;
struct i2c_adapter *adap; struct i2c_adapter *adap;
struct i2c_dev *i2c_dev; struct i2c_dev *i2c_dev;
int ret = 0;
lock_kernel();
i2c_dev = i2c_dev_get_by_minor(minor); i2c_dev = i2c_dev_get_by_minor(minor);
if (!i2c_dev) { if (!i2c_dev)
ret = -ENODEV; return -ENODEV;
goto out;
}
adap = i2c_get_adapter(i2c_dev->adap->nr); adap = i2c_get_adapter(i2c_dev->adap->nr);
if (!adap) { if (!adap)
ret = -ENODEV; return -ENODEV;
goto out;
}
/* This creates an anonymous i2c_client, which may later be /* This creates an anonymous i2c_client, which may later be
* pointed to some address using I2C_SLAVE or I2C_SLAVE_FORCE. * pointed to some address using I2C_SLAVE or I2C_SLAVE_FORCE.
...@@ -470,8 +463,7 @@ static int i2cdev_open(struct inode *inode, struct file *file) ...@@ -470,8 +463,7 @@ static int i2cdev_open(struct inode *inode, struct file *file)
client = kzalloc(sizeof(*client), GFP_KERNEL); client = kzalloc(sizeof(*client), GFP_KERNEL);
if (!client) { if (!client) {
i2c_put_adapter(adap); i2c_put_adapter(adap);
ret = -ENOMEM; return -ENOMEM;
goto out;
} }
snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr); snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr);
client->driver = &i2cdev_driver; client->driver = &i2cdev_driver;
...@@ -479,9 +471,7 @@ static int i2cdev_open(struct inode *inode, struct file *file) ...@@ -479,9 +471,7 @@ static int i2cdev_open(struct inode *inode, struct file *file)
client->adapter = adap; client->adapter = adap;
file->private_data = client; file->private_data = client;
out: return 0;
unlock_kernel();
return ret;
} }
static int i2cdev_release(struct inode *inode, struct file *file) static int i2cdev_release(struct inode *inode, struct file *file)
......
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