aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/i2c-dev.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-12-08 11:12:16 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-08 11:12:16 -0500
commit41440ffe21f29bdb985cab76b2d0b06d83e63b19 (patch)
tree1d7d1ff6f699ccbabb71c7bc4172f7d15bc4bc45 /drivers/i2c/i2c-dev.c
parentdad3de7d0090280f44ff27131ed2878f1ab6ddad (diff)
parent6471b68982d3bb1a593c3e183c804ecf830125d3 (diff)
Merge branch 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging
* 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging: i2c-stub: Documentation update i2c-stub: Allow user to disable some commands i2c-stub: Implement I2C block support i2c: Refactor for_each callbacks i2c-i801: Retry on lost arbitration i2c: Remove big kernel lock from i2cdev_open ics932s401: Clean up detect function i2c: Simplify i2c_detect_address i2c: Drop probe, ignore and force module parameters i2c: Add missing __devinit markers to old i2c adapter drivers i2c: Bus drivers don't have to support I2C_M_REV_DIR_ADDR i2c: Prevent priority inversion on top of bus lock i2c-voodoo3: Delete i2c-powermac: Drop temporary name buffer i2c-powermac: Include the i2c_adapter in struct pmac_i2c_bus i2c-powermac: Log errors i2c-powermac: Refactor i2c_powermac_smbus_xfer i2c-powermac: Reject unsupported I2C transactions i2c/chips: Move ds1682 to drivers/misc
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)