summaryrefslogtreecommitdiffstats
path: root/drivers/input/misc/ad714x-spi.c
diff options
context:
space:
mode:
authorMichael Hennerich <michael.hennerich@analog.com>2011-08-21 21:04:12 -0700
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2011-08-22 09:59:12 -0700
commit6337de2204be3b7b40825a1d30de30e514e8947b (patch)
treee76e4b6ba4460ed5e20d8ebdcfa91273f7c5cb5f /drivers/input/misc/ad714x-spi.c
parent5b9063b19caaffe7135e1f9b8b22174ded0f586b (diff)
downloadlinux-6337de2204be3b7b40825a1d30de30e514e8947b.tar.bz2
Input: ad714x - fix endianness issues
Allow driver to be used on Big Endian boxes. Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/misc/ad714x-spi.c')
-rw-r--r--drivers/input/misc/ad714x-spi.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/drivers/input/misc/ad714x-spi.c b/drivers/input/misc/ad714x-spi.c
index da83ac9bed7e..0c7f9488f5cb 100644
--- a/drivers/input/misc/ad714x-spi.c
+++ b/drivers/input/misc/ad714x-spi.c
@@ -6,7 +6,7 @@
* Licensed under the GPL-2 or later.
*/
-#include <linux/input.h> /* BUS_I2C */
+#include <linux/input.h> /* BUS_SPI */
#include <linux/module.h>
#include <linux/spi/spi.h>
#include <linux/pm.h>
@@ -30,22 +30,28 @@ static int ad714x_spi_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(ad714x_spi_pm, ad714x_spi_suspend, ad714x_spi_resume);
-static int ad714x_spi_read(struct device *dev, unsigned short reg,
- unsigned short *data)
+static int ad714x_spi_read(struct device *dev,
+ unsigned short reg, unsigned short *data)
{
struct spi_device *spi = to_spi_device(dev);
- unsigned short tx = AD714x_SPI_CMD_PREFIX | AD714x_SPI_READ | reg;
+ unsigned short tx = cpu_to_be16(AD714x_SPI_CMD_PREFIX |
+ AD714x_SPI_READ | reg);
+ int ret;
- return spi_write_then_read(spi, (u8 *)&tx, 2, (u8 *)data, 2);
+ ret = spi_write_then_read(spi, &tx, 2, data, 2);
+
+ *data = be16_to_cpup(data);
+
+ return ret;
}
-static int ad714x_spi_write(struct device *dev, unsigned short reg,
- unsigned short data)
+static int ad714x_spi_write(struct device *dev,
+ unsigned short reg, unsigned short data)
{
struct spi_device *spi = to_spi_device(dev);
unsigned short tx[2] = {
- AD714x_SPI_CMD_PREFIX | reg,
- data
+ cpu_to_be16(AD714x_SPI_CMD_PREFIX | reg),
+ cpu_to_be16(data)
};
return spi_write(spi, (u8 *)tx, 4);