summaryrefslogtreecommitdiff
path: root/drivers/input/misc/ad714x-i2c.c
diff options
context:
space:
mode:
authorMichael Hennerich <michael.hennerich@analog.com>2011-08-22 20:45:42 +0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2011-08-22 20:59:26 +0400
commit9eff794b777ac9ca034129a1b637204000c8fb29 (patch)
tree5f833d94eb3b3a084e5083b89bdc8728447f1665 /drivers/input/misc/ad714x-i2c.c
parentc0409feb86893f5ccf73964c7b2b47ca64bdb014 (diff)
downloadlinux-9eff794b777ac9ca034129a1b637204000c8fb29.tar.xz
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>
Diffstat (limited to 'drivers/input/misc/ad714x-i2c.c')
-rw-r--r--drivers/input/misc/ad714x-i2c.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/input/misc/ad714x-i2c.c b/drivers/input/misc/ad714x-i2c.c
index 6c6121865f0e..025417d74ca2 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_write(struct ad714x_chip *chip,
}
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 @@ static int ad714x_i2c_read(struct ad714x_chip *chip,
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;
}