spi: Add a spi_w8r16be() helper
authorLars-Peter Clausen <lars@metafoo.de>
Fri, 27 Sep 2013 14:34:27 +0000 (16:34 +0200)
committerMark Brown <broonie@linaro.org>
Thu, 3 Oct 2013 12:52:03 +0000 (13:52 +0100)
commit05071aa864e84000759191438a4a9ff7ba2c360e
tree08528c6a707ad83eefbf57950fa19cfad86e579b
parent15c03dd4859ab16f9212238f29dd315654aa94f6
spi: Add a spi_w8r16be() helper

This patch adds a new spi_w8r16be() helper, which is similar to spi_w8r16()
except that it converts the read data word from big endian to native endianness
before returning it. The reason for introducing this new helper is that for SPI
slave devices it is quite common that the read 16 bit data word is in big
endian. So users of spi_w8r16() have to convert the result to native endianness
manually. A second reason is that in this case the endianness of the return
value of spi_w8r16() depends on its sign. If it is negative (i.e. a error code)
it is already in native endianness, if it is positive it is in big endian. The
sparse code checker doesn't like this kind of mixed endianness and special
annotations are necessary to keep it quiet (E.g. casting to be16 using __force).
Doing the conversion to native endianness in the helper function does not
require such annotations since we are not mixing different endiannesses in the
same variable.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
include/linux/spi/spi.h
This page took 0.025565 seconds and 5 git commands to generate.