Skip to content

Commit

Permalink
acpi: utils: move acpi_lpss_dep() to utils
Browse files Browse the repository at this point in the history
I need to be able to identify devices which declare themselves to be
dependent on other devices through _DEP; add this function to utils.c
and export it to the rest of the ACPI layer.

Signed-off-by: Daniel Scally <djrscally@gmail.com>
Patchset: cameras
  • Loading branch information
djrscally authored and qzed committed Feb 15, 2021
1 parent d98b0de commit 5ecff4b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
24 changes: 0 additions & 24 deletions drivers/acpi/acpi_lpss.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,30 +543,6 @@ static struct device *acpi_lpss_find_device(const char *hid, const char *uid)
return bus_find_device(&pci_bus_type, NULL, &data, match_hid_uid);
}

static bool acpi_lpss_dep(struct acpi_device *adev, acpi_handle handle)
{
struct acpi_handle_list dep_devices;
acpi_status status;
int i;

if (!acpi_has_method(adev->handle, "_DEP"))
return false;

status = acpi_evaluate_reference(adev->handle, "_DEP", NULL,
&dep_devices);
if (ACPI_FAILURE(status)) {
dev_dbg(&adev->dev, "Failed to evaluate _DEP.\n");
return false;
}

for (i = 0; i < dep_devices.count; i++) {
if (dep_devices.handles[i] == handle)
return true;
}

return false;
}

static void acpi_lpss_link_consumer(struct device *dev1,
const struct lpss_device_links *link)
{
Expand Down
1 change: 1 addition & 0 deletions drivers/acpi/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ static inline void acpi_lpss_init(void) {}
#endif

void acpi_apd_init(void);
bool acpi_lpss_dep(struct acpi_device *adev, acpi_handle handle);

acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src);
bool acpi_queue_hotplug_work(struct work_struct *work);
Expand Down
24 changes: 24 additions & 0 deletions drivers/acpi/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,30 @@ static int acpi_dev_match_cb(struct device *dev, const void *data)
return hrv == match->hrv;
}

bool acpi_lpss_dep(struct acpi_device *adev, acpi_handle handle)
{
struct acpi_handle_list dep_devices;
acpi_status status;
int i;

if (!acpi_has_method(adev->handle, "_DEP"))
return false;

status = acpi_evaluate_reference(adev->handle, "_DEP", NULL,
&dep_devices);
if (ACPI_FAILURE(status)) {
dev_dbg(&adev->dev, "Failed to evaluate _DEP.\n");
return false;
}

for (i = 0; i < dep_devices.count; i++) {
if (dep_devices.handles[i] == handle)
return true;
}

return false;
}

/**
* acpi_dev_present - Detect that a given ACPI device is present
* @hid: Hardware ID of the device.
Expand Down

0 comments on commit 5ecff4b

Please sign in to comment.