Commit b7002875 authored by Patrick Mochel's avatar Patrick Mochel

ACPI: Remove unnecessary objects and code from drivers/acpi/system.c

First, we remove acpi_system_driver, since it's not really a driver, and making it its own 
object is just silly. This allows us to not have to register it, and we can hence remove
the add and remove callbacks. 

For initialization, acpi_system_add_fs() has been inlined in acpi_system_init(). The proc file
creation was cleaned up to use create_proc_read_entry() where possible. Any failures now
result in a goto Error, which prints the error message previously replicated after each
failure. We also remove all the files that were created if that happens. acpi_system_init()
was made a subsys_initcall and declared static. 

The acpi_system_exit() code and friends was removed, since it's never, ever called. 
parent cd61f673
...@@ -257,14 +257,6 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type); ...@@ -257,14 +257,6 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type);
#define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer" #define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer"
#define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level" #define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level"
#ifdef CONFIG_ACPI_SYSTEM
int acpi_system_init (void);
void acpi_system_exit (void);
#endif
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
Thermal Zone Thermal Zone
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
......
...@@ -1953,7 +1953,6 @@ acpi_bus_init (void) ...@@ -1953,7 +1953,6 @@ acpi_bus_init (void)
* Install drivers required for proper enumeration of the * Install drivers required for proper enumeration of the
* ACPI namespace. * ACPI namespace.
*/ */
acpi_system_init(); /* ACPI System */
acpi_power_init(); /* ACPI Bus Power Management */ acpi_power_init(); /* ACPI Bus Power Management */
#ifdef CONFIG_ACPI_EC #ifdef CONFIG_ACPI_EC
acpi_ec_init(); /* ACPI Embedded Controller */ acpi_ec_init(); /* ACPI Embedded Controller */
...@@ -2010,7 +2009,6 @@ acpi_bus_exit (void) ...@@ -2010,7 +2009,6 @@ acpi_bus_exit (void)
acpi_ec_exit(); acpi_ec_exit();
#endif #endif
acpi_power_exit(); acpi_power_exit();
acpi_system_exit();
acpi_bus_remove(acpi_root, ACPI_BUS_REMOVAL_NORMAL); acpi_bus_remove(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
......
...@@ -37,19 +37,6 @@ ACPI_MODULE_NAME ("acpi_system") ...@@ -37,19 +37,6 @@ ACPI_MODULE_NAME ("acpi_system")
extern FADT_DESCRIPTOR acpi_fadt; extern FADT_DESCRIPTOR acpi_fadt;
static int acpi_system_add (struct acpi_device *device);
static int acpi_system_remove (struct acpi_device *device, int type);
static struct acpi_driver acpi_system_driver = {
.name = ACPI_SYSTEM_DRIVER_NAME,
.class = ACPI_SYSTEM_CLASS,
.ids = ACPI_SYSTEM_HID,
.ops = {
.add = acpi_system_add,
.remove = acpi_system_remove
},
};
/* Global vars for handling event proc entry */ /* Global vars for handling event proc entry */
static spinlock_t acpi_system_event_lock = SPIN_LOCK_UNLOCKED; static spinlock_t acpi_system_event_lock = SPIN_LOCK_UNLOCKED;
int event_is_open = 0; int event_is_open = 0;
...@@ -352,182 +339,85 @@ acpi_system_write_debug ( ...@@ -352,182 +339,85 @@ acpi_system_write_debug (
#endif /* ACPI_DEBUG */ #endif /* ACPI_DEBUG */
static int __init acpi_system_init (void)
static int
acpi_system_add_fs (
struct acpi_device *device)
{ {
struct proc_dir_entry *entry = NULL; struct proc_dir_entry *entry;
int error = 0;
ACPI_FUNCTION_TRACE("acpi_system_add_fs"); char * name;
if (!device) ACPI_FUNCTION_TRACE("acpi_system_init");
return_VALUE(-EINVAL);
/* 'info' [R] */ /* 'info' [R] */
entry = create_proc_entry(ACPI_SYSTEM_FILE_INFO, name = ACPI_SYSTEM_FILE_INFO;
S_IRUGO, acpi_device_dir(device)); entry = create_proc_read_entry(name,
S_IRUGO, acpi_root_dir, acpi_system_read_info,NULL);
if (!entry) if (!entry)
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, goto Error;
"Unable to create '%s' fs entry\n",
ACPI_SYSTEM_FILE_INFO));
else {
entry->read_proc = acpi_system_read_info;
entry->data = acpi_driver_data(device);
}
/* 'dsdt' [R] */ /* 'dsdt' [R] */
entry = create_proc_entry(ACPI_SYSTEM_FILE_DSDT, name = ACPI_SYSTEM_FILE_DSDT;
S_IRUSR, acpi_device_dir(device)); entry = create_proc_entry(name, S_IRUSR, acpi_root_dir);
if (!entry) if (entry)
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unable to create '%s' fs entry\n",
ACPI_SYSTEM_FILE_DSDT));
else
entry->proc_fops = &acpi_system_dsdt_ops; entry->proc_fops = &acpi_system_dsdt_ops;
else
goto Error;
/* 'fadt' [R] */ /* 'fadt' [R] */
entry = create_proc_entry(ACPI_SYSTEM_FILE_FADT, name = ACPI_SYSTEM_FILE_FADT;
S_IRUSR, acpi_device_dir(device)); entry = create_proc_entry(name, S_IRUSR, acpi_root_dir);
if (!entry) if (entry)
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unable to create '%s' fs entry\n",
ACPI_SYSTEM_FILE_FADT));
else
entry->proc_fops = &acpi_system_fadt_ops; entry->proc_fops = &acpi_system_fadt_ops;
else
goto Error;
/* 'event' [R] */ /* 'event' [R] */
entry = create_proc_entry(ACPI_SYSTEM_FILE_EVENT, name = ACPI_SYSTEM_FILE_EVENT;
S_IRUSR, acpi_device_dir(device)); entry = create_proc_entry(name, S_IRUSR, acpi_root_dir);
if (!entry) if (entry)
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Unable to create '%s' fs entry\n",
ACPI_SYSTEM_FILE_EVENT));
else
entry->proc_fops = &acpi_system_event_ops; entry->proc_fops = &acpi_system_event_ops;
else
goto Error;
#ifdef ACPI_DEBUG #ifdef ACPI_DEBUG
/* 'debug_layer' [R/W] */ /* 'debug_layer' [R/W] */
entry = create_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, name = ACPI_SYSTEM_FILE_DEBUG_LAYER;
S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); entry = create_proc_read_entry(name, S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir,
if (!entry) acpi_system_read_debug,(void *)0);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, if (entry)
"Unable to create '%s' fs entry\n",
ACPI_SYSTEM_FILE_DEBUG_LAYER));
else {
entry->read_proc = acpi_system_read_debug;
entry->write_proc = acpi_system_write_debug; entry->write_proc = acpi_system_write_debug;
entry->data = (void *) 0; else
} goto Error;
/* 'debug_level' [R/W] */ /* 'debug_level' [R/W] */
entry = create_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, name = ACPI_SYSTEM_FILE_DEBUG_LEVEL;
S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); entry = create_proc_read_entry(name, S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir,
if (!entry) acpi_system_read_debug, (void *)1);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, if (entry)
"Unable to create '%s' fs entry\n",
ACPI_SYSTEM_FILE_DEBUG_LEVEL));
else {
entry->read_proc = acpi_system_read_debug;
entry->write_proc = acpi_system_write_debug; entry->write_proc = acpi_system_write_debug;
entry->data = (void *) 1; else
} goto Error;
#endif /*ACPI_DEBUG*/ #endif /*ACPI_DEBUG*/
return_VALUE(0); Done:
} return_VALUE(error);
Error:
static int ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
acpi_system_remove_fs ( "Unable to create '%s' proc fs entry\n", name));
struct acpi_device *device)
{
ACPI_FUNCTION_TRACE("acpi_system_remove_fs");
if (!device)
return_VALUE(-EINVAL);
remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_device_dir(device));
remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_device_dir(device));
remove_proc_entry(ACPI_SYSTEM_FILE_EVENT, acpi_device_dir(device));
#ifdef ACPI_DEBUG #ifdef ACPI_DEBUG
remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, acpi_root_dir);
acpi_device_dir(device)); remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir);
remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL,
acpi_device_dir(device));
#endif #endif
remove_proc_entry(ACPI_SYSTEM_FILE_EVENT, acpi_root_dir);
remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir);
remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir);
remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir);
return_VALUE(0); error = -EINVAL;
goto Done;
} }
/* -------------------------------------------------------------------------- subsys_initcall(acpi_system_init);
Driver Interface
-------------------------------------------------------------------------- */
static int
acpi_system_add (
struct acpi_device *device)
{
int result = 0;
ACPI_FUNCTION_TRACE("acpi_system_add");
if (!device)
return_VALUE(-EINVAL);
sprintf(acpi_device_name(device), "%s", ACPI_SYSTEM_DEVICE_NAME);
sprintf(acpi_device_class(device), "%s", ACPI_SYSTEM_CLASS);
result = acpi_system_add_fs(device);
return_VALUE(result);
}
static int
acpi_system_remove (
struct acpi_device *device,
int type)
{
struct acpi_system *system = NULL;
ACPI_FUNCTION_TRACE("acpi_system_remove");
if (!device || !acpi_driver_data(device))
return_VALUE(-EINVAL);
system = (struct acpi_system *) acpi_driver_data(device);
acpi_system_remove_fs(device);
kfree(system);
return 0;
}
int __init
acpi_system_init (void)
{
int result = 0;
ACPI_FUNCTION_TRACE("acpi_system_init");
result = acpi_bus_register_driver(&acpi_system_driver);
if (result < 0)
return_VALUE(-ENODEV);
return_VALUE(0);
}
void __exit
acpi_system_exit (void)
{
ACPI_FUNCTION_TRACE("acpi_system_exit");
acpi_bus_unregister_driver(&acpi_system_driver);
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