Skip to content

Commit

Permalink
Merge branch 'bjorn-start-stop-2.6.32' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Len Brown committed Sep 19, 2009
2 parents 7a92d80 + dcf52fb commit 3b87bb6
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 231 deletions.
40 changes: 14 additions & 26 deletions drivers/acpi/acpi_memhotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ MODULE_LICENSE("GPL");

static int acpi_memory_device_add(struct acpi_device *device);
static int acpi_memory_device_remove(struct acpi_device *device, int type);
static int acpi_memory_device_start(struct acpi_device *device);

static const struct acpi_device_id memory_device_ids[] = {
{ACPI_MEMORY_DEVICE_HID, 0},
Expand All @@ -68,7 +67,6 @@ static struct acpi_driver acpi_memory_device_driver = {
.ops = {
.add = acpi_memory_device_add,
.remove = acpi_memory_device_remove,
.start = acpi_memory_device_start,
},
};

Expand Down Expand Up @@ -431,28 +429,6 @@ static int acpi_memory_device_add(struct acpi_device *device)

printk(KERN_DEBUG "%s \n", acpi_device_name(device));

return result;
}

static int acpi_memory_device_remove(struct acpi_device *device, int type)
{
struct acpi_memory_device *mem_device = NULL;


if (!device || !acpi_driver_data(device))
return -EINVAL;

mem_device = acpi_driver_data(device);
kfree(mem_device);

return 0;
}

static int acpi_memory_device_start (struct acpi_device *device)
{
struct acpi_memory_device *mem_device;
int result = 0;

/*
* Early boot code has recognized memory area by EFI/E820.
* If DSDT shows these memory devices on boot, hotplug is not necessary
Expand All @@ -462,8 +438,6 @@ static int acpi_memory_device_start (struct acpi_device *device)
if (!acpi_hotmem_initialized)
return 0;

mem_device = acpi_driver_data(device);

if (!acpi_memory_check_device(mem_device)) {
/* call add_memory func */
result = acpi_memory_enable_device(mem_device);
Expand All @@ -474,6 +448,20 @@ static int acpi_memory_device_start (struct acpi_device *device)
return result;
}

static int acpi_memory_device_remove(struct acpi_device *device, int type)
{
struct acpi_memory_device *mem_device = NULL;


if (!device || !acpi_driver_data(device))
return -EINVAL;

mem_device = acpi_driver_data(device);
kfree(mem_device);

return 0;
}

/*
* Helper function to check for memory device
*/
Expand Down
118 changes: 44 additions & 74 deletions drivers/acpi/ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,42 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
return AE_CTRL_TERMINATE;
}

static int ec_install_handlers(struct acpi_ec *ec)
{
acpi_status status;
if (test_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags))
return 0;
status = acpi_install_gpe_handler(NULL, ec->gpe,
ACPI_GPE_EDGE_TRIGGERED,
&acpi_ec_gpe_handler, ec);
if (ACPI_FAILURE(status))
return -ENODEV;
acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
acpi_enable_gpe(NULL, ec->gpe);
status = acpi_install_address_space_handler(ec->handle,
ACPI_ADR_SPACE_EC,
&acpi_ec_space_handler,
NULL, ec);
if (ACPI_FAILURE(status)) {
if (status == AE_NOT_FOUND) {
/*
* Maybe OS fails in evaluating the _REG object.
* The AE_NOT_FOUND error will be ignored and OS
* continue to initialize EC.
*/
printk(KERN_ERR "Fail in evaluating the _REG object"
" of EC device. Broken bios is suspected.\n");
} else {
acpi_remove_gpe_handler(NULL, ec->gpe,
&acpi_ec_gpe_handler);
return -ENODEV;
}
}

set_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags);
return 0;
}

static void ec_remove_handlers(struct acpi_ec *ec)
{
if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
Expand All @@ -801,9 +837,8 @@ static void ec_remove_handlers(struct acpi_ec *ec)
static int acpi_ec_add(struct acpi_device *device)
{
struct acpi_ec *ec = NULL;
int ret;

if (!device)
return -EINVAL;
strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_EC_CLASS);

Expand Down Expand Up @@ -838,7 +873,12 @@ static int acpi_ec_add(struct acpi_device *device)
ec->gpe, ec->command_addr, ec->data_addr);
pr_info(PREFIX "driver started in %s mode\n",
(test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll");
return 0;

ret = ec_install_handlers(ec);

/* EC is fully operational, allow queries */
clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
return ret;
}

static int acpi_ec_remove(struct acpi_device *device, int type)
Expand All @@ -850,6 +890,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type)
return -EINVAL;

ec = acpi_driver_data(device);
ec_remove_handlers(ec);
mutex_lock(&ec->lock);
list_for_each_entry_safe(handler, tmp, &ec->list, node) {
list_del(&handler->node);
Expand Down Expand Up @@ -887,75 +928,6 @@ ec_parse_io_ports(struct acpi_resource *resource, void *context)
return AE_OK;
}

static int ec_install_handlers(struct acpi_ec *ec)
{
acpi_status status;
if (test_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags))
return 0;
status = acpi_install_gpe_handler(NULL, ec->gpe,
ACPI_GPE_EDGE_TRIGGERED,
&acpi_ec_gpe_handler, ec);
if (ACPI_FAILURE(status))
return -ENODEV;
acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
acpi_enable_gpe(NULL, ec->gpe);
status = acpi_install_address_space_handler(ec->handle,
ACPI_ADR_SPACE_EC,
&acpi_ec_space_handler,
NULL, ec);
if (ACPI_FAILURE(status)) {
if (status == AE_NOT_FOUND) {
/*
* Maybe OS fails in evaluating the _REG object.
* The AE_NOT_FOUND error will be ignored and OS
* continue to initialize EC.
*/
printk(KERN_ERR "Fail in evaluating the _REG object"
" of EC device. Broken bios is suspected.\n");
} else {
acpi_remove_gpe_handler(NULL, ec->gpe,
&acpi_ec_gpe_handler);
return -ENODEV;
}
}

set_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags);
return 0;
}

static int acpi_ec_start(struct acpi_device *device)
{
struct acpi_ec *ec;
int ret = 0;

if (!device)
return -EINVAL;

ec = acpi_driver_data(device);

if (!ec)
return -EINVAL;

ret = ec_install_handlers(ec);

/* EC is fully operational, allow queries */
clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
return ret;
}

static int acpi_ec_stop(struct acpi_device *device, int type)
{
struct acpi_ec *ec;
if (!device)
return -EINVAL;
ec = acpi_driver_data(device);
if (!ec)
return -EINVAL;
ec_remove_handlers(ec);

return 0;
}

int __init acpi_boot_ec_enable(void)
{
if (!boot_ec || test_bit(EC_FLAGS_HANDLERS_INSTALLED, &boot_ec->flags))
Expand Down Expand Up @@ -1076,8 +1048,6 @@ static struct acpi_driver acpi_ec_driver = {
.ops = {
.add = acpi_ec_add,
.remove = acpi_ec_remove,
.start = acpi_ec_start,
.stop = acpi_ec_stop,
.suspend = acpi_ec_suspend,
.resume = acpi_ec_resume,
},
Expand Down
Loading

0 comments on commit 3b87bb6

Please sign in to comment.