Input: ad714x - read the interrupt status registers in a row
The interrupt status registers should be read in row to avoid invalid data.
Alter "read" method for both bus options to allow reading several registers
in a row and make sure we read interrupt status registers properly.
Read sequence saves 50% of bus transactions compared to single register
reads. So use it also for the result registers, which are also located
in a row.
Also update copyright notice.
Signed-off-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 6c61218..025417d 100644
--- a/drivers/input/misc/ad714x-i2c.c
+++ b/drivers/input/misc/ad714x-i2c.c
@@ -1,7 +1,7 @@
/*
* AD714X CapTouch Programmable Controller driver (I2C bus)
*
- * Copyright 2009 Analog Devices Inc.
+ * Copyright 2009-2011 Analog Devices Inc.
*
* Licensed under the GPL-2 or later.
*/
@@ -47,9 +47,10 @@
}
static int ad714x_i2c_read(struct ad714x_chip *chip,
- unsigned short reg, unsigned short *data)
+ unsigned short reg, unsigned short *data, size_t len)
{
struct i2c_client *client = to_i2c_client(chip->dev);
+ int i;
int error;
chip->xfer_buf[0] = cpu_to_be16(reg);
@@ -58,14 +59,16 @@
sizeof(*chip->xfer_buf));
if (error >= 0)
error = i2c_master_recv(client, (u8 *)chip->xfer_buf,
- sizeof(*chip->xfer_buf));
+ len * sizeof(*chip->xfer_buf));
if (unlikely(error < 0)) {
dev_err(&client->dev, "I2C read error: %d\n", error);
return error;
}
- *data = be16_to_cpup(chip->xfer_buf);
+ for (i = 0; i < len; i++)
+ data[i] = be16_to_cpu(chip->xfer_buf[i]);
+
return 0;
}