From patchwork Fri Mar 31 11:49:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Raghavendra X-Patchwork-Id: 9656113 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 E406F60352 for ; Fri, 31 Mar 2017 11:58:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D51ED28650 for ; Fri, 31 Mar 2017 11:58:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA2422868B; Fri, 31 Mar 2017 11:58:24 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 8179C28678 for ; Fri, 31 Mar 2017 11:58:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932976AbdCaL6G (ORCPT ); Fri, 31 Mar 2017 07:58:06 -0400 Received: from lelnx193.ext.ti.com ([198.47.27.77]:13339 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932732AbdCaL5k (ORCPT ); Fri, 31 Mar 2017 07:57:40 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id v2VBvbHR032268; Fri, 31 Mar 2017 06:57:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1490961457; bh=uWOpB9Fdv6Av/nw+urzn6HrvB6eJLaGVM2p8AyY7N5U=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=w93FqXDzCwmY7Pb/yINIrNREdoT2XWr2Rv0vtfKYRByj2o6KHnMp6fVywAQcnBvkL jQNwNbhaKezWkuRIC2kBXcg3veePIXpq0zsUtypxc1DurzhW2fWo2DvgGDXwuZe1YM oZGQ+cB+VgvJRG4+TGL9HF22pS1I3IlwoawfSgyo= Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v2VBvbAo012674; Fri, 31 Mar 2017 06:57:37 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.294.0; Fri, 31 Mar 2017 06:57:36 -0500 Received: from a0132425.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v2VBvXVG029992; Fri, 31 Mar 2017 06:57:35 -0500 From: Vignesh R To: Mark Brown CC: , , , Vignesh R Subject: [PATCH 1/2] spi: Add can_dma like interface for spi_flash_read Date: Fri, 31 Mar 2017 17:19:49 +0530 Message-ID: <20170331114950.21489-2-vigneshr@ti.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170331114950.21489-1-vigneshr@ti.com> References: <20170331114950.21489-1-vigneshr@ti.com> MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add an interface analogous to ->can_dma() for spi_flash_read() interface. This will enable SPI controller drivers to inform SPI core when not to do DMA mappings. Signed-off-by: Vignesh R --- drivers/spi/spi.c | 2 +- include/linux/spi/spi.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index f699ea530b88..57b64d2128e5 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2854,7 +2854,7 @@ int spi_flash_read(struct spi_device *spi, mutex_lock(&master->bus_lock_mutex); mutex_lock(&master->io_mutex); - if (master->dma_rx) { + if (master->dma_rx && master->spi_flash_can_dma(spi, msg)) { rx_dev = master->dma_rx->device->dev; ret = spi_map_buf(master, rx_dev, &msg->rx_sg, msg->buf, msg->len, diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 805878d61a8f..935bd2854ff1 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -376,6 +376,8 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) * @unprepare_message: undo any work done by prepare_message(). * @spi_flash_read: to support spi-controller hardwares that provide * accelerated interface to read from flash devices. + * @spi_flash_can_dma: analogous to can_dma() interface, but for + * controllers implementing spi_flash_read. * @flash_read_supported: spi device supports flash read * @cs_gpios: Array of GPIOs to use as chip select lines; one per CS * number. Any individual value may be -ENOENT for CS lines that @@ -539,6 +541,8 @@ struct spi_master { struct spi_message *message); int (*spi_flash_read)(struct spi_device *spi, struct spi_flash_read_message *msg); + bool (*spi_flash_can_dma)(struct spi_device *spi, + struct spi_flash_read_message *msg); bool (*flash_read_supported)(struct spi_device *spi); /*