[v2,16/28] drivers: Introduce class_find_device_by_acpi_dev() helper
diff mbox series

Message ID 1560534863-15115-17-git-send-email-suzuki.poulose@arm.com
State New
Headers show
Series
  • [v2,01/28] staging: most-core: Use bus_find_device_by_name
Related show

Commit Message

Suzuki K Poulose June 14, 2019, 5:54 p.m. UTC
Add a wrapper to class_find_device() to search for a device
by the ACPI COMPANION device, reusing the generic match function.

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

Patch
diff mbox series

diff --git a/include/linux/device.h b/include/linux/device.h
index 2effcc2..b1b8c90 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -534,6 +534,27 @@  static inline struct device *class_find_device_by_devt(struct class *class,
 	return class_find_device(class, NULL, &devt, device_match_devt);
 }
 
+#ifdef CONFIG_ACPI
+struct acpi_device;
+/**
+ * class_find_device_by_acpi_dev : device iterator for locating a particular
+ * device matching the ACPI_COMPANION device.
+ * @class: class type
+ * @adev: ACPI_COMPANION device to match.
+ */
+static inline struct device *
+class_find_device_by_acpi_dev(struct class *class, const struct acpi_device *adev)
+{
+	return class_find_device(class, NULL, adev, device_match_acpi_dev);
+}
+#else
+static inline struct device *
+class_find_device_by_acpi_dev(struct class *class, const void *adev)
+{
+	return NULL;
+}
+#endif
+
 struct class_attribute {
 	struct attribute attr;
 	ssize_t (*show)(struct class *class, struct class_attribute *attr,