mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-11-01 02:21:16 +00:00
input: synaptics_dsx: remove array declaration in write function
Remove array declaration in i2c write function of Synaptics DSX touch driver and use the malloc function to allocate the memory. This change is added to use heap memory instead of stack memory. CRs-Fixed: 1010986 Change-Id: I8f2f75744bb442191d7d4577795d986e10ea1cf6 Signed-off-by: Shantanu Jain <shjain@codeaurora.org>
This commit is contained in:
parent
c69a4a60de
commit
49b52b0117
3 changed files with 31 additions and 7 deletions
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* Copyright (C) 2012 Alexandra Chin <alexandra.chin@tw.synaptics.com>
|
||||
* Copyright (C) 2012 Scott Lin <scott.lin@tw.synaptics.com>
|
||||
* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -3545,6 +3545,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;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* Copyright (C) 2012 Alexandra Chin <alexandra.chin@tw.synaptics.com>
|
||||
* Copyright (C) 2012 Scott Lin <scott.lin@tw.synaptics.com>
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2014, 2016, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -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,
|
||||
|
@ -264,6 +265,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;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Synaptics DSX touchscreen driver
|
||||
*
|
||||
* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Linux foundation chooses to take subject only to the GPLv2 license terms,
|
||||
* and distributes only under these terms.
|
||||
|
@ -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 stucture 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…
Reference in a new issue