Commit da6a1551 authored by Len Brown's avatar Len Brown Committed by Len Brown

[ACPI] rmmod ACPI modules vs /proc

from Anil S Keshavamurthy and David Shaohua Li
http://bugzilla.kernel.org/show_bug.cgi?id=2457
parent b7b8c5cb
......@@ -158,6 +158,7 @@ acpi_ac_add_fs (
acpi_ac_dir);
if (!acpi_device_dir(device))
return_VALUE(-ENODEV);
acpi_device_dir(device)->owner = THIS_MODULE;
}
/* 'state' [R] */
......@@ -170,6 +171,7 @@ acpi_ac_add_fs (
else {
entry->proc_fops = &acpi_ac_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
return_VALUE(0);
......@@ -320,6 +322,7 @@ acpi_ac_init (void)
acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir);
if (!acpi_ac_dir)
return_VALUE(-ENODEV);
acpi_ac_dir->owner = THIS_MODULE;
result = acpi_bus_register_driver(&acpi_ac_driver);
if (result < 0) {
......
......@@ -625,6 +625,7 @@ acpi_battery_add_fs (
acpi_battery_dir);
if (!acpi_device_dir(device))
return_VALUE(-ENODEV);
acpi_device_dir(device)->owner = THIS_MODULE;
}
/* 'info' [R] */
......@@ -637,6 +638,7 @@ acpi_battery_add_fs (
else {
entry->read_proc = acpi_battery_read_info;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'status' [R] */
......@@ -649,6 +651,7 @@ acpi_battery_add_fs (
else {
entry->read_proc = acpi_battery_read_state;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'alarm' [R/W] */
......@@ -662,6 +665,7 @@ acpi_battery_add_fs (
entry->read_proc = acpi_battery_read_alarm;
entry->write_proc = acpi_battery_write_alarm;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
return_VALUE(0);
......@@ -813,6 +817,7 @@ acpi_battery_init (void)
acpi_battery_dir = proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir);
if (!acpi_battery_dir)
return_VALUE(-ENODEV);
acpi_battery_dir->owner = THIS_MODULE;
result = acpi_bus_register_driver(&acpi_battery_driver);
if (result < 0) {
......
......@@ -187,9 +187,14 @@ acpi_button_add_fs (
break;
}
if (!entry)
return_VALUE(-ENODEV);
entry->owner = THIS_MODULE;
acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry);
if (!acpi_device_dir(device))
return_VALUE(-ENODEV);
acpi_device_dir(device)->owner = THIS_MODULE;
/* 'info' [R] */
entry = create_proc_entry(ACPI_BUTTON_FILE_INFO,
......@@ -201,6 +206,7 @@ acpi_button_add_fs (
else {
entry->proc_fops = &acpi_button_info_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* show lid state [R] */
......@@ -214,6 +220,7 @@ acpi_button_add_fs (
else {
entry->proc_fops = &acpi_button_state_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
}
......@@ -225,10 +232,28 @@ static int
acpi_button_remove_fs (
struct acpi_device *device)
{
struct acpi_button *button = NULL;
ACPI_FUNCTION_TRACE("acpi_button_remove_fs");
button = acpi_driver_data(device);
if (acpi_device_dir(device)) {
remove_proc_entry(acpi_device_bid(device), acpi_button_dir);
switch (button->type) {
case ACPI_BUTTON_TYPE_POWER:
case ACPI_BUTTON_TYPE_POWERF:
remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER,
acpi_button_dir);
break;
case ACPI_BUTTON_TYPE_SLEEP:
case ACPI_BUTTON_TYPE_SLEEPF:
remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP,
acpi_button_dir);
break;
case ACPI_BUTTON_TYPE_LID:
remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID,
acpi_button_dir);
break;
}
acpi_device_dir(device) = NULL;
}
......@@ -485,6 +510,7 @@ acpi_button_init (void)
acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
if (!acpi_button_dir)
return_VALUE(-ENODEV);
acpi_button_dir->owner = THIS_MODULE;
result = acpi_bus_register_driver(&acpi_button_driver);
if (result < 0) {
......
......@@ -157,6 +157,7 @@ acpi_fan_add_fs (
acpi_fan_dir);
if (!acpi_device_dir(device))
return_VALUE(-ENODEV);
acpi_device_dir(device)->owner = THIS_MODULE;
}
/* 'status' [R/W] */
......@@ -170,6 +171,7 @@ acpi_fan_add_fs (
entry->read_proc = acpi_fan_read_state;
entry->write_proc = acpi_fan_write_state;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
return_VALUE(0);
......@@ -273,6 +275,7 @@ acpi_fan_init (void)
acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir);
if (!acpi_fan_dir)
return_VALUE(-ENODEV);
acpi_fan_dir->owner = THIS_MODULE;
result = acpi_bus_register_driver(&acpi_fan_driver);
if (result < 0) {
......
......@@ -1190,6 +1190,7 @@ acpi_cpufreq_add_file (
entry->proc_fops = &acpi_processor_perf_fops;
entry->proc_fops->write = acpi_processor_write_performance;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
return_VOID;
}
......@@ -2066,6 +2067,7 @@ acpi_processor_add_fs (
if (!acpi_device_dir(device))
return_VALUE(-ENODEV);
}
acpi_device_dir(device)->owner = THIS_MODULE;
/* 'info' [R] */
entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO,
......@@ -2077,6 +2079,7 @@ acpi_processor_add_fs (
else {
entry->proc_fops = &acpi_processor_info_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'power' [R] */
......@@ -2089,6 +2092,7 @@ acpi_processor_add_fs (
else {
entry->proc_fops = &acpi_processor_power_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'throttling' [R/W] */
......@@ -2102,6 +2106,7 @@ acpi_processor_add_fs (
entry->proc_fops = &acpi_processor_throttling_fops;
entry->proc_fops->write = acpi_processor_write_throttling;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'limit' [R/W] */
......@@ -2115,6 +2120,7 @@ acpi_processor_add_fs (
entry->proc_fops = &acpi_processor_limit_fops;
entry->proc_fops->write = acpi_processor_write_limit;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
return_VALUE(0);
......@@ -2128,6 +2134,11 @@ acpi_processor_remove_fs (
ACPI_FUNCTION_TRACE("acpi_processor_remove_fs");
if (acpi_device_dir(device)) {
remove_proc_entry(ACPI_PROCESSOR_FILE_INFO,acpi_device_dir(device));
remove_proc_entry(ACPI_PROCESSOR_FILE_POWER,acpi_device_dir(device));
remove_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING,
acpi_device_dir(device));
remove_proc_entry(ACPI_PROCESSOR_FILE_LIMIT,acpi_device_dir(device));
remove_proc_entry(acpi_device_bid(device), acpi_processor_dir);
acpi_device_dir(device) = NULL;
}
......@@ -2385,6 +2396,7 @@ acpi_processor_init (void)
acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir);
if (!acpi_processor_dir)
return_VALUE(-ENODEV);
acpi_processor_dir->owner = THIS_MODULE;
result = acpi_bus_register_driver(&acpi_processor_driver);
if (result < 0) {
......
......@@ -1060,6 +1060,7 @@ acpi_thermal_add_fs (
acpi_thermal_dir);
if (!acpi_device_dir(device))
return_VALUE(-ENODEV);
acpi_device_dir(device)->owner = THIS_MODULE;
}
/* 'state' [R] */
......@@ -1072,6 +1073,7 @@ acpi_thermal_add_fs (
else {
entry->proc_fops = &acpi_thermal_state_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'temperature' [R] */
......@@ -1084,6 +1086,7 @@ acpi_thermal_add_fs (
else {
entry->proc_fops = &acpi_thermal_temp_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'trip_points' [R/W] */
......@@ -1096,6 +1099,7 @@ acpi_thermal_add_fs (
else {
entry->proc_fops = &acpi_thermal_trip_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'cooling_mode' [R/W] */
......@@ -1108,6 +1112,7 @@ acpi_thermal_add_fs (
else {
entry->proc_fops = &acpi_thermal_cooling_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
/* 'polling_frequency' [R/W] */
......@@ -1120,6 +1125,7 @@ acpi_thermal_add_fs (
else {
entry->proc_fops = &acpi_thermal_polling_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
}
return_VALUE(0);
......@@ -1338,6 +1344,7 @@ acpi_thermal_init (void)
acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir);
if (!acpi_thermal_dir)
return_VALUE(-ENODEV);
acpi_thermal_dir->owner = THIS_MODULE;
result = acpi_bus_register_driver(&acpi_thermal_driver);
if (result < 0) {
......
......@@ -502,6 +502,8 @@ add_device(void)
proc = create_proc_read_entry(item->name,
S_IFREG | S_IRUGO | S_IWUSR,
toshiba_proc_dir, (read_proc_t*)dispatch_read, item);
if (proc)
proc->owner = THIS_MODULE;
if (proc && item->write_func)
proc->write_proc = (write_proc_t*)dispatch_write;
}
......@@ -547,6 +549,7 @@ toshiba_acpi_init(void)
if (!toshiba_proc_dir) {
status = AE_ERROR;
} else {
toshiba_proc_dir->owner = THIS_MODULE;
status = add_device();
if (ACPI_FAILURE(status))
remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
......
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