[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1559747630-28065-14-git-send-email-suzuki.poulose@arm.com>
Date: Wed, 5 Jun 2019 16:13:50 +0100
From: Suzuki K Poulose <suzuki.poulose@....com>
To: linux-kernel@...r.kernel.org
Cc: gregkh@...uxfoundation.org, rafael@...nel.org,
suzuki.poulose@....com, Eric Anholt <eric@...olt.net>,
Heiko Stübner <heiko@...ech.de>,
Inki Dae <inki.dae@...sung.com>,
Sandy Huang <hjc@...k-chips.com>,
Seung-Woo Kim <sw0312.kim@...sung.com>
Subject: [PATCH 13/13] platform: Add platform_find_device_by_driver() helper
Provide a helper to lookup platform devices by matching device
driver in order to avoid drivers trying to use platform bus
internals.
Cc: Eric Anholt <eric@...olt.net>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: "Heiko Stübner" <heiko@...ech.de>
Cc: Inki Dae <inki.dae@...sung.com>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>
Cc: Sandy Huang <hjc@...k-chips.com>
Cc: Seung-Woo Kim <sw0312.kim@...sung.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@....com>
---
drivers/base/platform.c | 14 ++++++++++++++
include/linux/platform_device.h | 3 +++
2 files changed, 17 insertions(+)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 4d17298..158ac24 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1197,6 +1197,20 @@ struct bus_type platform_bus_type = {
};
EXPORT_SYMBOL_GPL(platform_bus_type);
+/**
+ * platform_find_device_by_driver - Find a platform device with a given
+ * driver.
+ * @start: The device to start the search from.
+ * @drv: The device driver to look for.
+ */
+struct device *platform_find_device_by_driver(struct device *start,
+ const struct device_driver *drv)
+{
+ return bus_find_device(&platform_bus_type, start, drv,
+ (void *)platform_match);
+}
+EXPORT_SYMBOL_GPL(platform_find_device_by_driver);
+
int __init platform_bus_init(void)
{
int error;
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index cc46485..36aa775 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -52,6 +52,9 @@ extern struct device platform_bus;
extern void arch_setup_pdev_archdata(struct platform_device *);
extern struct resource *platform_get_resource(struct platform_device *,
unsigned int, unsigned int);
+extern struct device *
+platform_find_device_by_driver(struct device * dev,
+ const struct device_driver *drv);
extern void __iomem *
devm_platform_ioremap_resource(struct platform_device *pdev,
unsigned int index);
--
2.7.4
Powered by blists - more mailing lists