Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp184355pxb; Fri, 16 Apr 2021 03:03:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsa3BbMpCg+nLXuQmd0CIUHc6yCndZG5MYODALPepjjQO5EOxXKYXoGGA2qgSalnW95iV8 X-Received: by 2002:aa7:838d:0:b029:221:cd7d:90d8 with SMTP id u13-20020aa7838d0000b0290221cd7d90d8mr7136813pfm.61.1618567420975; Fri, 16 Apr 2021 03:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618567420; cv=none; d=google.com; s=arc-20160816; b=xGulFjVwEYy8BnnvVs0EG4CMM4trEYhuMAbM5Noktmjd9HwoKxIAEDI3k5rnKxrg/y fVtmBhRNaGRQPyoPMTW+VvEW12t3ViS/Y7XvO5upaca4J7xFrs9xeM2fVFcB9kX+NDdl 2NgDud/qePSVYeF1FjGQHdSHNmRF9ZwLN825EmBgR1RRALRMZ91OmjhCbrlYy8lHf50K rC7OcrQHp0PsJuuwu2ufze7+gEe+cljcBRp6TWbNlzi1ynw1o9eO3PxKJpNEbiBAPx05 bGxAjMHibebi3osFxiOI7eBNuMcvvc2S6vQoOiQZWlPvYfTmZ6jTM73nsnN96iC4HpVA FWIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=TRVE7z62v9qhQO7chQTkK2bppHKsInaqOBmKNEJYArk=; b=qvNcr9fm8diZNr3m1N38J2waWJvybBbxzR5QUCjoUPnXIpJmoSTVffPO9GYDyO4Klr 53GunhfQ5dJC2Xh17oHWaIyQ8+abVNe8F+pkP4EzPDKZ1Ry7DtMmPXXDpt/NmqB9e8al lu7v/T8rHUspaAIsXrQxIbroG6lhNimmpjl4K4w0B/jbGtN9CyEilg3YYqK8l4G30c1t zYE8XSxlCuYccXzMLHNXR/dEJsIMB2GRDKvlawAOIJQM2+Qlp54SxJ3yyfCaCV6w0ZLF iXnpuHJGdR+u9m8lumFRxSxYjmq/XlUpcoEtbALr0S+W48gXgPOjX9cVwl1GSRpBteVZ 53DA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c10si6255066pfr.199.2021.04.16.03.03.29; Fri, 16 Apr 2021 03:03:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241216AbhDPIwp (ORCPT + 99 others); Fri, 16 Apr 2021 04:52:45 -0400 Received: from mx2.suse.de ([195.135.220.15]:53988 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240816AbhDPIwh (ORCPT ); Fri, 16 Apr 2021 04:52:37 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9A52FAEE5; Fri, 16 Apr 2021 08:52:11 +0000 (UTC) From: Thomas Bogendoerfer To: "David S. Miller" , Jakub Kicinski , Rob Herring , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Cc: Andrew Lunn Subject: [PATCH v5 net-next 02/10] net: korina: Use devres functions Date: Fri, 16 Apr 2021 10:51:58 +0200 Message-Id: <20210416085207.63181-3-tsbogend@alpha.franken.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210416085207.63181-1-tsbogend@alpha.franken.de> References: <20210416085207.63181-1-tsbogend@alpha.franken.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Simplify probe/remove code by using devm_ functions. Reviewed-by: Andrew Lunn Signed-off-by: Thomas Bogendoerfer --- drivers/net/ethernet/korina.c | 64 ++++++++++++----------------------- 1 file changed, 21 insertions(+), 43 deletions(-) diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c index 1b7e1c75ed9e..b56de01f6bb8 100644 --- a/drivers/net/ethernet/korina.c +++ b/drivers/net/ethernet/korina.c @@ -105,9 +105,9 @@ enum chain_status { /* Information that need to be kept for each board. */ struct korina_private { - struct eth_regs *eth_regs; - struct dma_reg *rx_dma_regs; - struct dma_reg *tx_dma_regs; + struct eth_regs __iomem *eth_regs; + struct dma_reg __iomem *rx_dma_regs; + struct dma_reg __iomem *tx_dma_regs; struct dma_desc *td_ring; /* transmit descriptor ring */ struct dma_desc *rd_ring; /* receive descriptor ring */ @@ -1044,10 +1044,10 @@ static int korina_probe(struct platform_device *pdev) struct korina_device *bif = platform_get_drvdata(pdev); struct korina_private *lp; struct net_device *dev; - struct resource *r; + void __iomem *p; int rc; - dev = alloc_etherdev(sizeof(struct korina_private)); + dev = devm_alloc_etherdev(&pdev->dev, sizeof(struct korina_private)); if (!dev) return -ENOMEM; @@ -1060,36 +1060,30 @@ static int korina_probe(struct platform_device *pdev) lp->rx_irq = platform_get_irq_byname(pdev, "korina_rx"); lp->tx_irq = platform_get_irq_byname(pdev, "korina_tx"); - r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "korina_regs"); - dev->base_addr = r->start; - lp->eth_regs = ioremap(r->start, resource_size(r)); - if (!lp->eth_regs) { + p = devm_platform_ioremap_resource_byname(pdev, "korina_regs"); + if (!p) { printk(KERN_ERR DRV_NAME ": cannot remap registers\n"); - rc = -ENXIO; - goto probe_err_out; + return -ENOMEM; } + lp->eth_regs = p; - r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "korina_dma_rx"); - lp->rx_dma_regs = ioremap(r->start, resource_size(r)); - if (!lp->rx_dma_regs) { + p = devm_platform_ioremap_resource_byname(pdev, "korina_dma_rx"); + if (!p) { printk(KERN_ERR DRV_NAME ": cannot remap Rx DMA registers\n"); - rc = -ENXIO; - goto probe_err_dma_rx; + return -ENOMEM; } + lp->rx_dma_regs = p; - r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "korina_dma_tx"); - lp->tx_dma_regs = ioremap(r->start, resource_size(r)); - if (!lp->tx_dma_regs) { + p = devm_platform_ioremap_resource_byname(pdev, "korina_dma_tx"); + if (!p) { printk(KERN_ERR DRV_NAME ": cannot remap Tx DMA registers\n"); - rc = -ENXIO; - goto probe_err_dma_tx; + return -ENOMEM; } + lp->tx_dma_regs = p; lp->td_ring = kmalloc(TD_RING_SIZE + RD_RING_SIZE, GFP_KERNEL); - if (!lp->td_ring) { - rc = -ENXIO; - goto probe_err_td_ring; - } + if (!lp->td_ring) + return -ENOMEM; dma_cache_inv((unsigned long)(lp->td_ring), TD_RING_SIZE + RD_RING_SIZE); @@ -1119,7 +1113,8 @@ static int korina_probe(struct platform_device *pdev) if (rc < 0) { printk(KERN_ERR DRV_NAME ": cannot register net device: %d\n", rc); - goto probe_err_register; + kfree((struct dma_desc *)KSEG0ADDR(lp->td_ring)); + return rc; } timer_setup(&lp->media_check_timer, korina_poll_media, 0); @@ -1127,20 +1122,7 @@ static int korina_probe(struct platform_device *pdev) printk(KERN_INFO "%s: " DRV_NAME "-" DRV_VERSION " " DRV_RELDATE "\n", dev->name); -out: return rc; - -probe_err_register: - kfree((struct dma_desc *)KSEG0ADDR(lp->td_ring)); -probe_err_td_ring: - iounmap(lp->tx_dma_regs); -probe_err_dma_tx: - iounmap(lp->rx_dma_regs); -probe_err_dma_rx: - iounmap(lp->eth_regs); -probe_err_out: - free_netdev(dev); - goto out; } static int korina_remove(struct platform_device *pdev) @@ -1148,13 +1130,9 @@ static int korina_remove(struct platform_device *pdev) struct korina_device *bif = platform_get_drvdata(pdev); struct korina_private *lp = netdev_priv(bif->dev); - iounmap(lp->eth_regs); - iounmap(lp->rx_dma_regs); - iounmap(lp->tx_dma_regs); kfree((struct dma_desc *)KSEG0ADDR(lp->td_ring)); unregister_netdev(bif->dev); - free_netdev(bif->dev); return 0; } -- 2.29.2