From patchwork Thu Dec 7 21:10:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10101069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ED17A6056F for ; Thu, 7 Dec 2017 21:12:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE00028711 for ; Thu, 7 Dec 2017 21:12:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D32E128712; Thu, 7 Dec 2017 21:12:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DBFC28726 for ; Thu, 7 Dec 2017 21:12:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752609AbdLGVKo (ORCPT ); Thu, 7 Dec 2017 16:10:44 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:59362 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751014AbdLGVKl (ORCPT ); Thu, 7 Dec 2017 16:10:41 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C786B60852; Thu, 7 Dec 2017 21:10:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1512681040; bh=zoq2Fx79fTPBCxOc4t3HgkyPfyDEoqVG6gm8OoQBQwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iPEu+EWaqmOwy//qmBX180WEGIp2lWvGaEesyu9zf8sRcQNVJbdA5z2KToJpolGwZ 18Z3D+sJGESXKtitxsXvvV3Ue3Hcpqcl+sKGxDGvjPO/V38MDdtpKD/kpbdBvL4eu1 rCfmLi0BFxw1I6NLOMLf8LLdeZH9fagx1D4mgB4M= Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 16B016083B; Thu, 7 Dec 2017 21:10:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1512681040; bh=zoq2Fx79fTPBCxOc4t3HgkyPfyDEoqVG6gm8OoQBQwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iPEu+EWaqmOwy//qmBX180WEGIp2lWvGaEesyu9zf8sRcQNVJbdA5z2KToJpolGwZ 18Z3D+sJGESXKtitxsXvvV3Ue3Hcpqcl+sKGxDGvjPO/V38MDdtpKD/kpbdBvL4eu1 rCfmLi0BFxw1I6NLOMLf8LLdeZH9fagx1D4mgB4M= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 16B016083B Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: dmaengine@vger.kernel.org, timur@codeaurora.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, sakari.ailus@linux.intel.com Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , "Rafael J. Wysocki" , Len Brown , linux-kernel@vger.kernel.org (open list) Subject: [PATCH V7 2/7] ACPI / bus: Introduce acpi_get_match_data() function Date: Thu, 7 Dec 2017 16:10:26 -0500 Message-Id: <1512681031-11343-3-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512681031-11343-1-git-send-email-okaya@codeaurora.org> References: <1512681031-11343-1-git-send-email-okaya@codeaurora.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP OF has of_device_get_match_data() function to extract driver specific data structure. Add a similar function for ACPI. Signed-off-by: Sinan Kaya Acked-by: Rafael J. Wysocki --- drivers/acpi/bus.c | 18 ++++++++++++++++++ include/linux/acpi.h | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 4d0979e..f87ed3b 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -785,6 +785,24 @@ const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, } EXPORT_SYMBOL_GPL(acpi_match_device); +void *acpi_get_match_data(const struct device *dev) +{ + const struct acpi_device_id *match; + + if (!dev->driver) + return NULL; + + if (!dev->driver->acpi_match_table) + return NULL; + + match = acpi_match_device(dev->driver->acpi_match_table, dev); + if (!match) + return NULL; + + return (void *)match->driver_data; +} +EXPORT_SYMBOL_GPL(acpi_get_match_data); + int acpi_match_device_ids(struct acpi_device *device, const struct acpi_device_id *ids) { diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 502af53..a927260 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -584,6 +584,7 @@ extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *), const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, const struct device *dev); +void *acpi_get_match_data(const struct device *dev); extern bool acpi_driver_match_device(struct device *dev, const struct device_driver *drv); int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *); @@ -755,6 +756,11 @@ static inline const struct acpi_device_id *acpi_match_device( return NULL; } +static inline void *acpi_get_match_data(const struct device *dev) +{ + return NULL; +} + static inline bool acpi_driver_match_device(struct device *dev, const struct device_driver *drv) {