Merge "input: synaptics_dsx: remove array declaration in write function"
This commit is contained in:
commit
d0ae02c103
3 changed files with 29 additions and 5 deletions
|
@ -3666,7 +3666,7 @@ static int synaptics_rmi4_probe(struct platform_device *pdev)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
rmi4_data = kzalloc(sizeof(*rmi4_data), GFP_KERNEL);
|
||||
rmi4_data = devm_kzalloc(&pdev->dev, sizeof(*rmi4_data), GFP_KERNEL);
|
||||
if (!rmi4_data) {
|
||||
dev_err(&pdev->dev,
|
||||
"%s: Failed to alloc mem for rmi4_data\n",
|
||||
|
@ -3684,6 +3684,12 @@ static int synaptics_rmi4_probe(struct platform_device *pdev)
|
|||
rmi4_data->fingers_on_2d = false;
|
||||
rmi4_data->update_coords = true;
|
||||
|
||||
rmi4_data->write_buf = devm_kzalloc(&pdev->dev, I2C_WRITE_BUF_MAX_LEN,
|
||||
GFP_KERNEL);
|
||||
if (!rmi4_data->write_buf)
|
||||
return -ENOMEM;
|
||||
rmi4_data->write_buf_len = I2C_WRITE_BUF_MAX_LEN;
|
||||
|
||||
rmi4_data->irq_enable = synaptics_rmi4_irq_enable;
|
||||
rmi4_data->reset_device = synaptics_rmi4_reset_device;
|
||||
|
||||
|
|
|
@ -101,6 +101,7 @@
|
|||
#define PINCTRL_STATE_RELEASE "pmx_ts_release"
|
||||
|
||||
#define SYNA_FW_NAME_MAX_LEN 50
|
||||
#define I2C_WRITE_BUF_MAX_LEN 32
|
||||
|
||||
enum exp_fn {
|
||||
RMI_DEV = 0,
|
||||
|
@ -277,6 +278,8 @@ struct synaptics_rmi4_data {
|
|||
unsigned char no_sleep_setting;
|
||||
unsigned char intr_mask[MAX_INTR_REGISTERS];
|
||||
unsigned char *button_txrx_mapping;
|
||||
unsigned char *write_buf;
|
||||
unsigned short write_buf_len;
|
||||
unsigned short num_of_intr_regs;
|
||||
unsigned short f01_query_base_addr;
|
||||
unsigned short f01_cmd_base_addr;
|
||||
|
|
|
@ -134,18 +134,33 @@ static int synaptics_rmi4_i2c_write(struct synaptics_rmi4_data *rmi4_data,
|
|||
{
|
||||
int retval;
|
||||
unsigned char retry;
|
||||
unsigned char buf[length + 1];
|
||||
struct i2c_client *i2c = to_i2c_client(rmi4_data->pdev->dev.parent);
|
||||
struct i2c_msg msg[] = {
|
||||
{
|
||||
.addr = i2c->addr,
|
||||
.flags = 0,
|
||||
.len = length + 1,
|
||||
.buf = buf,
|
||||
}
|
||||
};
|
||||
|
||||
mutex_lock(&rmi4_data->rmi4_io_ctrl_mutex);
|
||||
/*
|
||||
* Reassign memory for write_buf in case length is greater than 32 bytes
|
||||
*/
|
||||
if (rmi4_data->write_buf_len < length + 1) {
|
||||
devm_kfree(rmi4_data->pdev->dev.parent, rmi4_data->write_buf);
|
||||
rmi4_data->write_buf = devm_kzalloc(rmi4_data->pdev->dev.parent,
|
||||
length + 1, GFP_KERNEL);
|
||||
if (!rmi4_data->write_buf) {
|
||||
rmi4_data->write_buf_len = 0;
|
||||
retval = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
rmi4_data->write_buf_len = length + 1;
|
||||
}
|
||||
|
||||
/* Assign the write_buf of driver structure to i2c_msg buf */
|
||||
msg[0].buf = rmi4_data->write_buf;
|
||||
|
||||
retval = synaptics_rmi4_i2c_set_page(rmi4_data, addr);
|
||||
if (retval != PAGE_SELECT_LEN) {
|
||||
|
@ -153,8 +168,8 @@ static int synaptics_rmi4_i2c_write(struct synaptics_rmi4_data *rmi4_data,
|
|||
goto exit;
|
||||
}
|
||||
|
||||
buf[0] = addr & MASK_8BIT;
|
||||
memcpy(&buf[1], &data[0], length);
|
||||
rmi4_data->write_buf[0] = addr & MASK_8BIT;
|
||||
memcpy(&rmi4_data->write_buf[1], &data[0], length);
|
||||
|
||||
for (retry = 0; retry < SYN_I2C_RETRY_TIMES; retry++) {
|
||||
if (i2c_transfer(i2c->adapter, msg, 1) == 1) {
|
||||
|
|
Loading…
Add table
Reference in a new issue