diff options
| author | Roland Dreier <rolandd@cisco.com> | 2005-10-28 18:50:51 -0400 |
|---|---|---|
| committer | Roland Dreier <rolandd@cisco.com> | 2005-10-28 18:50:51 -0400 |
| commit | a4da0628efd788eb199dd9df225e296035ec2539 (patch) | |
| tree | 1e611030c993e1480dc2f07f26976d2d33002b0d /drivers/i2c/i2c-dev.c | |
| parent | 70a30e16a8a9d22396a4d1e96af86e43594df584 (diff) | |
| parent | 20731945ae743034353a88c307920d1f16cf8ac8 (diff) | |
Merge master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'drivers/i2c/i2c-dev.c')
| -rw-r--r-- | drivers/i2c/i2c-dev.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index aa7a4fadef64..ea14c8f1c82b 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
| @@ -26,15 +26,11 @@ | |||
| 26 | 26 | ||
| 27 | /* The I2C_RDWR ioctl code is written by Kolja Waschk <waschk@telos.de> */ | 27 | /* The I2C_RDWR ioctl code is written by Kolja Waschk <waschk@telos.de> */ |
| 28 | 28 | ||
| 29 | /* The devfs code is contributed by Philipp Matthias Hahn | ||
| 30 | <pmhahn@titan.lahn.de> */ | ||
| 31 | |||
| 32 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
| 33 | #include <linux/module.h> | 30 | #include <linux/module.h> |
| 34 | #include <linux/fs.h> | 31 | #include <linux/fs.h> |
| 35 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
| 36 | #include <linux/smp_lock.h> | 33 | #include <linux/smp_lock.h> |
| 37 | #include <linux/devfs_fs_kernel.h> | ||
| 38 | #include <linux/init.h> | 34 | #include <linux/init.h> |
| 39 | #include <linux/i2c.h> | 35 | #include <linux/i2c.h> |
| 40 | #include <linux/i2c-dev.h> | 36 | #include <linux/i2c-dev.h> |
| @@ -80,10 +76,9 @@ static struct i2c_dev *get_free_i2c_dev(struct i2c_adapter *adap) | |||
| 80 | { | 76 | { |
| 81 | struct i2c_dev *i2c_dev; | 77 | struct i2c_dev *i2c_dev; |
| 82 | 78 | ||
| 83 | i2c_dev = kmalloc(sizeof(*i2c_dev), GFP_KERNEL); | 79 | i2c_dev = kzalloc(sizeof(*i2c_dev), GFP_KERNEL); |
| 84 | if (!i2c_dev) | 80 | if (!i2c_dev) |
| 85 | return ERR_PTR(-ENOMEM); | 81 | return ERR_PTR(-ENOMEM); |
| 86 | memset(i2c_dev, 0x00, sizeof(*i2c_dev)); | ||
| 87 | 82 | ||
| 88 | spin_lock(&i2c_dev_array_lock); | 83 | spin_lock(&i2c_dev_array_lock); |
| 89 | if (i2c_dev_array[adap->nr]) { | 84 | if (i2c_dev_array[adap->nr]) { |
| @@ -177,8 +172,8 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
| 177 | int i,datasize,res; | 172 | int i,datasize,res; |
| 178 | unsigned long funcs; | 173 | unsigned long funcs; |
| 179 | 174 | ||
| 180 | dev_dbg(&client->adapter->dev, "i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n", | 175 | dev_dbg(&client->adapter->dev, "ioctl, cmd=0x%02x, arg=0x%02lx\n", |
| 181 | iminor(inode),cmd, arg); | 176 | cmd, arg); |
| 182 | 177 | ||
| 183 | switch ( cmd ) { | 178 | switch ( cmd ) { |
| 184 | case I2C_SLAVE: | 179 | case I2C_SLAVE: |
| @@ -432,8 +427,6 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) | |||
| 432 | if (IS_ERR(i2c_dev)) | 427 | if (IS_ERR(i2c_dev)) |
| 433 | return PTR_ERR(i2c_dev); | 428 | return PTR_ERR(i2c_dev); |
| 434 | 429 | ||
| 435 | devfs_mk_cdev(MKDEV(I2C_MAJOR, i2c_dev->minor), | ||
| 436 | S_IFCHR|S_IRUSR|S_IWUSR, "i2c/%d", i2c_dev->minor); | ||
| 437 | pr_debug("i2c-dev: adapter [%s] registered as minor %d\n", | 430 | pr_debug("i2c-dev: adapter [%s] registered as minor %d\n", |
| 438 | adap->name, i2c_dev->minor); | 431 | adap->name, i2c_dev->minor); |
| 439 | 432 | ||
| @@ -466,7 +459,6 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap) | |||
| 466 | return -ENODEV; | 459 | return -ENODEV; |
| 467 | 460 | ||
| 468 | init_completion(&i2c_dev->released); | 461 | init_completion(&i2c_dev->released); |
| 469 | devfs_remove("i2c/%d", i2c_dev->minor); | ||
| 470 | return_i2c_dev(i2c_dev); | 462 | return_i2c_dev(i2c_dev); |
| 471 | class_device_unregister(&i2c_dev->class_dev); | 463 | class_device_unregister(&i2c_dev->class_dev); |
| 472 | wait_for_completion(&i2c_dev->released); | 464 | wait_for_completion(&i2c_dev->released); |
| @@ -522,8 +514,6 @@ static int __init i2c_dev_init(void) | |||
| 522 | if (res) | 514 | if (res) |
| 523 | goto out_unreg_class; | 515 | goto out_unreg_class; |
| 524 | 516 | ||
| 525 | devfs_mk_dir("i2c"); | ||
| 526 | |||
| 527 | return 0; | 517 | return 0; |
| 528 | 518 | ||
| 529 | out_unreg_class: | 519 | out_unreg_class: |
| @@ -539,7 +529,6 @@ static void __exit i2c_dev_exit(void) | |||
| 539 | { | 529 | { |
| 540 | i2c_del_driver(&i2cdev_driver); | 530 | i2c_del_driver(&i2cdev_driver); |
| 541 | class_unregister(&i2c_dev_class); | 531 | class_unregister(&i2c_dev_class); |
| 542 | devfs_remove("i2c"); | ||
| 543 | unregister_chrdev(I2C_MAJOR,"i2c"); | 532 | unregister_chrdev(I2C_MAJOR,"i2c"); |
| 544 | } | 533 | } |
| 545 | 534 | ||
