diff options
author | Vincent Sanders <vince@simtec.co.uk> | 2009-12-06 17:06:26 +0100 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-12-06 17:06:26 +0100 |
commit | 9669f54194b4df34c96478d696d9ba2b977545f5 (patch) | |
tree | 395bf1b080dedf018c12d69398853878f882d0d5 | |
parent | c2e90e9b6835d71cbadd42fe5b38704acaccf8aa (diff) |
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: Vincent Sanders <vince@simtec.co.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
-rw-r--r-- | drivers/i2c/i2c-dev.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 7e13d2df9af..f4110aa4960 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -34,7 +34,6 @@ #include <linux/list.h> #include <linux/i2c.h> #include <linux/i2c-dev.h> -#include <linux/smp_lock.h> #include <linux/jiffies.h> #include <asm/uaccess.h> @@ -445,20 +444,14 @@ static int i2cdev_open(struct inode *inode, struct file *file) struct i2c_client *client; struct i2c_adapter *adap; struct i2c_dev *i2c_dev; - int ret = 0; - lock_kernel(); i2c_dev = i2c_dev_get_by_minor(minor); - if (!i2c_dev) { - ret = -ENODEV; - goto out; - } + if (!i2c_dev) + return -ENODEV; adap = i2c_get_adapter(i2c_dev->adap->nr); - if (!adap) { - ret = -ENODEV; - goto out; - } + if (!adap) + return -ENODEV; /* This creates an anonymous i2c_client, which may later be * 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) client = kzalloc(sizeof(*client), GFP_KERNEL); if (!client) { i2c_put_adapter(adap); - ret = -ENOMEM; - goto out; + return -ENOMEM; } snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr); client->driver = &i2cdev_driver; @@ -479,9 +471,7 @@ static int i2cdev_open(struct inode *inode, struct file *file) client->adapter = adap; file->private_data = client; -out: - unlock_kernel(); - return ret; + return 0; } static int i2cdev_release(struct inode *inode, struct file *file) |