From patchwork Thu Jun 2 09:38:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 843132 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p529fBkX016777 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 2 Jun 2011 09:41:31 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QS4Oi-0006J6-Ee; Thu, 02 Jun 2011 09:41:00 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QS4Oi-0002wn-1l; Thu, 02 Jun 2011 09:41:00 +0000 Received: from mail-ew0-f49.google.com ([209.85.215.49]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QS4OI-0002rs-UA for linux-arm-kernel@lists.infradead.org; Thu, 02 Jun 2011 09:40:37 +0000 Received: by ewy3 with SMTP id 3so261787ewy.36 for ; Thu, 02 Jun 2011 02:40:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer; bh=PItHdyAJ/QaBAVO2klx4444M5riXaWFCRXbukazubRE=; b=h5ozNSRG+6a7NlxuwwKjQ3zYFVAZG3vHVV4UxjVA6IQpbgfrt6lBLRkZw/c0f79Duz oh8bxtdzzSV1f8craKIsNHiDwoAoAdHP/ySZDtOnqXiPsDXYItr/jXQkS9GM6vlgiJ+t 4TdeWOC68WN085pjGOkTu3OgjndseG4VLfjL0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer; b=s/Z60r2yvf2uTuFsjrDCR+qSLifd6QlJlvJriA6nGBvq74s8+GNCvfkjaNzHkS3DGE 8BjT5U3+1f6fnW4pFCVWqzCtiRZ3CF8GlHKYWHea7/9JciIeK6CaI2Lgbzy4vw910gYq KOhYhJrKSuh8asVtd5kVuO+QZgzz2wE+4tKCo= Received: by 10.14.35.163 with SMTP id u35mr197888eea.137.1307007631528; Thu, 02 Jun 2011 02:40:31 -0700 (PDT) Received: from acer.healthdatacare.com (a88-115-37-157.elisa-laajakaista.fi [88.115.37.157]) by mx.google.com with ESMTPS id y6sm282499eem.4.2011.06.02.02.40.29 (version=SSLv3 cipher=OTHER); Thu, 02 Jun 2011 02:40:30 -0700 (PDT) From: Mika Westerberg To: netdev@vger.kernel.org Subject: [PATCH 1/5] net: ep93xx_eth: pass struct device to DMA API functions Date: Thu, 2 Jun 2011 12:38:13 +0300 Message-Id: <89df467f9811b4f869513de3ada90ce7de74c6d1.1307006502.git.mika.westerberg@iki.fi> X-Mailer: git-send-email 1.7.4.4 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110602_054035_340635_8E588EBA X-CRM114-Status: GOOD ( 14.96 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is freemail (mika.westerberg[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.49 listed in list.dnswl.org] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain 0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL Cc: Mika Westerberg , hsweeten@visionengravers.com, ryan@bluewatersys.com, kernel@wantstofly.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 02 Jun 2011 09:41:32 +0000 (UTC) We shouldn't use NULL for any DMA API functions, unless we are dealing with ISA or EISA device. So pass correct struct dev pointer to these functions. Signed-off-by: Mika Westerberg Acked-by: Russell King --- drivers/net/arm/ep93xx_eth.c | 26 ++++++++++++++++---------- 1 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/net/arm/ep93xx_eth.c b/drivers/net/arm/ep93xx_eth.c index 5a77001..8779d3b 100644 --- a/drivers/net/arm/ep93xx_eth.c +++ b/drivers/net/arm/ep93xx_eth.c @@ -159,6 +159,8 @@ struct ep93xx_priv void __iomem *base_addr; int irq; + struct device *dma_dev; + struct ep93xx_descs *descs; dma_addr_t descs_dma_addr; @@ -284,7 +286,8 @@ static int ep93xx_rx(struct net_device *dev, int processed, int budget) skb = dev_alloc_skb(length + 2); if (likely(skb != NULL)) { skb_reserve(skb, 2); - dma_sync_single_for_cpu(NULL, ep->descs->rdesc[entry].buf_addr, + dma_sync_single_for_cpu(ep->dma_dev, + ep->descs->rdesc[entry].buf_addr, length, DMA_FROM_DEVICE); skb_copy_to_linear_data(skb, ep->rx_buf[entry], length); skb_put(skb, length); @@ -362,7 +365,7 @@ static int ep93xx_xmit(struct sk_buff *skb, struct net_device *dev) ep->descs->tdesc[entry].tdesc1 = TDESC1_EOF | (entry << 16) | (skb->len & 0xfff); skb_copy_and_csum_dev(skb, ep->tx_buf[entry]); - dma_sync_single_for_cpu(NULL, ep->descs->tdesc[entry].buf_addr, + dma_sync_single_for_cpu(ep->dma_dev, ep->descs->tdesc[entry].buf_addr, skb->len, DMA_TO_DEVICE); dev_kfree_skb(skb); @@ -457,6 +460,7 @@ static irqreturn_t ep93xx_irq(int irq, void *dev_id) static void ep93xx_free_buffers(struct ep93xx_priv *ep) { + struct device *dev = ep->dma_dev; int i; for (i = 0; i < RX_QUEUE_ENTRIES; i += 2) { @@ -464,7 +468,7 @@ static void ep93xx_free_buffers(struct ep93xx_priv *ep) d = ep->descs->rdesc[i].buf_addr; if (d) - dma_unmap_single(NULL, d, PAGE_SIZE, DMA_FROM_DEVICE); + dma_unmap_single(dev, d, PAGE_SIZE, DMA_FROM_DEVICE); if (ep->rx_buf[i] != NULL) free_page((unsigned long)ep->rx_buf[i]); @@ -475,13 +479,13 @@ static void ep93xx_free_buffers(struct ep93xx_priv *ep) d = ep->descs->tdesc[i].buf_addr; if (d) - dma_unmap_single(NULL, d, PAGE_SIZE, DMA_TO_DEVICE); + dma_unmap_single(dev, d, PAGE_SIZE, DMA_TO_DEVICE); if (ep->tx_buf[i] != NULL) free_page((unsigned long)ep->tx_buf[i]); } - dma_free_coherent(NULL, sizeof(struct ep93xx_descs), ep->descs, + dma_free_coherent(dev, sizeof(struct ep93xx_descs), ep->descs, ep->descs_dma_addr); } @@ -491,9 +495,10 @@ static void ep93xx_free_buffers(struct ep93xx_priv *ep) */ static int ep93xx_alloc_buffers(struct ep93xx_priv *ep) { + struct device *dev = ep->dma_dev; int i; - ep->descs = dma_alloc_coherent(NULL, sizeof(struct ep93xx_descs), + ep->descs = dma_alloc_coherent(dev, sizeof(struct ep93xx_descs), &ep->descs_dma_addr, GFP_KERNEL | GFP_DMA); if (ep->descs == NULL) return 1; @@ -506,8 +511,8 @@ static int ep93xx_alloc_buffers(struct ep93xx_priv *ep) if (page == NULL) goto err; - d = dma_map_single(NULL, page, PAGE_SIZE, DMA_FROM_DEVICE); - if (dma_mapping_error(NULL, d)) { + d = dma_map_single(dev, page, PAGE_SIZE, DMA_FROM_DEVICE); + if (dma_mapping_error(dev, d)) { free_page((unsigned long)page); goto err; } @@ -529,8 +534,8 @@ static int ep93xx_alloc_buffers(struct ep93xx_priv *ep) if (page == NULL) goto err; - d = dma_map_single(NULL, page, PAGE_SIZE, DMA_TO_DEVICE); - if (dma_mapping_error(NULL, d)) { + d = dma_map_single(dev, page, PAGE_SIZE, DMA_TO_DEVICE); + if (dma_mapping_error(dev, d)) { free_page((unsigned long)page); goto err; } @@ -829,6 +834,7 @@ static int ep93xx_eth_probe(struct platform_device *pdev) } ep = netdev_priv(dev); ep->dev = dev; + ep->dma_dev = &pdev->dev; netif_napi_add(dev, &ep->napi, ep93xx_poll, 64); platform_set_drvdata(pdev, dev);