Input: ad714x - use DMA-safe buffers for spi_write()

spi_write() requires use of DMA-safe (cacheline aligned) buffers.
Also use the same buffers when reading data since to avoid extra
locking and potential memory allocation in spi_write_then_read().

Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
diff --git a/drivers/input/misc/ad714x-i2c.c b/drivers/input/misc/ad714x-i2c.c
index 00a6a22..6c61218 100644
--- a/drivers/input/misc/ad714x-i2c.c
+++ b/drivers/input/misc/ad714x-i2c.c
@@ -27,40 +27,46 @@
 
 static SIMPLE_DEV_PM_OPS(ad714x_i2c_pm, ad714x_i2c_suspend, ad714x_i2c_resume);
 
-static int ad714x_i2c_write(struct device *dev, unsigned short reg,
-				unsigned short data)
+static int ad714x_i2c_write(struct ad714x_chip *chip,
+			    unsigned short reg, unsigned short data)
 {
-	struct i2c_client *client = to_i2c_client(dev);
-	int ret = 0;
-	unsigned short tx[2] = {
-		cpu_to_be16(reg),
-		cpu_to_be16(data)
-	};
+	struct i2c_client *client = to_i2c_client(chip->dev);
+	int error;
 
-	ret = i2c_master_send(client, (u8 *)tx, 4);
-	if (ret < 0)
-		dev_err(&client->dev, "I2C write error\n");
+	chip->xfer_buf[0] = cpu_to_be16(reg);
+	chip->xfer_buf[1] = cpu_to_be16(data);
 
-	return ret;
+	error = i2c_master_send(client, (u8 *)chip->xfer_buf,
+				2 * sizeof(*chip->xfer_buf));
+	if (unlikely(error < 0)) {
+		dev_err(&client->dev, "I2C write error: %d\n", error);
+		return error;
+	}
+
+	return 0;
 }
 
-static int ad714x_i2c_read(struct device *dev, unsigned short reg,
-				unsigned short *data)
+static int ad714x_i2c_read(struct ad714x_chip *chip,
+			   unsigned short reg, unsigned short *data)
 {
-	struct i2c_client *client = to_i2c_client(dev);
-	int ret = 0;
-	unsigned short tx = cpu_to_be16(reg);
+	struct i2c_client *client = to_i2c_client(chip->dev);
+	int error;
 
-	ret = i2c_master_send(client, (u8 *)&tx, 2);
-	if (ret >= 0)
-		ret = i2c_master_recv(client, (u8 *)data, 2);
+	chip->xfer_buf[0] = cpu_to_be16(reg);
 
-	if (unlikely(ret < 0))
-		dev_err(&client->dev, "I2C read error\n");
-	else
-		*data = be16_to_cpu(*data);
+	error = i2c_master_send(client, (u8 *)chip->xfer_buf,
+				sizeof(*chip->xfer_buf));
+	if (error >= 0)
+		error = i2c_master_recv(client, (u8 *)chip->xfer_buf,
+					sizeof(*chip->xfer_buf));
 
-	return ret;
+	if (unlikely(error < 0)) {
+		dev_err(&client->dev, "I2C read error: %d\n", error);
+		return error;
+	}
+
+	*data = be16_to_cpup(chip->xfer_buf);
+	return 0;
 }
 
 static int __devinit ad714x_i2c_probe(struct i2c_client *client,