Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1423584 > unrolled thread
| Started by | Andi Shyti <andi.shyti@samsung.com> |
|---|---|
| First post | 2016-06-16 01:50 +0200 |
| Last post | 2016-06-17 13:50 +0200 |
| Articles | 5 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH] spi: add spi_sync_single_transfer wrapper for single spi_transfer Andi Shyti <andi.shyti@samsung.com> - 2016-06-16 01:50 +0200
Re: [PATCH] spi: add spi_sync_single_transfer wrapper for single spi_transfer Lars-Peter Clausen <lars@metafoo.de> - 2016-06-16 18:20 +0200
Re: [PATCH] spi: add spi_sync_single_transfer wrapper for single spi_transfer Andi Shyti <andi.shyti@samsung.com> - 2016-06-17 02:50 +0200
Re: [PATCH] spi: add spi_sync_single_transfer wrapper for single spi_transfer Mark Brown <broonie@kernel.org> - 2016-06-17 13:40 +0200
Re: [PATCH] spi: add spi_sync_single_transfer wrapper for single spi_transfer Andi Shyti <andi@etezian.org> - 2016-06-17 13:50 +0200
| From | Andi Shyti <andi.shyti@samsung.com> |
|---|---|
| Date | 2016-06-16 01:50 +0200 |
| Subject | [PATCH] spi: add spi_sync_single_transfer wrapper for single spi_transfer |
| Message-ID | <rKsJj-HV-1@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Lars-Peter Clausen <lars@metafoo.de> |
|---|---|
| Date | 2016-06-16 18:20 +0200 |
| Message-ID | <rKIbn-28U-3@gated-at.bofh.it> |
| In reply to | #1423584 |
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?
[toc] | [prev] | [next] | [standalone]
| From | Andi Shyti <andi.shyti@samsung.com> |
|---|---|
| Date | 2016-06-17 02:50 +0200 |
| Message-ID | <rKQ8V-7Ix-25@gated-at.bofh.it> |
| In reply to | #1424238 |
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
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2016-06-17 13:40 +0200 |
| Message-ID | <rL0hX-5Wp-1@gated-at.bofh.it> |
| In reply to | #1424573 |
[Multipart message — attachments visible in raw view] — view raw
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.
[toc] | [prev] | [next] | [standalone]
| From | Andi Shyti <andi@etezian.org> |
|---|---|
| Date | 2016-06-17 13:50 +0200 |
| Message-ID | <rL0rE-60E-13@gated-at.bofh.it> |
| In reply to | #1424960 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web