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