From patchwork Thu Jan 4 22:45:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 123458 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp80419qgn; Thu, 4 Jan 2018 14:45:49 -0800 (PST) X-Google-Smtp-Source: ACJfBov44egCVpVh8NaqYWJ77g9nSQ5C9BVol93bpzssyM/NFSvX3SyUdhrDWJhbF4DndoOXcdMP X-Received: by 10.159.244.140 with SMTP id y12mr988509plr.158.1515105948935; Thu, 04 Jan 2018 14:45:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515105948; cv=none; d=google.com; s=arc-20160816; b=G035Y6cwYgZ8cgyaQBMutJvQW3eaQ1oOKNe1pEHqNxH9tfyBKtXBWxY6tS3ZY1NWrF 9hilGCcIahDKyF6EvSSqEdvqB0q3OwnrjBAiYCGeFz4oPeDPh158W+FvaIHCQx5vKeRG QIrdxOC8EDzEv6+dzQlgSZfgvYMNTnOg/6AB9AP0O7Kqe1ReHexDQUhS+7DUU+Y5DSd2 LuLig43vOE1q1uatAYK7OLpiPLBQsHlP7d4ixcewquoWfi1NsyjMbRRCzGA7QbaK6QAW 2UIo1/VoBMPXo1vCAzDsiYgtbayR3iGujaEMVuiIErakedOvHPxGy/XGtfpK74w7QJY3 S3TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1+zeC2Q7NmR8W24Hx86XY//hRTIghL77XFwjJfqZm5M=; b=aoImdXPghtiVJ/6ijdhM1ZqaEXNT1JkEUKxt1Goe6Jy8Q9YrzmPxWa9h9KLaBD+aEH UDMNHnRIsbNURvXZocuvCvmSelWQ8L2iXdiDKVCwpIbWtx86D8UnCtkXMbS+C51woOt0 toPNo297bZPLEug93GdPYTOGhFiR9g+OvuPzdwMAW2ZdBybn80Xrs1hIPcoGvWxTncJn BqaWCfBIDQHGyPQqHrXAeps92Qv3JA0ncctYvchJCdAK49e8JBg8HRqo7oDcifA993rg yp+l2td3JIeUqrQZliqNiGHNdyplOf6KZDMzxgxucS4j/P2SpDpRstU1shlX0X7ngqiI JUEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d19si2932840plr.654.2018.01.04.14.45.48; Thu, 04 Jan 2018 14:45:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753613AbeADWpq (ORCPT + 10 others); Thu, 4 Jan 2018 17:45:46 -0500 Received: from mail-oi0-f66.google.com ([209.85.218.66]:45772 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753583AbeADWpp (ORCPT ); Thu, 4 Jan 2018 17:45:45 -0500 Received: by mail-oi0-f66.google.com with SMTP id x20so2032775oix.12; Thu, 04 Jan 2018 14:45:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=o5KWGxLEe4WCV+rwkWcmVkbkCt5oQ5yzsowDn7VL8gY=; b=Dy5HekAzN/KnWyitC3z3AgL7XahbgxKgYJiqA3/E4EheFiL55QKjaMBFSrLtz+y12j pZGEyLNRpgROzN7dHgG6pdRieKRvS7fg6T/pl8iK4/r3+nAwtFbvjBt1xgJQwXFNMF3D kmAORaj9YYMIlp+AnYlxNQ/Xe/qNa9Js8Ok6U5JmfUe/WG1Roo4RAeilHF+YNidcbRF0 bHUVbw7JpV2Kgt5T74CyeHM4g+M8bIw/HPJRZU3p2j1zwpydJDeAN1DVxFMgiIvdXLWi 8/mDDXwMbMCOpFY9bC/epmjfHgYd06+zwrAzGZTdbQ6WBPGx/U8cDMGTnt6Mfha41u9J I63w== X-Gm-Message-State: AKGB3mKX57QNHsI/Th7YkD6SoxVU3XeWmCJHRbTUPQHL25wPaZ7X0MH6 u4/r4FYijRSAXhRrDAGqGA== X-Received: by 10.202.48.206 with SMTP id w197mr614425oiw.162.1515105944497; Thu, 04 Jan 2018 14:45:44 -0800 (PST) Received: from xps15.usacommunications.tv (216-188-254-6.dyn.grandenetworks.net. [216.188.254.6]) by smtp.googlemail.com with ESMTPSA id s63sm1704516oie.41.2018.01.04.14.45.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jan 2018 14:45:43 -0800 (PST) From: Rob Herring To: Vinod Koul Cc: linux-kernel@vger.kernel.org, Andy Gross , David Brown , Dan Williams , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, dmaengine@vger.kernel.org Subject: [PATCH] dmaengine: qcom_hidma: simplify DT resource parsing Date: Thu, 4 Jan 2018 16:45:40 -0600 Message-Id: <20180104224542.15333-2-robh@kernel.org> X-Mailer: git-send-email 2.14.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The hidma driver open codes populating address and IRQ resources from DT. We have standard functions of_address_to_resource and of_irq_to_resource for this, so use them instead. The DT binding states each child should have 2 addresses and 1 IRQ, so we can simplify the logic and do a fixed size resource allocation. Using the standard of_address_to_resource will also do any address translation which was missing. Cc: Andy Gross Cc: David Brown Cc: Dan Williams Cc: Vinod Koul Cc: linux-arm-msm@vger.kernel.org Cc: linux-soc@vger.kernel.org Cc: dmaengine@vger.kernel.org Signed-off-by: Rob Herring --- drivers/dma/qcom/hidma_mgmt.c | 61 +++++++++++-------------------------------- 1 file changed, 15 insertions(+), 46 deletions(-) -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Sinan Kaya diff --git a/drivers/dma/qcom/hidma_mgmt.c b/drivers/dma/qcom/hidma_mgmt.c index 7335e2eb9b72..000c7019ca7d 100644 --- a/drivers/dma/qcom/hidma_mgmt.c +++ b/drivers/dma/qcom/hidma_mgmt.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -356,67 +357,37 @@ static int __init hidma_mgmt_of_populate_channels(struct device_node *np) { struct platform_device *pdev_parent = of_find_device_by_node(np); struct platform_device_info pdevinfo; - struct of_phandle_args out_irq; struct device_node *child; - struct resource *res = NULL; - const __be32 *cell; - int ret = 0, size, i, num; - u64 addr, addr_size; + struct resource *res; + int ret = 0; + + /* allocate a resource array */ + res = kcalloc(3, sizeof(*res), GFP_KERNEL); + if (!res) + return -ENOMEM; for_each_available_child_of_node(np, child) { - struct resource *res_iter; struct platform_device *new_pdev; - cell = of_get_property(child, "reg", &size); - if (!cell) { - ret = -EINVAL; + ret = of_address_to_resource(child, 0, &res[0]); + if (!ret) goto out; - } - - size /= sizeof(*cell); - num = size / - (of_n_addr_cells(child) + of_n_size_cells(child)) + 1; - /* allocate a resource array */ - res = kcalloc(num, sizeof(*res), GFP_KERNEL); - if (!res) { - ret = -ENOMEM; + ret = of_address_to_resource(child, 1, &res[1]); + if (!ret) goto out; - } - - /* read each reg value */ - i = 0; - res_iter = res; - while (i < size) { - addr = of_read_number(&cell[i], - of_n_addr_cells(child)); - i += of_n_addr_cells(child); - - addr_size = of_read_number(&cell[i], - of_n_size_cells(child)); - i += of_n_size_cells(child); - - res_iter->start = addr; - res_iter->end = res_iter->start + addr_size - 1; - res_iter->flags = IORESOURCE_MEM; - res_iter++; - } - ret = of_irq_parse_one(child, 0, &out_irq); - if (ret) + ret = of_irq_to_resource(child, 0, &res[2]); + if (ret <= 0) goto out; - res_iter->start = irq_create_of_mapping(&out_irq); - res_iter->name = "hidma event irq"; - res_iter->flags = IORESOURCE_IRQ; - memset(&pdevinfo, 0, sizeof(pdevinfo)); pdevinfo.fwnode = &child->fwnode; pdevinfo.parent = pdev_parent ? &pdev_parent->dev : NULL; pdevinfo.name = child->name; pdevinfo.id = object_counter++; pdevinfo.res = res; - pdevinfo.num_res = num; + pdevinfo.num_res = 3; pdevinfo.data = NULL; pdevinfo.size_data = 0; pdevinfo.dma_mask = DMA_BIT_MASK(64); @@ -434,8 +405,6 @@ static int __init hidma_mgmt_of_populate_channels(struct device_node *np) */ of_msi_configure(&new_pdev->dev, child); of_node_put(child); - kfree(res); - res = NULL; } out: kfree(res);