diff options
author | Denis V. Lunev <den@openvz.org> | 2008-04-29 04:02:27 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:22 -0400 |
commit | cf7acfab032ff262f42954328cdfd20a5d9aaaac (patch) | |
tree | 231698d72d4508f3b26f606f18ef844387ec43e5 /drivers/acpi/button.c | |
parent | 667471386d4068e75a6a55b615701ced61eb6333 (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/button.c')
-rw-r--r-- | drivers/acpi/button.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 6c5da83cdb68..1dfec413588c 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c | |||
@@ -102,6 +102,7 @@ struct acpi_button { | |||
102 | }; | 102 | }; |
103 | 103 | ||
104 | static const struct file_operations acpi_button_info_fops = { | 104 | static const struct file_operations acpi_button_info_fops = { |
105 | .owner = THIS_MODULE, | ||
105 | .open = acpi_button_info_open_fs, | 106 | .open = acpi_button_info_open_fs, |
106 | .read = seq_read, | 107 | .read = seq_read, |
107 | .llseek = seq_lseek, | 108 | .llseek = seq_lseek, |
@@ -109,6 +110,7 @@ static const struct file_operations acpi_button_info_fops = { | |||
109 | }; | 110 | }; |
110 | 111 | ||
111 | static const struct file_operations acpi_button_state_fops = { | 112 | static const struct file_operations acpi_button_state_fops = { |
113 | .owner = THIS_MODULE, | ||
112 | .open = acpi_button_state_open_fs, | 114 | .open = acpi_button_state_open_fs, |
113 | .read = seq_read, | 115 | .read = seq_read, |
114 | .llseek = seq_lseek, | 116 | .llseek = seq_lseek, |
@@ -207,27 +209,21 @@ static int acpi_button_add_fs(struct acpi_device *device) | |||
207 | acpi_device_dir(device)->owner = THIS_MODULE; | 209 | acpi_device_dir(device)->owner = THIS_MODULE; |
208 | 210 | ||
209 | /* 'info' [R] */ | 211 | /* 'info' [R] */ |
210 | entry = create_proc_entry(ACPI_BUTTON_FILE_INFO, | 212 | entry = proc_create_data(ACPI_BUTTON_FILE_INFO, |
211 | S_IRUGO, acpi_device_dir(device)); | 213 | S_IRUGO, acpi_device_dir(device), |
214 | &acpi_button_info_fops, | ||
215 | acpi_driver_data(device)); | ||
212 | if (!entry) | 216 | if (!entry) |
213 | return -ENODEV; | 217 | return -ENODEV; |
214 | else { | ||
215 | entry->proc_fops = &acpi_button_info_fops; | ||
216 | entry->data = acpi_driver_data(device); | ||
217 | entry->owner = THIS_MODULE; | ||
218 | } | ||
219 | 218 | ||
220 | /* show lid state [R] */ | 219 | /* show lid state [R] */ |
221 | if (button->type == ACPI_BUTTON_TYPE_LID) { | 220 | if (button->type == ACPI_BUTTON_TYPE_LID) { |
222 | entry = create_proc_entry(ACPI_BUTTON_FILE_STATE, | 221 | entry = proc_create_data(ACPI_BUTTON_FILE_STATE, |
223 | S_IRUGO, acpi_device_dir(device)); | 222 | S_IRUGO, acpi_device_dir(device), |
223 | &acpi_button_state_fops, | ||
224 | acpi_driver_data(device)); | ||
224 | if (!entry) | 225 | if (!entry) |
225 | return -ENODEV; | 226 | return -ENODEV; |
226 | else { | ||
227 | entry->proc_fops = &acpi_button_state_fops; | ||
228 | entry->data = acpi_driver_data(device); | ||
229 | entry->owner = THIS_MODULE; | ||
230 | } | ||
231 | } | 227 | } |
232 | 228 | ||
233 | return 0; | 229 | return 0; |