Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966711AbbFJQJk (ORCPT ); Wed, 10 Jun 2015 12:09:40 -0400 Received: from mail-by2on0113.outbound.protection.outlook.com ([207.46.100.113]:62496 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965660AbbFJQJI (ORCPT ); Wed, 10 Jun 2015 12:09:08 -0400 Authentication-Results: spf=none (sender IP is 165.204.84.221) smtp.mailfrom=amd.com; arm.com; dkim=none (message not signed) header.d=none; X-WSS-ID: 0NPQKV3-07-U7I-02 X-M-MSG: From: Suravee Suthikulpanit To: , , , , , , , , , , , CC: , , , , , , , , , , , "Suravee Suthikulpanit" Subject: [V6 PATCH 3/7] device property: Introduces device_dma_is_coherent() Date: Wed, 10 Jun 2015 11:08:54 -0500 Message-ID: <1433952538-22455-4-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1433952538-22455-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1433952538-22455-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD038;1:QlsOZ8l2brCnUDEfHfdPhJr3Y90I/nzrTWw2cy+dghPl1rM3V1v7OgXzxNKkZ8Nzv3qUo/W4/IeoT39Hb6b7NNAhUDkmLT0jY4FBg8g7icNxBejG/XPIU8DSBF5kfIjVxBTwNKNYlDO7zdGUePk/LG1hPUr34F+XNFQSIwOCDo1bWtGQsLf1p+NxVpTDpAx5FPYB2EJuL3ncZDNJAhUyfmnKzeBbk46rJiSQgm4it10RgAysjgJkPqlge+lOM3hf1aYvJFjwEqG81gZ5jGaqanpP1S376m/Zw8yk3u9xdoDDGa+xnKYg9lsWdJLbyNMytX8WajNowAXdzy1Ny7xrKw== X-Forefront-Antispam-Report: CIP:165.204.84.221;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(428002)(189002)(199003)(50226001)(53416004)(92566002)(36756003)(76176999)(87936001)(19580405001)(105586002)(2201001)(48376002)(77096005)(229853001)(2950100001)(5001770100001)(77156002)(19580395003)(86362001)(189998001)(47776003)(50986999)(101416001)(575784001)(46102003)(62966003)(5003600100002)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR02MB1105;H:atltwp01.amd.com;FPR:;SPF:None;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR02MB1105; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(520003)(3002001);SRVR:BLUPR02MB1105;BCL:0;PCL:0;RULEID:;SRVR:BLUPR02MB1105; X-Forefront-PRVS: 06036BD506 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2015 16:09:04.4368 (UTC) X-MS-Exchange-CrossTenant-Id: fde4dada-be84-483f-92cc-e026cbee8e96 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fde4dada-be84-483f-92cc-e026cbee8e96;Ip=[165.204.84.221];Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR02MB1105 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1935 Lines: 62 Currently, device drivers, which support both OF and ACPI, need to call two separate APIs, of_dma_is_coherent() and acpi_dma_is_coherent()) to determine device coherency attribute. This patch simplifies this process by introducing a new device property API, device_dma_is_coherent(), which calls the appropriate interface based on the booting architecture. Signed-off-by: Suravee Suthikulpanit --- drivers/base/property.c | 14 ++++++++++++++ include/linux/property.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 1d0b116..e645852 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -14,6 +14,7 @@ #include #include #include +#include #include /** @@ -519,3 +520,16 @@ unsigned int device_get_child_node_count(struct device *dev) return count; } EXPORT_SYMBOL_GPL(device_get_child_node_count); + +bool device_dma_is_coherent(struct device *dev) +{ + bool coherent = false; + + if (IS_ENABLED(CONFIG_OF) && dev->of_node) + coherent = of_dma_is_coherent(dev->of_node); + else + acpi_check_dma(ACPI_COMPANION(dev), &coherent); + + return coherent; +} +EXPORT_SYMBOL_GPL(device_dma_is_coherent); diff --git a/include/linux/property.h b/include/linux/property.h index de8bdf4..76ebde9 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -164,4 +164,6 @@ struct property_set { void device_add_property_set(struct device *dev, struct property_set *pset); +bool device_dma_is_coherent(struct device *dev); + #endif /* _LINUX_PROPERTY_H_ */ -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/