Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp146747ima; Fri, 1 Feb 2019 00:51:48 -0800 (PST) X-Google-Smtp-Source: AHgI3IaPFL5vfuyRJPs9MRntFE4uegGWk7xIu45U9vUKfkzlZYno7YjC4QOY0Gs4sLqvn2st3Pwo X-Received: by 2002:a63:fd0a:: with SMTP id d10mr1413551pgh.164.1549011108081; Fri, 01 Feb 2019 00:51:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549011108; cv=none; d=google.com; s=arc-20160816; b=bA5scEZXWiZts7injWjCplcdRGdulVvMnGhM4lLFnD4BdPDldM083OKmFJjoVrdhX2 t1bSaaWOEfEGFo2F3VKtpkCqa5RTJflY6oQ07svlUHvwdggSVcs0zX0ltKqRnbi4xi2B dCNXP7epjjILjEjM/cRnN8sQ17Mo03g3T7731snJtKeW9TTYWlPhBK5F4IQJ68KeYeqQ DyyTkpIAxCIqsc/NnXvAnEIc2aozXqM7IJQRU4zdBNgNOtAhI7XLRc8ck3yj8fqvn85N JS3fePAt7liVVV8gb9zyYme0Av9OPYGDDppO3gnOtDLFSTO9WzO9/mnOKB/SBVLxCXEJ EkIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O5KJ8GRlbczaBVxGOYcgqpq+hGPfEepfpWMZvixHPpI=; b=iIwIQdqL2s54E5H+ua5JjwXD3T+GuLsJ+fFrjorUZGF9MJikg9GgCfM5kVB1X35kIX Xc5pU3tGCO9TF4yBfZuNRMRwnkNRt58MBZquzJS334eVNY/11FPG1d2gn+4CmLVHgMVp mX+skvf1RbB3N0Aaq4ulwISAhMIdGXzcayQgJREJDBMtGES71y7gtoJv/i1PAXmBffIb 1aNQzI6sYpCCGfwsUl4DVsO2yLk5LkwD6aDGvUOdyeX8UGlLpAd2MrZh6RGy/d/Elccj 5m8HvGQ6SAEFxKT0K7YxC41tadYoqUup3O2MusAaWZQGrsOkOsAwSyCqMS4S1vXVF/BW BgbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=o92IzzYC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 s4si6295695pfb.190.2019.02.01.00.51.32; Fri, 01 Feb 2019 00:51:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=o92IzzYC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729525AbfBAIs2 (ORCPT + 99 others); Fri, 1 Feb 2019 03:48:28 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48384 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729477AbfBAIsY (ORCPT ); Fri, 1 Feb 2019 03:48:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=O5KJ8GRlbczaBVxGOYcgqpq+hGPfEepfpWMZvixHPpI=; b=o92IzzYCttBzDcN4JdyXfmJaDz 28GVjj4SAVJS3enTaCLsnn4HRN3Z+9HaU4ZDJRiq5Ci7NWwJUhvd1ywHZKJFiVmjgtlgwS9n4em4O Nybc3rcenwrkLadXp8GvB1bVLUsgbo3lS6hH/laqCd9FZhri+rR6Hl/ITNDkprYcyBW7zr4PfB0Kw 2HwLCxbAFIkVSD+ZZ/Gf6INEjGPIo623cYKsqPQioYFMglk2kQIvNB4jCgKr5vYRXSnNeaOb0M5X/ 8Y2QqSkEh001eyP8LEh2Ngr3/hinZVxWireKYT0yt5Xo75dXCCdo/3sYutCok7E41thvSXRl/q0vc 0gQqWRzA==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUUn-0001Pj-B8; Fri, 01 Feb 2019 08:48:21 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 07/18] pxa168_eth: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:47:50 +0100 Message-Id: <20190201084801.10983-8-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Note that this driver seems to entirely lack dma_map_single error handling, but that is left for another time. Signed-off-by: Christoph Hellwig --- drivers/net/ethernet/marvell/pxa168_eth.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c index f8a6d6e3cb7a..35f2142aac5e 100644 --- a/drivers/net/ethernet/marvell/pxa168_eth.c +++ b/drivers/net/ethernet/marvell/pxa168_eth.c @@ -201,6 +201,7 @@ struct tx_desc { }; struct pxa168_eth_private { + struct platform_device *pdev; int port_num; /* User Ethernet port number */ int phy_addr; int phy_speed; @@ -331,7 +332,7 @@ static void rxq_refill(struct net_device *dev) used_rx_desc = pep->rx_used_desc_q; p_used_rx_desc = &pep->p_rx_desc_area[used_rx_desc]; size = skb_end_pointer(skb) - skb->data; - p_used_rx_desc->buf_ptr = dma_map_single(NULL, + p_used_rx_desc->buf_ptr = dma_map_single(&pep->pdev->dev, skb->data, size, DMA_FROM_DEVICE); @@ -743,7 +744,7 @@ static int txq_reclaim(struct net_device *dev, int force) netdev_err(dev, "Error in TX\n"); dev->stats.tx_errors++; } - dma_unmap_single(NULL, addr, count, DMA_TO_DEVICE); + dma_unmap_single(&pep->pdev->dev, addr, count, DMA_TO_DEVICE); if (skb) dev_kfree_skb_irq(skb); released++; @@ -805,7 +806,7 @@ static int rxq_process(struct net_device *dev, int budget) if (rx_next_curr_desc == rx_used_desc) pep->rx_resource_err = 1; pep->rx_desc_count--; - dma_unmap_single(NULL, rx_desc->buf_ptr, + dma_unmap_single(&pep->pdev->dev, rx_desc->buf_ptr, rx_desc->buf_size, DMA_FROM_DEVICE); received_packets++; @@ -1274,7 +1275,8 @@ pxa168_eth_start_xmit(struct sk_buff *skb, struct net_device *dev) length = skb->len; pep->tx_skb[tx_index] = skb; desc->byte_cnt = length; - desc->buf_ptr = dma_map_single(NULL, skb->data, length, DMA_TO_DEVICE); + desc->buf_ptr = dma_map_single(&pep->pdev->dev, skb->data, length, + DMA_TO_DEVICE); skb_tx_timestamp(skb); @@ -1528,6 +1530,7 @@ static int pxa168_eth_probe(struct platform_device *pdev) if (err) goto err_free_mdio; + pep->pdev = pdev; SET_NETDEV_DEV(dev, &pdev->dev); pxa168_init_hw(pep); err = register_netdev(dev); -- 2.20.1