提交 952c63e9 编写于 作者: J Jiang Liu 提交者: Rafael J. Wysocki

ACPI: introduce helper function acpi_has_method()

Introduce helper function acpi_has_method() and use it in a number
of places to simplify code.

[rjw: Changelog]
Signed-off-by: NJiang Liu <jiang.liu@huawei.com>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 472d963b
...@@ -548,12 +548,8 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery) ...@@ -548,12 +548,8 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery)
static int acpi_battery_init_alarm(struct acpi_battery *battery) static int acpi_battery_init_alarm(struct acpi_battery *battery)
{ {
acpi_status status = AE_OK;
acpi_handle handle = NULL;
/* See if alarms are supported, and if so, set default */ /* See if alarms are supported, and if so, set default */
status = acpi_get_handle(battery->device->handle, "_BTP", &handle); if (!acpi_has_method(battery->device->handle, "_BTP")) {
if (ACPI_FAILURE(status)) {
clear_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags); clear_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags);
return 0; return 0;
} }
...@@ -1066,7 +1062,7 @@ static int acpi_battery_add(struct acpi_device *device) ...@@ -1066,7 +1062,7 @@ static int acpi_battery_add(struct acpi_device *device)
{ {
int result = 0; int result = 0;
struct acpi_battery *battery = NULL; struct acpi_battery *battery = NULL;
acpi_handle handle;
if (!device) if (!device)
return -EINVAL; return -EINVAL;
battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
...@@ -1078,8 +1074,7 @@ static int acpi_battery_add(struct acpi_device *device) ...@@ -1078,8 +1074,7 @@ static int acpi_battery_add(struct acpi_device *device)
device->driver_data = battery; device->driver_data = battery;
mutex_init(&battery->lock); mutex_init(&battery->lock);
mutex_init(&battery->sysfs_lock); mutex_init(&battery->sysfs_lock);
if (ACPI_SUCCESS(acpi_get_handle(battery->device->handle, if (acpi_has_method(battery->device->handle, "_BIX"))
"_BIX", &handle)))
set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags); set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);
result = acpi_battery_update(battery); result = acpi_battery_update(battery);
if (result) if (result)
......
...@@ -1049,10 +1049,8 @@ int __init acpi_ec_ecdt_probe(void) ...@@ -1049,10 +1049,8 @@ int __init acpi_ec_ecdt_probe(void)
* which needs it, has fake EC._INI method, so use it as flag. * which needs it, has fake EC._INI method, so use it as flag.
* Keep boot_ec struct as it will be needed soon. * Keep boot_ec struct as it will be needed soon.
*/ */
acpi_handle dummy;
if (!dmi_name_in_vendors("ASUS") || if (!dmi_name_in_vendors("ASUS") ||
ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", !acpi_has_method(boot_ec->handle, "_INI"))
&dummy)))
return -ENODEV; return -ENODEV;
} }
install: install:
......
...@@ -164,17 +164,12 @@ static void acpi_processor_ppc_ost(acpi_handle handle, int status) ...@@ -164,17 +164,12 @@ static void acpi_processor_ppc_ost(acpi_handle handle, int status)
{.type = ACPI_TYPE_INTEGER,}, {.type = ACPI_TYPE_INTEGER,},
}; };
struct acpi_object_list arg_list = {2, params}; struct acpi_object_list arg_list = {2, params};
acpi_handle temp;
params[0].integer.value = ACPI_PROCESSOR_NOTIFY_PERFORMANCE; if (acpi_has_method(handle, "_OST")) {
params[1].integer.value = status; params[0].integer.value = ACPI_PROCESSOR_NOTIFY_PERFORMANCE;
params[1].integer.value = status;
/* when there is no _OST , skip it */ acpi_evaluate_object(handle, "_OST", &arg_list, NULL);
if (ACPI_FAILURE(acpi_get_handle(handle, "_OST", &temp))) }
return;
acpi_evaluate_object(handle, "_OST", &arg_list, NULL);
return;
} }
int acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag) int acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag)
...@@ -468,14 +463,11 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr) ...@@ -468,14 +463,11 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
int acpi_processor_get_performance_info(struct acpi_processor *pr) int acpi_processor_get_performance_info(struct acpi_processor *pr)
{ {
int result = 0; int result = 0;
acpi_status status = AE_OK;
acpi_handle handle = NULL;
if (!pr || !pr->performance || !pr->handle) if (!pr || !pr->performance || !pr->handle)
return -EINVAL; return -EINVAL;
status = acpi_get_handle(pr->handle, "_PCT", &handle); if (!acpi_has_method(pr->handle, "_PCT")) {
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO, ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"ACPI-based processor performance control unavailable\n")); "ACPI-based processor performance control unavailable\n"));
return -ENODEV; return -ENODEV;
...@@ -501,7 +493,7 @@ int acpi_processor_get_performance_info(struct acpi_processor *pr) ...@@ -501,7 +493,7 @@ int acpi_processor_get_performance_info(struct acpi_processor *pr)
*/ */
update_bios: update_bios:
#ifdef CONFIG_X86 #ifdef CONFIG_X86
if (ACPI_SUCCESS(acpi_get_handle(pr->handle, "_PPC", &handle))){ if (acpi_has_method(pr->handle, "_PPC")) {
if(boot_cpu_has(X86_FEATURE_EST)) if(boot_cpu_has(X86_FEATURE_EST))
printk(KERN_WARNING FW_BUG "BIOS needs update for CPU " printk(KERN_WARNING FW_BUG "BIOS needs update for CPU "
"frequency support\n"); "frequency support\n");
......
...@@ -505,14 +505,12 @@ int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list, ...@@ -505,14 +505,12 @@ int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
void *preproc_data) void *preproc_data)
{ {
struct res_proc_context c; struct res_proc_context c;
acpi_handle not_used;
acpi_status status; acpi_status status;
if (!adev || !adev->handle || !list_empty(list)) if (!adev || !adev->handle || !list_empty(list))
return -EINVAL; return -EINVAL;
status = acpi_get_handle(adev->handle, METHOD_NAME__CRS, &not_used); if (!acpi_has_method(adev->handle, METHOD_NAME__CRS))
if (ACPI_FAILURE(status))
return 0; return 0;
c.list = list; c.list = list;
......
...@@ -193,7 +193,6 @@ static acpi_status acpi_bus_online_companions(acpi_handle handle, u32 lvl, ...@@ -193,7 +193,6 @@ static acpi_status acpi_bus_online_companions(acpi_handle handle, u32 lvl,
static int acpi_scan_hot_remove(struct acpi_device *device) static int acpi_scan_hot_remove(struct acpi_device *device)
{ {
acpi_handle handle = device->handle; acpi_handle handle = device->handle;
acpi_handle not_used;
struct acpi_object_list arg_list; struct acpi_object_list arg_list;
union acpi_object arg; union acpi_object arg;
struct device *errdev; struct device *errdev;
...@@ -258,7 +257,7 @@ static int acpi_scan_hot_remove(struct acpi_device *device) ...@@ -258,7 +257,7 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
put_device(&device->dev); put_device(&device->dev);
device = NULL; device = NULL;
if (ACPI_SUCCESS(acpi_get_handle(handle, "_LCK", &not_used))) { if (acpi_has_method(handle, "_LCK")) {
arg_list.count = 1; arg_list.count = 1;
arg_list.pointer = &arg; arg_list.pointer = &arg;
arg.type = ACPI_TYPE_INTEGER; arg.type = ACPI_TYPE_INTEGER;
...@@ -652,7 +651,6 @@ static int acpi_device_setup_files(struct acpi_device *dev) ...@@ -652,7 +651,6 @@ static int acpi_device_setup_files(struct acpi_device *dev)
{ {
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
acpi_status status; acpi_status status;
acpi_handle temp;
unsigned long long sun; unsigned long long sun;
int result = 0; int result = 0;
...@@ -678,8 +676,7 @@ static int acpi_device_setup_files(struct acpi_device *dev) ...@@ -678,8 +676,7 @@ static int acpi_device_setup_files(struct acpi_device *dev)
/* /*
* If device has _STR, 'description' file is created * If device has _STR, 'description' file is created
*/ */
status = acpi_get_handle(dev->handle, "_STR", &temp); if (acpi_has_method(dev->handle, "_STR")) {
if (ACPI_SUCCESS(status)) {
status = acpi_evaluate_object(dev->handle, "_STR", status = acpi_evaluate_object(dev->handle, "_STR",
NULL, &buffer); NULL, &buffer);
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
...@@ -709,8 +706,7 @@ static int acpi_device_setup_files(struct acpi_device *dev) ...@@ -709,8 +706,7 @@ static int acpi_device_setup_files(struct acpi_device *dev)
* If device has _EJ0, 'eject' file is created that is used to trigger * If device has _EJ0, 'eject' file is created that is used to trigger
* hot-removal function from userland. * hot-removal function from userland.
*/ */
status = acpi_get_handle(dev->handle, "_EJ0", &temp); if (acpi_has_method(dev->handle, "_EJ0")) {
if (ACPI_SUCCESS(status)) {
result = device_create_file(&dev->dev, &dev_attr_eject); result = device_create_file(&dev->dev, &dev_attr_eject);
if (result) if (result)
return result; return result;
...@@ -732,9 +728,6 @@ static int acpi_device_setup_files(struct acpi_device *dev) ...@@ -732,9 +728,6 @@ static int acpi_device_setup_files(struct acpi_device *dev)
static void acpi_device_remove_files(struct acpi_device *dev) static void acpi_device_remove_files(struct acpi_device *dev)
{ {
acpi_status status;
acpi_handle temp;
if (dev->flags.power_manageable) { if (dev->flags.power_manageable) {
device_remove_file(&dev->dev, &dev_attr_power_state); device_remove_file(&dev->dev, &dev_attr_power_state);
if (dev->power.flags.power_resources) if (dev->power.flags.power_resources)
...@@ -745,20 +738,17 @@ static void acpi_device_remove_files(struct acpi_device *dev) ...@@ -745,20 +738,17 @@ static void acpi_device_remove_files(struct acpi_device *dev)
/* /*
* If device has _STR, remove 'description' file * If device has _STR, remove 'description' file
*/ */
status = acpi_get_handle(dev->handle, "_STR", &temp); if (acpi_has_method(dev->handle, "_STR")) {
if (ACPI_SUCCESS(status)) {
kfree(dev->pnp.str_obj); kfree(dev->pnp.str_obj);
device_remove_file(&dev->dev, &dev_attr_description); device_remove_file(&dev->dev, &dev_attr_description);
} }
/* /*
* If device has _EJ0, remove 'eject' file. * If device has _EJ0, remove 'eject' file.
*/ */
status = acpi_get_handle(dev->handle, "_EJ0", &temp); if (acpi_has_method(dev->handle, "_EJ0"))
if (ACPI_SUCCESS(status))
device_remove_file(&dev->dev, &dev_attr_eject); device_remove_file(&dev->dev, &dev_attr_eject);
status = acpi_get_handle(dev->handle, "_SUN", &temp); if (acpi_has_method(dev->handle, "_SUN"))
if (ACPI_SUCCESS(status))
device_remove_file(&dev->dev, &dev_attr_sun); device_remove_file(&dev->dev, &dev_attr_sun);
if (dev->pnp.unique_id) if (dev->pnp.unique_id)
...@@ -1334,13 +1324,10 @@ static void acpi_bus_set_run_wake_flags(struct acpi_device *device) ...@@ -1334,13 +1324,10 @@ static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device) static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
{ {
acpi_handle temp;
acpi_status status = 0;
int err; int err;
/* Presence of _PRW indicates wake capable */ /* Presence of _PRW indicates wake capable */
status = acpi_get_handle(device->handle, "_PRW", &temp); if (!acpi_has_method(device->handle, "_PRW"))
if (ACPI_FAILURE(status))
return; return;
err = acpi_bus_extract_wakeup_device_power_package(device->handle, err = acpi_bus_extract_wakeup_device_power_package(device->handle,
...@@ -1370,7 +1357,6 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state) ...@@ -1370,7 +1357,6 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state)
struct acpi_device_power_state *ps = &device->power.states[state]; struct acpi_device_power_state *ps = &device->power.states[state];
char pathname[5] = { '_', 'P', 'R', '0' + state, '\0' }; char pathname[5] = { '_', 'P', 'R', '0' + state, '\0' };
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
acpi_handle handle;
acpi_status status; acpi_status status;
INIT_LIST_HEAD(&ps->resources); INIT_LIST_HEAD(&ps->resources);
...@@ -1393,8 +1379,7 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state) ...@@ -1393,8 +1379,7 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state)
/* Evaluate "_PSx" to see if we can do explicit sets */ /* Evaluate "_PSx" to see if we can do explicit sets */
pathname[2] = 'S'; pathname[2] = 'S';
status = acpi_get_handle(device->handle, pathname, &handle); if (acpi_has_method(device->handle, pathname))
if (ACPI_SUCCESS(status))
ps->flags.explicit_set = 1; ps->flags.explicit_set = 1;
/* /*
...@@ -1413,28 +1398,21 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state) ...@@ -1413,28 +1398,21 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state)
static void acpi_bus_get_power_flags(struct acpi_device *device) static void acpi_bus_get_power_flags(struct acpi_device *device)
{ {
acpi_status status;
acpi_handle handle;
u32 i; u32 i;
/* Presence of _PS0|_PR0 indicates 'power manageable' */ /* Presence of _PS0|_PR0 indicates 'power manageable' */
status = acpi_get_handle(device->handle, "_PS0", &handle); if (!acpi_has_method(device->handle, "_PS0") &&
if (ACPI_FAILURE(status)) { !acpi_has_method(device->handle, "_PR0"))
status = acpi_get_handle(device->handle, "_PR0", &handle); return;
if (ACPI_FAILURE(status))
return;
}
device->flags.power_manageable = 1; device->flags.power_manageable = 1;
/* /*
* Power Management Flags * Power Management Flags
*/ */
status = acpi_get_handle(device->handle, "_PSC", &handle); if (acpi_has_method(device->handle, "_PSC"))
if (ACPI_SUCCESS(status))
device->power.flags.explicit_get = 1; device->power.flags.explicit_get = 1;
status = acpi_get_handle(device->handle, "_IRC", &handle); if (acpi_has_method(device->handle, "_IRC"))
if (ACPI_SUCCESS(status))
device->power.flags.inrush_current = 1; device->power.flags.inrush_current = 1;
/* /*
...@@ -1468,28 +1446,18 @@ static void acpi_bus_get_power_flags(struct acpi_device *device) ...@@ -1468,28 +1446,18 @@ static void acpi_bus_get_power_flags(struct acpi_device *device)
static void acpi_bus_get_flags(struct acpi_device *device) static void acpi_bus_get_flags(struct acpi_device *device)
{ {
acpi_status status = AE_OK;
acpi_handle temp = NULL;
/* Presence of _STA indicates 'dynamic_status' */ /* Presence of _STA indicates 'dynamic_status' */
status = acpi_get_handle(device->handle, "_STA", &temp); if (acpi_has_method(device->handle, "_STA"))
if (ACPI_SUCCESS(status))
device->flags.dynamic_status = 1; device->flags.dynamic_status = 1;
/* Presence of _RMV indicates 'removable' */ /* Presence of _RMV indicates 'removable' */
status = acpi_get_handle(device->handle, "_RMV", &temp); if (acpi_has_method(device->handle, "_RMV"))
if (ACPI_SUCCESS(status))
device->flags.removable = 1; device->flags.removable = 1;
/* Presence of _EJD|_EJ0 indicates 'ejectable' */ /* Presence of _EJD|_EJ0 indicates 'ejectable' */
status = acpi_get_handle(device->handle, "_EJD", &temp); if (acpi_has_method(device->handle, "_EJD") ||
if (ACPI_SUCCESS(status)) acpi_has_method(device->handle, "_EJ0"))
device->flags.ejectable = 1; device->flags.ejectable = 1;
else {
status = acpi_get_handle(device->handle, "_EJ0", &temp);
if (ACPI_SUCCESS(status))
device->flags.ejectable = 1;
}
} }
static void acpi_device_get_busid(struct acpi_device *device) static void acpi_device_get_busid(struct acpi_device *device)
...@@ -1538,27 +1506,24 @@ static void acpi_device_get_busid(struct acpi_device *device) ...@@ -1538,27 +1506,24 @@ static void acpi_device_get_busid(struct acpi_device *device)
*/ */
static int acpi_bay_match(acpi_handle handle) static int acpi_bay_match(acpi_handle handle)
{ {
acpi_status status;
acpi_handle tmp;
acpi_handle phandle; acpi_handle phandle;
status = acpi_get_handle(handle, "_EJ0", &tmp); if (!acpi_has_method(handle, "_EJ0"))
if (ACPI_FAILURE(status))
return -ENODEV; return -ENODEV;
if ((ACPI_SUCCESS(acpi_get_handle(handle, "_GTF", &tmp))) || if (acpi_has_method(handle, "_GTF") ||
(ACPI_SUCCESS(acpi_get_handle(handle, "_GTM", &tmp))) || acpi_has_method(handle, "_GTM") ||
(ACPI_SUCCESS(acpi_get_handle(handle, "_STM", &tmp))) || acpi_has_method(handle, "_STM") ||
(ACPI_SUCCESS(acpi_get_handle(handle, "_SDD", &tmp)))) acpi_has_method(handle, "_SDD"))
return 0; return 0;
if (acpi_get_parent(handle, &phandle)) if (acpi_get_parent(handle, &phandle))
return -ENODEV; return -ENODEV;
if ((ACPI_SUCCESS(acpi_get_handle(phandle, "_GTF", &tmp))) || if (acpi_has_method(phandle, "_GTF") ||
(ACPI_SUCCESS(acpi_get_handle(phandle, "_GTM", &tmp))) || acpi_has_method(phandle, "_GTM") ||
(ACPI_SUCCESS(acpi_get_handle(phandle, "_STM", &tmp))) || acpi_has_method(phandle, "_STM") ||
(ACPI_SUCCESS(acpi_get_handle(phandle, "_SDD", &tmp)))) acpi_has_method(phandle, "_SDD"))
return 0; return 0;
return -ENODEV; return -ENODEV;
...@@ -1610,7 +1575,6 @@ static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id) ...@@ -1610,7 +1575,6 @@ static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id)
*/ */
static int acpi_ibm_smbus_match(acpi_handle handle) static int acpi_ibm_smbus_match(acpi_handle handle)
{ {
acpi_handle h_dummy;
struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL}; struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL};
int result; int result;
...@@ -1629,9 +1593,9 @@ static int acpi_ibm_smbus_match(acpi_handle handle) ...@@ -1629,9 +1593,9 @@ static int acpi_ibm_smbus_match(acpi_handle handle)
/* Does it have the necessary (but misnamed) methods? */ /* Does it have the necessary (but misnamed) methods? */
result = -ENODEV; result = -ENODEV;
if (ACPI_SUCCESS(acpi_get_handle(handle, "SBI", &h_dummy)) && if (acpi_has_method(handle, "SBI") &&
ACPI_SUCCESS(acpi_get_handle(handle, "SBR", &h_dummy)) && acpi_has_method(handle, "SBR") &&
ACPI_SUCCESS(acpi_get_handle(handle, "SBW", &h_dummy))) acpi_has_method(handle, "SBW"))
result = 0; result = 0;
out: out:
kfree(path.pointer); kfree(path.pointer);
...@@ -1898,7 +1862,6 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, ...@@ -1898,7 +1862,6 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
struct acpi_device *device = NULL; struct acpi_device *device = NULL;
int type; int type;
unsigned long long sta; unsigned long long sta;
acpi_status status;
int result; int result;
acpi_bus_get_device(handle, &device); acpi_bus_get_device(handle, &device);
...@@ -1919,10 +1882,8 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, ...@@ -1919,10 +1882,8 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
if (!(sta & ACPI_STA_DEVICE_PRESENT) && if (!(sta & ACPI_STA_DEVICE_PRESENT) &&
!(sta & ACPI_STA_DEVICE_FUNCTIONING)) { !(sta & ACPI_STA_DEVICE_FUNCTIONING)) {
struct acpi_device_wakeup wakeup; struct acpi_device_wakeup wakeup;
acpi_handle temp;
status = acpi_get_handle(handle, "_PRW", &temp); if (acpi_has_method(handle, "_PRW")) {
if (ACPI_SUCCESS(status)) {
acpi_bus_extract_wakeup_device_power_package(handle, acpi_bus_extract_wakeup_device_power_package(handle,
&wakeup); &wakeup);
acpi_power_resources_list_free(&wakeup.resources); acpi_power_resources_list_free(&wakeup.resources);
......
...@@ -495,3 +495,18 @@ acpi_handle_printk(const char *level, acpi_handle handle, const char *fmt, ...) ...@@ -495,3 +495,18 @@ acpi_handle_printk(const char *level, acpi_handle handle, const char *fmt, ...)
kfree(buffer.pointer); kfree(buffer.pointer);
} }
EXPORT_SYMBOL(acpi_handle_printk); EXPORT_SYMBOL(acpi_handle_printk);
/**
* acpi_has_method: Check whether @handle has a method named @name
* @handle: ACPI device handle
* @name: name of object or method
*
* Check whether @handle has a method named @name.
*/
bool acpi_has_method(acpi_handle handle, char *name)
{
acpi_handle tmp;
return ACPI_SUCCESS(acpi_get_handle(handle, name, &tmp));
}
EXPORT_SYMBOL(acpi_has_method);
...@@ -875,28 +875,21 @@ acpi_video_init_brightness(struct acpi_video_device *device) ...@@ -875,28 +875,21 @@ acpi_video_init_brightness(struct acpi_video_device *device)
static void acpi_video_device_find_cap(struct acpi_video_device *device) static void acpi_video_device_find_cap(struct acpi_video_device *device)
{ {
acpi_handle h_dummy1; if (acpi_has_method(device->dev->handle, "_ADR"))
if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_ADR", &h_dummy1))) {
device->cap._ADR = 1; device->cap._ADR = 1;
} if (acpi_has_method(device->dev->handle, "_BCL"))
if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCL", &h_dummy1))) {
device->cap._BCL = 1; device->cap._BCL = 1;
} if (acpi_has_method(device->dev->handle, "_BCM"))
if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCM", &h_dummy1))) {
device->cap._BCM = 1; device->cap._BCM = 1;
} if (acpi_has_method(device->dev->handle, "_BQC")) {
if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle,"_BQC",&h_dummy1)))
device->cap._BQC = 1; device->cap._BQC = 1;
else if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCQ", } else if (acpi_has_method(device->dev->handle, "_BCQ")) {
&h_dummy1))) {
printk(KERN_WARNING FW_BUG "_BCQ is used instead of _BQC\n"); printk(KERN_WARNING FW_BUG "_BCQ is used instead of _BQC\n");
device->cap._BCQ = 1; device->cap._BCQ = 1;
} }
if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DDC", &h_dummy1))) { if (acpi_has_method(device->dev->handle, "_DDC"))
device->cap._DDC = 1; device->cap._DDC = 1;
}
if (acpi_video_backlight_support()) { if (acpi_video_backlight_support()) {
struct backlight_properties props; struct backlight_properties props;
...@@ -984,26 +977,18 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) ...@@ -984,26 +977,18 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
static void acpi_video_bus_find_cap(struct acpi_video_bus *video) static void acpi_video_bus_find_cap(struct acpi_video_bus *video)
{ {
acpi_handle h_dummy1; if (acpi_has_method(video->device->handle, "_DOS"))
if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_DOS", &h_dummy1))) {
video->cap._DOS = 1; video->cap._DOS = 1;
} if (acpi_has_method(video->device->handle, "_DOD"))
if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_DOD", &h_dummy1))) {
video->cap._DOD = 1; video->cap._DOD = 1;
} if (acpi_has_method(video->device->handle, "_ROM"))
if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_ROM", &h_dummy1))) {
video->cap._ROM = 1; video->cap._ROM = 1;
} if (acpi_has_method(video->device->handle, "_GPD"))
if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_GPD", &h_dummy1))) {
video->cap._GPD = 1; video->cap._GPD = 1;
} if (acpi_has_method(video->device->handle, "_SPD"))
if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_SPD", &h_dummy1))) {
video->cap._SPD = 1; video->cap._SPD = 1;
} if (acpi_has_method(video->device->handle, "_VPO"))
if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_VPO", &h_dummy1))) {
video->cap._VPO = 1; video->cap._VPO = 1;
}
} }
/* /*
......
...@@ -51,14 +51,13 @@ acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context, ...@@ -51,14 +51,13 @@ acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context,
void **retyurn_value) void **retyurn_value)
{ {
long *cap = context; long *cap = context;
acpi_handle h_dummy;
if (ACPI_SUCCESS(acpi_get_handle(handle, "_BCM", &h_dummy)) && if (acpi_has_method(handle, "_BCM") &&
ACPI_SUCCESS(acpi_get_handle(handle, "_BCL", &h_dummy))) { acpi_has_method(handle, "_BCL")) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found generic backlight " ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found generic backlight "
"support\n")); "support\n"));
*cap |= ACPI_VIDEO_BACKLIGHT; *cap |= ACPI_VIDEO_BACKLIGHT;
if (ACPI_FAILURE(acpi_get_handle(handle, "_BQC", &h_dummy))) if (!acpi_has_method(handle, "_BQC"))
printk(KERN_WARNING FW_BUG PREFIX "No _BQC method, " printk(KERN_WARNING FW_BUG PREFIX "No _BQC method, "
"cannot determine initial brightness\n"); "cannot determine initial brightness\n");
/* We have backlight support, no need to scan further */ /* We have backlight support, no need to scan further */
...@@ -77,22 +76,20 @@ acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context, ...@@ -77,22 +76,20 @@ acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context,
*/ */
long acpi_is_video_device(acpi_handle handle) long acpi_is_video_device(acpi_handle handle)
{ {
acpi_handle h_dummy;
long video_caps = 0; long video_caps = 0;
/* Is this device able to support video switching ? */ /* Is this device able to support video switching ? */
if (ACPI_SUCCESS(acpi_get_handle(handle, "_DOD", &h_dummy)) || if (acpi_has_method(handle, "_DOD") || acpi_has_method(handle, "_DOS"))
ACPI_SUCCESS(acpi_get_handle(handle, "_DOS", &h_dummy)))
video_caps |= ACPI_VIDEO_OUTPUT_SWITCHING; video_caps |= ACPI_VIDEO_OUTPUT_SWITCHING;
/* Is this device able to retrieve a video ROM ? */ /* Is this device able to retrieve a video ROM ? */
if (ACPI_SUCCESS(acpi_get_handle(handle, "_ROM", &h_dummy))) if (acpi_has_method(handle, "_ROM"))
video_caps |= ACPI_VIDEO_ROM_AVAILABLE; video_caps |= ACPI_VIDEO_ROM_AVAILABLE;
/* Is this device able to configure which video head to be POSTed ? */ /* Is this device able to configure which video head to be POSTed ? */
if (ACPI_SUCCESS(acpi_get_handle(handle, "_VPO", &h_dummy)) && if (acpi_has_method(handle, "_VPO") &&
ACPI_SUCCESS(acpi_get_handle(handle, "_GPD", &h_dummy)) && acpi_has_method(handle, "_GPD") &&
ACPI_SUCCESS(acpi_get_handle(handle, "_SPD", &h_dummy))) acpi_has_method(handle, "_SPD"))
video_caps |= ACPI_VIDEO_DEVICE_POSTING; video_caps |= ACPI_VIDEO_DEVICE_POSTING;
/* Only check for backlight functionality if one of the above hit. */ /* Only check for backlight functionality if one of the above hit. */
......
...@@ -56,6 +56,9 @@ acpi_evaluate_hotplug_ost(acpi_handle handle, u32 source_event, ...@@ -56,6 +56,9 @@ acpi_evaluate_hotplug_ost(acpi_handle handle, u32 source_event,
acpi_status acpi_status
acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld); acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld);
bool acpi_has_method(acpi_handle handle, char *name);
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册