diff options
Diffstat (limited to 'drivers/spi/spidev.c')
-rw-r--r-- | drivers/spi/spidev.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 5d23983f02fc..ea1bec3c9a13 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/errno.h> | 30 | #include <linux/errno.h> |
31 | #include <linux/mutex.h> | 31 | #include <linux/mutex.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/smp_lock.h> | ||
34 | 33 | ||
35 | #include <linux/spi/spi.h> | 34 | #include <linux/spi/spi.h> |
36 | #include <linux/spi/spidev.h> | 35 | #include <linux/spi/spidev.h> |
@@ -42,7 +41,7 @@ | |||
42 | * This supports acccess to SPI devices using normal userspace I/O calls. | 41 | * This supports acccess to SPI devices using normal userspace I/O calls. |
43 | * Note that while traditional UNIX/POSIX I/O semantics are half duplex, | 42 | * Note that while traditional UNIX/POSIX I/O semantics are half duplex, |
44 | * and often mask message boundaries, full SPI support requires full duplex | 43 | * and often mask message boundaries, full SPI support requires full duplex |
45 | * transfers. There are several kinds of of internal message boundaries to | 44 | * transfers. There are several kinds of internal message boundaries to |
46 | * handle chipselect management and other protocol options. | 45 | * handle chipselect management and other protocol options. |
47 | * | 46 | * |
48 | * SPI has a character major number assigned. We allocate minor numbers | 47 | * SPI has a character major number assigned. We allocate minor numbers |
@@ -54,7 +53,7 @@ | |||
54 | #define SPIDEV_MAJOR 153 /* assigned */ | 53 | #define SPIDEV_MAJOR 153 /* assigned */ |
55 | #define N_SPI_MINORS 32 /* ... up to 256 */ | 54 | #define N_SPI_MINORS 32 /* ... up to 256 */ |
56 | 55 | ||
57 | static unsigned long minors[N_SPI_MINORS / BITS_PER_LONG]; | 56 | static DECLARE_BITMAP(minors, N_SPI_MINORS); |
58 | 57 | ||
59 | 58 | ||
60 | /* Bit masks for spi_device.mode management. Note that incorrect | 59 | /* Bit masks for spi_device.mode management. Note that incorrect |
@@ -267,15 +266,15 @@ static int spidev_message(struct spidev_data *spidev, | |||
267 | k_tmp->delay_usecs = u_tmp->delay_usecs; | 266 | k_tmp->delay_usecs = u_tmp->delay_usecs; |
268 | k_tmp->speed_hz = u_tmp->speed_hz; | 267 | k_tmp->speed_hz = u_tmp->speed_hz; |
269 | #ifdef VERBOSE | 268 | #ifdef VERBOSE |
270 | dev_dbg(&spi->dev, | 269 | dev_dbg(&spidev->spi->dev, |
271 | " xfer len %zd %s%s%s%dbits %u usec %uHz\n", | 270 | " xfer len %zd %s%s%s%dbits %u usec %uHz\n", |
272 | u_tmp->len, | 271 | u_tmp->len, |
273 | u_tmp->rx_buf ? "rx " : "", | 272 | u_tmp->rx_buf ? "rx " : "", |
274 | u_tmp->tx_buf ? "tx " : "", | 273 | u_tmp->tx_buf ? "tx " : "", |
275 | u_tmp->cs_change ? "cs " : "", | 274 | u_tmp->cs_change ? "cs " : "", |
276 | u_tmp->bits_per_word ? : spi->bits_per_word, | 275 | u_tmp->bits_per_word ? : spidev->spi->bits_per_word, |
277 | u_tmp->delay_usecs, | 276 | u_tmp->delay_usecs, |
278 | u_tmp->speed_hz ? : spi->max_speed_hz); | 277 | u_tmp->speed_hz ? : spidev->spi->max_speed_hz); |
279 | #endif | 278 | #endif |
280 | spi_message_add_tail(k_tmp, &msg); | 279 | spi_message_add_tail(k_tmp, &msg); |
281 | } | 280 | } |
@@ -477,7 +476,6 @@ static int spidev_open(struct inode *inode, struct file *filp) | |||
477 | struct spidev_data *spidev; | 476 | struct spidev_data *spidev; |
478 | int status = -ENXIO; | 477 | int status = -ENXIO; |
479 | 478 | ||
480 | lock_kernel(); | ||
481 | mutex_lock(&device_list_lock); | 479 | mutex_lock(&device_list_lock); |
482 | 480 | ||
483 | list_for_each_entry(spidev, &device_list, device_entry) { | 481 | list_for_each_entry(spidev, &device_list, device_entry) { |
@@ -503,7 +501,6 @@ static int spidev_open(struct inode *inode, struct file *filp) | |||
503 | pr_debug("spidev: nothing for minor %d\n", iminor(inode)); | 501 | pr_debug("spidev: nothing for minor %d\n", iminor(inode)); |
504 | 502 | ||
505 | mutex_unlock(&device_list_lock); | 503 | mutex_unlock(&device_list_lock); |
506 | unlock_kernel(); | ||
507 | return status; | 504 | return status; |
508 | } | 505 | } |
509 | 506 | ||
@@ -561,7 +558,7 @@ static struct class *spidev_class; | |||
561 | 558 | ||
562 | /*-------------------------------------------------------------------------*/ | 559 | /*-------------------------------------------------------------------------*/ |
563 | 560 | ||
564 | static int spidev_probe(struct spi_device *spi) | 561 | static int __devinit spidev_probe(struct spi_device *spi) |
565 | { | 562 | { |
566 | struct spidev_data *spidev; | 563 | struct spidev_data *spidev; |
567 | int status; | 564 | int status; |
@@ -610,7 +607,7 @@ static int spidev_probe(struct spi_device *spi) | |||
610 | return status; | 607 | return status; |
611 | } | 608 | } |
612 | 609 | ||
613 | static int spidev_remove(struct spi_device *spi) | 610 | static int __devexit spidev_remove(struct spi_device *spi) |
614 | { | 611 | { |
615 | struct spidev_data *spidev = spi_get_drvdata(spi); | 612 | struct spidev_data *spidev = spi_get_drvdata(spi); |
616 | 613 | ||
@@ -632,7 +629,7 @@ static int spidev_remove(struct spi_device *spi) | |||
632 | return 0; | 629 | return 0; |
633 | } | 630 | } |
634 | 631 | ||
635 | static struct spi_driver spidev_spi = { | 632 | static struct spi_driver spidev_spi_driver = { |
636 | .driver = { | 633 | .driver = { |
637 | .name = "spidev", | 634 | .name = "spidev", |
638 | .owner = THIS_MODULE, | 635 | .owner = THIS_MODULE, |
@@ -664,14 +661,14 @@ static int __init spidev_init(void) | |||
664 | 661 | ||
665 | spidev_class = class_create(THIS_MODULE, "spidev"); | 662 | spidev_class = class_create(THIS_MODULE, "spidev"); |
666 | if (IS_ERR(spidev_class)) { | 663 | if (IS_ERR(spidev_class)) { |
667 | unregister_chrdev(SPIDEV_MAJOR, spidev_spi.driver.name); | 664 | unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name); |
668 | return PTR_ERR(spidev_class); | 665 | return PTR_ERR(spidev_class); |
669 | } | 666 | } |
670 | 667 | ||
671 | status = spi_register_driver(&spidev_spi); | 668 | status = spi_register_driver(&spidev_spi_driver); |
672 | if (status < 0) { | 669 | if (status < 0) { |
673 | class_destroy(spidev_class); | 670 | class_destroy(spidev_class); |
674 | unregister_chrdev(SPIDEV_MAJOR, spidev_spi.driver.name); | 671 | unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name); |
675 | } | 672 | } |
676 | return status; | 673 | return status; |
677 | } | 674 | } |
@@ -679,9 +676,9 @@ module_init(spidev_init); | |||
679 | 676 | ||
680 | static void __exit spidev_exit(void) | 677 | static void __exit spidev_exit(void) |
681 | { | 678 | { |
682 | spi_unregister_driver(&spidev_spi); | 679 | spi_unregister_driver(&spidev_spi_driver); |
683 | class_destroy(spidev_class); | 680 | class_destroy(spidev_class); |
684 | unregister_chrdev(SPIDEV_MAJOR, spidev_spi.driver.name); | 681 | unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name); |
685 | } | 682 | } |
686 | module_exit(spidev_exit); | 683 | module_exit(spidev_exit); |
687 | 684 | ||