From patchwork Mon Mar 27 18:25:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9647345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A744460328 for ; Mon, 27 Mar 2017 18:33:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F96528409 for ; Mon, 27 Mar 2017 18:33:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 944A328408; Mon, 27 Mar 2017 18:33:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39E1028403 for ; Mon, 27 Mar 2017 18:33:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751935AbdC0Scx (ORCPT ); Mon, 27 Mar 2017 14:32:53 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:32776 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751564AbdC0Scw (ORCPT ); Mon, 27 Mar 2017 14:32:52 -0400 Received: by mail-wr0-f193.google.com with SMTP id 20so15757722wrx.0 for ; Mon, 27 Mar 2017 11:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=FNEKcHsZ4pi5Cil2/+RxtKVj0DkTLKC1MIuFHNSslm4=; b=ei/IZoaouwvg11yFxAPoR4PZaNqXE1B25vU4kQoc7SvCpkyQW7ECui8KT228sT5C66 D9A4VvYhcoAFRJcBlZhc+0UYMEGCTV3hnZXK66yqXWBCDmeJ2fl+48dxzGDrw/MuKfmk kLbeuwELJCJXYjFR5hH208rKv68nmkqaGhztO+RUsZ0Poy04VxiKBE9FOrasrneAoJm0 skumX/c4FjcOD+GmG/PnD5JL3UpHXBXyMuuBkJbX9JFV4jQvvxz/2CIzq6slJYYgWgtu LcHk9UTf0xa23P95sw7vE1QO5mlnsuokaJzMSZ42qNRmTvAm0OBgeV+dFWE2TKqCgir7 4Dzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=FNEKcHsZ4pi5Cil2/+RxtKVj0DkTLKC1MIuFHNSslm4=; b=N6jvNySpKn6xX5aPXuHJWqKj4vKFBWRj07L2cSHzqpY7HuSvVT/OfnnfpF9sa9vO6o TlBojT9cxVn8iN2LoKuKE5Pf4GiE6vyifdO/Lt61sKsh/XYSEDdLJSFt2/hnPkK7NnvH 7zXTsSOms0G6WGRYdoprvOfjM+qgCF63u/is3l5XNmvSkvB9zecZJm95AUjuUdQBvQRq t9xATdtWnveCxd4nY77tNCspIfZZs7pgxhXj94e1vLN5JwfMMij+LJ6BHd3mdEPLS/g2 D11VrptHY/l75p+khtrLTNhB4X2ejFDI6hWvoolzUpLxozL0YQ4U8Gs9o9ablyeQYRXp WziQ== X-Gm-Message-State: AFeK/H2vIR+MXl9qljkkMBdIXFFG7WkU1F+VkLkuE58hP+8lKskWuAmNnJG/5rK7EBRkpw== X-Received: by 10.28.151.211 with SMTP id z202mr10391501wmd.88.1490639124691; Mon, 27 Mar 2017 11:25:24 -0700 (PDT) Received: from ?IPv6:2003:c6:ebdc:4000:9598:a7fc:fe65:51e7? (p200300C6EBDC40009598A7FCFE6551E7.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:9598:a7fc:fe65:51e7]) by smtp.googlemail.com with ESMTPSA id 189sm423561wmm.31.2017.03.27.11.25.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2017 11:25:24 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH 1/2] mmc: core: add functions mmc_dma_(un)map_sg To: Ulf Hansson Cc: "linux-mmc@vger.kernel.org" Message-ID: <11e5aed4-c3ca-0d04-484a-9387302eaff2@gmail.com> Date: Mon, 27 Mar 2017 20:25:11 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After the recent introduction of mmc_get_dma_dir next step is to factor out the typical usage of dma_(un)map_sg to the core. Several host drivers use dma_(un)map_sg with these parameters: data->sg, data->sg_len, mmc_get_dma_dir(data) Therefore factor this out to the core and introduce mmc_dma_(un)map_sg. Signed-off-by: Heiner Kallweit --- include/linux/mmc/host.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 21385ac0..8d28a600 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include struct mmc_ios { unsigned int clock; /* clock rate */ @@ -505,6 +505,16 @@ static inline enum dma_data_direction mmc_get_dma_dir(struct mmc_data *data) return data->flags & MMC_DATA_WRITE ? DMA_TO_DEVICE : DMA_FROM_DEVICE; } +static inline int mmc_dma_map_sg(struct device *dev, struct mmc_data *data) +{ + return dma_map_sg(dev, data->sg, data->sg_len, mmc_get_dma_dir(data)); +} + +static inline void mmc_dma_unmap_sg(struct device *dev, struct mmc_data *data) +{ + dma_unmap_sg(dev, data->sg, data->sg_len, mmc_get_dma_dir(data)); +} + int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error); int mmc_abort_tuning(struct mmc_host *host, u32 opcode);