Commit 66747138 authored by Denis V. Lunev's avatar Denis V. Lunev Committed by Linus Torvalds

powerpc: 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: default avatarDenis V. Lunev <den@openvz.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6f1c86ec
...@@ -591,10 +591,8 @@ int __init lparcfg_init(void) ...@@ -591,10 +591,8 @@ int __init lparcfg_init(void)
!firmware_has_feature(FW_FEATURE_ISERIES)) !firmware_has_feature(FW_FEATURE_ISERIES))
mode |= S_IWUSR; mode |= S_IWUSR;
ent = create_proc_entry("ppc64/lparcfg", mode, NULL); ent = proc_create("ppc64/lparcfg", mode, NULL, &lparcfg_fops);
if (ent) { if (!ent) {
ent->proc_fops = &lparcfg_fops;
} else {
printk(KERN_ERR "Failed to create ppc64/lparcfg\n"); printk(KERN_ERR "Failed to create ppc64/lparcfg\n");
return -EIO; return -EIO;
} }
......
...@@ -68,12 +68,11 @@ static int __init proc_ppc64_init(void) ...@@ -68,12 +68,11 @@ static int __init proc_ppc64_init(void)
{ {
struct proc_dir_entry *pde; struct proc_dir_entry *pde;
pde = create_proc_entry("ppc64/systemcfg", S_IFREG|S_IRUGO, NULL); pde = proc_create_data("ppc64/systemcfg", S_IFREG|S_IRUGO, NULL,
&page_map_fops, vdso_data);
if (!pde) if (!pde)
return 1; return 1;
pde->data = vdso_data;
pde->size = PAGE_SIZE; pde->size = PAGE_SIZE;
pde->proc_fops = &page_map_fops;
return 0; return 0;
} }
......
...@@ -255,8 +255,6 @@ static void check_location(struct seq_file *m, const char *c); ...@@ -255,8 +255,6 @@ static void check_location(struct seq_file *m, const char *c);
static int __init proc_rtas_init(void) static int __init proc_rtas_init(void)
{ {
struct proc_dir_entry *entry;
if (!machine_is(pseries)) if (!machine_is(pseries))
return -ENODEV; return -ENODEV;
...@@ -264,35 +262,20 @@ static int __init proc_rtas_init(void) ...@@ -264,35 +262,20 @@ static int __init proc_rtas_init(void)
if (rtas_node == NULL) if (rtas_node == NULL)
return -ENODEV; return -ENODEV;
entry = create_proc_entry("ppc64/rtas/progress", S_IRUGO|S_IWUSR, NULL); proc_create("ppc64/rtas/progress", S_IRUGO|S_IWUSR, NULL,
if (entry) &ppc_rtas_progress_operations);
entry->proc_fops = &ppc_rtas_progress_operations; proc_create("ppc64/rtas/clock", S_IRUGO|S_IWUSR, NULL,
&ppc_rtas_clock_operations);
entry = create_proc_entry("ppc64/rtas/clock", S_IRUGO|S_IWUSR, NULL); proc_create("ppc64/rtas/poweron", S_IWUSR|S_IRUGO, NULL,
if (entry) &ppc_rtas_poweron_operations);
entry->proc_fops = &ppc_rtas_clock_operations; proc_create("ppc64/rtas/sensors", S_IRUGO, NULL,
&ppc_rtas_sensors_operations);
entry = create_proc_entry("ppc64/rtas/poweron", S_IWUSR|S_IRUGO, NULL); proc_create("ppc64/rtas/frequency", S_IWUSR|S_IRUGO, NULL,
if (entry) &ppc_rtas_tone_freq_operations);
entry->proc_fops = &ppc_rtas_poweron_operations; proc_create("ppc64/rtas/volume", S_IWUSR|S_IRUGO, NULL,
&ppc_rtas_tone_volume_operations);
entry = create_proc_entry("ppc64/rtas/sensors", S_IRUGO, NULL); proc_create("ppc64/rtas/rmo_buffer", S_IRUSR, NULL,
if (entry) &ppc_rtas_rmo_buf_ops);
entry->proc_fops = &ppc_rtas_sensors_operations;
entry = create_proc_entry("ppc64/rtas/frequency", S_IWUSR|S_IRUGO,
NULL);
if (entry)
entry->proc_fops = &ppc_rtas_tone_freq_operations;
entry = create_proc_entry("ppc64/rtas/volume", S_IWUSR|S_IRUGO, NULL);
if (entry)
entry->proc_fops = &ppc_rtas_tone_volume_operations;
entry = create_proc_entry("ppc64/rtas/rmo_buffer", S_IRUSR, NULL);
if (entry)
entry->proc_fops = &ppc_rtas_rmo_buf_ops;
return 0; return 0;
} }
......
...@@ -704,18 +704,11 @@ static int initialize_flash_pde_data(const char *rtas_call_name, ...@@ -704,18 +704,11 @@ static int initialize_flash_pde_data(const char *rtas_call_name,
static struct proc_dir_entry *create_flash_pde(const char *filename, static struct proc_dir_entry *create_flash_pde(const char *filename,
const struct file_operations *fops) const struct file_operations *fops)
{ {
struct proc_dir_entry *ent = NULL; return proc_create(filename, S_IRUSR | S_IWUSR, NULL, fops);
ent = create_proc_entry(filename, S_IRUSR | S_IWUSR, NULL);
if (ent != NULL) {
ent->proc_fops = fops;
ent->owner = THIS_MODULE;
}
return ent;
} }
static const struct file_operations rtas_flash_operations = { static const struct file_operations rtas_flash_operations = {
.owner = THIS_MODULE,
.read = rtas_flash_read, .read = rtas_flash_read,
.write = rtas_flash_write, .write = rtas_flash_write,
.open = rtas_excl_open, .open = rtas_excl_open,
...@@ -723,6 +716,7 @@ static const struct file_operations rtas_flash_operations = { ...@@ -723,6 +716,7 @@ static const struct file_operations rtas_flash_operations = {
}; };
static const struct file_operations manage_flash_operations = { static const struct file_operations manage_flash_operations = {
.owner = THIS_MODULE,
.read = manage_flash_read, .read = manage_flash_read,
.write = manage_flash_write, .write = manage_flash_write,
.open = rtas_excl_open, .open = rtas_excl_open,
...@@ -730,6 +724,7 @@ static const struct file_operations manage_flash_operations = { ...@@ -730,6 +724,7 @@ static const struct file_operations manage_flash_operations = {
}; };
static const struct file_operations validate_flash_operations = { static const struct file_operations validate_flash_operations = {
.owner = THIS_MODULE,
.read = validate_flash_read, .read = validate_flash_read,
.write = validate_flash_write, .write = validate_flash_write,
.open = rtas_excl_open, .open = rtas_excl_open,
......
...@@ -1063,10 +1063,9 @@ int __init spu_sched_init(void) ...@@ -1063,10 +1063,9 @@ int __init spu_sched_init(void)
mod_timer(&spuloadavg_timer, 0); mod_timer(&spuloadavg_timer, 0);
entry = create_proc_entry("spu_loadavg", 0, NULL); entry = proc_create("spu_loadavg", 0, NULL, &spu_loadavg_fops);
if (!entry) if (!entry)
goto out_stop_kthread; goto out_stop_kthread;
entry->proc_fops = &spu_loadavg_fops;
pr_debug("spusched: tick: %d, min ticks: %d, default ticks: %d\n", pr_debug("spusched: tick: %d, min ticks: %d, default ticks: %d\n",
SPUSCHED_TICK, MIN_SPU_TIMESLICE, DEF_SPU_TIMESLICE); SPUSCHED_TICK, MIN_SPU_TIMESLICE, DEF_SPU_TIMESLICE);
......
...@@ -201,10 +201,9 @@ static int __init sputrace_init(void) ...@@ -201,10 +201,9 @@ static int __init sputrace_init(void)
if (!sputrace_log) if (!sputrace_log)
goto out; goto out;
entry = create_proc_entry("sputrace", S_IRUSR, NULL); entry = proc_create("sputrace", S_IRUSR, NULL, &sputrace_fops);
if (!entry) if (!entry)
goto out_free_log; goto out_free_log;
entry->proc_fops = &sputrace_fops;
for (i = 0; i < ARRAY_SIZE(spu_probes); i++) { for (i = 0; i < ARRAY_SIZE(spu_probes); i++) {
struct spu_probe *p = &spu_probes[i]; struct spu_probe *p = &spu_probes[i];
......
...@@ -330,15 +330,11 @@ static const struct file_operations proc_lpevents_operations = { ...@@ -330,15 +330,11 @@ static const struct file_operations proc_lpevents_operations = {
static int __init proc_lpevents_init(void) static int __init proc_lpevents_init(void)
{ {
struct proc_dir_entry *e;
if (!firmware_has_feature(FW_FEATURE_ISERIES)) if (!firmware_has_feature(FW_FEATURE_ISERIES))
return 0; return 0;
e = create_proc_entry("iSeries/lpevents", S_IFREG|S_IRUGO, NULL); proc_create("iSeries/lpevents", S_IFREG|S_IRUGO, NULL,
if (e) &proc_lpevents_operations);
e->proc_fops = &proc_lpevents_operations;
return 0; return 0;
} }
__initcall(proc_lpevents_init); __initcall(proc_lpevents_init);
......
...@@ -1255,11 +1255,11 @@ static int __init mf_proc_init(void) ...@@ -1255,11 +1255,11 @@ static int __init mf_proc_init(void)
if (i == 3) /* no vmlinux entry for 'D' */ if (i == 3) /* no vmlinux entry for 'D' */
continue; continue;
ent = create_proc_entry("vmlinux", S_IFREG|S_IWUSR, mf); ent = proc_create_data("vmlinux", S_IFREG|S_IWUSR, mf,
&proc_vmlinux_operations,
(void *)(long)i);
if (!ent) if (!ent)
return 1; return 1;
ent->data = (void *)(long)i;
ent->proc_fops = &proc_vmlinux_operations;
} }
ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root); ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
......
...@@ -110,15 +110,11 @@ static const struct file_operations proc_titantod_operations = { ...@@ -110,15 +110,11 @@ static const struct file_operations proc_titantod_operations = {
static int __init iseries_proc_init(void) static int __init iseries_proc_init(void)
{ {
struct proc_dir_entry *e;
if (!firmware_has_feature(FW_FEATURE_ISERIES)) if (!firmware_has_feature(FW_FEATURE_ISERIES))
return 0; return 0;
e = create_proc_entry("iSeries/titanTod", S_IFREG|S_IRUGO, NULL); proc_create("iSeries/titanTod", S_IFREG|S_IRUGO, NULL,
if (e) &proc_titantod_operations);
e->proc_fops = &proc_titantod_operations;
return 0; return 0;
} }
__initcall(iseries_proc_init); __initcall(iseries_proc_init);
...@@ -180,15 +180,10 @@ static const struct file_operations proc_viopath_operations = { ...@@ -180,15 +180,10 @@ static const struct file_operations proc_viopath_operations = {
static int __init vio_proc_init(void) static int __init vio_proc_init(void)
{ {
struct proc_dir_entry *e;
if (!firmware_has_feature(FW_FEATURE_ISERIES)) if (!firmware_has_feature(FW_FEATURE_ISERIES))
return 0; return 0;
e = create_proc_entry("iSeries/config", 0, NULL); proc_create("iSeries/config", 0, NULL, &proc_viopath_operations);
if (e)
e->proc_fops = &proc_viopath_operations;
return 0; return 0;
} }
__initcall(vio_proc_init); __initcall(vio_proc_init);
......
...@@ -1259,14 +1259,8 @@ static const struct file_operations proc_eeh_operations = { ...@@ -1259,14 +1259,8 @@ static const struct file_operations proc_eeh_operations = {
static int __init eeh_init_proc(void) static int __init eeh_init_proc(void)
{ {
struct proc_dir_entry *e; if (machine_is(pseries))
proc_create("ppc64/eeh", 0, NULL, &proc_eeh_operations);
if (machine_is(pseries)) {
e = create_proc_entry("ppc64/eeh", 0, NULL);
if (e)
e->proc_fops = &proc_eeh_operations;
}
return 0; return 0;
} }
__initcall(eeh_init_proc); __initcall(eeh_init_proc);
...@@ -512,12 +512,9 @@ static int proc_ppc64_create_ofdt(void) ...@@ -512,12 +512,9 @@ static int proc_ppc64_create_ofdt(void)
if (!machine_is(pseries)) if (!machine_is(pseries))
return 0; return 0;
ent = create_proc_entry("ppc64/ofdt", S_IWUSR, NULL); ent = proc_create("ppc64/ofdt", S_IWUSR, NULL, &ofdt_fops);
if (ent) { if (ent)
ent->data = NULL;
ent->size = 0; ent->size = 0;
ent->proc_fops = &ofdt_fops;
}
return 0; return 0;
} }
......
...@@ -468,10 +468,9 @@ static int __init rtas_init(void) ...@@ -468,10 +468,9 @@ static int __init rtas_init(void)
return -ENOMEM; return -ENOMEM;
} }
entry = create_proc_entry("ppc64/rtas/error_log", S_IRUSR, NULL); entry = proc_create("ppc64/rtas/error_log", S_IRUSR, NULL,
if (entry) &proc_rtas_log_operations);
entry->proc_fops = &proc_rtas_log_operations; if (!entry)
else
printk(KERN_ERR "Failed to create error_log proc entry\n"); printk(KERN_ERR "Failed to create error_log proc entry\n");
if (kernel_thread(rtasd, NULL, CLONE_FS) < 0) if (kernel_thread(rtasd, NULL, CLONE_FS) < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment