* [PATCH] spi: add spi_sync_single_transfer wrapper for single spi_transfer
@ 2016-06-15 23:40 Andi Shyti
2016-06-16 16:10 ` Lars-Peter Clausen
0 siblings, 1 reply; 5+ messages in thread
From: Andi Shyti @ 2016-06-15 23:40 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-spi, linux-kernel, Andi Shyti, Andi Shyti
The spi_sync_single_transfer function calls spi_sync_transfer
with a single spi_transfer element, instead of an array.
Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
---
include/linux/spi/spi.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 1f03483..660f6a1 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -1051,6 +1051,24 @@ spi_sync_transfer(struct spi_device *spi, struct spi_transfer *xfers,
return spi_sync(spi, &msg);
}
+/**
+ * spi_sync_single_transfer - synchronous SPI data transfer of one spi_transfer
+ * @spi: device with which data will be exchanged
+ * @xfers: One spi_transfer struct
+ * Context: can sleep
+ *
+ * Does a synchronous SPI data transfer of a given spi_transfer.
+ *
+ * For more specific semantics see spi_sync_transfer().
+ *
+ * It returns zero on success, else a negative error code.
+ */
+static inline int
+spi_sync_single_transfer(struct spi_device *spi, struct spi_transfer *xfers)
+{
+ return spi_sync_transfer(spi, xfers, 1);
+}
+
/* this copies txbuf and rxbuf data; for small transfers only! */
extern int spi_write_then_read(struct spi_device *spi,
const void *txbuf, unsigned n_tx,
--
2.8.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: add spi_sync_single_transfer wrapper for single spi_transfer
2016-06-15 23:40 [PATCH] spi: add spi_sync_single_transfer wrapper for single spi_transfer Andi Shyti
@ 2016-06-16 16:10 ` Lars-Peter Clausen
2016-06-17 0:43 ` Andi Shyti
0 siblings, 1 reply; 5+ messages in thread
From: Lars-Peter Clausen @ 2016-06-16 16:10 UTC (permalink / raw)
To: Andi Shyti, Mark Brown; +Cc: linux-spi, linux-kernel, Andi Shyti
On 06/16/2016 01:40 AM, Andi Shyti wrote:
> The spi_sync_single_transfer function calls spi_sync_transfer
> with a single spi_transfer element, instead of an array.
So, what's the advantage of using this as opposed to calling
spi_sync_transfer with a 1 for the number of transfers?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: add spi_sync_single_transfer wrapper for single spi_transfer
2016-06-16 16:10 ` Lars-Peter Clausen
@ 2016-06-17 0:43 ` Andi Shyti
2016-06-17 11:34 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Andi Shyti @ 2016-06-17 0:43 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Mark Brown, linux-spi, linux-kernel, Andi Shyti
Hi Lars,
> > The spi_sync_single_transfer function calls spi_sync_transfer
> > with a single spi_transfer element, instead of an array.
>
> So, what's the advantage of using this as opposed to calling
> spi_sync_transfer with a 1 for the number of transfers?
Not much, but it keeps the code a bit nicer to read for those
using spi_sync_transfer with only one spi_transfer. Besides it's
also more understandable what the function itself does and there
would not be any need to jump into the spi_sync_transfer to check
what the number '1' is needed for (for example it's not a boolean
'true' value).
I checked and there are quite many uses of spi_sync_transfer with
only 1 transfer.
Thanks,
Andi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: add spi_sync_single_transfer wrapper for single spi_transfer
2016-06-17 0:43 ` Andi Shyti
@ 2016-06-17 11:34 ` Mark Brown
2016-06-17 11:38 ` Andi Shyti
0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2016-06-17 11:34 UTC (permalink / raw)
To: Andi Shyti; +Cc: Lars-Peter Clausen, linux-spi, linux-kernel, Andi Shyti
[-- Attachment #1: Type: text/plain, Size: 761 bytes --]
On Fri, Jun 17, 2016 at 09:43:11AM +0900, Andi Shyti wrote:
> > > The spi_sync_single_transfer function calls spi_sync_transfer
> > > with a single spi_transfer element, instead of an array.
> > So, what's the advantage of using this as opposed to calling
> > spi_sync_transfer with a 1 for the number of transfers?
> Not much, but it keeps the code a bit nicer to read for those
> using spi_sync_transfer with only one spi_transfer. Besides it's
> also more understandable what the function itself does and there
> would not be any need to jump into the spi_sync_transfer to check
> what the number '1' is needed for (for example it's not a boolean
> 'true' value).
I really don't think this has been a big source of confusion for people.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: add spi_sync_single_transfer wrapper for single spi_transfer
2016-06-17 11:34 ` Mark Brown
@ 2016-06-17 11:38 ` Andi Shyti
0 siblings, 0 replies; 5+ messages in thread
From: Andi Shyti @ 2016-06-17 11:38 UTC (permalink / raw)
To: Mark Brown
Cc: Andi Shyti, Lars-Peter Clausen, linux-spi, linux-kernel, Andi Shyti
On Fri, Jun 17, 2016 at 12:34:53PM +0100, Mark Brown wrote:
> On Fri, Jun 17, 2016 at 09:43:11AM +0900, Andi Shyti wrote:
>
> > > > The spi_sync_single_transfer function calls spi_sync_transfer
> > > > with a single spi_transfer element, instead of an array.
>
> > > So, what's the advantage of using this as opposed to calling
> > > spi_sync_transfer with a 1 for the number of transfers?
>
> > Not much, but it keeps the code a bit nicer to read for those
> > using spi_sync_transfer with only one spi_transfer. Besides it's
> > also more understandable what the function itself does and there
> > would not be any need to jump into the spi_sync_transfer to check
> > what the number '1' is needed for (for example it's not a boolean
> > 'true' value).
>
> I really don't think this has been a big source of confusion for people.
OK, nevermind, then :)
Thanks,
Andi
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-06-17 11:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-15 23:40 [PATCH] spi: add spi_sync_single_transfer wrapper for single spi_transfer Andi Shyti
2016-06-16 16:10 ` Lars-Peter Clausen
2016-06-17 0:43 ` Andi Shyti
2016-06-17 11:34 ` Mark Brown
2016-06-17 11:38 ` Andi Shyti
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).