aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firmware/dcdbas.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firmware/dcdbas.c')
-rw-r--r--drivers/firmware/dcdbas.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index 3a4e5c5b4e1f..d6543fc4a923 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -33,6 +33,7 @@
33#include <linux/spinlock.h> 33#include <linux/spinlock.h>
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/types.h> 35#include <linux/types.h>
36#include <linux/mutex.h>
36#include <asm/io.h> 37#include <asm/io.h>
37#include <asm/semaphore.h> 38#include <asm/semaphore.h>
38 39
@@ -48,7 +49,7 @@ static u8 *smi_data_buf;
48static dma_addr_t smi_data_buf_handle; 49static dma_addr_t smi_data_buf_handle;
49static unsigned long smi_data_buf_size; 50static unsigned long smi_data_buf_size;
50static u32 smi_data_buf_phys_addr; 51static u32 smi_data_buf_phys_addr;
51static DECLARE_MUTEX(smi_data_lock); 52static DEFINE_MUTEX(smi_data_lock);
52 53
53static unsigned int host_control_action; 54static unsigned int host_control_action;
54static unsigned int host_control_smi_type; 55static unsigned int host_control_smi_type;
@@ -139,9 +140,9 @@ static ssize_t smi_data_buf_size_store(struct device *dev,
139 buf_size = simple_strtoul(buf, NULL, 10); 140 buf_size = simple_strtoul(buf, NULL, 10);
140 141
141 /* make sure SMI data buffer is at least buf_size */ 142 /* make sure SMI data buffer is at least buf_size */
142 down(&smi_data_lock); 143 mutex_lock(&smi_data_lock);
143 ret = smi_data_buf_realloc(buf_size); 144 ret = smi_data_buf_realloc(buf_size);
144 up(&smi_data_lock); 145 mutex_unlock(&smi_data_lock);
145 if (ret) 146 if (ret)
146 return ret; 147 return ret;
147 148
@@ -154,7 +155,7 @@ static ssize_t smi_data_read(struct kobject *kobj, char *buf, loff_t pos,
154 size_t max_read; 155 size_t max_read;
155 ssize_t ret; 156 ssize_t ret;
156 157
157 down(&smi_data_lock); 158 mutex_lock(&smi_data_lock);
158 159
159 if (pos >= smi_data_buf_size) { 160 if (pos >= smi_data_buf_size) {
160 ret = 0; 161 ret = 0;
@@ -165,7 +166,7 @@ static ssize_t smi_data_read(struct kobject *kobj, char *buf, loff_t pos,
165 ret = min(max_read, count); 166 ret = min(max_read, count);
166 memcpy(buf, smi_data_buf + pos, ret); 167 memcpy(buf, smi_data_buf + pos, ret);
167out: 168out:
168 up(&smi_data_lock); 169 mutex_unlock(&smi_data_lock);
169 return ret; 170 return ret;
170} 171}
171 172
@@ -174,7 +175,7 @@ static ssize_t smi_data_write(struct kobject *kobj, char *buf, loff_t pos,
174{ 175{
175 ssize_t ret; 176 ssize_t ret;
176 177
177 down(&smi_data_lock); 178 mutex_lock(&smi_data_lock);
178 179
179 ret = smi_data_buf_realloc(pos + count); 180 ret = smi_data_buf_realloc(pos + count);
180 if (ret) 181 if (ret)
@@ -183,7 +184,7 @@ static ssize_t smi_data_write(struct kobject *kobj, char *buf, loff_t pos,
183 memcpy(smi_data_buf + pos, buf, count); 184 memcpy(smi_data_buf + pos, buf, count);
184 ret = count; 185 ret = count;
185out: 186out:
186 up(&smi_data_lock); 187 mutex_unlock(&smi_data_lock);
187 return ret; 188 return ret;
188} 189}
189 190
@@ -201,9 +202,9 @@ static ssize_t host_control_action_store(struct device *dev,
201 ssize_t ret; 202 ssize_t ret;
202 203
203 /* make sure buffer is available for host control command */ 204 /* make sure buffer is available for host control command */
204 down(&smi_data_lock); 205 mutex_lock(&smi_data_lock);
205 ret = smi_data_buf_realloc(sizeof(struct apm_cmd)); 206 ret = smi_data_buf_realloc(sizeof(struct apm_cmd));
206 up(&smi_data_lock); 207 mutex_unlock(&smi_data_lock);
207 if (ret) 208 if (ret)
208 return ret; 209 return ret;
209 210
@@ -302,7 +303,7 @@ static ssize_t smi_request_store(struct device *dev,
302 unsigned long val = simple_strtoul(buf, NULL, 10); 303 unsigned long val = simple_strtoul(buf, NULL, 10);
303 ssize_t ret; 304 ssize_t ret;
304 305
305 down(&smi_data_lock); 306 mutex_lock(&smi_data_lock);
306 307
307 if (smi_data_buf_size < sizeof(struct smi_cmd)) { 308 if (smi_data_buf_size < sizeof(struct smi_cmd)) {
308 ret = -ENODEV; 309 ret = -ENODEV;
@@ -334,7 +335,7 @@ static ssize_t smi_request_store(struct device *dev,
334 } 335 }
335 336
336out: 337out:
337 up(&smi_data_lock); 338 mutex_unlock(&smi_data_lock);
338 return ret; 339 return ret;
339} 340}
340 341