nvram.c (b65b34895437915f411882dd40d704eb0863ffb0) | nvram.c (55929332c92e5d34d65a8f784604c92677ea3e15) |
---|---|
1/* 2 * CMOS/NV-RAM driver for Linux 3 * 4 * Copyright (C) 1997 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> 5 * idea by and with help from Richard Jelinek <rj@suse.de> 6 * Portions copyright (c) 2001,2002 Sun Microsystems (thockin@sun.com) 7 * 8 * This driver allows you to access the contents of the non-volatile memory in --- 282 unchanged lines hidden (view full) --- 291 292 return tmp - contents; 293 294checksum_err: 295 spin_unlock_irq(&rtc_lock); 296 return -EIO; 297} 298 | 1/* 2 * CMOS/NV-RAM driver for Linux 3 * 4 * Copyright (C) 1997 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> 5 * idea by and with help from Richard Jelinek <rj@suse.de> 6 * Portions copyright (c) 2001,2002 Sun Microsystems (thockin@sun.com) 7 * 8 * This driver allows you to access the contents of the non-volatile memory in --- 282 unchanged lines hidden (view full) --- 291 292 return tmp - contents; 293 294checksum_err: 295 spin_unlock_irq(&rtc_lock); 296 return -EIO; 297} 298 |
299static int nvram_ioctl(struct inode *inode, struct file *file, 300 unsigned int cmd, unsigned long arg) | 299static long nvram_ioctl(struct file *file, unsigned int cmd, 300 unsigned long arg) |
301{ 302 int i; 303 304 switch (cmd) { 305 306 case NVRAM_INIT: 307 /* initialize NVRAM contents and checksum */ 308 if (!capable(CAP_SYS_ADMIN)) 309 return -EACCES; 310 | 301{ 302 int i; 303 304 switch (cmd) { 305 306 case NVRAM_INIT: 307 /* initialize NVRAM contents and checksum */ 308 if (!capable(CAP_SYS_ADMIN)) 309 return -EACCES; 310 |
311 lock_kernel(); |
|
311 spin_lock_irq(&rtc_lock); 312 313 for (i = 0; i < NVRAM_BYTES; ++i) 314 __nvram_write_byte(0, i); 315 __nvram_set_checksum(); 316 317 spin_unlock_irq(&rtc_lock); | 312 spin_lock_irq(&rtc_lock); 313 314 for (i = 0; i < NVRAM_BYTES; ++i) 315 __nvram_write_byte(0, i); 316 __nvram_set_checksum(); 317 318 spin_unlock_irq(&rtc_lock); |
319 unlock_kernel(); |
|
318 return 0; 319 320 case NVRAM_SETCKS: 321 /* just set checksum, contents unchanged (maybe useful after 322 * checksum garbaged somehow...) */ 323 if (!capable(CAP_SYS_ADMIN)) 324 return -EACCES; 325 | 320 return 0; 321 322 case NVRAM_SETCKS: 323 /* just set checksum, contents unchanged (maybe useful after 324 * checksum garbaged somehow...) */ 325 if (!capable(CAP_SYS_ADMIN)) 326 return -EACCES; 327 |
328 lock_kernel(); |
|
326 spin_lock_irq(&rtc_lock); 327 __nvram_set_checksum(); 328 spin_unlock_irq(&rtc_lock); | 329 spin_lock_irq(&rtc_lock); 330 __nvram_set_checksum(); 331 spin_unlock_irq(&rtc_lock); |
332 unlock_kernel(); |
|
329 return 0; 330 331 default: 332 return -ENOTTY; 333 } 334} 335 336static int nvram_open(struct inode *inode, struct file *file) --- 80 unchanged lines hidden (view full) --- 417 418#endif /* CONFIG_PROC_FS */ 419 420static const struct file_operations nvram_fops = { 421 .owner = THIS_MODULE, 422 .llseek = nvram_llseek, 423 .read = nvram_read, 424 .write = nvram_write, | 333 return 0; 334 335 default: 336 return -ENOTTY; 337 } 338} 339 340static int nvram_open(struct inode *inode, struct file *file) --- 80 unchanged lines hidden (view full) --- 421 422#endif /* CONFIG_PROC_FS */ 423 424static const struct file_operations nvram_fops = { 425 .owner = THIS_MODULE, 426 .llseek = nvram_llseek, 427 .read = nvram_read, 428 .write = nvram_write, |
425 .ioctl = nvram_ioctl, | 429 .unlocked_ioctl = nvram_ioctl, |
426 .open = nvram_open, 427 .release = nvram_release, 428}; 429 430static struct miscdevice nvram_dev = { 431 NVRAM_MINOR, 432 "nvram", 433 &nvram_fops --- 285 unchanged lines hidden --- | 430 .open = nvram_open, 431 .release = nvram_release, 432}; 433 434static struct miscdevice nvram_dev = { 435 NVRAM_MINOR, 436 "nvram", 437 &nvram_fops --- 285 unchanged lines hidden --- |