aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/i2c-dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/i2c-dev.c')
-rw-r--r--drivers/i2c/i2c-dev.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 7e13d2df9af3..f4110aa49600 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -34,7 +34,6 @@
34#include <linux/list.h> 34#include <linux/list.h>
35#include <linux/i2c.h> 35#include <linux/i2c.h>
36#include <linux/i2c-dev.h> 36#include <linux/i2c-dev.h>
37#include <linux/smp_lock.h>
38#include <linux/jiffies.h> 37#include <linux/jiffies.h>
39#include <asm/uaccess.h> 38#include <asm/uaccess.h>
40 39
@@ -445,20 +444,14 @@ static int i2cdev_open(struct inode *inode, struct file *file)
445 struct i2c_client *client; 444 struct i2c_client *client;
446 struct i2c_adapter *adap; 445 struct i2c_adapter *adap;
447 struct i2c_dev *i2c_dev; 446 struct i2c_dev *i2c_dev;
448 int ret = 0;
449 447
450 lock_kernel();
451 i2c_dev = i2c_dev_get_by_minor(minor); 448 i2c_dev = i2c_dev_get_by_minor(minor);
452 if (!i2c_dev) { 449 if (!i2c_dev)
453 ret = -ENODEV; 450 return -ENODEV;
454 goto out;
455 }
456 451
457 adap = i2c_get_adapter(i2c_dev->adap->nr); 452 adap = i2c_get_adapter(i2c_dev->adap->nr);
458 if (!adap) { 453 if (!adap)
459 ret = -ENODEV; 454 return -ENODEV;
460 goto out;
461 }
462 455
463 /* This creates an anonymous i2c_client, which may later be 456 /* This creates an anonymous i2c_client, which may later be
464 * pointed to some address using I2C_SLAVE or I2C_SLAVE_FORCE. 457 * 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 client = kzalloc(sizeof(*client), GFP_KERNEL); 463 client = kzalloc(sizeof(*client), GFP_KERNEL);
471 if (!client) { 464 if (!client) {
472 i2c_put_adapter(adap); 465 i2c_put_adapter(adap);
473 ret = -ENOMEM; 466 return -ENOMEM;
474 goto out;
475 } 467 }
476 snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr); 468 snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr);
477 client->driver = &i2cdev_driver; 469 client->driver = &i2cdev_driver;
@@ -479,9 +471,7 @@ static int i2cdev_open(struct inode *inode, struct file *file)
479 client->adapter = adap; 471 client->adapter = adap;
480 file->private_data = client; 472 file->private_data = client;
481 473
482out: 474 return 0;
483 unlock_kernel();
484 return ret;
485} 475}
486 476
487static int i2cdev_release(struct inode *inode, struct file *file) 477static int i2cdev_release(struct inode *inode, struct file *file)