ia64: use non-racy method for proc entries creation
authorDenis V. Lunev <den@openvz.org>
Tue, 29 Apr 2008 08:02:25 +0000 (01:02 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 29 Apr 2008 15:06:21 +0000 (08:06 -0700)
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>
Cc: Tony Luck <tony.luck@intel.com>
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>
arch/ia64/hp/common/sba_iommu.c
arch/ia64/kernel/perfmon.c
arch/ia64/kernel/salinfo.c
arch/ia64/sn/kernel/sn2/sn2_smp.c
arch/ia64/sn/kernel/sn2/sn_proc_fs.c

index 6ce729f46de848a423c596b5f4fbb321e65d3bed..34421aed1e2ab95ff0d4f4d4e458003b409fd1a2 100644 (file)
@@ -1932,15 +1932,13 @@ static const struct file_operations ioc_fops = {
 static void __init
 ioc_proc_init(void)
 {
-       struct proc_dir_entry *dir, *entry;
+       struct proc_dir_entry *dir;
 
        dir = proc_mkdir("bus/mckinley", NULL);
        if (!dir)
                return;
 
-       entry = create_proc_entry(ioc_list->name, 0, dir);
-       if (entry)
-               entry->proc_fops = &ioc_fops;
+       proc_create(ioc_list->name, 0, dir, &ioc_fops);
 }
 #endif
 
index c8e403752a0c54d5c519b6ada5f3df1b68508bac..7fbb51e10bbe04e70c2cc66570400f3569f3804c 100644 (file)
@@ -6695,16 +6695,12 @@ pfm_init(void)
        /*
         * create /proc/perfmon (mostly for debugging purposes)
         */
-       perfmon_dir = create_proc_entry("perfmon", S_IRUGO, NULL);
+       perfmon_dir = proc_create("perfmon", S_IRUGO, NULL, &pfm_proc_fops);
        if (perfmon_dir == NULL) {
                printk(KERN_ERR "perfmon: cannot create /proc entry, perfmon disabled\n");
                pmu_conf = NULL;
                return -1;
        }
-       /*
-        * install customized file operations for /proc/perfmon entry
-        */
-       perfmon_dir->proc_fops = &pfm_proc_fops;
 
        /*
         * create /proc/sys/kernel/perfmon (for debugging purposes)
index b11bb50a197a68ff8aa5f8661ef7552618940c56..ecb9eb78d6877685de4d677d52e4b21292de4ddc 100644 (file)
@@ -648,18 +648,16 @@ salinfo_init(void)
                if (!dir)
                        continue;
 
-               entry = create_proc_entry("event", S_IRUSR, dir);
+               entry = proc_create_data("event", S_IRUSR, dir,
+                                        &salinfo_event_fops, data);
                if (!entry)
                        continue;
-               entry->data = data;
-               entry->proc_fops = &salinfo_event_fops;
                *sdir++ = entry;
 
-               entry = create_proc_entry("data", S_IRUSR | S_IWUSR, dir);
+               entry = proc_create_data("data", S_IRUSR | S_IWUSR, dir,
+                                        &salinfo_data_fops, data);
                if (!entry)
                        continue;
-               entry->data = data;
-               entry->proc_fops = &salinfo_data_fops;
                *sdir++ = entry;
 
                /* we missed any events before now */
index dfc6bf1c7b412084a6a3038a6b2bb35fb0c1da7d..49d3120415eb740154a5469be144e51598775d04 100644 (file)
@@ -550,11 +550,12 @@ static int __init sn2_ptc_init(void)
        if (!ia64_platform_is("sn2"))
                return 0;
 
-       if (!(proc_sn2_ptc = create_proc_entry(PTC_BASENAME, 0444, NULL))) {
+       proc_sn2_ptc = proc_create(PTC_BASENAME, 0444,
+                                  NULL, &proc_sn2_ptc_operations);
+       if (!&proc_sn2_ptc_operations) {
                printk(KERN_ERR "unable to create %s proc entry", PTC_BASENAME);
                return -EINVAL;
        }
-       proc_sn2_ptc->proc_fops = &proc_sn2_ptc_operations;
        spin_lock_init(&sn2_global_ptc_lock);
        return 0;
 }
index 62b3e9a496acc7bd0d716c74931cd6e58db78bf5..2526e5c783a42514fe6111b78c8c70c0233c4838 100644 (file)
@@ -139,30 +139,21 @@ static const struct file_operations proc_sn_topo_fops = {
 void register_sn_procfs(void)
 {
        static struct proc_dir_entry *sgi_proc_dir = NULL;
-       struct proc_dir_entry *pde;
 
        BUG_ON(sgi_proc_dir != NULL);
        if (!(sgi_proc_dir = proc_mkdir("sgi_sn", NULL)))
                return;
 
-       pde = create_proc_entry("partition_id", 0444, sgi_proc_dir);
-       if (pde)
-               pde->proc_fops = &proc_partition_id_fops;
-       pde = create_proc_entry("system_serial_number", 0444, sgi_proc_dir);
-       if (pde)
-               pde->proc_fops = &proc_system_sn_fops;
-       pde = create_proc_entry("licenseID", 0444, sgi_proc_dir);
-       if (pde)
-               pde->proc_fops = &proc_license_id_fops;
-       pde = create_proc_entry("sn_force_interrupt", 0644, sgi_proc_dir);
-       if (pde)
-               pde->proc_fops = &proc_sn_force_intr_fops;
-       pde = create_proc_entry("coherence_id", 0444, sgi_proc_dir);
-       if (pde)
-               pde->proc_fops = &proc_coherence_id_fops;
-       pde = create_proc_entry("sn_topology", 0444, sgi_proc_dir);
-       if (pde)
-               pde->proc_fops = &proc_sn_topo_fops;
+       proc_create("partition_id", 0444, sgi_proc_dir,
+                   &proc_partition_id_fops);
+       proc_create("system_serial_number", 0444, sgi_proc_dir,
+                   &proc_system_sn_fops);
+       proc_create("licenseID", 0444, sgi_proc_dir, &proc_license_id_fops);
+       proc_create("sn_force_interrupt", 0644, sgi_proc_dir,
+                   &proc_sn_force_intr_fops);
+       proc_create("coherence_id", 0444, sgi_proc_dir,
+                   &proc_coherence_id_fops);
+       proc_create("sn_topology", 0444, sgi_proc_dir, &proc_sn_topo_fops);
 }
 
 #endif /* CONFIG_PROC_FS */