aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/thermal.c
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-04-29 04:02:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:22 -0400
commitcf7acfab032ff262f42954328cdfd20a5d9aaaac (patch)
tree231698d72d4508f3b26f606f18ef844387ec43e5 /drivers/acpi/thermal.c
parent667471386d4068e75a6a55b615701ced61eb6333 (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/thermal.c')
-rw-r--r--drivers/acpi/thermal.c67
1 files changed, 28 insertions, 39 deletions
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 766bd25d3376..0815ac3ae3d6 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -198,6 +198,7 @@ struct acpi_thermal {
198}; 198};
199 199
200static const struct file_operations acpi_thermal_state_fops = { 200static const struct file_operations acpi_thermal_state_fops = {
201 .owner = THIS_MODULE,
201 .open = acpi_thermal_state_open_fs, 202 .open = acpi_thermal_state_open_fs,
202 .read = seq_read, 203 .read = seq_read,
203 .llseek = seq_lseek, 204 .llseek = seq_lseek,
@@ -205,6 +206,7 @@ static const struct file_operations acpi_thermal_state_fops = {
205}; 206};
206 207
207static const struct file_operations acpi_thermal_temp_fops = { 208static const struct file_operations acpi_thermal_temp_fops = {
209 .owner = THIS_MODULE,
208 .open = acpi_thermal_temp_open_fs, 210 .open = acpi_thermal_temp_open_fs,
209 .read = seq_read, 211 .read = seq_read,
210 .llseek = seq_lseek, 212 .llseek = seq_lseek,
@@ -212,6 +214,7 @@ static const struct file_operations acpi_thermal_temp_fops = {
212}; 214};
213 215
214static const struct file_operations acpi_thermal_trip_fops = { 216static const struct file_operations acpi_thermal_trip_fops = {
217 .owner = THIS_MODULE,
215 .open = acpi_thermal_trip_open_fs, 218 .open = acpi_thermal_trip_open_fs,
216 .read = seq_read, 219 .read = seq_read,
217 .llseek = seq_lseek, 220 .llseek = seq_lseek,
@@ -219,6 +222,7 @@ static const struct file_operations acpi_thermal_trip_fops = {
219}; 222};
220 223
221static const struct file_operations acpi_thermal_cooling_fops = { 224static const struct file_operations acpi_thermal_cooling_fops = {
225 .owner = THIS_MODULE,
222 .open = acpi_thermal_cooling_open_fs, 226 .open = acpi_thermal_cooling_open_fs,
223 .read = seq_read, 227 .read = seq_read,
224 .write = acpi_thermal_write_cooling_mode, 228 .write = acpi_thermal_write_cooling_mode,
@@ -227,6 +231,7 @@ static const struct file_operations acpi_thermal_cooling_fops = {
227}; 231};
228 232
229static const struct file_operations acpi_thermal_polling_fops = { 233static const struct file_operations acpi_thermal_polling_fops = {
234 .owner = THIS_MODULE,
230 .open = acpi_thermal_polling_open_fs, 235 .open = acpi_thermal_polling_open_fs,
231 .read = seq_read, 236 .read = seq_read,
232 .write = acpi_thermal_write_polling, 237 .write = acpi_thermal_write_polling,
@@ -1419,63 +1424,47 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
1419 } 1424 }
1420 1425
1421 /* 'state' [R] */ 1426 /* 'state' [R] */
1422 entry = create_proc_entry(ACPI_THERMAL_FILE_STATE, 1427 entry = proc_create_data(ACPI_THERMAL_FILE_STATE,
1423 S_IRUGO, acpi_device_dir(device)); 1428 S_IRUGO, acpi_device_dir(device),
1429 &acpi_thermal_state_fops,
1430 acpi_driver_data(device));
1424 if (!entry) 1431 if (!entry)
1425 return -ENODEV; 1432 return -ENODEV;
1426 else {
1427 entry->proc_fops = &acpi_thermal_state_fops;
1428 entry->data = acpi_driver_data(device);
1429 entry->owner = THIS_MODULE;
1430 }
1431 1433
1432 /* 'temperature' [R] */ 1434 /* 'temperature' [R] */
1433 entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE, 1435 entry = proc_create_data(ACPI_THERMAL_FILE_TEMPERATURE,
1434 S_IRUGO, acpi_device_dir(device)); 1436 S_IRUGO, acpi_device_dir(device),
1437 &acpi_thermal_temp_fops,
1438 acpi_driver_data(device));
1435 if (!entry) 1439 if (!entry)
1436 return -ENODEV; 1440 return -ENODEV;
1437 else {
1438 entry->proc_fops = &acpi_thermal_temp_fops;
1439 entry->data = acpi_driver_data(device);
1440 entry->owner = THIS_MODULE;
1441 }
1442 1441
1443 /* 'trip_points' [R] */ 1442 /* 'trip_points' [R] */
1444 entry = create_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS, 1443 entry = proc_create_data(ACPI_THERMAL_FILE_TRIP_POINTS,
1445 S_IRUGO, 1444 S_IRUGO,
1446 acpi_device_dir(device)); 1445 acpi_device_dir(device),
1446 &acpi_thermal_trip_fops,
1447 acpi_driver_data(device));
1447 if (!entry) 1448 if (!entry)
1448 return -ENODEV; 1449 return -ENODEV;
1449 else {
1450 entry->proc_fops = &acpi_thermal_trip_fops;
1451 entry->data = acpi_driver_data(device);
1452 entry->owner = THIS_MODULE;
1453 }
1454 1450
1455 /* 'cooling_mode' [R/W] */ 1451 /* 'cooling_mode' [R/W] */
1456 entry = create_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE, 1452 entry = proc_create_data(ACPI_THERMAL_FILE_COOLING_MODE,
1457 S_IFREG | S_IRUGO | S_IWUSR, 1453 S_IFREG | S_IRUGO | S_IWUSR,
1458 acpi_device_dir(device)); 1454 acpi_device_dir(device),
1455 &acpi_thermal_cooling_fops,
1456 acpi_driver_data(device));
1459 if (!entry) 1457 if (!entry)
1460 return -ENODEV; 1458 return -ENODEV;
1461 else {
1462 entry->proc_fops = &acpi_thermal_cooling_fops;
1463 entry->data = acpi_driver_data(device);
1464 entry->owner = THIS_MODULE;
1465 }
1466 1459
1467 /* 'polling_frequency' [R/W] */ 1460 /* 'polling_frequency' [R/W] */
1468 entry = create_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ, 1461 entry = proc_create_data(ACPI_THERMAL_FILE_POLLING_FREQ,
1469 S_IFREG | S_IRUGO | S_IWUSR, 1462 S_IFREG | S_IRUGO | S_IWUSR,
1470 acpi_device_dir(device)); 1463 acpi_device_dir(device),
1464 &acpi_thermal_polling_fops,
1465 acpi_driver_data(device));
1471 if (!entry) 1466 if (!entry)
1472 return -ENODEV; 1467 return -ENODEV;
1473 else {
1474 entry->proc_fops = &acpi_thermal_polling_fops;
1475 entry->data = acpi_driver_data(device);
1476 entry->owner = THIS_MODULE;
1477 }
1478
1479 return 0; 1468 return 0;
1480} 1469}
1481 1470