Skip to content

Commit

Permalink
Pull acpi_device_handle_cleanup into release branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Len Brown committed Jul 1, 2006
2 parents b197ba3 + d07a857 commit 5f765b8
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 148 deletions.
14 changes: 6 additions & 8 deletions drivers/acpi/ac.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static struct acpi_driver acpi_ac_driver = {
};

struct acpi_ac {
acpi_handle handle;
struct acpi_device * device;
unsigned long state;
};

Expand All @@ -88,7 +88,7 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
if (!ac)
return -EINVAL;

status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state);
status = acpi_evaluate_integer(ac->device->handle, "_PSR", NULL, &ac->state);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "Error reading AC Adapter state"));
ac->state = ACPI_AC_STATUS_UNKNOWN;
Expand Down Expand Up @@ -191,9 +191,7 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
if (!ac)
return;

if (acpi_bus_get_device(ac->handle, &device))
return;

device = ac->device;
switch (event) {
case ACPI_AC_NOTIFY_STATUS:
acpi_ac_get_state(ac);
Expand Down Expand Up @@ -223,7 +221,7 @@ static int acpi_ac_add(struct acpi_device *device)
return -ENOMEM;
memset(ac, 0, sizeof(struct acpi_ac));

ac->handle = device->handle;
ac->device = device;
strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_AC_CLASS);
acpi_driver_data(device) = ac;
Expand All @@ -236,7 +234,7 @@ static int acpi_ac_add(struct acpi_device *device)
if (result)
goto end;

