Commit 99ece713 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
parent e3c963c4
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -1733,13 +1733,12 @@ acpi_video_bus_match(acpi_handle handle, u32 level, void *context,
{
	struct acpi_device *device = context;
	struct acpi_device *sibling;
	int result;

	if (handle == device->handle)
		return AE_CTRL_TERMINATE;

	result = acpi_bus_get_device(handle, &sibling);
	if (result)
	sibling = acpi_fetch_acpi_dev(handle);
	if (!sibling)
		return AE_OK;

	if (!strcmp(acpi_device_name(sibling), ACPI_VIDEO_BUS_NAME))
+13 −18
Original line number Diff line number Diff line
@@ -285,14 +285,12 @@ EXPORT_SYMBOL(acpi_device_set_power);

int acpi_bus_set_power(acpi_handle handle, int state)
{
	struct acpi_device *device;
	int result;

	result = acpi_bus_get_device(handle, &device);
	if (result)
		return result;
	struct acpi_device *device = acpi_fetch_acpi_dev(handle);

	if (device)
		return acpi_device_set_power(device, state);

	return -ENODEV;
}
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)
{
	struct acpi_device *device;
	int result;
	struct acpi_device *device = acpi_fetch_acpi_dev(handle);

	if (device)
		return acpi_device_update_power(device, state_p);

	result = acpi_bus_get_device(handle, &device);
	return result ? result : acpi_device_update_power(device, state_p);
	return -ENODEV;
}
EXPORT_SYMBOL_GPL(acpi_bus_update_power);

bool acpi_bus_power_manageable(acpi_handle handle)
{
	struct acpi_device *device;
	int result;
	struct acpi_device *device = acpi_fetch_acpi_dev(handle);

	result = acpi_bus_get_device(handle, &device);
	return result ? false : device->flags.power_manageable;
	return device && device->flags.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)
{
	struct acpi_device *device;
	int result;
	struct acpi_device *device = acpi_fetch_acpi_dev(handle);

	result = acpi_bus_get_device(handle, &device);
	return result ? false : device->wakeup.flags.valid;
	return device && device->wakeup.flags.valid;
}
EXPORT_SYMBOL(acpi_bus_can_wakeup);

+1 −2
Original line number Diff line number Diff line
@@ -489,9 +489,8 @@ static ssize_t docked_show(struct device *dev,
			   struct device_attribute *attr, char *buf)
{
	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));
}
static DEVICE_ATTR_RO(docked);
+4 −8
Original line number Diff line number Diff line
@@ -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 *polarity, char **name)
{
	int result;
	struct acpi_device *device;
	struct acpi_device *device = acpi_fetch_acpi_dev(handle);
	struct acpi_pci_link *link;

	result = acpi_bus_get_device(handle, &device);
	if (result) {
	if (!device) {
		acpi_handle_err(handle, "Invalid link device\n");
		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)
{
	struct acpi_device *device;
	struct acpi_device *device = acpi_fetch_acpi_dev(handle);
	struct acpi_pci_link *link;
	acpi_status result;

	result = acpi_bus_get_device(handle, &device);
	if (result) {
	if (!device) {
		acpi_handle_err(handle, "Invalid link device\n");
		return -1;
	}
+4 −6
Original line number Diff line number Diff line
@@ -67,11 +67,10 @@ static struct acpi_scan_handler pci_root_handler = {
 */
int acpi_is_root_bridge(acpi_handle handle)
{
	struct acpi_device *device = acpi_fetch_acpi_dev(handle);
	int ret;
	struct acpi_device *device;

	ret = acpi_bus_get_device(handle, &device);
	if (ret)
	if (!device)
		return 0;

	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_device *device = acpi_fetch_acpi_dev(handle);
	struct acpi_pci_root *root;
	struct acpi_device *device;

	if (acpi_bus_get_device(handle, &device) ||
	    acpi_match_device_ids(device, root_device_ids))
	if (!device || acpi_match_device_ids(device, root_device_ids))
		return NULL;

	root = acpi_driver_data(device);
Loading