Input: cyttsp4 - use 16bit address for I2C/SPI communication
In TSG4, register map is 512bytes long and to access all of it, one bit from address byte is used (which bit to use differs for I2C and SPI); Since common code used for TSG3 and TSG4 for I2C, this parameter wrongly used as u8. TSG3 does not access beyond 255 bytes but TSG4 may. Tested-on:TMA3XX DVB && TMA4XX DVB Signed-off-by: Ferruh Yigit <fery@cypress.com> Acked-by: Javier Martinez Canillas <javier@dowhile0.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:

committed by
Dmitry Torokhov

parent
57961e3ba7
commit
62f548d0c2
@@ -32,18 +32,20 @@
|
||||
#include <linux/types.h>
|
||||
|
||||
int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf,
|
||||
u8 addr, u8 length, void *values)
|
||||
u16 addr, u8 length, void *values)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
u8 client_addr = client->addr | ((addr >> 8) & 0x1);
|
||||
u8 addr_lo = addr & 0xFF;
|
||||
struct i2c_msg msgs[] = {
|
||||
{
|
||||
.addr = client->addr,
|
||||
.addr = client_addr,
|
||||
.flags = 0,
|
||||
.len = 1,
|
||||
.buf = &addr,
|
||||
.buf = &addr_lo,
|
||||
},
|
||||
{
|
||||
.addr = client->addr,
|
||||
.addr = client_addr,
|
||||
.flags = I2C_M_RD,
|
||||
.len = length,
|
||||
.buf = values,
|
||||
@@ -60,17 +62,29 @@ int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf,
|
||||
EXPORT_SYMBOL_GPL(cyttsp_i2c_read_block_data);
|
||||
|
||||
int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf,
|
||||
u8 addr, u8 length, const void *values)
|
||||
u16 addr, u8 length, const void *values)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
u8 client_addr = client->addr | ((addr >> 8) & 0x1);
|
||||
u8 addr_lo = addr & 0xFF;
|
||||
struct i2c_msg msgs[] = {
|
||||
{
|
||||
.addr = client_addr,
|
||||
.flags = 0,
|
||||
.len = length + 1,
|
||||
.buf = xfer_buf,
|
||||
},
|
||||
};
|
||||
int retval;
|
||||
|
||||
xfer_buf[0] = addr;
|
||||
xfer_buf[0] = addr_lo;
|
||||
memcpy(&xfer_buf[1], values, length);
|
||||
|
||||
retval = i2c_master_send(client, xfer_buf, length + 1);
|
||||
retval = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
|
||||
if (retval < 0)
|
||||
return retval;
|
||||
|
||||
return retval < 0 ? retval : 0;
|
||||
return retval != ARRAY_SIZE(msgs) ? -EIO : 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cyttsp_i2c_write_block_data);
|
||||
|
||||
|
Reference in New Issue
Block a user