From patchwork Sun Dec 11 20:03:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 9469861 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 8868060231 for ; Sun, 11 Dec 2016 20:04:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77ED92815E for ; Sun, 11 Dec 2016 20:04:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CAFF28179; Sun, 11 Dec 2016 20:04:16 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 8328A28178 for ; Sun, 11 Dec 2016 20:04:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753807AbcLKUEO (ORCPT ); Sun, 11 Dec 2016 15:04:14 -0500 Received: from hauke-m.de ([5.39.93.123]:59517 "EHLO mail.hauke-m.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753620AbcLKUEO (ORCPT ); Sun, 11 Dec 2016 15:04:14 -0500 Received: from hauke-desktop.lan (p200300862810630000714C9ACAB1E5C3.dip0.t-ipconnect.de [IPv6:2003:86:2810:6300:71:4c9a:cab1:e5c3]) by mail.hauke-m.de (Postfix) with ESMTPSA id 738A110047B; Sun, 11 Dec 2016 21:04:10 +0100 (CET) From: Hauke Mehrtens To: broonie@kernel.org Cc: linux-spi@vger.kernel.org, hauke.mehrtens@intel.com, thomas.langer@intel.com, daniel.schwierzeck@gmail.com, john@phrozen.org, nbd@nbd.name, Hauke Mehrtens Subject: [PATCH v2 1/2] spi: add check_finished() callback Date: Sun, 11 Dec 2016 21:03:49 +0100 Message-Id: <20161211200350.13590-2-hauke@hauke-m.de> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161211200350.13590-1-hauke@hauke-m.de> References: <20161211200350.13590-1-hauke@hauke-m.de> 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 This callback checks if the transfer really finished. This allows a driver to directly call the completion list in the irq handler and it does not have to bushy wait till the hardware is really finished in the IRQ handler. This is needed for the Lantiq driver. Signed-off-by: Hauke Mehrtens --- drivers/spi/spi.c | 10 ++++++++++ include/linux/spi/spi.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 838783c..8702cdf 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1013,6 +1013,16 @@ static int spi_transfer_one_message(struct spi_master *master, msecs_to_jiffies(ms)); } + if (master->check_finished) { + ret = master->check_finished(master, ms); + if (ret) { + dev_err(&msg->spi->dev, + "SPI transfer not finished: %i\n", + ret); + msg->status = ret; + } + } + if (ms == 0) { SPI_STATISTICS_INCREMENT_FIELD(statm, timedout); diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 4b743ac..2b851a6 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -370,6 +370,9 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) * transfer_one_message are mutually exclusive; when both * are set, the generic subsystem does not call your * transfer_one callback. + * @check_finished: This callback allows the driver to check if the message + * was fully transferred. return a negative value in case + * of an error. * @handle_err: the subsystem calls the driver to handle an error that occurs * in the generic implementation of transfer_one_message(). * @unprepare_message: undo any work done by prepare_message(). @@ -546,6 +549,7 @@ struct spi_master { void (*set_cs)(struct spi_device *spi, bool enable); int (*transfer_one)(struct spi_master *master, struct spi_device *spi, struct spi_transfer *transfer); + int (*check_finished)(struct spi_master *master, unsigned long timeout); void (*handle_err)(struct spi_master *master, struct spi_message *message);