diff options
Diffstat (limited to 'drivers/sbus/char/flash.c')
| -rw-r--r-- | drivers/sbus/char/flash.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/sbus/char/flash.c b/drivers/sbus/char/flash.c index 368d66294d83..8bb31c584b64 100644 --- a/drivers/sbus/char/flash.c +++ b/drivers/sbus/char/flash.c | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | #include <linux/fcntl.h> | 10 | #include <linux/fcntl.h> |
| 11 | #include <linux/poll.h> | 11 | #include <linux/poll.h> |
| 12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
| 13 | #include <linux/smp_lock.h> | 13 | #include <linux/mutex.h> |
| 14 | #include <linux/spinlock.h> | 14 | #include <linux/spinlock.h> |
| 15 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
| 16 | #include <linux/of.h> | 16 | #include <linux/of.h> |
| @@ -22,6 +22,7 @@ | |||
| 22 | #include <asm/io.h> | 22 | #include <asm/io.h> |
| 23 | #include <asm/upa.h> | 23 | #include <asm/upa.h> |
| 24 | 24 | ||
| 25 | static DEFINE_MUTEX(flash_mutex); | ||
| 25 | static DEFINE_SPINLOCK(flash_lock); | 26 | static DEFINE_SPINLOCK(flash_lock); |
| 26 | static struct { | 27 | static struct { |
| 27 | unsigned long read_base; /* Physical read address */ | 28 | unsigned long read_base; /* Physical read address */ |
| @@ -80,7 +81,7 @@ flash_mmap(struct file *file, struct vm_area_struct *vma) | |||
| 80 | static long long | 81 | static long long |
| 81 | flash_llseek(struct file *file, long long offset, int origin) | 82 | flash_llseek(struct file *file, long long offset, int origin) |
| 82 | { | 83 | { |
| 83 | lock_kernel(); | 84 | mutex_lock(&flash_mutex); |
| 84 | switch (origin) { | 85 | switch (origin) { |
| 85 | case 0: | 86 | case 0: |
| 86 | file->f_pos = offset; | 87 | file->f_pos = offset; |
| @@ -94,10 +95,10 @@ flash_llseek(struct file *file, long long offset, int origin) | |||
| 94 | file->f_pos = flash.read_size; | 95 | file->f_pos = flash.read_size; |
| 95 | break; | 96 | break; |
| 96 | default: | 97 | default: |
| 97 | unlock_kernel(); | 98 | mutex_unlock(&flash_mutex); |
| 98 | return -EINVAL; | 99 | return -EINVAL; |
| 99 | } | 100 | } |
| 100 | unlock_kernel(); | 101 | mutex_unlock(&flash_mutex); |
| 101 | return file->f_pos; | 102 | return file->f_pos; |
| 102 | } | 103 | } |
| 103 | 104 | ||
| @@ -125,13 +126,13 @@ flash_read(struct file * file, char __user * buf, | |||
| 125 | static int | 126 | static int |
| 126 | flash_open(struct inode *inode, struct file *file) | 127 | flash_open(struct inode *inode, struct file *file) |
| 127 | { | 128 | { |
| 128 | lock_kernel(); | 129 | mutex_lock(&flash_mutex); |
| 129 | if (test_and_set_bit(0, (void *)&flash.busy) != 0) { | 130 | if (test_and_set_bit(0, (void *)&flash.busy) != 0) { |
| 130 | unlock_kernel(); | 131 | mutex_unlock(&flash_mutex); |
| 131 | return -EBUSY; | 132 | return -EBUSY; |
| 132 | } | 133 | } |
| 133 | 134 | ||
| 134 | unlock_kernel(); | 135 | mutex_unlock(&flash_mutex); |
| 135 | return 0; | 136 | return 0; |
| 136 | } | 137 | } |
| 137 | 138 | ||
| @@ -218,12 +219,12 @@ static struct of_platform_driver flash_driver = { | |||
| 218 | 219 | ||
| 219 | static int __init flash_init(void) | 220 | static int __init flash_init(void) |
| 220 | { | 221 | { |
| 221 | return of_register_driver(&flash_driver, &of_bus_type); | 222 | return of_register_platform_driver(&flash_driver); |
| 222 | } | 223 | } |
| 223 | 224 | ||
| 224 | static void __exit flash_cleanup(void) | 225 | static void __exit flash_cleanup(void) |
| 225 | { | 226 | { |
| 226 | of_unregister_driver(&flash_driver); | 227 | of_unregister_platform_driver(&flash_driver); |
| 227 | } | 228 | } |
| 228 | 229 | ||
| 229 | module_init(flash_init); | 230 | module_init(flash_init); |
