@@ -10,6 +10,8 @@
int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen)
{
+ int oldwordlen = slave->wordlen;
+
if (wordlen == 0 || wordlen > 32) {
printf("spi: invalid wordlen %u\n", wordlen);
return -1;
@@ -17,7 +19,7 @@ int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen)
slave->wordlen = wordlen;
- return 0;
+ return oldwordlen;
}
void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
@@ -259,7 +259,7 @@ void spi_release_bus(struct spi_slave *slave);
* @slave: The SPI slave
* @wordlen: The number of bits in a word
*
- * Returns: 0 on success, -1 on failure.
+ * Returns: The old word length on success, -1 on failure.
*/
int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen);
Return the current wordlen to the caller so they can restore it back when done. This is required to avoid clobbering the bus state. Signed-off-by: John Watts <contact@jookia.org> --- drivers/spi/spi.c | 4 +++- include/spi.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)