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/video.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/video.c')
-rw-r--r-- | drivers/acpi/video.c | 112 |
1 files changed, 44 insertions, 68 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 980a74188781..43b228314a86 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -192,6 +192,7 @@ struct acpi_video_device { | |||
192 | /* bus */ | 192 | /* bus */ |
193 | static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file); | 193 | static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file); |
194 | static struct file_operations acpi_video_bus_info_fops = { | 194 | static struct file_operations acpi_video_bus_info_fops = { |
195 | .owner = THIS_MODULE, | ||
195 | .open = acpi_video_bus_info_open_fs, | 196 | .open = acpi_video_bus_info_open_fs, |
196 | .read = seq_read, | 197 | .read = seq_read, |
197 | .llseek = seq_lseek, | 198 | .llseek = seq_lseek, |
@@ -200,6 +201,7 @@ static struct file_operations acpi_video_bus_info_fops = { | |||
200 | 201 | ||
201 | static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file); | 202 | static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file); |
202 | static struct file_operations acpi_video_bus_ROM_fops = { | 203 | static struct file_operations acpi_video_bus_ROM_fops = { |
204 | .owner = THIS_MODULE, | ||
203 | .open = acpi_video_bus_ROM_open_fs, | 205 | .open = acpi_video_bus_ROM_open_fs, |
204 | .read = seq_read, | 206 | .read = seq_read, |
205 | .llseek = seq_lseek, | 207 | .llseek = seq_lseek, |
@@ -209,6 +211,7 @@ static struct file_operations acpi_video_bus_ROM_fops = { | |||
209 | static int acpi_video_bus_POST_info_open_fs(struct inode *inode, | 211 | static int acpi_video_bus_POST_info_open_fs(struct inode *inode, |
210 | struct file *file); | 212 | struct file *file); |
211 | static struct file_operations acpi_video_bus_POST_info_fops = { | 213 | static struct file_operations acpi_video_bus_POST_info_fops = { |
214 | .owner = THIS_MODULE, | ||
212 | .open = acpi_video_bus_POST_info_open_fs, | 215 | .open = acpi_video_bus_POST_info_open_fs, |
213 | .read = seq_read, | 216 | .read = seq_read, |
214 | .llseek = seq_lseek, | 217 | .llseek = seq_lseek, |
@@ -217,6 +220,7 @@ static struct file_operations acpi_video_bus_POST_info_fops = { | |||
217 | 220 | ||
218 | static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file); | 221 | static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file); |
219 | static struct file_operations acpi_video_bus_POST_fops = { | 222 | static struct file_operations acpi_video_bus_POST_fops = { |
223 | .owner = THIS_MODULE, | ||
220 | .open = acpi_video_bus_POST_open_fs, | 224 | .open = acpi_video_bus_POST_open_fs, |
221 | .read = seq_read, | 225 | .read = seq_read, |
222 | .llseek = seq_lseek, | 226 | .llseek = seq_lseek, |
@@ -225,6 +229,7 @@ static struct file_operations acpi_video_bus_POST_fops = { | |||
225 | 229 | ||
226 | static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file); | 230 | static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file); |
227 | static struct file_operations acpi_video_bus_DOS_fops = { | 231 | static struct file_operations acpi_video_bus_DOS_fops = { |
232 | .owner = THIS_MODULE, | ||
228 | .open = acpi_video_bus_DOS_open_fs, | 233 | .open = acpi_video_bus_DOS_open_fs, |
229 | .read = seq_read, | 234 | .read = seq_read, |
230 | .llseek = seq_lseek, | 235 | .llseek = seq_lseek, |
@@ -235,6 +240,7 @@ static struct file_operations acpi_video_bus_DOS_fops = { | |||
235 | static int acpi_video_device_info_open_fs(struct inode *inode, | 240 | static int acpi_video_device_info_open_fs(struct inode *inode, |
236 | struct file *file); | 241 | struct file *file); |
237 | static struct file_operations acpi_video_device_info_fops = { | 242 | static struct file_operations acpi_video_device_info_fops = { |
243 | .owner = THIS_MODULE, | ||
238 | .open = acpi_video_device_info_open_fs, | 244 | .open = acpi_video_device_info_open_fs, |
239 | .read = seq_read, | 245 | .read = seq_read, |
240 | .llseek = seq_lseek, | 246 | .llseek = seq_lseek, |
@@ -244,6 +250,7 @@ static struct file_operations acpi_video_device_info_fops = { | |||
244 | static int acpi_video_device_state_open_fs(struct inode *inode, | 250 | static int acpi_video_device_state_open_fs(struct inode *inode, |
245 | struct file *file); | 251 | struct file *file); |
246 | static struct file_operations acpi_video_device_state_fops = { | 252 | static struct file_operations acpi_video_device_state_fops = { |
253 | .owner = THIS_MODULE, | ||
247 | .open = acpi_video_device_state_open_fs, | 254 | .open = acpi_video_device_state_open_fs, |
248 | .read = seq_read, | 255 | .read = seq_read, |
249 | .llseek = seq_lseek, | 256 | .llseek = seq_lseek, |
@@ -253,6 +260,7 @@ static struct file_operations acpi_video_device_state_fops = { | |||
253 | static int acpi_video_device_brightness_open_fs(struct inode *inode, | 260 | static int acpi_video_device_brightness_open_fs(struct inode *inode, |
254 | struct file *file); | 261 | struct file *file); |
255 | static struct file_operations acpi_video_device_brightness_fops = { | 262 | static struct file_operations acpi_video_device_brightness_fops = { |
263 | .owner = THIS_MODULE, | ||
256 | .open = acpi_video_device_brightness_open_fs, | 264 | .open = acpi_video_device_brightness_open_fs, |
257 | .read = seq_read, | 265 | .read = seq_read, |
258 | .llseek = seq_lseek, | 266 | .llseek = seq_lseek, |
@@ -262,6 +270,7 @@ static struct file_operations acpi_video_device_brightness_fops = { | |||
262 | static int acpi_video_device_EDID_open_fs(struct inode *inode, | 270 | static int acpi_video_device_EDID_open_fs(struct inode *inode, |
263 | struct file *file); | 271 | struct file *file); |
264 | static struct file_operations acpi_video_device_EDID_fops = { | 272 | static struct file_operations acpi_video_device_EDID_fops = { |
273 | .owner = THIS_MODULE, | ||
265 | .open = acpi_video_device_EDID_open_fs, | 274 | .open = acpi_video_device_EDID_open_fs, |
266 | .read = seq_read, | 275 | .read = seq_read, |
267 | .llseek = seq_lseek, | 276 | .llseek = seq_lseek, |
@@ -1070,51 +1079,36 @@ static int acpi_video_device_add_fs(struct acpi_device *device) | |||
1070 | } | 1079 | } |
1071 | 1080 | ||
1072 | /* 'info' [R] */ | 1081 | /* 'info' [R] */ |
1073 | entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); | 1082 | entry = proc_create_data("info", S_IRUGO, acpi_device_dir(device), |
1083 | &acpi_video_device_info_fops, acpi_driver_data(device)); | ||
1074 | if (!entry) | 1084 | if (!entry) |
1075 | return -ENODEV; | 1085 | return -ENODEV; |
1076 | else { | ||
1077 | entry->proc_fops = &acpi_video_device_info_fops; | ||
1078 | entry->data = acpi_driver_data(device); | ||
1079 | entry->owner = THIS_MODULE; | ||
1080 | } | ||
1081 | 1086 | ||
1082 | /* 'state' [R/W] */ | 1087 | /* 'state' [R/W] */ |
1083 | entry = | 1088 | acpi_video_device_state_fops.write = acpi_video_device_write_state; |
1084 | create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR, | 1089 | entry = proc_create_data("state", S_IFREG | S_IRUGO | S_IWUSR, |
1085 | acpi_device_dir(device)); | 1090 | acpi_device_dir(device), |
1091 | &acpi_video_device_state_fops, | ||
1092 | acpi_driver_data(device)); | ||
1086 | if (!entry) | 1093 | if (!entry) |
1087 | return -ENODEV; | 1094 | return -ENODEV; |
1088 | else { | ||
1089 | acpi_video_device_state_fops.write = acpi_video_device_write_state; | ||
1090 | entry->proc_fops = &acpi_video_device_state_fops; | ||
1091 | entry->data = acpi_driver_data(device); | ||
1092 | entry->owner = THIS_MODULE; | ||
1093 | } | ||
1094 | 1095 | ||
1095 | /* 'brightness' [R/W] */ | 1096 | /* 'brightness' [R/W] */ |
1096 | entry = | 1097 | acpi_video_device_brightness_fops.write = |
1097 | create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR, | 1098 | acpi_video_device_write_brightness; |
1098 | acpi_device_dir(device)); | 1099 | entry = proc_create_data("brightness", S_IFREG | S_IRUGO | S_IWUSR, |
1100 | acpi_device_dir(device), | ||
1101 | &acpi_video_device_brightness_fops, | ||
1102 | acpi_driver_data(device)); | ||
1099 | if (!entry) | 1103 | if (!entry) |
1100 | return -ENODEV; | 1104 | return -ENODEV; |
1101 | else { | ||
1102 | acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness; | ||
1103 | entry->proc_fops = &acpi_video_device_brightness_fops; | ||
1104 | entry->data = acpi_driver_data(device); | ||
1105 | entry->owner = THIS_MODULE; | ||
1106 | } | ||
1107 | 1105 | ||
1108 | /* 'EDID' [R] */ | 1106 | /* 'EDID' [R] */ |
1109 | entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device)); | 1107 | entry = proc_create_data("EDID", S_IRUGO, acpi_device_dir(device), |
1108 | &acpi_video_device_EDID_fops, | ||
1109 | acpi_driver_data(device)); | ||
1110 | if (!entry) | 1110 | if (!entry) |
1111 | return -ENODEV; | 1111 | return -ENODEV; |
1112 | else { | ||
1113 | entry->proc_fops = &acpi_video_device_EDID_fops; | ||
1114 | entry->data = acpi_driver_data(device); | ||
1115 | entry->owner = THIS_MODULE; | ||
1116 | } | ||
1117 | |||
1118 | return 0; | 1112 | return 0; |
1119 | } | 1113 | } |
1120 | 1114 | ||
@@ -1353,61 +1347,43 @@ static int acpi_video_bus_add_fs(struct acpi_device *device) | |||
1353 | } | 1347 | } |
1354 | 1348 | ||
1355 | /* 'info' [R] */ | 1349 | /* 'info' [R] */ |
1356 | entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); | 1350 | entry = proc_create_data("info", S_IRUGO, acpi_device_dir(device), |
1351 | &acpi_video_bus_info_fops, | ||
1352 | acpi_driver_data(device)); | ||
1357 | if (!entry) | 1353 | if (!entry) |
1358 | return -ENODEV; | 1354 | return -ENODEV; |
1359 | else { | ||
1360 | entry->proc_fops = &acpi_video_bus_info_fops; | ||
1361 | entry->data = acpi_driver_data(device); | ||
1362 | entry->owner = THIS_MODULE; | ||
1363 | } | ||
1364 | 1355 | ||
1365 | /* 'ROM' [R] */ | 1356 | /* 'ROM' [R] */ |
1366 | entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device)); | 1357 | entry = proc_create_data("ROM", S_IRUGO, acpi_device_dir(device), |
1358 | &acpi_video_bus_ROM_fops, | ||
1359 | acpi_driver_data(device)); | ||
1367 | if (!entry) | 1360 | if (!entry) |
1368 | return -ENODEV; | 1361 | return -ENODEV; |
1369 | else { | ||
1370 | entry->proc_fops = &acpi_video_bus_ROM_fops; | ||
1371 | entry->data = acpi_driver_data(device); | ||
1372 | entry->owner = THIS_MODULE; | ||
1373 | } | ||
1374 | 1362 | ||
1375 | /* 'POST_info' [R] */ | 1363 | /* 'POST_info' [R] */ |
1376 | entry = | 1364 | entry = proc_create_data("POST_info", S_IRUGO, acpi_device_dir(device), |
1377 | create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device)); | 1365 | &acpi_video_bus_POST_info_fops, |
1366 | acpi_driver_data(device)); | ||
1378 | if (!entry) | 1367 | if (!entry) |
1379 | return -ENODEV; | 1368 | return -ENODEV; |
1380 | else { | ||
1381 | entry->proc_fops = &acpi_video_bus_POST_info_fops; | ||
1382 | entry->data = acpi_driver_data(device); | ||
1383 | entry->owner = THIS_MODULE; | ||
1384 | } | ||
1385 | 1369 | ||
1386 | /* 'POST' [R/W] */ | 1370 | /* 'POST' [R/W] */ |
1387 | entry = | 1371 | acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST; |
1388 | create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR, | 1372 | entry = proc_create_data("POST", S_IFREG | S_IRUGO | S_IRUSR, |
1389 | acpi_device_dir(device)); | 1373 | acpi_device_dir(device), |
1374 | &acpi_video_bus_POST_fops, | ||
1375 | acpi_driver_data(device)); | ||
1390 | if (!entry) | 1376 | if (!entry) |
1391 | return -ENODEV; | 1377 | return -ENODEV; |
1392 | else { | ||
1393 | acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST; | ||
1394 | entry->proc_fops = &acpi_video_bus_POST_fops; | ||
1395 | entry->data = acpi_driver_data(device); | ||
1396 | entry->owner = THIS_MODULE; | ||
1397 | } | ||
1398 | 1378 | ||
1399 | /* 'DOS' [R/W] */ | 1379 | /* 'DOS' [R/W] */ |
1400 | entry = | 1380 | acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS; |
1401 | create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR, | 1381 | entry = proc_create_data("DOS", S_IFREG | S_IRUGO | S_IRUSR, |
1402 | acpi_device_dir(device)); | 1382 | acpi_device_dir(device), |
1383 | &acpi_video_bus_DOS_fops, | ||
1384 | acpi_driver_data(device)); | ||
1403 | if (!entry) | 1385 | if (!entry) |
1404 | return -ENODEV; | 1386 | return -ENODEV; |
1405 | else { | ||
1406 | acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS; | ||
1407 | entry->proc_fops = &acpi_video_bus_DOS_fops; | ||
1408 | entry->data = acpi_driver_data(device); | ||
1409 | entry->owner = THIS_MODULE; | ||
1410 | } | ||
1411 | 1387 | ||
1412 | return 0; | 1388 | return 0; |
1413 | } | 1389 | } |