aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/sleep
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-04-29 04:02:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:22 -0400
commitcf7acfab032ff262f42954328cdfd20a5d9aaaac (patch)
tree231698d72d4508f3b26f606f18ef844387ec43e5 /drivers/acpi/sleep
parent667471386d4068e75a6a55b615701ced61eb6333 (diff)
acpi: use non-racy method for proc entries creation
Use proc_create()/proc_create_data() to make sure that ->proc_fops and ->data be setup before gluing PDE to main tree. Add correct ->owner to proc_fops to fix reading/module unloading race. Signed-off-by: Denis V. Lunev <den@openvz.org> Cc: Len Brown <lenb@kernel.org> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/acpi/sleep')
-rw-r--r--drivers/acpi/sleep/proc.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index f8df5217d477..8a5fe8710513 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -440,6 +440,7 @@ acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file)
440} 440}
441 441
442static const struct file_operations acpi_system_wakeup_device_fops = { 442static const struct file_operations acpi_system_wakeup_device_fops = {
443 .owner = THIS_MODULE,
443 .open = acpi_system_wakeup_device_open_fs, 444 .open = acpi_system_wakeup_device_open_fs,
444 .read = seq_read, 445 .read = seq_read,
445 .write = acpi_system_write_wakeup_device, 446 .write = acpi_system_write_wakeup_device,
@@ -449,6 +450,7 @@ static const struct file_operations acpi_system_wakeup_device_fops = {
449 450
450#ifdef CONFIG_ACPI_PROCFS 451#ifdef CONFIG_ACPI_PROCFS
451static const struct file_operations acpi_system_sleep_fops = { 452static const struct file_operations acpi_system_sleep_fops = {
453 .owner = THIS_MODULE,
452 .open = acpi_system_sleep_open_fs, 454 .open = acpi_system_sleep_open_fs,
453 .read = seq_read, 455 .read = seq_read,
454 .write = acpi_system_write_sleep, 456 .write = acpi_system_write_sleep,
@@ -459,6 +461,7 @@ static const struct file_operations acpi_system_sleep_fops = {
459 461
460#ifdef HAVE_ACPI_LEGACY_ALARM 462#ifdef HAVE_ACPI_LEGACY_ALARM
461static const struct file_operations acpi_system_alarm_fops = { 463static const struct file_operations acpi_system_alarm_fops = {
464 .owner = THIS_MODULE,
462 .open = acpi_system_alarm_open_fs, 465 .open = acpi_system_alarm_open_fs,
463 .read = seq_read, 466 .read = seq_read,
464 .write = acpi_system_write_alarm, 467 .write = acpi_system_write_alarm,
@@ -477,37 +480,26 @@ static u32 rtc_handler(void *context)
477 480
478static int __init acpi_sleep_proc_init(void) 481static int __init acpi_sleep_proc_init(void)
479{ 482{
480 struct proc_dir_entry *entry = NULL;
481
482 if (acpi_disabled) 483 if (acpi_disabled)
483 return 0; 484 return 0;
484 485
485#ifdef CONFIG_ACPI_PROCFS 486#ifdef CONFIG_ACPI_PROCFS
486 /* 'sleep' [R/W] */ 487 /* 'sleep' [R/W] */
487 entry = 488 proc_create("sleep", S_IFREG | S_IRUGO | S_IWUSR,
488 create_proc_entry("sleep", S_IFREG | S_IRUGO | S_IWUSR, 489 acpi_root_dir, &acpi_system_sleep_fops);
489 acpi_root_dir);
490 if (entry)
491 entry->proc_fops = &acpi_system_sleep_fops;
492#endif /* CONFIG_ACPI_PROCFS */ 490#endif /* CONFIG_ACPI_PROCFS */
493 491
494#ifdef HAVE_ACPI_LEGACY_ALARM 492#ifdef HAVE_ACPI_LEGACY_ALARM
495 /* 'alarm' [R/W] */ 493 /* 'alarm' [R/W] */
496 entry = 494 proc_create("alarm", S_IFREG | S_IRUGO | S_IWUSR,
497 create_proc_entry("alarm", S_IFREG | S_IRUGO | S_IWUSR, 495 acpi_root_dir, &acpi_system_alarm_fops);
498 acpi_root_dir);
499 if (entry)
500 entry->proc_fops = &acpi_system_alarm_fops;
501 496
502 acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL); 497 acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL);
503#endif /* HAVE_ACPI_LEGACY_ALARM */ 498#endif /* HAVE_ACPI_LEGACY_ALARM */
504 499
505 /* 'wakeup device' [R/W] */ 500 /* 'wakeup device' [R/W] */
506 entry = 501 proc_create("wakeup", S_IFREG | S_IRUGO | S_IWUSR,
507 create_proc_entry("wakeup", S_IFREG | S_IRUGO | S_IWUSR, 502 acpi_root_dir, &acpi_system_wakeup_device_fops);
508 acpi_root_dir);
509 if (entry)
510 entry->proc_fops = &acpi_system_wakeup_device_fops;
511 503
512 return 0; 504 return 0;
513} 505}