aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/nvram.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/nvram.c')
-rw-r--r--drivers/char/nvram.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index 66d2917b003f..166f1e7aaa7e 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -109,10 +109,11 @@
109#include <linux/spinlock.h> 109#include <linux/spinlock.h>
110#include <linux/io.h> 110#include <linux/io.h>
111#include <linux/uaccess.h> 111#include <linux/uaccess.h>
112#include <linux/smp_lock.h> 112#include <linux/mutex.h>
113 113
114#include <asm/system.h> 114#include <asm/system.h>
115 115
116static DEFINE_MUTEX(nvram_mutex);
116static DEFINE_SPINLOCK(nvram_state_lock); 117static DEFINE_SPINLOCK(nvram_state_lock);
117static int nvram_open_cnt; /* #times opened */ 118static int nvram_open_cnt; /* #times opened */
118static int nvram_open_mode; /* special open modes */ 119static int nvram_open_mode; /* special open modes */
@@ -308,7 +309,7 @@ static long nvram_ioctl(struct file *file, unsigned int cmd,
308 if (!capable(CAP_SYS_ADMIN)) 309 if (!capable(CAP_SYS_ADMIN))
309 return -EACCES; 310 return -EACCES;
310 311
311 lock_kernel(); 312 mutex_lock(&nvram_mutex);
312 spin_lock_irq(&rtc_lock); 313 spin_lock_irq(&rtc_lock);
313 314
314 for (i = 0; i < NVRAM_BYTES; ++i) 315 for (i = 0; i < NVRAM_BYTES; ++i)
@@ -316,7 +317,7 @@ static long nvram_ioctl(struct file *file, unsigned int cmd,
316 __nvram_set_checksum(); 317 __nvram_set_checksum();
317 318
318 spin_unlock_irq(&rtc_lock); 319 spin_unlock_irq(&rtc_lock);
319 unlock_kernel(); 320 mutex_unlock(&nvram_mutex);
320 return 0; 321 return 0;
321 322
322 case NVRAM_SETCKS: 323 case NVRAM_SETCKS:
@@ -325,11 +326,11 @@ static long nvram_ioctl(struct file *file, unsigned int cmd,
325 if (!capable(CAP_SYS_ADMIN)) 326 if (!capable(CAP_SYS_ADMIN))
326 return -EACCES; 327 return -EACCES;
327 328
328 lock_kernel(); 329 mutex_lock(&nvram_mutex);
329 spin_lock_irq(&rtc_lock); 330 spin_lock_irq(&rtc_lock);
330 __nvram_set_checksum(); 331 __nvram_set_checksum();
331 spin_unlock_irq(&rtc_lock); 332 spin_unlock_irq(&rtc_lock);
332 unlock_kernel(); 333 mutex_unlock(&nvram_mutex);
333 return 0; 334 return 0;
334 335
335 default: 336 default: