From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEA03C10F0E for ; Tue, 9 Apr 2019 05:48:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F0A221473 for ; Tue, 9 Apr 2019 05:48:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="q1Fw+CTG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F0A221473 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=zte.com.cn Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=mWaBu1ns8CFCkPXO8+MInOFxE822u/A04yuDecH012c=; b=q1F w+CTGssi1vZdLfRGC3iOH1STFxzxHFUFZpIBGIj3o+S+GkUxnDnwE4oUwp/RfJlFhYaLrySM/7hXA 38vP19UwlFdo3JAJM9PKTZFM9TtsYcIuhTzyn8Uq7+Dl3jAaiTh4VCSRk9GNGWRqQ0Bz0gAIZ8+tK 4mdop1Yk5h3J341vDxFUXgwDWuG2ygG6ywLBMycnFtux49hSdZloX1fpRfw4CWDHJk9j5yaxl4i4y sexeSiJ08JTOmZhZCFvYzGTixJr0y6Fs7qjyhCH4fRvRWLXPfwccBu/VclttwhRSv5hw0YfK9nMd4 jfUgCUMcZs8HzECgzDnTY8XVowF8SIg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDjcQ-0007UX-RH; Tue, 09 Apr 2019 05:48:26 +0000 Received: from out1.zte.com.cn ([202.103.147.172] helo=mxct.zte.com.cn) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDjcN-0007TQ-GW for linux-arm-kernel@lists.infradead.org; Tue, 09 Apr 2019 05:48:26 +0000 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 2D51645D417A2F6FA42D; Tue, 9 Apr 2019 13:48:11 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x395m5Fc046077; Tue, 9 Apr 2019 13:48:05 +0800 (GMT-8) (envelope-from wen.yang99@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2019040913482107-7975996 ; Tue, 9 Apr 2019 13:48:21 +0800 From: Wen Yang To: linux-kernel@vger.kernel.org Subject: [PATCH 1/2] net: xilinx: add a helper function for axienet_probe Date: Tue, 9 Apr 2019 13:48:00 +0800 Message-Id: <1554788881-22647-1-git-send-email-wen.yang99@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2019-04-09 13:48:21, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-04-09 13:48:03, Serialize complete at 2019-04-09 13:48:03 X-MAIL: mse01.zte.com.cn x395m5Fc046077 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190408_224823_716097_A4804668 X-CRM114-Status: GOOD ( 15.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wang.yi59@zte.com.cn, netdev@vger.kernel.org, Michal Simek , Wen Yang , Markus Elfring , Anirudha Sarangi , John Linn , "David S. Miller" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org The "Find DMA Node, Map DMA Register, and Decode DMA IRQ" code snippets in Axienet_Probe are independent. Tidy up axienet_probe a little by factoring these out into a helper function. Signed-off-by: Wen Yang Reported-by: Markus Elfring Cc: Anirudha Sarangi Cc: John Linn Cc: "David S. Miller" Cc: Michal Simek Cc: Markus Elfring Cc: netdev@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 69 +++++++++++++++-------- 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 4041c75..2d15897 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1434,6 +1434,48 @@ static void axienet_dma_err_handler(unsigned long data) } /** + * axienet_dma_res_init - Initialize the DMA related resources of + * the axienet local structure. + * @lp: Pointer to axienet local structure + * + * Return: 0, on success + * Non-zero error value on failure. + * + * This function find the DMA node via pdev, map the DMA registers, + * and decode the DMA IRQs. + */ +static int axienet_dma_res_init(struct axienet_local *lp) +{ + struct resource dmares; + struct device_node *np; + int ret; + + np = of_parse_phandle(lp->dev->of_node, "axistream-connected", 0); + if (!np) { + dev_err(lp->dev, "could not find DMA node\n"); + ret = -ENODEV; + return ret; + } + ret = of_address_to_resource(np, 0, &dmares); + if (ret) { + dev_err(lp->dev, "unable to get DMA resource\n"); + goto put_node; + } + lp->dma_regs = devm_ioremap_resource(lp->dev, &dmares); + if (IS_ERR(lp->dma_regs)) { + dev_err(lp->dev, "could not map DMA regs\n"); + ret = PTR_ERR(lp->dma_regs); + goto put_node; + } + lp->rx_irq = irq_of_parse_and_map(np, 1); + lp->tx_irq = irq_of_parse_and_map(np, 0); + +put_node: + of_node_put(np); + return ret; +} + +/** * axienet_probe - Axi Ethernet probe function. * @pdev: Pointer to platform device structure. * @@ -1448,11 +1490,10 @@ static void axienet_dma_err_handler(unsigned long data) static int axienet_probe(struct platform_device *pdev) { int ret; - struct device_node *np; struct axienet_local *lp; struct net_device *ndev; const void *mac_addr; - struct resource *ethres, dmares; + struct resource *ethres; u32 value; ndev = alloc_etherdev(sizeof(*lp)); @@ -1565,29 +1606,9 @@ static int axienet_probe(struct platform_device *pdev) } } - /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ - np = of_parse_phandle(pdev->dev.of_node, "axistream-connected", 0); - if (!np) { - dev_err(&pdev->dev, "could not find DMA node\n"); - ret = -ENODEV; - goto free_netdev; - } - ret = of_address_to_resource(np, 0, &dmares); - if (ret) { - dev_err(&pdev->dev, "unable to get DMA resource\n"); - of_node_put(np); - goto free_netdev; - } - lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares); - if (IS_ERR(lp->dma_regs)) { - dev_err(&pdev->dev, "could not map DMA regs\n"); - ret = PTR_ERR(lp->dma_regs); - of_node_put(np); + ret = axienet_dma_res_init(lp); + if (ret) goto free_netdev; - } - lp->rx_irq = irq_of_parse_and_map(np, 1); - lp->tx_irq = irq_of_parse_and_map(np, 0); - of_node_put(np); if ((lp->rx_irq <= 0) || (lp->tx_irq <= 0)) { dev_err(&pdev->dev, "could not determine irqs\n"); ret = -ENOMEM; -- 2.9.5 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel