mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
ACPI: Use acpi_fetch_acpi_dev() instead of acpi_bus_get_device()
Modify the ACPI code to use acpi_fetch_acpi_dev() instead of acpi_bus_get_device() where applicable. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
e3c963c498
commit
99ece71377
@ -1733,13 +1733,12 @@ acpi_video_bus_match(acpi_handle handle, u32 level, void *context,
|
|||||||
{
|
{
|
||||||
struct acpi_device *device = context;
|
struct acpi_device *device = context;
|
||||||
struct acpi_device *sibling;
|
struct acpi_device *sibling;
|
||||||
int result;
|
|
||||||
|
|
||||||
if (handle == device->handle)
|
if (handle == device->handle)
|
||||||
return AE_CTRL_TERMINATE;
|
return AE_CTRL_TERMINATE;
|
||||||
|
|
||||||
result = acpi_bus_get_device(handle, &sibling);
|
sibling = acpi_fetch_acpi_dev(handle);
|
||||||
if (result)
|
if (!sibling)
|
||||||
return AE_OK;
|
return AE_OK;
|
||||||
|
|
||||||
if (!strcmp(acpi_device_name(sibling), ACPI_VIDEO_BUS_NAME))
|
if (!strcmp(acpi_device_name(sibling), ACPI_VIDEO_BUS_NAME))
|
||||||
|
@ -285,14 +285,12 @@ EXPORT_SYMBOL(acpi_device_set_power);
|
|||||||
|
|
||||||
int acpi_bus_set_power(acpi_handle handle, int state)
|
int acpi_bus_set_power(acpi_handle handle, int state)
|
||||||
{
|
{
|
||||||
struct acpi_device *device;
|
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
|
||||||
int result;
|
|
||||||
|
|
||||||
result = acpi_bus_get_device(handle, &device);
|
if (device)
|
||||||
if (result)
|
return acpi_device_set_power(device, state);
|
||||||
return result;
|
|
||||||
|
|
||||||
return acpi_device_set_power(device, state);
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(acpi_bus_set_power);
|
EXPORT_SYMBOL(acpi_bus_set_power);
|
||||||
|
|
||||||
@ -410,21 +408,20 @@ EXPORT_SYMBOL_GPL(acpi_device_update_power);
|
|||||||
|
|
||||||
int acpi_bus_update_power(acpi_handle handle, int *state_p)
|
int acpi_bus_update_power(acpi_handle handle, int *state_p)
|
||||||
{
|
{
|
||||||
struct acpi_device *device;
|
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
|
||||||
int result;
|
|
||||||
|
|
||||||
result = acpi_bus_get_device(handle, &device);
|
if (device)
|
||||||
return result ? result : acpi_device_update_power(device, state_p);
|
return acpi_device_update_power(device, state_p);
|
||||||
|
|
||||||
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(acpi_bus_update_power);
|
EXPORT_SYMBOL_GPL(acpi_bus_update_power);
|
||||||
|
|
||||||
bool acpi_bus_power_manageable(acpi_handle handle)
|
bool acpi_bus_power_manageable(acpi_handle handle)
|
||||||
{
|
{
|
||||||
struct acpi_device *device;
|
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
|
||||||
int result;
|
|
||||||
|
|
||||||
result = acpi_bus_get_device(handle, &device);
|
return device && device->flags.power_manageable;
|
||||||
return result ? false : device->flags.power_manageable;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(acpi_bus_power_manageable);
|
EXPORT_SYMBOL(acpi_bus_power_manageable);
|
||||||
|
|
||||||
@ -543,11 +540,9 @@ acpi_status acpi_remove_pm_notifier(struct acpi_device *adev)
|
|||||||
|
|
||||||
bool acpi_bus_can_wakeup(acpi_handle handle)
|
bool acpi_bus_can_wakeup(acpi_handle handle)
|
||||||
{
|
{
|
||||||
struct acpi_device *device;
|
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
|
||||||
int result;
|
|
||||||
|
|
||||||
result = acpi_bus_get_device(handle, &device);
|
return device && device->wakeup.flags.valid;
|
||||||
return result ? false : device->wakeup.flags.valid;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(acpi_bus_can_wakeup);
|
EXPORT_SYMBOL(acpi_bus_can_wakeup);
|
||||||
|
|
||||||
|
@ -489,9 +489,8 @@ static ssize_t docked_show(struct device *dev,
|
|||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct dock_station *dock_station = dev->platform_data;
|
struct dock_station *dock_station = dev->platform_data;
|
||||||
struct acpi_device *adev = NULL;
|
struct acpi_device *adev = acpi_fetch_acpi_dev(dock_station->handle);
|
||||||
|
|
||||||
acpi_bus_get_device(dock_station->handle, &adev);
|
|
||||||
return sysfs_emit(buf, "%u\n", acpi_device_enumerated(adev));
|
return sysfs_emit(buf, "%u\n", acpi_device_enumerated(adev));
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR_RO(docked);
|
static DEVICE_ATTR_RO(docked);
|
||||||
|
@ -606,12 +606,10 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
|
|||||||
int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering,
|
int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering,
|
||||||
int *polarity, char **name)
|
int *polarity, char **name)
|
||||||
{
|
{
|
||||||
int result;
|
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
|
||||||
struct acpi_device *device;
|
|
||||||
struct acpi_pci_link *link;
|
struct acpi_pci_link *link;
|
||||||
|
|
||||||
result = acpi_bus_get_device(handle, &device);
|
if (!device) {
|
||||||
if (result) {
|
|
||||||
acpi_handle_err(handle, "Invalid link device\n");
|
acpi_handle_err(handle, "Invalid link device\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -658,12 +656,10 @@ int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering,
|
|||||||
*/
|
*/
|
||||||
int acpi_pci_link_free_irq(acpi_handle handle)
|
int acpi_pci_link_free_irq(acpi_handle handle)
|
||||||
{
|
{
|
||||||
struct acpi_device *device;
|
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
|
||||||
struct acpi_pci_link *link;
|
struct acpi_pci_link *link;
|
||||||
acpi_status result;
|
|
||||||
|
|
||||||
result = acpi_bus_get_device(handle, &device);
|
if (!device) {
|
||||||
if (result) {
|
|
||||||
acpi_handle_err(handle, "Invalid link device\n");
|
acpi_handle_err(handle, "Invalid link device\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -67,11 +67,10 @@ static struct acpi_scan_handler pci_root_handler = {
|
|||||||
*/
|
*/
|
||||||
int acpi_is_root_bridge(acpi_handle handle)
|
int acpi_is_root_bridge(acpi_handle handle)
|
||||||
{
|
{
|
||||||
|
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
|
||||||
int ret;
|
int ret;
|
||||||
struct acpi_device *device;
|
|
||||||
|
|
||||||
ret = acpi_bus_get_device(handle, &device);
|
if (!device)
|
||||||
if (ret)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = acpi_match_device_ids(device, root_device_ids);
|
ret = acpi_match_device_ids(device, root_device_ids);
|
||||||
@ -215,11 +214,10 @@ static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root,
|
|||||||
|
|
||||||
struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
|
struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
|
||||||
{
|
{
|
||||||
|
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
|
||||||
struct acpi_pci_root *root;
|
struct acpi_pci_root *root;
|
||||||
struct acpi_device *device;
|
|
||||||
|
|
||||||
if (acpi_bus_get_device(handle, &device) ||
|
if (!device || acpi_match_device_ids(device, root_device_ids))
|
||||||
acpi_match_device_ids(device, root_device_ids))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
root = acpi_driver_data(device);
|
root = acpi_driver_data(device);
|
||||||
|
@ -81,9 +81,9 @@ struct acpi_power_resource *to_power_resource(struct acpi_device *device)
|
|||||||
|
|
||||||
static struct acpi_power_resource *acpi_power_get_context(acpi_handle handle)
|
static struct acpi_power_resource *acpi_power_get_context(acpi_handle handle)
|
||||||
{
|
{
|
||||||
struct acpi_device *device;
|
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
|
||||||
|
|
||||||
if (acpi_bus_get_device(handle, &device))
|
if (!device)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return to_power_resource(device);
|
return to_power_resource(device);
|
||||||
@ -916,15 +916,14 @@ static void acpi_power_add_resource_to_list(struct acpi_power_resource *resource
|
|||||||
|
|
||||||
struct acpi_device *acpi_add_power_resource(acpi_handle handle)
|
struct acpi_device *acpi_add_power_resource(acpi_handle handle)
|
||||||
{
|
{
|
||||||
|
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
|
||||||
struct acpi_power_resource *resource;
|
struct acpi_power_resource *resource;
|
||||||
struct acpi_device *device = NULL;
|
|
||||||
union acpi_object acpi_object;
|
union acpi_object acpi_object;
|
||||||
struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object };
|
struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object };
|
||||||
acpi_status status;
|
acpi_status status;
|
||||||
u8 state_dummy;
|
u8 state_dummy;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
acpi_bus_get_device(handle, &device);
|
|
||||||
if (device)
|
if (device)
|
||||||
return device;
|
return device;
|
||||||
|
|
||||||
|
@ -98,8 +98,13 @@ static int acpi_soft_cpu_online(unsigned int cpu)
|
|||||||
struct acpi_processor *pr = per_cpu(processors, cpu);
|
struct acpi_processor *pr = per_cpu(processors, cpu);
|
||||||
struct acpi_device *device;
|
struct acpi_device *device;
|
||||||
|
|
||||||
if (!pr || acpi_bus_get_device(pr->handle, &device))
|
if (!pr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
device = acpi_fetch_acpi_dev(pr->handle);
|
||||||
|
if (!device)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CPU got physically hotplugged and onlined for the first time:
|
* CPU got physically hotplugged and onlined for the first time:
|
||||||
* Initialize missing things.
|
* Initialize missing things.
|
||||||
@ -125,9 +130,8 @@ static int acpi_soft_cpu_online(unsigned int cpu)
|
|||||||
static int acpi_soft_cpu_dead(unsigned int cpu)
|
static int acpi_soft_cpu_dead(unsigned int cpu)
|
||||||
{
|
{
|
||||||
struct acpi_processor *pr = per_cpu(processors, cpu);
|
struct acpi_processor *pr = per_cpu(processors, cpu);
|
||||||
struct acpi_device *device;
|
|
||||||
|
|
||||||
if (!pr || acpi_bus_get_device(pr->handle, &device))
|
if (!pr || !acpi_fetch_acpi_dev(pr->handle))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
acpi_processor_reevaluate_tstate(pr, true);
|
acpi_processor_reevaluate_tstate(pr, true);
|
||||||
|
@ -1101,7 +1101,7 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr)
|
|||||||
|
|
||||||
status = acpi_get_parent(handle, &pr_ahandle);
|
status = acpi_get_parent(handle, &pr_ahandle);
|
||||||
while (ACPI_SUCCESS(status)) {
|
while (ACPI_SUCCESS(status)) {
|
||||||
acpi_bus_get_device(pr_ahandle, &d);
|
d = acpi_fetch_acpi_dev(pr_ahandle);
|
||||||
handle = pr_ahandle;
|
handle = pr_ahandle;
|
||||||
|
|
||||||
if (strcmp(acpi_device_hid(d), ACPI_PROCESSOR_CONTAINER_HID))
|
if (strcmp(acpi_device_hid(d), ACPI_PROCESSOR_CONTAINER_HID))
|
||||||
|
@ -687,9 +687,9 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
|
|||||||
if (index)
|
if (index)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
ret = acpi_bus_get_device(obj->reference.handle, &device);
|
device = acpi_fetch_acpi_dev(obj->reference.handle);
|
||||||
if (ret)
|
if (!device)
|
||||||
return ret == -ENODEV ? -EINVAL : ret;
|
return -EINVAL;
|
||||||
|
|
||||||
args->fwnode = acpi_fwnode_handle(device);
|
args->fwnode = acpi_fwnode_handle(device);
|
||||||
args->nargs = 0;
|
args->nargs = 0;
|
||||||
@ -719,9 +719,8 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
|
|||||||
if (element->type == ACPI_TYPE_LOCAL_REFERENCE) {
|
if (element->type == ACPI_TYPE_LOCAL_REFERENCE) {
|
||||||
struct fwnode_handle *ref_fwnode;
|
struct fwnode_handle *ref_fwnode;
|
||||||
|
|
||||||
ret = acpi_bus_get_device(element->reference.handle,
|
device = acpi_fetch_acpi_dev(element->reference.handle);
|
||||||
&device);
|
if (!device)
|
||||||
if (ret)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
nargs = 0;
|
nargs = 0;
|
||||||
|
@ -791,9 +791,9 @@ static acpi_status acpi_res_consumer_cb(acpi_handle handle, u32 depth,
|
|||||||
{
|
{
|
||||||
struct resource *res = context;
|
struct resource *res = context;
|
||||||
struct acpi_device **consumer = (struct acpi_device **) ret;
|
struct acpi_device **consumer = (struct acpi_device **) ret;
|
||||||
struct acpi_device *adev;
|
struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
|
||||||
|
|
||||||
if (acpi_bus_get_device(handle, &adev))
|
if (!adev)
|
||||||
return AE_OK;
|
return AE_OK;
|
||||||
|
|
||||||
if (acpi_dev_consumes_res(adev, res)) {
|
if (acpi_dev_consumes_res(adev, res)) {
|
||||||
|
@ -697,7 +697,6 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
|
|||||||
struct acpi_device *device = cdev->devdata;
|
struct acpi_device *device = cdev->devdata;
|
||||||
struct acpi_thermal *tz = thermal->devdata;
|
struct acpi_thermal *tz = thermal->devdata;
|
||||||
struct acpi_device *dev;
|
struct acpi_device *dev;
|
||||||
acpi_status status;
|
|
||||||
acpi_handle handle;
|
acpi_handle handle;
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
@ -715,8 +714,8 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
|
|||||||
for (i = 0; i < tz->trips.passive.devices.count;
|
for (i = 0; i < tz->trips.passive.devices.count;
|
||||||
i++) {
|
i++) {
|
||||||
handle = tz->trips.passive.devices.handles[i];
|
handle = tz->trips.passive.devices.handles[i];
|
||||||
status = acpi_bus_get_device(handle, &dev);
|
dev = acpi_fetch_acpi_dev(handle);
|
||||||
if (ACPI_FAILURE(status) || dev != device)
|
if (dev != device)
|
||||||
continue;
|
continue;
|
||||||
if (bind)
|
if (bind)
|
||||||
result =
|
result =
|
||||||
@ -741,8 +740,8 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
|
|||||||
j < tz->trips.active[i].devices.count;
|
j < tz->trips.active[i].devices.count;
|
||||||
j++) {
|
j++) {
|
||||||
handle = tz->trips.active[i].devices.handles[j];
|
handle = tz->trips.active[i].devices.handles[j];
|
||||||
status = acpi_bus_get_device(handle, &dev);
|
dev = acpi_fetch_acpi_dev(handle);
|
||||||
if (ACPI_FAILURE(status) || dev != device)
|
if (dev != device)
|
||||||
continue;
|
continue;
|
||||||
if (bind)
|
if (bind)
|
||||||
result = thermal_zone_bind_cooling_device
|
result = thermal_zone_bind_cooling_device
|
||||||
|
@ -59,18 +59,16 @@ static void acpi_video_parse_cmdline(void)
|
|||||||
static acpi_status
|
static acpi_status
|
||||||
find_video(acpi_handle handle, u32 lvl, void *context, void **rv)
|
find_video(acpi_handle handle, u32 lvl, void *context, void **rv)
|
||||||
{
|
{
|
||||||
|
struct acpi_device *acpi_dev = acpi_fetch_acpi_dev(handle);
|
||||||
long *cap = context;
|
long *cap = context;
|
||||||
struct pci_dev *dev;
|
struct pci_dev *dev;
|
||||||
struct acpi_device *acpi_dev;
|
|
||||||
|
|
||||||
static const struct acpi_device_id video_ids[] = {
|
static const struct acpi_device_id video_ids[] = {
|
||||||
{ACPI_VIDEO_HID, 0},
|
{ACPI_VIDEO_HID, 0},
|
||||||
{"", 0},
|
{"", 0},
|
||||||
};
|
};
|
||||||
if (acpi_bus_get_device(handle, &acpi_dev))
|
|
||||||
return AE_OK;
|
|
||||||
|
|
||||||
if (!acpi_match_device_ids(acpi_dev, video_ids)) {
|
if (acpi_dev && !acpi_match_device_ids(acpi_dev, video_ids)) {
|
||||||
dev = acpi_get_pci_dev(handle);
|
dev = acpi_get_pci_dev(handle);
|
||||||
if (!dev)
|
if (!dev)
|
||||||
return AE_OK;
|
return AE_OK;
|
||||||
|
@ -293,9 +293,9 @@ static void lpi_check_constraints(void)
|
|||||||
|
|
||||||
for (i = 0; i < lpi_constraints_table_size; ++i) {
|
for (i = 0; i < lpi_constraints_table_size; ++i) {
|
||||||
acpi_handle handle = lpi_constraints_table[i].handle;
|
acpi_handle handle = lpi_constraints_table[i].handle;
|
||||||
struct acpi_device *adev;
|
struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
|
||||||
|
|
||||||
if (!handle || acpi_bus_get_device(handle, &adev))
|
if (!adev)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
acpi_handle_debug(handle,
|
acpi_handle_debug(handle,
|
||||||
|
Loading…
Reference in New Issue
Block a user