From patchwork Thu Feb 27 21:17:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Shilimkar X-Patchwork-Id: 25480 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E65D120447 for ; Thu, 27 Feb 2014 21:19:02 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id le5sf6881987vcb.3 for ; Thu, 27 Feb 2014 13:19:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=0KFa4KBCISe5bGpPu7GMW8my9cHhJ5APkoHIzk5ES7M=; b=K6EXwIBDKn3B9CwN81PyNYjSLu7KKvIvCkzeDwUKqnbBPcMqgsLVi9/WvtfvaNYAxG V9SgluxlNpABqOh36iU8/YKBeFfr6ZPg+e/2Sfl80rHR1B06lkKA5G1P6wFa8yW5YqyN YAAxBCkzPqj5kFLZpVd/YsLZSLA0O3q6fHphEIm9fvCfh0+NHY4jrxowaIQ6VsRs9XMo 7Flqx2vR9XTMdbOOiKVQknrctIqtPG79Re5kxas+5us+/vKrG7oA7NYwhYGvaCKrofEO bI15APJzUtvNFyGxXdyFBrTehEzfhibhFtLIY9CtSHjWSD13469YDzEC9tOy48woPK3B XNag== X-Gm-Message-State: ALoCoQl6pd0LV3m8JNTkNR6xLMr/TueuB45Jb6NicjmivOx+axmj4yxBI7KZtozhVcye/cbkqnEg X-Received: by 10.236.65.136 with SMTP id f8mr5701275yhd.11.1393535942681; Thu, 27 Feb 2014 13:19:02 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.169 with SMTP id j38ls913303qgd.10.gmail; Thu, 27 Feb 2014 13:19:02 -0800 (PST) X-Received: by 10.52.69.172 with SMTP id f12mr237756vdu.58.1393535942530; Thu, 27 Feb 2014 13:19:02 -0800 (PST) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id rq10si1045936vcb.24.2014.02.27.13.19.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Feb 2014 13:19:02 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id jy13so4452746veb.37 for ; Thu, 27 Feb 2014 13:19:02 -0800 (PST) X-Received: by 10.220.188.10 with SMTP id cy10mr2381110vcb.36.1393535942442; Thu, 27 Feb 2014 13:19:02 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.130.193 with SMTP id u1csp6167vcs; Thu, 27 Feb 2014 13:19:01 -0800 (PST) X-Received: by 10.66.241.73 with SMTP id wg9mr17587702pac.69.1393535924705; Thu, 27 Feb 2014 13:18:44 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bi5si5843182pbb.319.2014.02.27.13.18.44; Thu, 27 Feb 2014 13:18:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751453AbaB0VSn (ORCPT + 9 others); Thu, 27 Feb 2014 16:18:43 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:41946 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751007AbaB0VSn (ORCPT ); Thu, 27 Feb 2014 16:18:43 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s1RLIEVG018369; Thu, 27 Feb 2014 15:18:14 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s1RLIEXn010266; Thu, 27 Feb 2014 15:18:14 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Thu, 27 Feb 2014 15:18:14 -0600 Received: from ula0393909.am.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s1RLHrfh023451; Thu, 27 Feb 2014 15:18:13 -0600 From: Santosh Shilimkar To: CC: , , , , , , Santosh Shilimkar , Russell King , Olof Johansson Subject: [PATCH v2 4/7] dma: of: introduce of_dma_is_coherent() helper Date: Thu, 27 Feb 2014 16:17:49 -0500 Message-ID: <1393535872-20915-5-git-send-email-santosh.shilimkar@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1393535872-20915-1-git-send-email-santosh.shilimkar@ti.com> References: <1393535872-20915-1-git-send-email-santosh.shilimkar@ti.com> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: santosh.shilimkar@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The of_dma_is_coherent() helper parses the given DT device node to see if the "dma-coherent" property is supported and returns true or false accordingly. Cc: Russell King Cc: Arnd Bergmann Cc: Olof Johansson Cc: Grant Likely Cc: Rob Herring Signed-off-by: Santosh Shilimkar --- drivers/dma/of-dma.c | 22 ++++++++++++++++++++++ include/linux/of_dma.h | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c index 9b51768..c5958d1 100644 --- a/drivers/dma/of-dma.c +++ b/drivers/dma/of-dma.c @@ -304,3 +304,25 @@ out: return ret; } EXPORT_SYMBOL_GPL(of_dma_get_range); + +/** + * of_dma_is_coherent - Check if device is coherent + * @np: device node + * + * It returns true if "dma-coherent" property was found + * for this device in DT. + */ +bool of_dma_is_coherent(struct device_node *np) +{ + struct device_node *node = np; + + while (node) { + if (of_property_read_bool(node, "dma-coherent")) { + of_node_put(node); + return true; + } + node = of_get_next_parent(node); + } + return false; +} +EXPORT_SYMBOL_GPL(of_dma_is_coherent); diff --git a/include/linux/of_dma.h b/include/linux/of_dma.h index f04171a..6191f02 100644 --- a/include/linux/of_dma.h +++ b/include/linux/of_dma.h @@ -44,6 +44,7 @@ extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec, extern int of_dma_get_range(struct device_node *np, dma_addr_t *dma_addr, phys_addr_t *paddr, phys_addr_t *size); +extern bool of_dma_is_coherent(struct device_node *np); #else static inline int of_dma_controller_register(struct device_node *np, struct dma_chan *(*of_dma_xlate) @@ -74,6 +75,10 @@ static inline int of_dma_get_range(struct device_node *np, dma_addr_t *dma_addr, { return -ENODEV; } +static inline bool of_dma_is_coherent(struct device_node *np) +{ + return false; +} #endif #endif /* __LINUX_OF_DMA_H */