From: wangkefeng.wang@huawei.com (Kefeng Wang)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 3/4] ACPI/platform: Introduce helper acpi_dev_find_plat_dev()
Date: Wed, 2 Dec 2015 17:09:27 +0800 [thread overview]
Message-ID: <1449047368-5768-4-git-send-email-wangkefeng.wang@huawei.com> (raw)
In-Reply-To: <1449047368-5768-1-git-send-email-wangkefeng.wang@huawei.com>
Sometimes in a device object, we refer to another device object,
mostly in _DSD method, and we need to get platform device with
the ACPI device node from the referenced device object. So introduce
the helper acpi_dev_find_plat_dev() to do this.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
drivers/acpi/acpi_platform.c | 25 +++++++++++++++++++++++++
include/linux/acpi.h | 6 ++++++
2 files changed, 31 insertions(+)
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 296b7a1..2603f9b 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -121,3 +121,28 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
return pdev;
}
EXPORT_SYMBOL_GPL(acpi_create_platform_device);
+
+static int acpi_dev_object_match(struct device *dev, void *data)
+{
+ return ACPI_COMPANION(dev) == data;
+}
+
+/*
+ * acpi_find_plat_device - Find the platform_device associated
+ * with an acpi device
+ * @adev: Pointer to the acpi device
+ *
+ * Returns platform_device pointer, or NULL if not found
+ */
+struct platform_device *acpi_dev_find_plat_dev(struct acpi_device *adev)
+{
+ struct device *dev;
+
+ if (!adev)
+ return NULL;
+
+ dev = bus_find_device(&platform_bus_type, NULL, adev,
+ acpi_dev_object_match);
+ return dev ? to_platform_device(dev) : NULL;
+}
+EXPORT_SYMBOL(acpi_dev_find_plat_dev);
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index d76a688..16af22f 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -468,6 +468,7 @@ int acpi_device_modalias(struct device *, char *, int);
void acpi_walk_dep_device_list(acpi_handle handle);
struct platform_device *acpi_create_platform_device(struct acpi_device *);
+struct platform_device *acpi_dev_find_plat_dev(struct acpi_device *adev);
#define ACPI_PTR(_ptr) (_ptr)
#else /* !CONFIG_ACPI */
@@ -929,6 +930,11 @@ static inline struct fwnode_handle *acpi_get_next_subnode(struct device *dev,
return NULL;
}
+static inline struct platform_device *acpi_dev_find_plat_dev(struct acpi_device *adev)
+{
+ return NULL;
+}
+
#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, validate, data, fn) \
static const void * __acpi_table_##name[] \
__attribute__((unused)) \
--
1.7.12.4
next prev parent reply other threads:[~2015-12-02 9:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-02 9:09 [RFC PATCH 0/4] add ACPI support for syscon Kefeng Wang
2015-12-02 9:09 ` [RFC PATCH 1/4] acpi: property: Introduce helper acpi_dev_get_reference_device() Kefeng Wang
2015-12-02 9:20 ` Mika Westerberg
2015-12-02 9:09 ` [RFC PATCH 2/4] device property: Introduce helper device_get_reference_node() Kefeng Wang
2015-12-03 15:28 ` Russell King - ARM Linux
2015-12-03 23:29 ` Rafael J. Wysocki
2015-12-04 1:02 ` Rafael J. Wysocki
2015-12-11 12:35 ` Lorenzo Pieralisi
2015-12-02 9:09 ` Kefeng Wang [this message]
2015-12-02 9:09 ` [RFC PATCH 4/4] mfd: syscon: add ACPI support Kefeng Wang
2015-12-02 10:44 ` Arnd Bergmann
2015-12-03 10:41 ` Graeme Gregory
2015-12-03 13:01 ` Kefeng Wang
2015-12-03 15:56 ` Lorenzo Pieralisi
2015-12-07 6:15 ` Kefeng Wang
2015-12-07 8:47 ` Arnd Bergmann
2015-12-11 10:35 ` Zhangfei Gao
2015-12-11 10:51 ` Arnd Bergmann
2015-12-11 10:59 ` Graeme Gregory
2015-12-11 12:23 ` Hanjun Guo
2015-12-02 10:50 ` [RFC PATCH 0/4] add ACPI support for syscon Lorenzo Pieralisi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1449047368-5768-4-git-send-email-wangkefeng.wang@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).