aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/sbus/char/flash.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/sbus/char/flash.c')
-rw-r--r--drivers/sbus/char/flash.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/sbus/char/flash.c b/drivers/sbus/char/flash.c
index 368d66294d83..ed9494e18859 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
25static DEFINE_MUTEX(flash_mutex);
25static DEFINE_SPINLOCK(flash_lock); 26static DEFINE_SPINLOCK(flash_lock);
26static struct { 27static 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)
80static long long 81static long long
81flash_llseek(struct file *file, long long offset, int origin) 82flash_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,
125static int 126static int
126flash_open(struct inode *inode, struct file *file) 127flash_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