From patchwork Tue Apr 11 11:52:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Raghavendra X-Patchwork-Id: 9674997 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 1036360234 for ; Tue, 11 Apr 2017 11:52:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C80E72097A for ; Tue, 11 Apr 2017 11:52:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCFDF284F5; Tue, 11 Apr 2017 11:52:21 +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=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 408512097A for ; Tue, 11 Apr 2017 11:52:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753272AbdDKLwU (ORCPT ); Tue, 11 Apr 2017 07:52:20 -0400 Received: from fllnx210.ext.ti.com ([198.47.19.17]:52579 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752492AbdDKLwT (ORCPT ); Tue, 11 Apr 2017 07:52:19 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v3BBqH7q006053; Tue, 11 Apr 2017 06:52:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1491911537; bh=6w+m1+Hk1DzZ+ocE/VSRnZR1NCGfk73Fh2BsylJt6+8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=X61yZGW6L0kOD6qyZjcshqJ5hYxBdMBl6m/9IEP1/RmDguy2F++Hr8dfjYpQhI+dl 4b/E55GEnn9BKnT/kARN5+NCUZuE2ZRsNRgB1f97SMh15BVUZIZV1bVjDzuziWSA7x utfPYNMZRVfBXDeTEETguz3lXNgukOr2ujlO2KE0= Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3BBqHHw005983; Tue, 11 Apr 2017 06:52:17 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.294.0; Tue, 11 Apr 2017 06:52:16 -0500 Received: from a0132425.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3BBqCV0017636; Tue, 11 Apr 2017 06:52:15 -0500 From: Vignesh R To: Mark Brown CC: , , , Vignesh R Subject: [PATCH v2 1/2] spi: Add can_dma like interface for spi_flash_read Date: Tue, 11 Apr 2017 17:22:24 +0530 Message-ID: <20170411115225.31709-2-vigneshr@ti.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170411115225.31709-1-vigneshr@ti.com> References: <20170411115225.31709-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 --- v2: No changes. 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); /*