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: Denis 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Denis V. Lunev
2008-04-29 01:02:26 -07:00
committed by Linus Torvalds
parent 6f1c86ec31
commit 667471386d
13 changed files with 39 additions and 89 deletions
+14 -31
View File
@@ -255,8 +255,6 @@ static void check_location(struct seq_file *m, const char *c);
static int __init proc_rtas_init(void)
{
struct proc_dir_entry *entry;
if (!machine_is(pseries))
return -ENODEV;
@@ -264,35 +262,20 @@ static int __init proc_rtas_init(void)
if (rtas_node == NULL)
return -ENODEV;
entry = create_proc_entry("ppc64/rtas/progress", S_IRUGO|S_IWUSR, NULL);
if (entry)
entry->proc_fops = &ppc_rtas_progress_operations;
entry = create_proc_entry("ppc64/rtas/clock", S_IRUGO|S_IWUSR, NULL);
if (entry)
entry->proc_fops = &ppc_rtas_clock_operations;
entry = create_proc_entry("ppc64/rtas/poweron", S_IWUSR|S_IRUGO, NULL);
if (entry)
entry->proc_fops = &ppc_rtas_poweron_operations;
entry = create_proc_entry("ppc64/rtas/sensors", S_IRUGO, NULL);
if (entry)
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;
proc_create("ppc64/rtas/progress", S_IRUGO|S_IWUSR, NULL,
&ppc_rtas_progress_operations);
proc_create("ppc64/rtas/clock", S_IRUGO|S_IWUSR, NULL,
&ppc_rtas_clock_operations);
proc_create("ppc64/rtas/poweron", S_IWUSR|S_IRUGO, NULL,
&ppc_rtas_poweron_operations);
proc_create("ppc64/rtas/sensors", S_IRUGO, NULL,
&ppc_rtas_sensors_operations);
proc_create("ppc64/rtas/frequency", S_IWUSR|S_IRUGO, NULL,
&ppc_rtas_tone_freq_operations);
proc_create("ppc64/rtas/volume", S_IWUSR|S_IRUGO, NULL,
&ppc_rtas_tone_volume_operations);
proc_create("ppc64/rtas/rmo_buffer", S_IRUSR, NULL,
&ppc_rtas_rmo_buf_ops);
return 0;
}