Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ab329d5 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "input: synaptics_dsx: remove array declaration in write function"

parents 34ea1080 a64c0bfe
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -3596,6 +3596,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;

+3 −0
Original line number Diff line number Diff line
@@ -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,
@@ -265,6 +266,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;
+19 −4
Original line number Diff line number Diff line
@@ -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) {