Commit 52a619c7 authored by Andy Grover's avatar Andy Grover

ACPI: Make unload/reload of modules work properly w.r.t. /proc

parent f0b8f932
...@@ -159,12 +159,6 @@ acpi_ac_add_fs ( ...@@ -159,12 +159,6 @@ acpi_ac_add_fs (
ACPI_FUNCTION_TRACE("acpi_ac_add_fs"); ACPI_FUNCTION_TRACE("acpi_ac_add_fs");
if (!acpi_ac_dir) {
acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir);
if (!acpi_ac_dir)
return_VALUE(-ENODEV);
}
if (!acpi_device_dir(device)) { if (!acpi_device_dir(device)) {
acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
acpi_ac_dir); acpi_ac_dir);
...@@ -194,9 +188,6 @@ acpi_ac_remove_fs ( ...@@ -194,9 +188,6 @@ acpi_ac_remove_fs (
{ {
ACPI_FUNCTION_TRACE("acpi_ac_remove_fs"); ACPI_FUNCTION_TRACE("acpi_ac_remove_fs");
if (!acpi_ac_dir)
return_VALUE(-ENODEV);
if (acpi_device_dir(device)) if (acpi_device_dir(device))
remove_proc_entry(acpi_device_bid(device), acpi_ac_dir); remove_proc_entry(acpi_device_bid(device), acpi_ac_dir);
...@@ -330,6 +321,10 @@ acpi_ac_init (void) ...@@ -330,6 +321,10 @@ acpi_ac_init (void)
ACPI_FUNCTION_TRACE("acpi_ac_init"); ACPI_FUNCTION_TRACE("acpi_ac_init");
acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir);
if (!acpi_ac_dir)
return_VALUE(-ENODEV);
result = acpi_bus_register_driver(&acpi_ac_driver); result = acpi_bus_register_driver(&acpi_ac_driver);
if (result < 0) { if (result < 0) {
remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
...@@ -343,13 +338,11 @@ acpi_ac_init (void) ...@@ -343,13 +338,11 @@ acpi_ac_init (void)
void __exit void __exit
acpi_ac_exit (void) acpi_ac_exit (void)
{ {
int result = 0;
ACPI_FUNCTION_TRACE("acpi_ac_exit"); ACPI_FUNCTION_TRACE("acpi_ac_exit");
result = acpi_bus_unregister_driver(&acpi_ac_driver); acpi_bus_unregister_driver(&acpi_ac_driver);
if (!result)
remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
return_VOID; return_VOID;
} }
......
...@@ -615,12 +615,6 @@ acpi_battery_add_fs ( ...@@ -615,12 +615,6 @@ acpi_battery_add_fs (
ACPI_FUNCTION_TRACE("acpi_battery_add_fs"); ACPI_FUNCTION_TRACE("acpi_battery_add_fs");
if (!acpi_battery_dir) {
acpi_battery_dir = proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir);
if (!acpi_battery_dir)
return_VALUE(-ENODEV);
}
if (!acpi_device_dir(device)) { if (!acpi_device_dir(device)) {
acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
acpi_battery_dir); acpi_battery_dir);
...@@ -675,9 +669,6 @@ acpi_battery_remove_fs ( ...@@ -675,9 +669,6 @@ acpi_battery_remove_fs (
{ {
ACPI_FUNCTION_TRACE("acpi_battery_remove_fs"); ACPI_FUNCTION_TRACE("acpi_battery_remove_fs");
if (!acpi_battery_dir)
return_VALUE(-ENODEV);
if (acpi_device_dir(device)) if (acpi_device_dir(device))
remove_proc_entry(acpi_device_bid(device), acpi_battery_dir); remove_proc_entry(acpi_device_bid(device), acpi_battery_dir);
...@@ -812,6 +803,10 @@ acpi_battery_init (void) ...@@ -812,6 +803,10 @@ acpi_battery_init (void)
ACPI_FUNCTION_TRACE("acpi_battery_init"); ACPI_FUNCTION_TRACE("acpi_battery_init");
acpi_battery_dir = proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir);
if (!acpi_battery_dir)
return_VALUE(-ENODEV);
result = acpi_bus_register_driver(&acpi_battery_driver); result = acpi_bus_register_driver(&acpi_battery_driver);
if (result < 0) { if (result < 0) {
remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
...@@ -825,13 +820,11 @@ acpi_battery_init (void) ...@@ -825,13 +820,11 @@ acpi_battery_init (void)
static void __exit static void __exit
acpi_battery_exit (void) acpi_battery_exit (void)
{ {
int result = 0;
ACPI_FUNCTION_TRACE("acpi_battery_exit"); ACPI_FUNCTION_TRACE("acpi_battery_exit");
result = acpi_bus_unregister_driver(&acpi_battery_driver); acpi_bus_unregister_driver(&acpi_battery_driver);
if (!result)
remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
return_VOID; return_VOID;
} }
......
...@@ -141,12 +141,6 @@ acpi_button_add_fs ( ...@@ -141,12 +141,6 @@ acpi_button_add_fs (
button = acpi_driver_data(device); button = acpi_driver_data(device);
if (!acpi_button_dir) {
acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
if (!acpi_button_dir)
return_VALUE(-ENODEV);
}
switch (button->type) { switch (button->type) {
case ACPI_BUTTON_TYPE_POWER: case ACPI_BUTTON_TYPE_POWER:
case ACPI_BUTTON_TYPE_POWERF: case ACPI_BUTTON_TYPE_POWERF:
...@@ -190,9 +184,6 @@ acpi_button_remove_fs ( ...@@ -190,9 +184,6 @@ acpi_button_remove_fs (
{ {
ACPI_FUNCTION_TRACE("acpi_button_remove_fs"); ACPI_FUNCTION_TRACE("acpi_button_remove_fs");
if (!acpi_button_dir)
return_VALUE(-ENODEV);
if (acpi_device_dir(device)) if (acpi_device_dir(device))
remove_proc_entry(acpi_device_bid(device), acpi_button_dir); remove_proc_entry(acpi_device_bid(device), acpi_button_dir);
...@@ -446,9 +437,15 @@ acpi_button_init (void) ...@@ -446,9 +437,15 @@ acpi_button_init (void)
ACPI_FUNCTION_TRACE("acpi_button_init"); ACPI_FUNCTION_TRACE("acpi_button_init");
acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
if (!acpi_button_dir)
return_VALUE(-ENODEV);
result = acpi_bus_register_driver(&acpi_button_driver); result = acpi_bus_register_driver(&acpi_button_driver);
if (result < 0) if (result < 0) {
remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
}
return_VALUE(0); return_VALUE(0);
} }
...@@ -461,6 +458,8 @@ acpi_button_exit (void) ...@@ -461,6 +458,8 @@ acpi_button_exit (void)
acpi_bus_unregister_driver(&acpi_button_driver); acpi_bus_unregister_driver(&acpi_button_driver);
remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
return_VOID; return_VOID;
} }
......
...@@ -477,12 +477,6 @@ acpi_ec_add_fs ( ...@@ -477,12 +477,6 @@ acpi_ec_add_fs (
ACPI_FUNCTION_TRACE("acpi_ec_add_fs"); ACPI_FUNCTION_TRACE("acpi_ec_add_fs");
if (!acpi_ec_dir) {
acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
if (!acpi_ec_dir)
return_VALUE(-ENODEV);
}
if (!acpi_device_dir(device)) { if (!acpi_device_dir(device)) {
acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
acpi_ec_dir); acpi_ec_dir);
...@@ -508,12 +502,6 @@ acpi_ec_remove_fs ( ...@@ -508,12 +502,6 @@ acpi_ec_remove_fs (
{ {
ACPI_FUNCTION_TRACE("acpi_ec_remove_fs"); ACPI_FUNCTION_TRACE("acpi_ec_remove_fs");
if (!acpi_ec_dir)
return_VALUE(-ENODEV);
if (acpi_device_dir(device))
remove_proc_entry(acpi_device_bid(device), acpi_ec_dir);
return_VALUE(0); return_VALUE(0);
} }
...@@ -789,8 +777,17 @@ static int __init acpi_ec_init (void) ...@@ -789,8 +777,17 @@ static int __init acpi_ec_init (void)
if (acpi_disabled) if (acpi_disabled)
return_VALUE(0); return_VALUE(0);
acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
if (!acpi_ec_dir)
return_VALUE(-ENODEV);
/* Now register the driver for the EC */ /* Now register the driver for the EC */
result = acpi_bus_register_driver(&acpi_ec_driver); result = acpi_bus_register_driver(&acpi_ec_driver);
if (result < 0) {
remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
return_VALUE(-ENODEV);
}
return_VALUE(result); return_VALUE(result);
} }
...@@ -813,14 +810,11 @@ acpi_ec_ecdt_exit (void) ...@@ -813,14 +810,11 @@ acpi_ec_ecdt_exit (void)
static void __exit static void __exit
acpi_ec_exit (void) acpi_ec_exit (void)
{ {
int result = 0;
ACPI_FUNCTION_TRACE("acpi_ec_exit"); ACPI_FUNCTION_TRACE("acpi_ec_exit");
result = acpi_bus_unregister_driver(&acpi_ec_driver); acpi_bus_unregister_driver(&acpi_ec_driver);
if (!result)
remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
acpi_ec_ecdt_exit(); acpi_ec_ecdt_exit();
......
...@@ -151,12 +151,6 @@ acpi_fan_add_fs ( ...@@ -151,12 +151,6 @@ acpi_fan_add_fs (
if (!device) if (!device)
return_VALUE(-EINVAL); return_VALUE(-EINVAL);
if (!acpi_fan_dir) {
acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir);
if (!acpi_fan_dir)
return_VALUE(-ENODEV);
}
if (!acpi_device_dir(device)) { if (!acpi_device_dir(device)) {
acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
acpi_fan_dir); acpi_fan_dir);
...@@ -187,9 +181,6 @@ acpi_fan_remove_fs ( ...@@ -187,9 +181,6 @@ acpi_fan_remove_fs (
{ {
ACPI_FUNCTION_TRACE("acpi_fan_remove_fs"); ACPI_FUNCTION_TRACE("acpi_fan_remove_fs");
if (!acpi_fan_dir)
return_VALUE(-ENODEV);
if (acpi_device_dir(device)) if (acpi_device_dir(device))
remove_proc_entry(acpi_device_bid(device), acpi_fan_dir); remove_proc_entry(acpi_device_bid(device), acpi_fan_dir);
...@@ -276,9 +267,15 @@ acpi_fan_init (void) ...@@ -276,9 +267,15 @@ acpi_fan_init (void)
ACPI_FUNCTION_TRACE("acpi_fan_init"); ACPI_FUNCTION_TRACE("acpi_fan_init");
acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir);
if (!acpi_fan_dir)
return_VALUE(-ENODEV);
result = acpi_bus_register_driver(&acpi_fan_driver); result = acpi_bus_register_driver(&acpi_fan_driver);
if (result < 0) if (result < 0) {
remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
}
return_VALUE(0); return_VALUE(0);
} }
...@@ -287,13 +284,11 @@ acpi_fan_init (void) ...@@ -287,13 +284,11 @@ acpi_fan_init (void)
void __exit void __exit
acpi_fan_exit (void) acpi_fan_exit (void)
{ {
int result = 0;
ACPI_FUNCTION_TRACE("acpi_fan_exit"); ACPI_FUNCTION_TRACE("acpi_fan_exit");
result = acpi_bus_unregister_driver(&acpi_fan_driver); acpi_bus_unregister_driver(&acpi_fan_driver);
if (!result)
remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir); remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
return_VOID; return_VOID;
} }
......
...@@ -443,12 +443,6 @@ acpi_power_add_fs ( ...@@ -443,12 +443,6 @@ acpi_power_add_fs (
if (!device) if (!device)
return_VALUE(-EINVAL); return_VALUE(-EINVAL);
if (!acpi_power_dir) {
acpi_power_dir = proc_mkdir(ACPI_POWER_CLASS, acpi_root_dir);
if (!acpi_power_dir)
return_VALUE(-ENODEV);
}
if (!acpi_device_dir(device)) { if (!acpi_device_dir(device)) {
acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
acpi_power_dir); acpi_power_dir);
...@@ -478,9 +472,6 @@ acpi_power_remove_fs ( ...@@ -478,9 +472,6 @@ acpi_power_remove_fs (
{ {
ACPI_FUNCTION_TRACE("acpi_power_remove_fs"); ACPI_FUNCTION_TRACE("acpi_power_remove_fs");
if (!acpi_power_dir)
return_VALUE(-ENODEV);
if (acpi_device_dir(device)) if (acpi_device_dir(device))
remove_proc_entry(acpi_device_bid(device), acpi_power_dir); remove_proc_entry(acpi_device_bid(device), acpi_power_dir);
...@@ -591,6 +582,10 @@ static int __init acpi_power_init (void) ...@@ -591,6 +582,10 @@ static int __init acpi_power_init (void)
INIT_LIST_HEAD(&acpi_power_resource_list); INIT_LIST_HEAD(&acpi_power_resource_list);
acpi_power_dir = proc_mkdir(ACPI_POWER_CLASS, acpi_root_dir);
if (!acpi_power_dir)
return_VALUE(-ENODEV);
result = acpi_bus_register_driver(&acpi_power_driver); result = acpi_bus_register_driver(&acpi_power_driver);
if (result < 0) { if (result < 0) {
remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir); remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir);
......
...@@ -2289,13 +2289,6 @@ acpi_processor_add_fs ( ...@@ -2289,13 +2289,6 @@ acpi_processor_add_fs (
ACPI_FUNCTION_TRACE("acpi_processor_add_fs"); ACPI_FUNCTION_TRACE("acpi_processor_add_fs");
if (!acpi_processor_dir) {
acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS,
acpi_root_dir);
if (!acpi_processor_dir)
return_VALUE(-ENODEV);
}
if (!acpi_device_dir(device)) { if (!acpi_device_dir(device)) {
acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
acpi_processor_dir); acpi_processor_dir);
...@@ -2378,9 +2371,6 @@ acpi_processor_remove_fs ( ...@@ -2378,9 +2371,6 @@ acpi_processor_remove_fs (
{ {
ACPI_FUNCTION_TRACE("acpi_processor_remove_fs"); ACPI_FUNCTION_TRACE("acpi_processor_remove_fs");
if (!acpi_processor_dir)
return_VALUE(-ENODEV);
if (acpi_device_dir(device)) if (acpi_device_dir(device))
remove_proc_entry(acpi_device_bid(device), acpi_processor_dir); remove_proc_entry(acpi_device_bid(device), acpi_processor_dir);
...@@ -2640,9 +2630,15 @@ acpi_processor_init (void) ...@@ -2640,9 +2630,15 @@ acpi_processor_init (void)
memset(&processors, 0, sizeof(processors)); memset(&processors, 0, sizeof(processors));
memset(&errata, 0, sizeof(errata)); memset(&errata, 0, sizeof(errata));
acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir);
if (!acpi_processor_dir)
return_VALUE(-ENODEV);
result = acpi_bus_register_driver(&acpi_processor_driver); result = acpi_bus_register_driver(&acpi_processor_driver);
if (result < 0) if (result < 0) {
remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
}
return_VALUE(0); return_VALUE(0);
} }
...@@ -2651,13 +2647,11 @@ acpi_processor_init (void) ...@@ -2651,13 +2647,11 @@ acpi_processor_init (void)
static void __exit static void __exit
acpi_processor_exit (void) acpi_processor_exit (void)
{ {
int result = 0;
ACPI_FUNCTION_TRACE("acpi_processor_exit"); ACPI_FUNCTION_TRACE("acpi_processor_exit");
result = acpi_bus_unregister_driver(&acpi_processor_driver); acpi_bus_unregister_driver(&acpi_processor_driver);
if (!result)
remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
return_VOID; return_VOID;
} }
......
...@@ -1060,13 +1060,6 @@ acpi_thermal_add_fs ( ...@@ -1060,13 +1060,6 @@ acpi_thermal_add_fs (
ACPI_FUNCTION_TRACE("acpi_thermal_add_fs"); ACPI_FUNCTION_TRACE("acpi_thermal_add_fs");
if (!acpi_thermal_dir) {
acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS,
acpi_root_dir);
if (!acpi_thermal_dir)
return_VALUE(-ENODEV);
}
if (!acpi_device_dir(device)) { if (!acpi_device_dir(device)) {
acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
acpi_thermal_dir); acpi_thermal_dir);
...@@ -1147,9 +1140,6 @@ acpi_thermal_remove_fs ( ...@@ -1147,9 +1140,6 @@ acpi_thermal_remove_fs (
{ {
ACPI_FUNCTION_TRACE("acpi_thermal_remove_fs"); ACPI_FUNCTION_TRACE("acpi_thermal_remove_fs");
if (!acpi_thermal_dir)
return_VALUE(-ENODEV);
if (acpi_device_dir(device)) if (acpi_device_dir(device))
remove_proc_entry(acpi_device_bid(device), acpi_thermal_dir); remove_proc_entry(acpi_device_bid(device), acpi_thermal_dir);
...@@ -1351,9 +1341,15 @@ acpi_thermal_init (void) ...@@ -1351,9 +1341,15 @@ acpi_thermal_init (void)
ACPI_FUNCTION_TRACE("acpi_thermal_init"); ACPI_FUNCTION_TRACE("acpi_thermal_init");
acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir);
if (!acpi_thermal_dir)
return_VALUE(-ENODEV);
result = acpi_bus_register_driver(&acpi_thermal_driver); result = acpi_bus_register_driver(&acpi_thermal_driver);
if (result < 0) if (result < 0) {
remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
return_VALUE(-ENODEV); return_VALUE(-ENODEV);
}
return_VALUE(0); return_VALUE(0);
} }
...@@ -1362,13 +1358,11 @@ acpi_thermal_init (void) ...@@ -1362,13 +1358,11 @@ acpi_thermal_init (void)
static void __exit static void __exit
acpi_thermal_exit (void) acpi_thermal_exit (void)
{ {
int result = 0;
ACPI_FUNCTION_TRACE("acpi_thermal_exit"); ACPI_FUNCTION_TRACE("acpi_thermal_exit");
result = acpi_bus_unregister_driver(&acpi_thermal_driver); acpi_bus_unregister_driver(&acpi_thermal_driver);
if (!result)
remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
return_VOID; return_VOID;
} }
......
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