From patchwork Wed Nov 19 12:43:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 5336981 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@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 81F8BC11AC for ; Wed, 19 Nov 2014 12:42:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 586BF201EF for ; Wed, 19 Nov 2014 12:42:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2506E201E4 for ; Wed, 19 Nov 2014 12:42:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754717AbaKSMmM (ORCPT ); Wed, 19 Nov 2014 07:42:12 -0500 Received: from sauhun.de ([89.238.76.85]:54081 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753832AbaKSMmL (ORCPT ); Wed, 19 Nov 2014 07:42:11 -0500 Received: from p4fe246e1.dip0.t-ipconnect.de ([79.226.70.225]:60186 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1Xr4aG-0001a2-MO; Wed, 19 Nov 2014 13:42:08 +0100 From: Wolfram Sang To: linux-i2c@vger.kernel.org Cc: linux-sh@vger.kernel.org, Wolfram Sang , Magnus Damm , Simon Horman , Laurent Pinchart , Geert Uytterhoeven , Arnd Bergmann Subject: [PATCH] i2c: sh_mobile: use proper device for mapping DMA memory Date: Wed, 19 Nov 2014 13:43:22 +0100 Message-Id: <1416401002-18128-1-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 2.1.1 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Wolfram Sang It should be the DMA device, not the platform device. Signed-off-by: Wolfram Sang Acked-by: Geert Uytterhoeven --- drivers/i2c/busses/i2c-sh_mobile.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index 903bb22aa5b4..c2362a4bec25 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c @@ -511,6 +511,17 @@ static irqreturn_t sh_mobile_i2c_isr(int irq, void *dev_id) return IRQ_HANDLED; } +static void sh_mobile_i2c_dma_unmap(struct sh_mobile_i2c_data *pd) +{ + struct dma_chan *chan = pd->dma_direction == DMA_FROM_DEVICE + ? pd->dma_rx : pd->dma_tx; + + dma_unmap_single(chan->device->dev, sg_dma_address(&pd->sg), + pd->msg->len, pd->dma_direction); + + pd->dma_direction = DMA_NONE; +} + static void sh_mobile_i2c_cleanup_dma(struct sh_mobile_i2c_data *pd) { if (pd->dma_direction == DMA_NONE) @@ -520,20 +531,14 @@ static void sh_mobile_i2c_cleanup_dma(struct sh_mobile_i2c_data *pd) else if (pd->dma_direction == DMA_TO_DEVICE) dmaengine_terminate_all(pd->dma_tx); - dma_unmap_single(pd->dev, sg_dma_address(&pd->sg), - pd->msg->len, pd->dma_direction); - - pd->dma_direction = DMA_NONE; + sh_mobile_i2c_dma_unmap(pd); } static void sh_mobile_i2c_dma_callback(void *data) { struct sh_mobile_i2c_data *pd = data; - dma_unmap_single(pd->dev, sg_dma_address(&pd->sg), - pd->msg->len, pd->dma_direction); - - pd->dma_direction = DMA_NONE; + sh_mobile_i2c_dma_unmap(pd); pd->pos = pd->msg->len; iic_set_clr(pd, ICIC, 0, ICIC_TDMAE | ICIC_RDMAE); @@ -551,7 +556,7 @@ static void sh_mobile_i2c_xfer_dma(struct sh_mobile_i2c_data *pd) if (!chan) return; - dma_addr = dma_map_single(pd->dev, pd->msg->buf, pd->msg->len, dir); + dma_addr = dma_map_single(chan->device->dev, pd->msg->buf, pd->msg->len, dir); if (dma_mapping_error(pd->dev, dma_addr)) { dev_dbg(pd->dev, "dma map failed, using PIO\n"); return;