From patchwork Mon Dec 15 14:13:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyrille Pitchen X-Patchwork-Id: 5493071 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 65156BEEA8 for ; Mon, 15 Dec 2014 14:17:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8995120A0C for ; Mon, 15 Dec 2014 14:16:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A16C020A0A for ; Mon, 15 Dec 2014 14:16:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y0WQI-00078b-5k; Mon, 15 Dec 2014 14:14:54 +0000 Received: from eusmtp01.atmel.com ([212.144.249.243]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y0WQ8-0006u1-UL for linux-arm-kernel@lists.infradead.org; Mon, 15 Dec 2014 14:14:46 +0000 Received: from tenerife.corp.atmel.com (10.161.101.13) by eusmtp01.atmel.com (10.161.101.31) with Microsoft SMTP Server id 14.2.347.0; Mon, 15 Dec 2014 15:14:20 +0100 From: Cyrille Pitchen To: , , , , Subject: [PATCH 2/2] net/macb: remove useless calls of devm_free_irq() Date: Mon, 15 Dec 2014 15:13:32 +0100 Message-ID: X-Mailer: git-send-email 1.8.2.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141215_061445_368618_A7F221D0 X-CRM114-Status: GOOD ( 12.64 ) X-Spam-Score: -0.0 (/) Cc: Cyrille Pitchen , linux-kernel@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 Inside macb_probe(), when devm_request_irq() fails on queue q, there is no need to call devm_free_irq() on queues 0..q-1 because the managed device resources are released later when calling free_netdev(). Also removing devm_free_irq() call from macb_remove() for the same reason. Signed-off-by: Cyrille Pitchen --- drivers/net/ethernet/cadence/macb.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index 81f317f..414f796 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c @@ -2160,7 +2160,7 @@ static int __init macb_probe(struct platform_device *pdev) int err = -ENXIO; const char *mac; void __iomem *mem; - unsigned int hw_q, queue_mask, q, num_queues, q_irq = 0; + unsigned int hw_q, queue_mask, q, num_queues; struct clk *pclk, *hclk, *tx_clk; regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -2235,11 +2235,11 @@ static int __init macb_probe(struct platform_device *pdev) * register mapping but we don't want to test the queue index then * compute the corresponding register offset at run time. */ - for (hw_q = 0; hw_q < MACB_MAX_QUEUES; ++hw_q) { + for (hw_q = 0, q = 0; hw_q < MACB_MAX_QUEUES; ++hw_q) { if (!(queue_mask & (1 << hw_q))) continue; - queue = &bp->queues[q_irq]; + queue = &bp->queues[q]; queue->bp = bp; if (hw_q) { queue->ISR = GEM_ISR(hw_q - 1); @@ -2261,18 +2261,18 @@ static int __init macb_probe(struct platform_device *pdev) * must remove the optional gaps that could exist in the * hardware queue mask. */ - queue->irq = platform_get_irq(pdev, q_irq); + queue->irq = platform_get_irq(pdev, q); err = devm_request_irq(&pdev->dev, queue->irq, macb_interrupt, 0, dev->name, queue); if (err) { dev_err(&pdev->dev, "Unable to request IRQ %d (error %d)\n", queue->irq, err); - goto err_out_free_irq; + goto err_out_free_netdev; } INIT_WORK(&queue->tx_error_task, macb_tx_error_task); - q_irq++; + q++; } dev->irq = bp->queues[0].irq; @@ -2350,7 +2350,7 @@ static int __init macb_probe(struct platform_device *pdev) err = register_netdev(dev); if (err) { dev_err(&pdev->dev, "Cannot register net device, aborting.\n"); - goto err_out_free_irq; + goto err_out_free_netdev; } err = macb_mii_init(bp); @@ -2373,9 +2373,7 @@ static int __init macb_probe(struct platform_device *pdev) err_out_unregister_netdev: unregister_netdev(dev); -err_out_free_irq: - for (q = 0, queue = bp->queues; q < q_irq; ++q, ++queue) - devm_free_irq(&pdev->dev, queue->irq, queue); +err_out_free_netdev: free_netdev(dev); err_out_disable_clocks: if (!IS_ERR(tx_clk)) @@ -2392,8 +2390,6 @@ static int __exit macb_remove(struct platform_device *pdev) { struct net_device *dev; struct macb *bp; - struct macb_queue *queue; - unsigned int q; dev = platform_get_drvdata(pdev); @@ -2405,9 +2401,6 @@ static int __exit macb_remove(struct platform_device *pdev) kfree(bp->mii_bus->irq); mdiobus_free(bp->mii_bus); unregister_netdev(dev); - queue = bp->queues; - for (q = 0; q < bp->num_queues; ++q, ++queue) - devm_free_irq(&pdev->dev, queue->irq, queue); if (!IS_ERR(bp->tx_clk)) clk_disable_unprepare(bp->tx_clk); clk_disable_unprepare(bp->hclk);