status = acpi_install_notify_handler(ac->handle,
status = acpi_install_notify_handler(device->handle,
ACPI_DEVICE_NOTIFY, acpi_ac_notify,
ac);
if (ACPI_FAILURE(status)) {
Expand Down Expand Up @@ -268,7 +266,7 @@ static int acpi_ac_remove(struct acpi_device *device, int type)

ac = (struct acpi_ac *)acpi_driver_data(device);

status = acpi_remove_notify_handler(ac->handle,
status = acpi_remove_notify_handler(device->handle,
ACPI_DEVICE_NOTIFY, acpi_ac_notify);

acpi_ac_remove_fs(device);
Expand Down
14 changes: 7 additions & 7 deletions drivers/acpi/acpi_memhotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct acpi_memory_info {
};

struct acpi_memory_device {
acpi_handle handle;
struct acpi_device * device;
unsigned int state; /* State of the memory device */
struct list_head res_list;
};
Expand Down Expand Up @@ -129,7 +129,7 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
struct acpi_memory_info *info, *n;


status = acpi_walk_resources(mem_device->handle, METHOD_NAME__CRS,
status = acpi_walk_resources(mem_device->device->handle, METHOD_NAME__CRS,
acpi_memory_get_resource, mem_device);
if (ACPI_FAILURE(status)) {
list_for_each_entry_safe(info, n, &mem_device->res_list, list)
Expand Down Expand Up @@ -192,7 +192,7 @@ static int acpi_memory_check_device(struct acpi_memory_device *mem_device)


/* Get device present/absent information from the _STA */
if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->handle, "_STA",
if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->device->handle, "_STA",
NULL, &current_status)))
return -ENODEV;
/*
Expand Down Expand Up @@ -222,7 +222,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
return result;
}

node = acpi_get_node(mem_device->handle);
node = acpi_get_node(mem_device->device->handle);
/*
* Tell the VM there is more memory here...
* Note: Assume that this function returns zero on success
Expand Down Expand Up @@ -269,7 +269,7 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
arg_list.pointer = &arg;
arg.type = ACPI_TYPE_INTEGER;
arg.integer.value = 1;
status = acpi_evaluate_object(mem_device->handle,
status = acpi_evaluate_object(mem_device->device->handle,
"_EJ0", &arg_list, NULL);
/* Return on _EJ0 failure */
if (ACPI_FAILURE(status)) {
Expand All @@ -278,7 +278,7 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
}

/* Evalute _STA to check if the device is disabled */
status = acpi_evaluate_integer(mem_device->handle, "_STA",
status = acpi_evaluate_integer(mem_device->device->handle, "_STA",
NULL, &current_status);
if (ACPI_FAILURE(status))
return -ENODEV;
Expand Down Expand Up @@ -398,7 +398,7 @@ static int acpi_memory_device_add(struct acpi_device *device)
memset(mem_device, 0, sizeof(struct acpi_memory_device));

INIT_LIST_HEAD(&mem_device->res_list);
mem_device->handle = device->handle;
mem_device->device = device;
sprintf(acpi_device_name(device), "%s", ACPI_MEMORY_DEVICE_NAME);
sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS);
acpi_driver_data(device) = mem_device;
Expand Down
23 changes: 10 additions & 13 deletions drivers/acpi/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ struct acpi_battery_trips {
};

struct acpi_battery {
acpi_handle handle;
struct acpi_device * device;
struct acpi_battery_flags flags;
struct acpi_battery_trips trips;
unsigned long alarm;
Expand Down Expand Up @@ -138,7 +138,7 @@ acpi_battery_get_info(struct acpi_battery *battery,

/* Evalute _BIF */

status = acpi_evaluate_object(battery->handle, "_BIF", NULL, &buffer);
status = acpi_evaluate_object(battery->device->handle, "_BIF", NULL, &buffer);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
return -ENODEV;
Expand Down Expand Up @@ -198,7 +198,7 @@ acpi_battery_get_status(struct acpi_battery *battery,

/* Evalute _BST */

status = acpi_evaluate_object(battery->handle, "_BST", NULL, &buffer);
status = acpi_evaluate_object(battery->device->handle, "_BST", NULL, &buffer);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
return -ENODEV;
Expand Down Expand Up @@ -255,7 +255,7 @@ acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm)

arg0.integer.value = alarm;

status = acpi_evaluate_object(battery->handle, "_BTP", &arg_list, NULL);
status = acpi_evaluate_object(battery->device->handle, "_BTP", &arg_list, NULL);
if (ACPI_FAILURE(status))
return -ENODEV;

Expand All @@ -278,9 +278,7 @@ static int acpi_battery_check(struct acpi_battery *battery)
if (!battery)
return -EINVAL;

result = acpi_bus_get_device(battery->handle, &device);
if (result)
return result;
device = battery->device;

result = acpi_bus_get_status(device);
if (result)
Expand All @@ -305,7 +303,7 @@ static int acpi_battery_check(struct acpi_battery *battery)

/* See if alarms are supported, and if so, set default */

status = acpi_get_handle(battery->handle, "_BTP", &handle);
status = acpi_get_handle(battery->device->handle, "_BTP", &handle);
if (ACPI_SUCCESS(status)) {
battery->flags.alarm = 1;
acpi_battery_set_alarm(battery, battery->trips.warning);
Expand Down Expand Up @@ -662,8 +660,7 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
if (!battery)
return;

if (acpi_bus_get_device(handle, &device))
return;
device = battery->device;

switch (event) {
case ACPI_BATTERY_NOTIFY_STATUS:
Expand Down Expand Up @@ -695,7 +692,7 @@ static int acpi_battery_add(struct acpi_device *device)
return -ENOMEM;
memset(battery, 0, sizeof(struct acpi_battery));

battery->handle = device->handle;
battery->device = device;
strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
acpi_driver_data(device) = battery;
Expand All @@ -708,7 +705,7 @@ static int acpi_battery_add(struct acpi_device *device)
if (result)
goto end;

status = acpi_install_notify_handler(battery->handle,
status = acpi_install_notify_handler(device->handle,
ACPI_DEVICE_NOTIFY,
acpi_battery_notify, battery);
if (ACPI_FAILURE(status)) {
Expand Down Expand Up @@ -740,7 +737,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type)

battery = (struct acpi_battery *)acpi_driver_data(device);

status = acpi_remove_notify_handler(battery->handle,
status = acpi_remove_notify_handler(device->handle,
ACPI_DEVICE_NOTIFY,
acpi_battery_notify);

Expand Down
10 changes: 4 additions & 6 deletions drivers/acpi/button.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ static struct acpi_driver acpi_button_driver = {
};

struct acpi_button {
acpi_handle handle;
struct acpi_device *device; /* Fixed button kludge */
u8 type;
unsigned long pushed;
Expand Down Expand Up @@ -137,7 +136,7 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
if (!button || !button->device)
return 0;

status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state);
status = acpi_evaluate_integer(button->device->handle, "_LID", NULL, &state);
if (ACPI_FAILURE(status)) {
seq_printf(seq, "state: unsupported\n");
} else {
Expand Down Expand Up @@ -282,7 +281,7 @@ static acpi_status acpi_button_notify_fixed(void *data)
if (!button)
return AE_BAD_PARAMETER;

acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button);
acpi_button_notify(button->device->handle, ACPI_BUTTON_NOTIFY_STATUS, button);

return AE_OK;
}
Expand All @@ -303,7 +302,6 @@ static int acpi_button_add(struct acpi_device *device)
memset(button, 0, sizeof(struct acpi_button));

button->device = device;
button->handle = device->handle;
acpi_driver_data(device) = button;

/*
Expand Down Expand Up @@ -362,7 +360,7 @@ static int acpi_button_add(struct acpi_device *device)
button);
break;
default:
status = acpi_install_notify_handler(button->handle,
status = acpi_install_notify_handler(device->handle,
ACPI_DEVICE_NOTIFY,
acpi_button_notify,
button);
Expand Down Expand Up @@ -420,7 +418,7 @@ static int acpi_button_remove(struct acpi_device *device, int type)
acpi_button_notify_fixed);
break;
default:
status = acpi_remove_notify_handler(button->handle,
status = acpi_remove_notify_handler(device->handle,
ACPI_DEVICE_NOTIFY,
acpi_button_notify);
break;
Expand Down
10 changes: 5 additions & 5 deletions drivers/acpi/fan.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static struct acpi_driver acpi_fan_driver = {
};

struct acpi_fan {
acpi_handle handle;
struct acpi_device * device;
};

/* --------------------------------------------------------------------------
Expand All @@ -80,7 +80,7 @@ static int acpi_fan_read_state(struct seq_file *seq, void *offset)


if (fan) {
if (acpi_bus_get_power(fan->handle, &state))
if (acpi_bus_get_power(fan->device->handle, &state))
seq_printf(seq, "status: ERROR\n");
else
seq_printf(seq, "status: %s\n",
Expand Down Expand Up @@ -112,7 +112,7 @@ acpi_fan_write_state(struct file *file, const char __user * buffer,

state_string[count] = '\0';

result = acpi_bus_set_power(fan->handle,
result = acpi_bus_set_power(fan->device->handle,
simple_strtoul(state_string, NULL, 0));
if (result)
return result;
Expand Down Expand Up @@ -191,12 +191,12 @@ static int acpi_fan_add(struct acpi_device *device)
return -ENOMEM;
memset(fan, 0, sizeof(struct acpi_fan));

fan->handle = device->handle;
fan->device = device;
strcpy(acpi_device_name(device), "Fan");
strcpy(acpi_device_class(device), ACPI_FAN_CLASS);
acpi_driver_data(device) = fan;

result = acpi_bus_get_power(fan->handle, &state);
result = acpi_bus_get_power(device->handle, &state);
if (result) {
printk(KERN_ERR PREFIX "Reading power state\n");
goto end;
Expand Down
15 changes: 6 additions & 9 deletions drivers/acpi/pci_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ struct acpi_pci_link_irq {
struct acpi_pci_link {
struct list_head node;
struct acpi_device *device;
acpi_handle handle;
struct acpi_pci_link_irq irq;
int refcnt;
};
Expand Down Expand Up @@ -175,7 +174,7 @@ static int acpi_pci_link_get_possible(struct acpi_pci_link *link)
if (!link)
return -EINVAL;

status = acpi_walk_resources(link->handle, METHOD_NAME__PRS,
status = acpi_walk_resources(link->device->handle, METHOD_NAME__PRS,
acpi_pci_link_check_possible, link);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRS"));
Expand Down Expand Up @@ -249,8 +248,7 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
acpi_status status = AE_OK;
int irq = 0;


if (!link || !link->handle)
if (!link)
return -EINVAL;

link->irq.active = 0;
Expand All @@ -274,7 +272,7 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
* Query and parse _CRS to get the current IRQ assignment.
*/

status = acpi_walk_resources(link->handle, METHOD_NAME__CRS,
status = acpi_walk_resources(link->device->handle, METHOD_NAME__CRS,
acpi_pci_link_check_current, &irq);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "Evaluating _CRS"));
Expand Down Expand Up @@ -360,7 +358,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
resource->end.type = ACPI_RESOURCE_TYPE_END_TAG;

/* Attempt to set the resource */
status = acpi_set_current_resources(link->handle, &buffer);
status = acpi_set_current_resources(link->device->handle, &buffer);

/* check for total failure */
if (ACPI_FAILURE(status)) {
Expand Down Expand Up @@ -699,7 +697,7 @@ int acpi_pci_link_free_irq(acpi_handle handle)
acpi_device_bid(link->device)));

if (link->refcnt == 0) {
acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
acpi_ut_evaluate_object(link->device->handle, "_DIS", 0, NULL);
}
mutex_unlock(&acpi_link_lock);
return (link->irq.active);
Expand All @@ -726,7 +724,6 @@ static int acpi_pci_link_add(struct acpi_device *device)
memset(link, 0, sizeof(struct acpi_pci_link));

link->device = device;
link->handle = device->handle;
strcpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS);
acpi_driver_data(device) = link;
Expand Down Expand Up @@ -765,7 +762,7 @@ static int acpi_pci_link_add(struct acpi_device *device)

end:
/* disable all links -- to be activated on use */
acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
acpi_ut_evaluate_object(device->handle, "_DIS", 0, NULL);
mutex_unlock(&acpi_link_lock);

if (result)
Expand Down
Loading

0 comments on commit 5f765b8

Please sign in to comment.