linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hauke Mehrtens <hauke-5/S+JYg5SzeELgA04lAiVw@public.gmane.org>
To: broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	hauke.mehrtens-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	thomas.langer-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	daniel.schwierzeck-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	john-Pj+rj9U5foFAfugRpC6u6w@public.gmane.org,
	nbd-Vt+b4OUoWG0@public.gmane.org,
	Hauke Mehrtens <hauke-5/S+JYg5SzeELgA04lAiVw@public.gmane.org>
Subject: [PATCH v2 1/2] spi: add check_finished() callback
Date: Sun, 11 Dec 2016 21:03:49 +0100	[thread overview]
Message-ID: <20161211200350.13590-2-hauke@hauke-m.de> (raw)
In-Reply-To: <20161211200350.13590-1-hauke-5/S+JYg5SzeELgA04lAiVw@public.gmane.org>

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 <hauke-5/S+JYg5SzeELgA04lAiVw@public.gmane.org>
---
 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);
 
-- 
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-12-11 20:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-11 20:03 [PATCH v2 0/2] spi: lantiq-ssc: add support for Lantiq SSC SPI controller Hauke Mehrtens
     [not found] ` <20161211200350.13590-1-hauke-5/S+JYg5SzeELgA04lAiVw@public.gmane.org>
2016-12-11 20:03   ` Hauke Mehrtens [this message]
     [not found]     ` <20161211200350.13590-2-hauke-5/S+JYg5SzeELgA04lAiVw@public.gmane.org>
2016-12-14 15:21       ` [PATCH v2 1/2] spi: add check_finished() callback Mark Brown
     [not found]         ` <20161214152156.uehjhqoxpng47pnh-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-12-14 21:48           ` Hauke Mehrtens
2016-12-17 22:16           ` Hauke Mehrtens
     [not found]             ` <7b420e94-3c33-3304-f7a0-ed87c8db425a-5/S+JYg5SzeELgA04lAiVw@public.gmane.org>
2017-01-10 12:34               ` Mark Brown
     [not found]                 ` <20170110123429.t6vsyqtnavranbdn-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2017-01-10 22:44                   ` Hauke Mehrtens
     [not found]                     ` <1d4bfe6a-c5a6-8fd5-310b-748413f7c946-5/S+JYg5SzeELgA04lAiVw@public.gmane.org>
2017-02-04 13:45                       ` Hauke Mehrtens
     [not found]                         ` <2b2776c7-4322-e5c7-e169-7d60c1830518-5/S+JYg5SzeELgA04lAiVw@public.gmane.org>
2017-02-04 15:37                           ` Mark Brown
2016-12-11 20:03   ` [PATCH v2 2/2] spi: lantiq-ssc: add support for Lantiq SSC SPI controller Hauke Mehrtens
     [not found]     ` <20161211200350.13590-3-hauke-5/S+JYg5SzeELgA04lAiVw@public.gmane.org>
2016-12-14 15:34       ` Mark Brown
     [not found]         ` <20161214153407.du2f63irwl2fi72h-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-12-14 21:51           ` Hauke Mehrtens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161211200350.13590-2-hauke@hauke-m.de \
    --to=hauke-5/s+jyg5szeelga04laivw@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=daniel.schwierzeck-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=hauke.mehrtens-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=john-Pj+rj9U5foFAfugRpC6u6w@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nbd-Vt+b4OUoWG0@public.gmane.org \
    --cc=thomas.langer-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).