spidev.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. /*
  2. * spidev.c -- simple synchronous userspace interface to SPI devices
  3. *
  4. * Copyright (C) 2006 SWAPP
  5. * Andrea Paterniani <a.paterniani@swapp-eng.it>
  6. * Copyright (C) 2007 David Brownell (simplification, cleanup)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #include <linux/init.h>
  23. #include <linux/module.h>
  24. #include <linux/ioctl.h>
  25. #include <linux/fs.h>
  26. #include <linux/device.h>
  27. #include <linux/err.h>
  28. #include <linux/list.h>
  29. #include <linux/errno.h>
  30. #include <linux/mutex.h>
  31. #include <linux/slab.h>
  32. #include <linux/spi/spi.h>
  33. #include <linux/spi/spidev.h>
  34. #include <asm/uaccess.h>
  35. /*
  36. * This supports acccess to SPI devices using normal userspace I/O calls.
  37. * Note that while traditional UNIX/POSIX I/O semantics are half duplex,
  38. * and often mask message boundaries, full SPI support requires full duplex
  39. * transfers. There are several kinds of of internal message boundaries to
  40. * handle chipselect management and other protocol options.
  41. *
  42. * SPI has a character major number assigned. We allocate minor numbers
  43. * dynamically using a bitmask. You must use hotplug tools, such as udev
  44. * (or mdev with busybox) to create and destroy the /dev/spidevB.C device
  45. * nodes, since there is no fixed association of minor numbers with any
  46. * particular SPI bus or device.
  47. */
  48. #define SPIDEV_MAJOR 153 /* assigned */
  49. #define N_SPI_MINORS 32 /* ... up to 256 */
  50. static unsigned long minors[N_SPI_MINORS / BITS_PER_LONG];
  51. /* Bit masks for spi_device.mode management. Note that incorrect
  52. * settings for CS_HIGH and 3WIRE can cause *lots* of trouble for other
  53. * devices on a shared bus: CS_HIGH, because this device will be
  54. * active when it shouldn't be; 3WIRE, because when active it won't
  55. * behave as it should.
  56. *
  57. * REVISIT should changing those two modes be privileged?
  58. */
  59. #define SPI_MODE_MASK (SPI_CPHA | SPI_CPOL | SPI_CS_HIGH \
  60. | SPI_LSB_FIRST | SPI_3WIRE | SPI_LOOP)
  61. struct spidev_data {
  62. dev_t devt;
  63. spinlock_t spi_lock;
  64. struct spi_device *spi;
  65. struct list_head device_entry;
  66. /* buffer is NULL unless this device is open (users > 0) */
  67. struct mutex buf_lock;
  68. unsigned users;
  69. u8 *buffer;
  70. };
  71. static LIST_HEAD(device_list);
  72. static DEFINE_MUTEX(device_list_lock);
  73. static unsigned bufsiz = 4096;
  74. module_param(bufsiz, uint, S_IRUGO);
  75. MODULE_PARM_DESC(bufsiz, "data bytes in biggest supported SPI message");
  76. /*-------------------------------------------------------------------------*/
  77. /*
  78. * We can't use the standard synchronous wrappers for file I/O; we
  79. * need to protect against async removal of the underlying spi_device.
  80. */
  81. static void spidev_complete(void *arg)
  82. {
  83. complete(arg);
  84. }
  85. static ssize_t
  86. spidev_sync(struct spidev_data *spidev, struct spi_message *message)
  87. {
  88. DECLARE_COMPLETION_ONSTACK(done);
  89. int status;
  90. message->complete = spidev_complete;
  91. message->context = &done;
  92. spin_lock_irq(&spidev->spi_lock);
  93. if (spidev->spi == NULL)
  94. status = -ESHUTDOWN;
  95. else
  96. status = spi_async(spidev->spi, message);
  97. spin_unlock_irq(&spidev->spi_lock);
  98. if (status == 0) {
  99. wait_for_completion(&done);
  100. status = message->status;
  101. if (status == 0)
  102. status = message->actual_length;
  103. }
  104. return status;
  105. }
  106. static inline ssize_t
  107. spidev_sync_write(struct spidev_data *spidev, size_t len)
  108. {
  109. struct spi_transfer t = {
  110. .tx_buf = spidev->buffer,
  111. .len = len,
  112. };
  113. struct spi_message m;
  114. spi_message_init(&m);
  115. spi_message_add_tail(&t, &m);
  116. return spidev_sync(spidev, &m);
  117. }
  118. static inline ssize_t
  119. spidev_sync_read(struct spidev_data *spidev, size_t len)
  120. {
  121. struct spi_transfer t = {
  122. .rx_buf = spidev->buffer,
  123. .len = len,
  124. };
  125. struct spi_message m;
  126. spi_message_init(&m);
  127. spi_message_add_tail(&t, &m);
  128. return spidev_sync(spidev, &m);
  129. }
  130. /*-------------------------------------------------------------------------*/
  131. /* Read-only message with current device setup */
  132. static ssize_t
  133. spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
  134. {
  135. struct spidev_data *spidev;
  136. ssize_t status = 0;
  137. /* chipselect only toggles at start or end of operation */
  138. if (count > bufsiz)
  139. return -EMSGSIZE;
  140. spidev = filp->private_data;
  141. mutex_lock(&spidev->buf_lock);
  142. status = spidev_sync_read(spidev, count);
  143. if (status == 0) {
  144. unsigned long missing;
  145. missing = copy_to_user(buf, spidev->buffer, count);
  146. if (count && missing == count)
  147. status = -EFAULT;
  148. else
  149. status = count - missing;
  150. }
  151. mutex_unlock(&spidev->buf_lock);
  152. return status;
  153. }
  154. /* Write-only message with current device setup */
  155. static ssize_t
  156. spidev_write(struct file *filp, const char __user *buf,
  157. size_t count, loff_t *f_pos)
  158. {
  159. struct spidev_data *spidev;
  160. ssize_t status = 0;
  161. unsigned long missing;
  162. /* chipselect only toggles at start or end of operation */
  163. if (count > bufsiz)
  164. return -EMSGSIZE;
  165. spidev = filp->private_data;
  166. mutex_lock(&spidev->buf_lock);
  167. missing = copy_from_user(spidev->buffer, buf, count);
  168. if (missing == 0) {
  169. status = spidev_sync_write(spidev, count);
  170. if (status == 0)
  171. status = count;
  172. } else
  173. status = -EFAULT;
  174. mutex_unlock(&spidev->buf_lock);
  175. return status;
  176. }
  177. static int spidev_message(struct spidev_data *spidev,
  178. struct spi_ioc_transfer *u_xfers, unsigned n_xfers)
  179. {
  180. struct spi_message msg;
  181. struct spi_transfer *k_xfers;
  182. struct spi_transfer *k_tmp;
  183. struct spi_ioc_transfer *u_tmp;
  184. unsigned n, total;
  185. u8 *buf;
  186. int status = -EFAULT;
  187. spi_message_init(&msg);
  188. k_xfers = kcalloc(n_xfers, sizeof(*k_tmp), GFP_KERNEL);
  189. if (k_xfers == NULL)
  190. return -ENOMEM;
  191. /* Construct spi_message, copying any tx data to bounce buffer.
  192. * We walk the array of user-provided transfers, using each one
  193. * to initialize a kernel version of the same transfer.
  194. */
  195. mutex_lock(&spidev->buf_lock);
  196. buf = spidev->buffer;
  197. total = 0;
  198. for (n = n_xfers, k_tmp = k_xfers, u_tmp = u_xfers;
  199. n;
  200. n--, k_tmp++, u_tmp++) {
  201. k_tmp->len = u_tmp->len;
  202. total += k_tmp->len;
  203. if (total > bufsiz) {
  204. status = -EMSGSIZE;
  205. goto done;
  206. }
  207. if (u_tmp->rx_buf) {
  208. k_tmp->rx_buf = buf;
  209. if (!access_ok(VERIFY_WRITE, (u8 __user *)
  210. (uintptr_t) u_tmp->rx_buf,
  211. u_tmp->len))
  212. goto done;
  213. }
  214. if (u_tmp->tx_buf) {
  215. k_tmp->tx_buf = buf;
  216. if (copy_from_user(buf, (const u8 __user *)
  217. (uintptr_t) u_tmp->tx_buf,
  218. u_tmp->len))
  219. goto done;
  220. }
  221. buf += k_tmp->len;
  222. k_tmp->cs_change = !!u_tmp->cs_change;
  223. k_tmp->bits_per_word = u_tmp->bits_per_word;
  224. k_tmp->delay_usecs = u_tmp->delay_usecs;
  225. k_tmp->speed_hz = u_tmp->speed_hz;
  226. #ifdef VERBOSE
  227. dev_dbg(&spi->dev,
  228. " xfer len %zd %s%s%s%dbits %u usec %uHz\n",
  229. u_tmp->len,
  230. u_tmp->rx_buf ? "rx " : "",
  231. u_tmp->tx_buf ? "tx " : "",
  232. u_tmp->cs_change ? "cs " : "",
  233. u_tmp->bits_per_word ? : spi->bits_per_word,
  234. u_tmp->delay_usecs,
  235. u_tmp->speed_hz ? : spi->max_speed_hz);
  236. #endif
  237. spi_message_add_tail(k_tmp, &msg);
  238. }
  239. status = spidev_sync(spidev, &msg);
  240. if (status < 0)
  241. goto done;
  242. /* copy any rx data out of bounce buffer */
  243. buf = spidev->buffer;
  244. for (n = n_xfers, u_tmp = u_xfers; n; n--, u_tmp++) {
  245. if (u_tmp->rx_buf) {
  246. if (__copy_to_user((u8 __user *)
  247. (uintptr_t) u_tmp->rx_buf, buf,
  248. u_tmp->len)) {
  249. status = -EFAULT;
  250. goto done;
  251. }
  252. }
  253. buf += u_tmp->len;
  254. }
  255. status = total;
  256. done:
  257. mutex_unlock(&spidev->buf_lock);
  258. kfree(k_xfers);
  259. return status;
  260. }
  261. static int
  262. spidev_ioctl(struct inode *inode, struct file *filp,
  263. unsigned int cmd, unsigned long arg)
  264. {
  265. int err = 0;
  266. int retval = 0;
  267. struct spidev_data *spidev;
  268. struct spi_device *spi;
  269. u32 tmp;
  270. unsigned n_ioc;
  271. struct spi_ioc_transfer *ioc;
  272. /* Check type and command number */
  273. if (_IOC_TYPE(cmd) != SPI_IOC_MAGIC)
  274. return -ENOTTY;
  275. /* Check access direction once here; don't repeat below.
  276. * IOC_DIR is from the user perspective, while access_ok is
  277. * from the kernel perspective; so they look reversed.
  278. */
  279. if (_IOC_DIR(cmd) & _IOC_READ)
  280. err = !access_ok(VERIFY_WRITE,
  281. (void __user *)arg, _IOC_SIZE(cmd));
  282. if (err == 0 && _IOC_DIR(cmd) & _IOC_WRITE)
  283. err = !access_ok(VERIFY_READ,
  284. (void __user *)arg, _IOC_SIZE(cmd));
  285. if (err)
  286. return -EFAULT;
  287. /* guard against device removal before, or while,
  288. * we issue this ioctl.
  289. */
  290. spidev = filp->private_data;
  291. spin_lock_irq(&spidev->spi_lock);
  292. spi = spi_dev_get(spidev->spi);
  293. spin_unlock_irq(&spidev->spi_lock);
  294. if (spi == NULL)
  295. return -ESHUTDOWN;
  296. switch (cmd) {
  297. /* read requests */
  298. case SPI_IOC_RD_MODE:
  299. retval = __put_user(spi->mode & SPI_MODE_MASK,
  300. (__u8 __user *)arg);
  301. break;
  302. case SPI_IOC_RD_LSB_FIRST:
  303. retval = __put_user((spi->mode & SPI_LSB_FIRST) ? 1 : 0,
  304. (__u8 __user *)arg);
  305. break;
  306. case SPI_IOC_RD_BITS_PER_WORD:
  307. retval = __put_user(spi->bits_per_word, (__u8 __user *)arg);
  308. break;
  309. case SPI_IOC_RD_MAX_SPEED_HZ:
  310. retval = __put_user(spi->max_speed_hz, (__u32 __user *)arg);
  311. break;
  312. /* write requests */
  313. case SPI_IOC_WR_MODE:
  314. retval = __get_user(tmp, (u8 __user *)arg);
  315. if (retval == 0) {
  316. u8 save = spi->mode;
  317. if (tmp & ~SPI_MODE_MASK) {
  318. retval = -EINVAL;
  319. break;
  320. }
  321. tmp |= spi->mode & ~SPI_MODE_MASK;
  322. spi->mode = (u8)tmp;
  323. retval = spi_setup(spi);
  324. if (retval < 0)
  325. spi->mode = save;
  326. else
  327. dev_dbg(&spi->dev, "spi mode %02x\n", tmp);
  328. }
  329. break;
  330. case SPI_IOC_WR_LSB_FIRST:
  331. retval = __get_user(tmp, (__u8 __user *)arg);
  332. if (retval == 0) {
  333. u8 save = spi->mode;
  334. if (tmp)
  335. spi->mode |= SPI_LSB_FIRST;
  336. else
  337. spi->mode &= ~SPI_LSB_FIRST;
  338. retval = spi_setup(spi);
  339. if (retval < 0)
  340. spi->mode = save;
  341. else
  342. dev_dbg(&spi->dev, "%csb first\n",
  343. tmp ? 'l' : 'm');
  344. }
  345. break;
  346. case SPI_IOC_WR_BITS_PER_WORD:
  347. retval = __get_user(tmp, (__u8 __user *)arg);
  348. if (retval == 0) {
  349. u8 save = spi->bits_per_word;
  350. spi->bits_per_word = tmp;
  351. retval = spi_setup(spi);
  352. if (retval < 0)
  353. spi->bits_per_word = save;
  354. else
  355. dev_dbg(&spi->dev, "%d bits per word\n", tmp);
  356. }
  357. break;
  358. case SPI_IOC_WR_MAX_SPEED_HZ:
  359. retval = __get_user(tmp, (__u32 __user *)arg);
  360. if (retval == 0) {
  361. u32 save = spi->max_speed_hz;
  362. spi->max_speed_hz = tmp;
  363. retval = spi_setup(spi);
  364. if (retval < 0)
  365. spi->max_speed_hz = save;
  366. else
  367. dev_dbg(&spi->dev, "%d Hz (max)\n", tmp);
  368. }
  369. break;
  370. default:
  371. /* segmented and/or full-duplex I/O request */
  372. if (_IOC_NR(cmd) != _IOC_NR(SPI_IOC_MESSAGE(0))
  373. || _IOC_DIR(cmd) != _IOC_WRITE) {
  374. retval = -ENOTTY;
  375. break;
  376. }
  377. tmp = _IOC_SIZE(cmd);
  378. if ((tmp % sizeof(struct spi_ioc_transfer)) != 0) {
  379. retval = -EINVAL;
  380. break;
  381. }
  382. n_ioc = tmp / sizeof(struct spi_ioc_transfer);
  383. if (n_ioc == 0)
  384. break;
  385. /* copy into scratch area */
  386. ioc = kmalloc(tmp, GFP_KERNEL);
  387. if (!ioc) {
  388. retval = -ENOMEM;
  389. break;
  390. }
  391. if (__copy_from_user(ioc, (void __user *)arg, tmp)) {
  392. kfree(ioc);
  393. retval = -EFAULT;
  394. break;
  395. }
  396. /* translate to spi_message, execute */
  397. retval = spidev_message(spidev, ioc, n_ioc);
  398. kfree(ioc);
  399. break;
  400. }
  401. spi_dev_put(spi);
  402. return retval;
  403. }
  404. static int spidev_open(struct inode *inode, struct file *filp)
  405. {
  406. struct spidev_data *spidev;
  407. int status = -ENXIO;
  408. mutex_lock(&device_list_lock);
  409. list_for_each_entry(spidev, &device_list, device_entry) {
  410. if (spidev->devt == inode->i_rdev) {
  411. status = 0;
  412. break;
  413. }
  414. }
  415. if (status == 0) {
  416. if (!spidev->buffer) {
  417. spidev->buffer = kmalloc(bufsiz, GFP_KERNEL);
  418. if (!spidev->buffer) {
  419. dev_dbg(&spidev->spi->dev, "open/ENOMEM\n");
  420. status = -ENOMEM;
  421. }
  422. }
  423. if (status == 0) {
  424. spidev->users++;
  425. filp->private_data = spidev;
  426. nonseekable_open(inode, filp);
  427. }
  428. } else
  429. pr_debug("spidev: nothing for minor %d\n", iminor(inode));
  430. mutex_unlock(&device_list_lock);
  431. return status;
  432. }
  433. static int spidev_release(struct inode *inode, struct file *filp)
  434. {
  435. struct spidev_data *spidev;
  436. int status = 0;
  437. mutex_lock(&device_list_lock);
  438. spidev = filp->private_data;
  439. filp->private_data = NULL;
  440. /* last close? */
  441. spidev->users--;
  442. if (!spidev->users) {
  443. int dofree;
  444. kfree(spidev->buffer);
  445. spidev->buffer = NULL;
  446. /* ... after we unbound from the underlying device? */
  447. spin_lock_irq(&spidev->spi_lock);
  448. dofree = (spidev->spi == NULL);
  449. spin_unlock_irq(&spidev->spi_lock);
  450. if (dofree)
  451. kfree(spidev);
  452. }
  453. mutex_unlock(&device_list_lock);
  454. return status;
  455. }
  456. static struct file_operations spidev_fops = {
  457. .owner = THIS_MODULE,
  458. /* REVISIT switch to aio primitives, so that userspace
  459. * gets more complete API coverage. It'll simplify things
  460. * too, except for the locking.
  461. */
  462. .write = spidev_write,
  463. .read = spidev_read,
  464. .ioctl = spidev_ioctl,
  465. .open = spidev_open,
  466. .release = spidev_release,
  467. };
  468. /*-------------------------------------------------------------------------*/
  469. /* The main reason to have this class is to make mdev/udev create the
  470. * /dev/spidevB.C character device nodes exposing our userspace API.
  471. * It also simplifies memory management.
  472. */
  473. static struct class *spidev_class;
  474. /*-------------------------------------------------------------------------*/
  475. static int spidev_probe(struct spi_device *spi)
  476. {
  477. struct spidev_data *spidev;
  478. int status;
  479. unsigned long minor;
  480. /* Allocate driver data */
  481. spidev = kzalloc(sizeof(*spidev), GFP_KERNEL);
  482. if (!spidev)
  483. return -ENOMEM;
  484. /* Initialize the driver data */
  485. spidev->spi = spi;
  486. spin_lock_init(&spidev->spi_lock);
  487. mutex_init(&spidev->buf_lock);
  488. INIT_LIST_HEAD(&spidev->device_entry);
  489. /* If we can allocate a minor number, hook up this device.
  490. * Reusing minors is fine so long as udev or mdev is working.
  491. */
  492. mutex_lock(&device_list_lock);
  493. minor = find_first_zero_bit(minors, N_SPI_MINORS);
  494. if (minor < N_SPI_MINORS) {
  495. struct device *dev;
  496. spidev->devt = MKDEV(SPIDEV_MAJOR, minor);
  497. dev = device_create(spidev_class, &spi->dev, spidev->devt,
  498. "spidev%d.%d",
  499. spi->master->bus_num, spi->chip_select);
  500. status = IS_ERR(dev) ? PTR_ERR(dev) : 0;
  501. } else {
  502. dev_dbg(&spi->dev, "no minor number available!\n");
  503. status = -ENODEV;
  504. }
  505. if (status == 0) {
  506. set_bit(minor, minors);
  507. spi_set_drvdata(spi, spidev);
  508. list_add(&spidev->device_entry, &device_list);
  509. }
  510. mutex_unlock(&device_list_lock);
  511. if (status != 0)
  512. kfree(spidev);
  513. return status;
  514. }
  515. static int spidev_remove(struct spi_device *spi)
  516. {
  517. struct spidev_data *spidev = spi_get_drvdata(spi);
  518. /* make sure ops on existing fds can abort cleanly */
  519. spin_lock_irq(&spidev->spi_lock);
  520. spidev->spi = NULL;
  521. spi_set_drvdata(spi, NULL);
  522. spin_unlock_irq(&spidev->spi_lock);
  523. /* prevent new opens */
  524. mutex_lock(&device_list_lock);
  525. list_del(&spidev->device_entry);
  526. device_destroy(spidev_class, spidev->devt);
  527. clear_bit(MINOR(spidev->devt), minors);
  528. if (spidev->users == 0)
  529. kfree(spidev);
  530. mutex_unlock(&device_list_lock);
  531. return 0;
  532. }
  533. static struct spi_driver spidev_spi = {
  534. .driver = {
  535. .name = "spidev",
  536. .owner = THIS_MODULE,
  537. },
  538. .probe = spidev_probe,
  539. .remove = __devexit_p(spidev_remove),
  540. /* NOTE: suspend/resume methods are not necessary here.
  541. * We don't do anything except pass the requests to/from
  542. * the underlying controller. The refrigerator handles
  543. * most issues; the controller driver handles the rest.
  544. */
  545. };
  546. /*-------------------------------------------------------------------------*/
  547. static int __init spidev_init(void)
  548. {
  549. int status;
  550. /* Claim our 256 reserved device numbers. Then register a class
  551. * that will key udev/mdev to add/remove /dev nodes. Last, register
  552. * the driver which manages those device numbers.
  553. */
  554. BUILD_BUG_ON(N_SPI_MINORS > 256);
  555. status = register_chrdev(SPIDEV_MAJOR, "spi", &spidev_fops);
  556. if (status < 0)
  557. return status;
  558. spidev_class = class_create(THIS_MODULE, "spidev");
  559. if (IS_ERR(spidev_class)) {
  560. unregister_chrdev(SPIDEV_MAJOR, spidev_spi.driver.name);
  561. return PTR_ERR(spidev_class);
  562. }
  563. status = spi_register_driver(&spidev_spi);
  564. if (status < 0) {
  565. class_destroy(spidev_class);
  566. unregister_chrdev(SPIDEV_MAJOR, spidev_spi.driver.name);
  567. }
  568. return status;
  569. }
  570. module_init(spidev_init);
  571. static void __exit spidev_exit(void)
  572. {
  573. spi_unregister_driver(&spidev_spi);
  574. class_destroy(spidev_class);
  575. unregister_chrdev(SPIDEV_MAJOR, spidev_spi.driver.name);
  576. }
  577. module_exit(spidev_exit);
  578. MODULE_AUTHOR("Andrea Paterniani, <a.paterniani@swapp-eng.it>");
  579. MODULE_DESCRIPTION("User mode SPI device interface");
  580. MODULE_LICENSE("GPL");