From patchwork Fri Sep 25 14:56:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 7265731 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4DB0E9F6DA for ; Fri, 25 Sep 2015 14:57:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5EC8320A3F for ; Fri, 25 Sep 2015 14:57:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 53CB020B5B for ; Fri, 25 Sep 2015 14:57:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756792AbbIYO5Q (ORCPT ); Fri, 25 Sep 2015 10:57:16 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:16121 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756713AbbIYO5N (ORCPT ); Fri, 25 Sep 2015 10:57:13 -0400 Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com id ; Fri, 25 Sep 2015 07:57:27 -0700 Received: from hqemhub03.nvidia.com ([172.20.150.15]) by hqnvupgp08.nvidia.com (PGP Universal service); Fri, 25 Sep 2015 07:56:37 -0700 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Fri, 25 Sep 2015 07:56:37 -0700 Received: from jonathanh-lm.nvidia.com (172.20.144.16) by hqemhub03.nvidia.com (172.20.150.15) with Microsoft SMTP Server (TLS) id 8.3.342.0; Fri, 25 Sep 2015 07:57:11 -0700 From: Jon Hunter To: Laxman Dewangan , Vinod Koul , Stephen Warren , Thierry Reding , Alexandre Courbot , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala CC: , , , Jon Hunter Subject: [PATCH 1/3] dmaengine: of: Allow #dma-cells to be zero Date: Fri, 25 Sep 2015 15:56:38 +0100 Message-ID: <1443193000-457-2-git-send-email-jonathanh@nvidia.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1443193000-457-1-git-send-email-jonathanh@nvidia.com> References: <1443193000-457-1-git-send-email-jonathanh@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, the #dma-cells property must be 1 or more. However, for some DMA controllers, where DMA clients may use any DMA channel and it is not necessary to specify any other DMA information in the device-tree DMA binding, setting #dma-cells to 0 is desirable. The Tegra210 ADMA controller is an example of a DMA controller where neither the DMA channel or the hardware request signal need to be encoded in the device-tree binding. By allowing DMA controllers to set #dma-cells to 0, means that the "dma-names" property for these controllers is not needed. Therefore, update the of_dma_request_slave_channel() and of_dma_match_channel() functions to ignore this property if no name is provided. Signed-off-by: Jon Hunter --- Documentation/devicetree/bindings/dma/dma.txt | 12 ++++++++---- drivers/dma/of-dma.c | 23 +++++++++++++++-------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Documentation/devicetree/bindings/dma/dma.txt b/Documentation/devicetree/bindings/dma/dma.txt index 6312fb00ce8d..4d73916fc879 100644 --- a/Documentation/devicetree/bindings/dma/dma.txt +++ b/Documentation/devicetree/bindings/dma/dma.txt @@ -8,9 +8,12 @@ controller. * DMA controller Required property: -- #dma-cells: Must be at least 1. Used to provide DMA controller - specific information. See DMA client binding below for - more details. +- #dma-cells: Used to provide DMA controller specific information. + Can be 0 for DMA controllers where clients may use + any channel and any DMA specific information, such + as a hardware request signal, does not need to be + encoded in the binding. See DMA client binding below + for more details. Optional properties: - dma-channels: Number of DMA channels supported by the controller. @@ -79,7 +82,8 @@ Required property: are defined in the binding of the DMA client device. Multiple DMA specifiers can be used to represent alternatives and in this case the dma-names for those - DMA specifiers must be identical (see examples). + DMA specifiers must be identical (see examples). This + is optional for DMA controllers where #dma-cells is 0. Examples: diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c index 1e1f2986eba8..ef3d260610ea 100644 --- a/drivers/dma/of-dma.c +++ b/drivers/dma/of-dma.c @@ -214,11 +214,13 @@ static int of_dma_match_channel(struct device_node *np, const char *name, { const char *s; - if (of_property_read_string_index(np, "dma-names", index, &s)) - return -ENODEV; + if (name) { + if (of_property_read_string_index(np, "dma-names", index, &s)) + return -ENODEV; - if (strcmp(name, s)) - return -ENODEV; + if (strcmp(name, s)) + return -ENODEV; + } if (of_parse_phandle_with_args(np, "dmas", "#dma-cells", index, dma_spec)) @@ -230,7 +232,7 @@ static int of_dma_match_channel(struct device_node *np, const char *name, /** * of_dma_request_slave_channel - Get the DMA slave channel * @np: device node to get DMA request from - * @name: name of desired channel + * @name: name of desired channel (optional) * * Returns pointer to appropriate DMA channel on success or an error pointer. */ @@ -243,8 +245,8 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np, int count, i; int ret_no_channel = -ENODEV; - if (!np || !name) { - pr_err("%s: not enough information provided\n", __func__); + if (!np) { + pr_err("%s: device node is not valid\n", __func__); return ERR_PTR(-ENODEV); } @@ -252,7 +254,12 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np, if (!of_find_property(np, "dmas", NULL)) return ERR_PTR(-ENODEV); - count = of_property_count_strings(np, "dma-names"); + /* + * If a name is not provided, then assume that there is one + * DMA specifier in the list for the client and so set the + * count to 1 and see if this matches. + */ + count = name ? of_property_count_strings(np, "dma-names") : 1; if (count < 0) { pr_err("%s: dma-names property of node '%s' missing or empty\n", __func__, np->full_name);