From patchwork Thu Apr 24 15:30:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Shilimkar X-Patchwork-Id: 28979 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5A6A42036A for ; Thu, 24 Apr 2014 15:32:00 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id lx4sf14935341iec.3 for ; Thu, 24 Apr 2014 08:31:59 -0700 (PDT) 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=4RQ16PgjKgWp03k0y6UDV7LHIbnaoBgEynkkh6+L0e8=; b=NuBUIGcuc5jxYOvCX8SIcZqHSqak1vAUgp60D8cDQCU1+en8o83G3h3i3G920NiJIY S5CElAqR0fOHrTfVTxGkcbg0gttcA6UGmHy/j9U7k3S1OgGvLDeqVRBgPKh1bJh/CTSG e+25RXgQQd43hxnteJaEX/lLH45Bsok87SvVvUARJpDpdOGHJK2QqwtZQpqm1a70gZgK dl6XB76S0uuGsbKHSPlMyDCk9i3Q7+lQK6PqF6h1dSvlAJYboVfKTYVAD7vtl5jJQlF/ DUsWJ0j5CRyB7ixsNes+8NFxy3ayR0pvVwumbEUHw0jyzOOZqJhizUkpfWQnb/Lb5qw9 mDIQ== X-Gm-Message-State: ALoCoQnkmQllf8tmWW3Ocy05perFA/oWsKLSPpXFFJqbx2HhcSjiYuiLUAXlFN03EgCQ2XHHpG4z X-Received: by 10.182.60.37 with SMTP id e5mr1535925obr.30.1398353519718; Thu, 24 Apr 2014 08:31:59 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.88.72 with SMTP id s66ls1185178qgd.11.gmail; Thu, 24 Apr 2014 08:31:59 -0700 (PDT) X-Received: by 10.52.230.161 with SMTP id sz1mr535697vdc.64.1398353519552; Thu, 24 Apr 2014 08:31:59 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id ck5si1004348vdd.91.2014.04.24.08.31.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Apr 2014 08:31:59 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id db12so3097689veb.38 for ; Thu, 24 Apr 2014 08:31:59 -0700 (PDT) X-Received: by 10.58.220.161 with SMTP id px1mr1670699vec.13.1398353519447; Thu, 24 Apr 2014 08:31:59 -0700 (PDT) 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.221.72 with SMTP id ib8csp25392vcb; Thu, 24 Apr 2014 08:31:58 -0700 (PDT) X-Received: by 10.66.155.102 with SMTP id vv6mr827784pab.89.1398353518045; Thu, 24 Apr 2014 08:31:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id uc7si2899098pbc.346.2014.04.24.08.31.57; Thu, 24 Apr 2014 08:31:57 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758203AbaDXPbm (ORCPT + 9 others); Thu, 24 Apr 2014 11:31:42 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:49535 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754569AbaDXPbj (ORCPT ); Thu, 24 Apr 2014 11:31:39 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s3OFUxhl032343; Thu, 24 Apr 2014 10:30:59 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3OFUxA3012685; Thu, 24 Apr 2014 10:30:59 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Thu, 24 Apr 2014 10:30:59 -0500 Received: from ula0393909.am.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3OFU9M9019851; Thu, 24 Apr 2014 10:30:59 -0500 From: Santosh Shilimkar To: CC: , , Santosh Shilimkar , Greg Kroah-Hartman , Russell King , Arnd Bergmann , Olof Johansson , Grant Likely , Rob Herring , Catalin Marinas , Linus Walleij , Grygorii Strashko Subject: [PATCH v3 3/7] of: introduce of_dma_is_coherent() helper Date: Thu, 24 Apr 2014 11:30:03 -0400 Message-ID: <1398353407-2345-4-git-send-email-santosh.shilimkar@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1398353407-2345-1-git-send-email-santosh.shilimkar@ti.com> References: <1398353407-2345-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: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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. If the arch is always coherent or always noncoherent, then the default DMA ops has to be specified accordingly. Cc: Greg Kroah-Hartman Cc: Russell King Cc: Arnd Bergmann Cc: Olof Johansson Cc: Grant Likely Cc: Rob Herring Cc: Catalin Marinas Cc: Linus Walleij Signed-off-by: Santosh Shilimkar Signed-off-by: Grygorii Strashko --- drivers/of/platform.c | 23 +++++++++++++++++++++++ include/linux/of_platform.h | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 404d1da..48de98f 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -485,4 +485,27 @@ int of_platform_populate(struct device_node *root, return rc; } EXPORT_SYMBOL_GPL(of_platform_populate); + +/** + * 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 = of_node_get(np); + + while (node) { + if (of_property_read_bool(node, "dma-coherent")) { + of_node_put(node); + return true; + } + node = of_get_next_parent(node); + } + of_node_put(node); + return false; +} +EXPORT_SYMBOL_GPL(of_dma_is_coherent); #endif /* CONFIG_OF_ADDRESS */ diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index 05cb4a9..b9a3cb2 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -72,6 +72,7 @@ extern int of_platform_populate(struct device_node *root, const struct of_device_id *matches, const struct of_dev_auxdata *lookup, struct device *parent); +extern bool of_dma_is_coherent(struct device_node *np); #else static inline int of_platform_populate(struct device_node *root, const struct of_device_id *matches, @@ -80,6 +81,11 @@ static inline int of_platform_populate(struct device_node *root, { return -ENODEV; } + +static inline bool of_dma_is_coherent(struct device_node *np) +{ + return false; +} #endif #endif /* _LINUX_OF_PLATFORM_H */