Changeset 3496 for i2c/trunk/kernel/i2c-dev.c
- Timestamp:
- 08/31/00 01:15:32 (13 years ago)
- Files:
-
- 1 modified
-
i2c/trunk/kernel/i2c-dev.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
i2c/trunk/kernel/i2c-dev.c
r3491 r3496 25 25 26 26 /* The I2C_RDWR ioctl code is written by Kolja Waschk <waschk@telos.de> */ 27 28 /* The devfs code is contributed by Philipp Matthias Hahn 29 <pmhahn@titan.lahn.de> */ 27 30 28 31 /* $Id$ */ … … 36 39 #include <linux/smp_lock.h> 37 40 #endif /* LINUX_KERNEL_VERSION >= KERNEL_VERSION(2,4,0) */ 41 #ifdef CONFIG_DEVFS_FS 42 #include <linux/devfs_fs_kernel.h> 43 #endif 44 38 45 39 46 /* If you want debugging uncomment: */ … … 93 100 #define I2CDEV_ADAPS_MAX I2C_ADAP_MAX 94 101 static struct i2c_adapter *i2cdev_adaps[I2CDEV_ADAPS_MAX]; 102 #ifdef CONFIG_DEVFS_FS 103 static devfs_handle_t devfs_i2c[I2CDEV_ADAPS_MAX]; 104 static devfs_handle_t devfs_handle = NULL; 105 #endif 95 106 96 107 static struct i2c_driver i2cdev_driver = { 97 /* name */"i2c-dev dummy driver",98 /* id */I2C_DRIVERID_I2CDEV,99 /* flags */I2C_DF_DUMMY,100 /* attach_adapter */i2cdev_attach_adapter,101 /* detach_client */i2cdev_detach_client,102 /* command */i2cdev_command,103 /* inc_use */NULL,104 /* dec_use */ NULL,108 name: "i2c-dev dummy driver", 109 id: I2C_DRIVERID_I2CDEV, 110 flags: I2C_DF_DUMMY, 111 attach_adapter: i2cdev_attach_adapter, 112 detach_client: i2cdev_detach_client, 113 command: i2cdev_command, 114 /* inc_use: NULL, 115 dec_use: NULL, */ 105 116 }; 106 117 107 118 static struct i2c_client i2cdev_client_template = { 108 /* name */"I2C /dev entry",109 /* id */1,110 /* flags */0,111 /* addr */-1,112 /* adapter */ NULL, 113 /* driver */&i2cdev_driver,114 /* data */ NULL 119 name: "I2C /dev entry", 120 id: 1, 121 flags: 0, 122 addr: -1, 123 /* adapter: NULL, */ 124 driver: &i2cdev_driver, 125 /* data: NULL */ 115 126 }; 116 127 … … 123 134 #ifdef DEBUG 124 135 struct inode *inode = file->f_dentry->d_inode; 125 printk("i2c-dev ,o: i2c-%d lseek to %ld bytes relative to %d.\n",136 printk("i2c-dev.o: i2c-%d lseek to %ld bytes relative to %d.\n", 126 137 MINOR(inode->i_rdev),(long) offset,origin); 127 138 #endif /* DEBUG */ … … 147 158 148 159 #ifdef DEBUG 149 printk("i2c-dev ,o: i2c-%d reading %d bytes.\n",MINOR(inode->i_rdev),160 printk("i2c-dev.o: i2c-%d reading %d bytes.\n",MINOR(inode->i_rdev), 150 161 count); 151 162 #endif … … 179 190 180 191 #ifdef DEBUG 181 printk("i2c-dev ,o: i2c-%d writing %d bytes.\n",MINOR(inode->i_rdev),192 printk("i2c-dev.o: i2c-%d writing %d bytes.\n",MINOR(inode->i_rdev), 182 193 count); 183 194 #endif … … 416 427 { 417 428 int i; 429 char name[8]; 418 430 419 431 if ((i = i2c_adapter_id(adap)) < 0) { … … 426 438 } 427 439 440 sprintf (name, "%d", i); 428 441 if (! i2cdev_adaps[i]) { 429 442 i2cdev_adaps[i] = adap; 443 #ifdef CONFIG_DEVFS_FS 444 devfs_i2c[i] = devfs_register (devfs_handle, name, 445 DEVFS_FL_DEFAULT, I2C_MAJOR, i, 446 S_IFCHR | S_IRUSR | S_IWUSR, 447 &i2cdev_fops, NULL); 448 #endif 430 449 printk("i2c-dev.o: Registered '%s' as minor %d\n",adap->name,i); 431 450 } else { 432 451 /* This is actually a detach_adapter call! */ 452 #ifdef CONFIG_DEVFS_FS 453 devfs_unregister(devfs_i2c[i]); 454 #endif 433 455 i2cdev_adaps[i] = NULL; 434 456 #ifdef DEBUG … … 458 480 459 481 i2cdev_initialized = 0; 482 #ifdef CONFIG_DEVFS_FS 483 if (devfs_register_chrdev(I2C_MAJOR, "i2c", &i2cdev_fops)) { 484 #else 460 485 if (register_chrdev(I2C_MAJOR,"i2c",&i2cdev_fops)) { 486 #endif 461 487 printk("i2c-dev.o: unable to get major %d for i2c bus\n", 462 488 I2C_MAJOR); 463 489 return -EIO; 464 490 } 491 #ifdef CONFIG_DEVFS_FS 492 devfs_handle = devfs_mk_dir(NULL, "i2c", NULL); 493 #endif 465 494 i2cdev_initialized ++; 466 495 … … 488 517 489 518 if (i2cdev_initialized >= 1) { 519 #ifdef CONFIG_DEVFS_FS 520 devfs_unregister(devfs_handle); 521 if ((res = devfs_unregister_chrdev(I2C_MAJOR, "i2c"))) { 522 #else 490 523 if ((res = unregister_chrdev(I2C_MAJOR,"i2c"))) { 524 #endif 491 525 printk("i2c-dev.o: unable to release major %d for i2c bus\n", 492 526 I2C_MAJOR);
