diff options
author | Denis V. Lunev <den@openvz.org> | 2008-04-29 04:02:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:22 -0400 |
commit | 1b50221738108c438d5f25c7a043fb89e9e27044 (patch) | |
tree | 510b2baf0675fee9ce450b6756ff36c77e2f626c /drivers | |
parent | 0fd689468231cb5eee9cc5d6331081b77c7a7a76 (diff) |
drivers: 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.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/i8k.c | 6 | ||||
-rw-r--r-- | drivers/char/misc.c | 27 | ||||
-rw-r--r-- | drivers/char/rtc.c | 6 | ||||
-rw-r--r-- | drivers/char/toshiba.c | 3 | ||||
-rw-r--r-- | drivers/char/viotape.c | 9 |
5 files changed, 23 insertions, 28 deletions
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c index 8609b8236c67..f49037b744f9 100644 --- a/drivers/char/i8k.c +++ b/drivers/char/i8k.c | |||
@@ -82,6 +82,7 @@ static int i8k_ioctl(struct inode *, struct file *, unsigned int, | |||
82 | unsigned long); | 82 | unsigned long); |
83 | 83 | ||
84 | static const struct file_operations i8k_fops = { | 84 | static const struct file_operations i8k_fops = { |
85 | .owner = THIS_MODULE, | ||
85 | .open = i8k_open_fs, | 86 | .open = i8k_open_fs, |
86 | .read = seq_read, | 87 | .read = seq_read, |
87 | .llseek = seq_lseek, | 88 | .llseek = seq_lseek, |
@@ -554,13 +555,10 @@ static int __init i8k_init(void) | |||
554 | return -ENODEV; | 555 | return -ENODEV; |
555 | 556 | ||
556 | /* Register the proc entry */ | 557 | /* Register the proc entry */ |
557 | proc_i8k = create_proc_entry("i8k", 0, NULL); | 558 | proc_i8k = proc_create("i8k", 0, NULL, &i8k_fops); |
558 | if (!proc_i8k) | 559 | if (!proc_i8k) |
559 | return -ENOENT; | 560 | return -ENOENT; |
560 | 561 | ||
561 | proc_i8k->proc_fops = &i8k_fops; | ||
562 | proc_i8k->owner = THIS_MODULE; | ||
563 | |||
564 | printk(KERN_INFO | 562 | printk(KERN_INFO |
565 | "Dell laptop SMM driver v%s Massimo Dal Zotto (dz@debian.org)\n", | 563 | "Dell laptop SMM driver v%s Massimo Dal Zotto (dz@debian.org)\n", |
566 | I8K_VERSION); | 564 | I8K_VERSION); |
diff --git a/drivers/char/misc.c b/drivers/char/misc.c index 4d058dadbfcc..eaace0db0ff4 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c | |||
@@ -263,23 +263,26 @@ EXPORT_SYMBOL(misc_deregister); | |||
263 | 263 | ||
264 | static int __init misc_init(void) | 264 | static int __init misc_init(void) |
265 | { | 265 | { |
266 | #ifdef CONFIG_PROC_FS | 266 | int err; |
267 | struct proc_dir_entry *ent; | ||
268 | 267 | ||
269 | ent = create_proc_entry("misc", 0, NULL); | 268 | #ifdef CONFIG_PROC_FS |
270 | if (ent) | 269 | proc_create("misc", 0, NULL, &misc_proc_fops); |
271 | ent->proc_fops = &misc_proc_fops; | ||
272 | #endif | 270 | #endif |
273 | misc_class = class_create(THIS_MODULE, "misc"); | 271 | misc_class = class_create(THIS_MODULE, "misc"); |
272 | err = PTR_ERR(misc_class); | ||
274 | if (IS_ERR(misc_class)) | 273 | if (IS_ERR(misc_class)) |
275 | return PTR_ERR(misc_class); | 274 | goto fail_remove; |
276 | 275 | ||
277 | if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) { | 276 | err = -EIO; |
278 | printk("unable to get major %d for misc devices\n", | 277 | if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) |
279 | MISC_MAJOR); | 278 | goto fail_printk; |
280 | class_destroy(misc_class); | ||
281 | return -EIO; | ||
282 | } | ||
283 | return 0; | 279 | return 0; |
280 | |||
281 | fail_printk: | ||
282 | printk("unable to get major %d for misc devices\n", MISC_MAJOR); | ||
283 | class_destroy(misc_class); | ||
284 | fail_remove: | ||
285 | remove_proc_entry("misc", NULL); | ||
286 | return err; | ||
284 | } | 287 | } |
285 | subsys_initcall(misc_init); | 288 | subsys_initcall(misc_init); |
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index e2ec2ee4cf79..5f80a9dff573 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c | |||
@@ -1069,10 +1069,8 @@ no_irq: | |||
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | #ifdef CONFIG_PROC_FS | 1071 | #ifdef CONFIG_PROC_FS |
1072 | ent = create_proc_entry("driver/rtc", 0, NULL); | 1072 | ent = proc_create("driver/rtc", 0, NULL, &rtc_proc_fops); |
1073 | if (ent) | 1073 | if (!ent) |
1074 | ent->proc_fops = &rtc_proc_fops; | ||
1075 | else | ||
1076 | printk(KERN_WARNING "rtc: Failed to register with procfs.\n"); | 1074 | printk(KERN_WARNING "rtc: Failed to register with procfs.\n"); |
1077 | #endif | 1075 | #endif |
1078 | 1076 | ||
diff --git a/drivers/char/toshiba.c b/drivers/char/toshiba.c index ce5ebe3b168f..64f1ceed0b2c 100644 --- a/drivers/char/toshiba.c +++ b/drivers/char/toshiba.c | |||
@@ -520,12 +520,11 @@ static int __init toshiba_init(void) | |||
520 | { | 520 | { |
521 | struct proc_dir_entry *pde; | 521 | struct proc_dir_entry *pde; |
522 | 522 | ||
523 | pde = create_proc_entry("toshiba", 0, NULL); | 523 | pde = proc_create("toshiba", 0, NULL, &proc_toshiba_fops); |
524 | if (!pde) { | 524 | if (!pde) { |
525 | misc_deregister(&tosh_device); | 525 | misc_deregister(&tosh_device); |
526 | return -ENOMEM; | 526 | return -ENOMEM; |
527 | } | 527 | } |
528 | pde->proc_fops = &proc_toshiba_fops; | ||
529 | } | 528 | } |
530 | #endif | 529 | #endif |
531 | 530 | ||
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c index db7a731e2362..58aad63831f4 100644 --- a/drivers/char/viotape.c +++ b/drivers/char/viotape.c | |||
@@ -249,6 +249,7 @@ static int proc_viotape_open(struct inode *inode, struct file *file) | |||
249 | } | 249 | } |
250 | 250 | ||
251 | static const struct file_operations proc_viotape_operations = { | 251 | static const struct file_operations proc_viotape_operations = { |
252 | .owner = THIS_MODULE, | ||
252 | .open = proc_viotape_open, | 253 | .open = proc_viotape_open, |
253 | .read = seq_read, | 254 | .read = seq_read, |
254 | .llseek = seq_lseek, | 255 | .llseek = seq_lseek, |
@@ -915,7 +916,6 @@ static struct vio_driver viotape_driver = { | |||
915 | int __init viotap_init(void) | 916 | int __init viotap_init(void) |
916 | { | 917 | { |
917 | int ret; | 918 | int ret; |
918 | struct proc_dir_entry *e; | ||
919 | 919 | ||
920 | if (!firmware_has_feature(FW_FEATURE_ISERIES)) | 920 | if (!firmware_has_feature(FW_FEATURE_ISERIES)) |
921 | return -ENODEV; | 921 | return -ENODEV; |
@@ -968,11 +968,8 @@ int __init viotap_init(void) | |||
968 | if (ret) | 968 | if (ret) |
969 | goto unreg_class; | 969 | goto unreg_class; |
970 | 970 | ||
971 | e = create_proc_entry("iSeries/viotape", S_IFREG|S_IRUGO, NULL); | 971 | proc_create("iSeries/viotape", S_IFREG|S_IRUGO, NULL, |
972 | if (e) { | 972 | &proc_viotape_operations); |
973 | e->owner = THIS_MODULE; | ||
974 | e->proc_fops = &proc_viotape_operations; | ||
975 | } | ||
976 | 973 | ||
977 | return 0; | 974 | return 0; |
978 | 975 | ||