From patchwork Wed Dec 2 09:09:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 57537 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp2738063lbb; Wed, 2 Dec 2015 01:12:33 -0800 (PST) X-Received: by 10.66.172.164 with SMTP id bd4mr3043816pac.64.1449047549620; Wed, 02 Dec 2015 01:12:29 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tq4si3363466pab.243.2015.12.02.01.12.29; Wed, 02 Dec 2015 01:12:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756789AbbLBJM1 (ORCPT + 6 others); Wed, 2 Dec 2015 04:12:27 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:12300 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756878AbbLBJMZ (ORCPT ); Wed, 2 Dec 2015 04:12:25 -0500 Received: from 172.24.1.49 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.49]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DAB70778; Wed, 02 Dec 2015 17:11:20 +0800 (CST) Received: from localhost (10.177.19.180) by szxeml431-hub.china.huawei.com (10.82.67.208) with Microsoft SMTP Server id 14.3.235.1; Wed, 2 Dec 2015 17:11:13 +0800 From: Kefeng Wang To: "Rafael J. Wysocki" , Arnd Bergmann CC: Hanjun Guo , , , Kefeng Wang Subject: [RFC PATCH 3/4] ACPI/platform: Introduce helper acpi_dev_find_plat_dev() Date: Wed, 2 Dec 2015 17:09:27 +0800 Message-ID: <1449047368-5768-4-git-send-email-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1449047368-5768-1-git-send-email-wangkefeng.wang@huawei.com> References: <1449047368-5768-1-git-send-email-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.19.180] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090201.565EB5B9.005F, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 9316aa6fc92689da7a2e8ee5a79b019e Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 --- drivers/acpi/acpi_platform.c | 25 +++++++++++++++++++++++++ include/linux/acpi.h | 6 ++++++ 2 files changed, 31 insertions(+) -- 1.7.12.4 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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)) \