i2c-dev.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. /*
  2. i2c-dev.c - i2c-bus driver, char device interface
  3. Copyright (C) 1995-97 Simon G. Vogl
  4. Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>
  5. Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. /* Note that this is a complete rewrite of Simon Vogl's i2c-dev module.
  19. But I have used so much of his original code and ideas that it seems
  20. only fair to recognize him as co-author -- Frodo */
  21. /* The I2C_RDWR ioctl code is written by Kolja Waschk <waschk@telos.de> */
  22. #include <linux/kernel.h>
  23. #include <linux/module.h>
  24. #include <linux/fs.h>
  25. #include <linux/slab.h>
  26. #include <linux/init.h>
  27. #include <linux/list.h>
  28. #include <linux/i2c.h>
  29. #include <linux/i2c-dev.h>
  30. #include <asm/uaccess.h>
  31. static struct i2c_driver i2cdev_driver;
  32. /*
  33. * An i2c_dev represents an i2c_adapter ... an I2C or SMBus master, not a
  34. * slave (i2c_client) with which messages will be exchanged. It's coupled
  35. * with a character special file which is accessed by user mode drivers.
  36. *
  37. * The list of i2c_dev structures is parallel to the i2c_adapter lists
  38. * maintained by the driver model, and is updated using notifications
  39. * delivered to the i2cdev_driver.
  40. */
  41. struct i2c_dev {
  42. struct list_head list;
  43. struct i2c_adapter *adap;
  44. struct device *dev;
  45. };
  46. #define I2C_MINORS 256
  47. static LIST_HEAD(i2c_dev_list);
  48. static DEFINE_SPINLOCK(i2c_dev_list_lock);
  49. static struct i2c_dev *i2c_dev_get_by_minor(unsigned index)
  50. {
  51. struct i2c_dev *i2c_dev;
  52. spin_lock(&i2c_dev_list_lock);
  53. list_for_each_entry(i2c_dev, &i2c_dev_list, list) {
  54. if (i2c_dev->adap->nr == index)
  55. goto found;
  56. }
  57. i2c_dev = NULL;
  58. found:
  59. spin_unlock(&i2c_dev_list_lock);
  60. return i2c_dev;
  61. }
  62. static struct i2c_dev *get_free_i2c_dev(struct i2c_adapter *adap)
  63. {
  64. struct i2c_dev *i2c_dev;
  65. if (adap->nr >= I2C_MINORS) {
  66. printk(KERN_ERR "i2c-dev: Out of device minors (%d)\n",
  67. adap->nr);
  68. return ERR_PTR(-ENODEV);
  69. }
  70. i2c_dev = kzalloc(sizeof(*i2c_dev), GFP_KERNEL);
  71. if (!i2c_dev)
  72. return ERR_PTR(-ENOMEM);
  73. i2c_dev->adap = adap;
  74. spin_lock(&i2c_dev_list_lock);
  75. list_add_tail(&i2c_dev->list, &i2c_dev_list);
  76. spin_unlock(&i2c_dev_list_lock);
  77. return i2c_dev;
  78. }
  79. static void return_i2c_dev(struct i2c_dev *i2c_dev)
  80. {
  81. spin_lock(&i2c_dev_list_lock);
  82. list_del(&i2c_dev->list);
  83. spin_unlock(&i2c_dev_list_lock);
  84. kfree(i2c_dev);
  85. }
  86. static ssize_t show_adapter_name(struct device *dev,
  87. struct device_attribute *attr, char *buf)
  88. {
  89. struct i2c_dev *i2c_dev = i2c_dev_get_by_minor(MINOR(dev->devt));
  90. if (!i2c_dev)
  91. return -ENODEV;
  92. return sprintf(buf, "%s\n", i2c_dev->adap->name);
  93. }
  94. static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
  95. /* ------------------------------------------------------------------------- */
  96. /*
  97. * After opening an instance of this character special file, a file
  98. * descriptor starts out associated only with an i2c_adapter (and bus).
  99. *
  100. * Using the I2C_RDWR ioctl(), you can then *immediately* issue i2c_msg
  101. * traffic to any devices on the bus used by that adapter. That's because
  102. * the i2c_msg vectors embed all the addressing information they need, and
  103. * are submitted directly to an i2c_adapter. However, SMBus-only adapters
  104. * don't support that interface.
  105. *
  106. * To use read()/write() system calls on that file descriptor, or to use
  107. * SMBus interfaces (and work with SMBus-only hosts!), you must first issue
  108. * an I2C_SLAVE (or I2C_SLAVE_FORCE) ioctl. That configures an anonymous
  109. * (never registered) i2c_client so it holds the addressing information
  110. * needed by those system calls and by this SMBus interface.
  111. */
  112. static ssize_t i2cdev_read (struct file *file, char __user *buf, size_t count,
  113. loff_t *offset)
  114. {
  115. char *tmp;
  116. int ret;
  117. struct i2c_client *client = (struct i2c_client *)file->private_data;
  118. if (count > 8192)
  119. count = 8192;
  120. tmp = kmalloc(count,GFP_KERNEL);
  121. if (tmp==NULL)
  122. return -ENOMEM;
  123. pr_debug("i2c-dev: i2c-%d reading %zd bytes.\n",
  124. iminor(file->f_path.dentry->d_inode), count);
  125. ret = i2c_master_recv(client,tmp,count);
  126. if (ret >= 0)
  127. ret = copy_to_user(buf,tmp,count)?-EFAULT:ret;
  128. kfree(tmp);
  129. return ret;
  130. }
  131. static ssize_t i2cdev_write (struct file *file, const char __user *buf, size_t count,
  132. loff_t *offset)
  133. {
  134. int ret;
  135. char *tmp;
  136. struct i2c_client *client = (struct i2c_client *)file->private_data;
  137. if (count > 8192)
  138. count = 8192;
  139. tmp = kmalloc(count,GFP_KERNEL);
  140. if (tmp==NULL)
  141. return -ENOMEM;
  142. if (copy_from_user(tmp,buf,count)) {
  143. kfree(tmp);
  144. return -EFAULT;
  145. }
  146. pr_debug("i2c-dev: i2c-%d writing %zd bytes.\n",
  147. iminor(file->f_path.dentry->d_inode), count);
  148. ret = i2c_master_send(client,tmp,count);
  149. kfree(tmp);
  150. return ret;
  151. }
  152. /* This address checking function differs from the one in i2c-core
  153. in that it considers an address with a registered device, but no
  154. bounded driver, as NOT busy. */
  155. static int i2cdev_check_addr(struct i2c_adapter *adapter, unsigned int addr)
  156. {
  157. struct list_head *item;
  158. struct i2c_client *client;
  159. int res = 0;
  160. mutex_lock(&adapter->clist_lock);
  161. list_for_each(item, &adapter->clients) {
  162. client = list_entry(item, struct i2c_client, list);
  163. if (client->addr == addr) {
  164. if (client->driver)
  165. res = -EBUSY;
  166. break;
  167. }
  168. }
  169. mutex_unlock(&adapter->clist_lock);
  170. return res;
  171. }
  172. static int i2cdev_ioctl(struct inode *inode, struct file *file,
  173. unsigned int cmd, unsigned long arg)
  174. {
  175. struct i2c_client *client = (struct i2c_client *)file->private_data;
  176. struct i2c_rdwr_ioctl_data rdwr_arg;
  177. struct i2c_smbus_ioctl_data data_arg;
  178. union i2c_smbus_data temp;
  179. struct i2c_msg *rdwr_pa;
  180. u8 __user **data_ptrs;
  181. int i,datasize,res;
  182. unsigned long funcs;
  183. dev_dbg(&client->adapter->dev, "ioctl, cmd=0x%02x, arg=0x%02lx\n",
  184. cmd, arg);
  185. switch ( cmd ) {
  186. case I2C_SLAVE:
  187. case I2C_SLAVE_FORCE:
  188. /* NOTE: devices set up to work with "new style" drivers
  189. * can't use I2C_SLAVE, even when the device node is not
  190. * bound to a driver. Only I2C_SLAVE_FORCE will work.
  191. *
  192. * Setting the PEC flag here won't affect kernel drivers,
  193. * which will be using the i2c_client node registered with
  194. * the driver model core. Likewise, when that client has
  195. * the PEC flag already set, the i2c-dev driver won't see
  196. * (or use) this setting.
  197. */
  198. if ((arg > 0x3ff) ||
  199. (((client->flags & I2C_M_TEN) == 0) && arg > 0x7f))
  200. return -EINVAL;
  201. if (cmd == I2C_SLAVE && i2cdev_check_addr(client->adapter, arg))
  202. return -EBUSY;
  203. /* REVISIT: address could become busy later */
  204. client->addr = arg;
  205. return 0;
  206. case I2C_TENBIT:
  207. if (arg)
  208. client->flags |= I2C_M_TEN;
  209. else
  210. client->flags &= ~I2C_M_TEN;
  211. return 0;
  212. case I2C_PEC:
  213. if (arg)
  214. client->flags |= I2C_CLIENT_PEC;
  215. else
  216. client->flags &= ~I2C_CLIENT_PEC;
  217. return 0;
  218. case I2C_FUNCS:
  219. funcs = i2c_get_functionality(client->adapter);
  220. return put_user(funcs, (unsigned long __user *)arg);
  221. case I2C_RDWR:
  222. if (copy_from_user(&rdwr_arg,
  223. (struct i2c_rdwr_ioctl_data __user *)arg,
  224. sizeof(rdwr_arg)))
  225. return -EFAULT;
  226. /* Put an arbitrary limit on the number of messages that can
  227. * be sent at once */
  228. if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
  229. return -EINVAL;
  230. rdwr_pa = (struct i2c_msg *)
  231. kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg),
  232. GFP_KERNEL);
  233. if (rdwr_pa == NULL) return -ENOMEM;
  234. if (copy_from_user(rdwr_pa, rdwr_arg.msgs,
  235. rdwr_arg.nmsgs * sizeof(struct i2c_msg))) {
  236. kfree(rdwr_pa);
  237. return -EFAULT;
  238. }
  239. data_ptrs = kmalloc(rdwr_arg.nmsgs * sizeof(u8 __user *), GFP_KERNEL);
  240. if (data_ptrs == NULL) {
  241. kfree(rdwr_pa);
  242. return -ENOMEM;
  243. }
  244. res = 0;
  245. for( i=0; i<rdwr_arg.nmsgs; i++ ) {
  246. /* Limit the size of the message to a sane amount;
  247. * and don't let length change either. */
  248. if ((rdwr_pa[i].len > 8192) ||
  249. (rdwr_pa[i].flags & I2C_M_RECV_LEN)) {
  250. res = -EINVAL;
  251. break;
  252. }
  253. data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
  254. rdwr_pa[i].buf = kmalloc(rdwr_pa[i].len, GFP_KERNEL);
  255. if(rdwr_pa[i].buf == NULL) {
  256. res = -ENOMEM;
  257. break;
  258. }
  259. if(copy_from_user(rdwr_pa[i].buf,
  260. data_ptrs[i],
  261. rdwr_pa[i].len)) {
  262. ++i; /* Needs to be kfreed too */
  263. res = -EFAULT;
  264. break;
  265. }
  266. }
  267. if (res < 0) {
  268. int j;
  269. for (j = 0; j < i; ++j)
  270. kfree(rdwr_pa[j].buf);
  271. kfree(data_ptrs);
  272. kfree(rdwr_pa);
  273. return res;
  274. }
  275. res = i2c_transfer(client->adapter,
  276. rdwr_pa,
  277. rdwr_arg.nmsgs);
  278. while(i-- > 0) {
  279. if( res>=0 && (rdwr_pa[i].flags & I2C_M_RD)) {
  280. if(copy_to_user(
  281. data_ptrs[i],
  282. rdwr_pa[i].buf,
  283. rdwr_pa[i].len)) {
  284. res = -EFAULT;
  285. }
  286. }
  287. kfree(rdwr_pa[i].buf);
  288. }
  289. kfree(data_ptrs);
  290. kfree(rdwr_pa);
  291. return res;
  292. case I2C_SMBUS:
  293. if (copy_from_user(&data_arg,
  294. (struct i2c_smbus_ioctl_data __user *) arg,
  295. sizeof(struct i2c_smbus_ioctl_data)))
  296. return -EFAULT;
  297. if ((data_arg.size != I2C_SMBUS_BYTE) &&
  298. (data_arg.size != I2C_SMBUS_QUICK) &&
  299. (data_arg.size != I2C_SMBUS_BYTE_DATA) &&
  300. (data_arg.size != I2C_SMBUS_WORD_DATA) &&
  301. (data_arg.size != I2C_SMBUS_PROC_CALL) &&
  302. (data_arg.size != I2C_SMBUS_BLOCK_DATA) &&
  303. (data_arg.size != I2C_SMBUS_I2C_BLOCK_BROKEN) &&
  304. (data_arg.size != I2C_SMBUS_I2C_BLOCK_DATA) &&
  305. (data_arg.size != I2C_SMBUS_BLOCK_PROC_CALL)) {
  306. dev_dbg(&client->adapter->dev,
  307. "size out of range (%x) in ioctl I2C_SMBUS.\n",
  308. data_arg.size);
  309. return -EINVAL;
  310. }
  311. /* Note that I2C_SMBUS_READ and I2C_SMBUS_WRITE are 0 and 1,
  312. so the check is valid if size==I2C_SMBUS_QUICK too. */
  313. if ((data_arg.read_write != I2C_SMBUS_READ) &&
  314. (data_arg.read_write != I2C_SMBUS_WRITE)) {
  315. dev_dbg(&client->adapter->dev,
  316. "read_write out of range (%x) in ioctl I2C_SMBUS.\n",
  317. data_arg.read_write);
  318. return -EINVAL;
  319. }
  320. /* Note that command values are always valid! */
  321. if ((data_arg.size == I2C_SMBUS_QUICK) ||
  322. ((data_arg.size == I2C_SMBUS_BYTE) &&
  323. (data_arg.read_write == I2C_SMBUS_WRITE)))
  324. /* These are special: we do not use data */
  325. return i2c_smbus_xfer(client->adapter, client->addr,
  326. client->flags,
  327. data_arg.read_write,
  328. data_arg.command,
  329. data_arg.size, NULL);
  330. if (data_arg.data == NULL) {
  331. dev_dbg(&client->adapter->dev,
  332. "data is NULL pointer in ioctl I2C_SMBUS.\n");
  333. return -EINVAL;
  334. }
  335. if ((data_arg.size == I2C_SMBUS_BYTE_DATA) ||
  336. (data_arg.size == I2C_SMBUS_BYTE))
  337. datasize = sizeof(data_arg.data->byte);
  338. else if ((data_arg.size == I2C_SMBUS_WORD_DATA) ||
  339. (data_arg.size == I2C_SMBUS_PROC_CALL))
  340. datasize = sizeof(data_arg.data->word);
  341. else /* size == smbus block, i2c block, or block proc. call */
  342. datasize = sizeof(data_arg.data->block);
  343. if ((data_arg.size == I2C_SMBUS_PROC_CALL) ||
  344. (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) ||
  345. (data_arg.size == I2C_SMBUS_I2C_BLOCK_DATA) ||
  346. (data_arg.read_write == I2C_SMBUS_WRITE)) {
  347. if (copy_from_user(&temp, data_arg.data, datasize))
  348. return -EFAULT;
  349. }
  350. if (data_arg.size == I2C_SMBUS_I2C_BLOCK_BROKEN) {
  351. /* Convert old I2C block commands to the new
  352. convention. This preserves binary compatibility. */
  353. data_arg.size = I2C_SMBUS_I2C_BLOCK_DATA;
  354. if (data_arg.read_write == I2C_SMBUS_READ)
  355. temp.block[0] = I2C_SMBUS_BLOCK_MAX;
  356. }
  357. res = i2c_smbus_xfer(client->adapter,client->addr,client->flags,
  358. data_arg.read_write,
  359. data_arg.command,data_arg.size,&temp);
  360. if (! res && ((data_arg.size == I2C_SMBUS_PROC_CALL) ||
  361. (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) ||
  362. (data_arg.read_write == I2C_SMBUS_READ))) {
  363. if (copy_to_user(data_arg.data, &temp, datasize))
  364. return -EFAULT;
  365. }
  366. return res;
  367. case I2C_RETRIES:
  368. client->adapter->retries = arg;
  369. break;
  370. case I2C_TIMEOUT:
  371. client->adapter->timeout = arg;
  372. break;
  373. default:
  374. /* NOTE: returning a fault code here could cause trouble
  375. * in buggy userspace code. Some old kernel bugs returned
  376. * zero in this case, and userspace code might accidentally
  377. * have depended on that bug.
  378. */
  379. return -ENOTTY;
  380. }
  381. return 0;
  382. }
  383. static int i2cdev_open(struct inode *inode, struct file *file)
  384. {
  385. unsigned int minor = iminor(inode);
  386. struct i2c_client *client;
  387. struct i2c_adapter *adap;
  388. struct i2c_dev *i2c_dev;
  389. i2c_dev = i2c_dev_get_by_minor(minor);
  390. if (!i2c_dev)
  391. return -ENODEV;
  392. adap = i2c_get_adapter(i2c_dev->adap->nr);
  393. if (!adap)
  394. return -ENODEV;
  395. /* This creates an anonymous i2c_client, which may later be
  396. * pointed to some address using I2C_SLAVE or I2C_SLAVE_FORCE.
  397. *
  398. * This client is ** NEVER REGISTERED ** with the driver model
  399. * or I2C core code!! It just holds private copies of addressing
  400. * information and maybe a PEC flag.
  401. */
  402. client = kzalloc(sizeof(*client), GFP_KERNEL);
  403. if (!client) {
  404. i2c_put_adapter(adap);
  405. return -ENOMEM;
  406. }
  407. snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr);
  408. client->driver = &i2cdev_driver;
  409. client->adapter = adap;
  410. file->private_data = client;
  411. return 0;
  412. }
  413. static int i2cdev_release(struct inode *inode, struct file *file)
  414. {
  415. struct i2c_client *client = file->private_data;
  416. i2c_put_adapter(client->adapter);
  417. kfree(client);
  418. file->private_data = NULL;
  419. return 0;
  420. }
  421. static const struct file_operations i2cdev_fops = {
  422. .owner = THIS_MODULE,
  423. .llseek = no_llseek,
  424. .read = i2cdev_read,
  425. .write = i2cdev_write,
  426. .ioctl = i2cdev_ioctl,
  427. .open = i2cdev_open,
  428. .release = i2cdev_release,
  429. };
  430. /* ------------------------------------------------------------------------- */
  431. /*
  432. * The legacy "i2cdev_driver" is used primarily to get notifications when
  433. * I2C adapters are added or removed, so that each one gets an i2c_dev
  434. * and is thus made available to userspace driver code.
  435. */
  436. static struct class *i2c_dev_class;
  437. static int i2cdev_attach_adapter(struct i2c_adapter *adap)
  438. {
  439. struct i2c_dev *i2c_dev;
  440. int res;
  441. i2c_dev = get_free_i2c_dev(adap);
  442. if (IS_ERR(i2c_dev))
  443. return PTR_ERR(i2c_dev);
  444. /* register this i2c device with the driver core */
  445. i2c_dev->dev = device_create(i2c_dev_class, &adap->dev,
  446. MKDEV(I2C_MAJOR, adap->nr),
  447. "i2c-%d", adap->nr);
  448. if (IS_ERR(i2c_dev->dev)) {
  449. res = PTR_ERR(i2c_dev->dev);
  450. goto error;
  451. }
  452. res = device_create_file(i2c_dev->dev, &dev_attr_name);
  453. if (res)
  454. goto error_destroy;
  455. pr_debug("i2c-dev: adapter [%s] registered as minor %d\n",
  456. adap->name, adap->nr);
  457. return 0;
  458. error_destroy:
  459. device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
  460. error:
  461. return_i2c_dev(i2c_dev);
  462. return res;
  463. }
  464. static int i2cdev_detach_adapter(struct i2c_adapter *adap)
  465. {
  466. struct i2c_dev *i2c_dev;
  467. i2c_dev = i2c_dev_get_by_minor(adap->nr);
  468. if (!i2c_dev) /* attach_adapter must have failed */
  469. return 0;
  470. device_remove_file(i2c_dev->dev, &dev_attr_name);
  471. return_i2c_dev(i2c_dev);
  472. device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
  473. pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name);
  474. return 0;
  475. }
  476. static int i2cdev_detach_client(struct i2c_client *client)
  477. {
  478. return 0;
  479. }
  480. static struct i2c_driver i2cdev_driver = {
  481. .driver = {
  482. .name = "dev_driver",
  483. },
  484. .id = I2C_DRIVERID_I2CDEV,
  485. .attach_adapter = i2cdev_attach_adapter,
  486. .detach_adapter = i2cdev_detach_adapter,
  487. .detach_client = i2cdev_detach_client,
  488. };
  489. /* ------------------------------------------------------------------------- */
  490. /*
  491. * module load/unload record keeping
  492. */
  493. static int __init i2c_dev_init(void)
  494. {
  495. int res;
  496. printk(KERN_INFO "i2c /dev entries driver\n");
  497. res = register_chrdev(I2C_MAJOR, "i2c", &i2cdev_fops);
  498. if (res)
  499. goto out;
  500. i2c_dev_class = class_create(THIS_MODULE, "i2c-dev");
  501. if (IS_ERR(i2c_dev_class))
  502. goto out_unreg_chrdev;
  503. res = i2c_add_driver(&i2cdev_driver);
  504. if (res)
  505. goto out_unreg_class;
  506. return 0;
  507. out_unreg_class:
  508. class_destroy(i2c_dev_class);
  509. out_unreg_chrdev:
  510. unregister_chrdev(I2C_MAJOR, "i2c");
  511. out:
  512. printk(KERN_ERR "%s: Driver Initialisation failed\n", __FILE__);
  513. return res;
  514. }
  515. static void __exit i2c_dev_exit(void)
  516. {
  517. i2c_del_driver(&i2cdev_driver);
  518. class_destroy(i2c_dev_class);
  519. unregister_chrdev(I2C_MAJOR,"i2c");
  520. }
  521. MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and "
  522. "Simon G. Vogl <simon@tk.uni-linz.ac.at>");
  523. MODULE_DESCRIPTION("I2C /dev entries driver");
  524. MODULE_LICENSE("GPL");
  525. module_init(i2c_dev_init);
  526. module_exit(i2c_dev_exit);