[PATCH v2 27/28] drivers: Introduce driver_find_device_by_acpi_dev() helper

From: Suzuki K Poulose
Date: Fri Jun 14 2019 - 14:00:25 EST


Add a wrapper to driver_find_device() to search for a device
by the ACPI COMPANION device, reusing the generic match function.

Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
---
include/linux/device.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/include/linux/device.h b/include/linux/device.h
index 77f817d..a2a8ac2 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -481,6 +481,27 @@ static inline struct device *driver_find_next_device(struct device_driver *drv,
return driver_find_device(drv, start, NULL, device_match_any);
}

+#ifdef CONFIG_ACPI
+/**
+ * driver_find_device_by_acpi_dev : device iterator for locating a particular
+ * device matching the ACPI_COMPANION device.
+ * @driver: the driver we're iterating
+ * @adev: ACPI_COMPANION device to match.
+ */
+static inline struct device *
+driver_find_device_by_acpi_dev(struct device_driver *drv,
+ const struct acpi_device *adev)
+{
+ return driver_find_device(drv, NULL, adev, device_match_acpi_dev);
+}
+#else
+static inline struct device *
+driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev)
+{
+ return NULL;
+}
+#endif
+
void driver_deferred_probe_add(struct device *dev);
int driver_deferred_probe_check_state(struct device *dev);

--
2.7.4