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

Commit 138c7b31 authored by Shantanu Jain's avatar Shantanu Jain
Browse files

input: touchscreen: st: add fix in driver to support VMAP_STACK



Add fix in ST micro touch driver to support VMAP_STACK
security feature.

Change-Id: Iff463150bd307901bf756fc251c4efa3cbb59d78
Signed-off-by: default avatarShantanu Jain <shjain@codeaurora.org>
parent 906ec760
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -4390,6 +4390,14 @@ static int fts_probe(struct i2c_client *client,
	info->client = client;

	i2c_set_clientdata(client, info);

	info->i2c_data = kmalloc(I2C_DATA_MAX_LEN, GFP_KERNEL);
	if (info->i2c_data == NULL) {
		error = -ENOMEM;
		goto ProbeErrorExit_0P1;
	}
	info->i2c_data_len = I2C_DATA_MAX_LEN;

	logError(0, "%s i2c address: %x\n", tag, client->addr);
	info->dev = &info->client->dev;
	if (dp) {
@@ -4685,6 +4693,8 @@ static int fts_probe(struct i2c_client *client,
	fts_get_reg(info, false);

ProbeErrorExit_1:
	kfree(info->i2c_data);
ProbeErrorExit_0P1:
	kfree(info);

ProbeErrorExit_0:
@@ -4745,6 +4755,7 @@ static int fts_remove(struct i2c_client *client)
	fts_get_reg(info, false);

	/* free all */
	kfree(info->i2c_data);
	kfree(info);

	return OK;
+5 −2
Original line number Diff line number Diff line
@@ -162,7 +162,7 @@
#define EXP_FN_WORK_DELAY_MS 1000

#define CMD_STR_LEN		32

#define I2C_DATA_MAX_LEN	32

#ifdef SCRIPTLESS
/*
@@ -296,6 +296,9 @@ struct fts_ts_info {
	int edge_rej_enabled;
	int corner_rej_enabled;
	int edge_palm_rej_enabled;

	uint8_t *i2c_data;
	uint8_t i2c_data_len;
};

extern struct chipInfo ftsInfo;
+90 −8
Original line number Diff line number Diff line
@@ -67,12 +67,12 @@
#include "ftsHardware.h"
#include "ftsIO.h"
#include "ftsTool.h"
#include "../fts.h"

static char tag[8] = "[ FTS ]\0";
static struct i2c_client *client;
static u16 I2CSAD;


int openChannel(struct i2c_client *clt)
{
	client = clt;
@@ -102,18 +102,37 @@ int fts_readCmd(u8 *cmd, int cmdLength, u8 *outBuf, int byteToRead)
	int ret = -1;
	int retry = 0;
	struct i2c_msg I2CMsg[2];
	struct fts_ts_info *info = i2c_get_clientdata(client);
	uint8_t *buf = info->i2c_data;

	/*
	 * Reassign memory for i2c_data in case length is greater than 32 bytes
	 */
	if (info->i2c_data_len < cmdLength + byteToRead + 1) {
		kfree(info->i2c_data);
		info->i2c_data = kmalloc(cmdLength + byteToRead + 1,
							GFP_KERNEL);
		if (!info->i2c_data) {
			info->i2c_data_len = 0;
			return -ENOMEM;
		}
		info->i2c_data_len = cmdLength + byteToRead + 1;
		buf = info->i2c_data;
	}

	//write msg
	I2CMsg[0].addr = (__u16)I2CSAD;
	I2CMsg[0].flags = (__u16)0;
	I2CMsg[0].len = (__u16)cmdLength;
	I2CMsg[0].buf = (__u8 *)cmd;
	I2CMsg[0].buf = buf;

	//read msg
	I2CMsg[1].addr = (__u16)I2CSAD;
	I2CMsg[1].flags = I2C_M_RD;
	I2CMsg[1].len = byteToRead;
	I2CMsg[1].buf = (__u8 *)outBuf;
	I2CMsg[1].buf = buf + cmdLength;

	memcpy(buf, cmd, cmdLength);

	if (client == NULL)
		return ERROR_I2C_O;
@@ -128,6 +147,9 @@ int fts_readCmd(u8 *cmd, int cmdLength, u8 *outBuf, int byteToRead)
			tag, __func__, ERROR_I2C_R);
		return ERROR_I2C_R;
	}

	memcpy(outBuf, buf + cmdLength, byteToRead);

	return OK;
}

@@ -136,11 +158,29 @@ int fts_writeCmd(u8 *cmd, int cmdLength)
	int ret = -1;
	int retry = 0;
	struct i2c_msg I2CMsg[1];
	struct fts_ts_info *info = i2c_get_clientdata(client);
	uint8_t *buf = info->i2c_data;

	/*
	 * Reassign memory for i2c_data in case length is greater than 32 bytes
	 */
	if (info->i2c_data_len < cmdLength + 1) {
		kfree(info->i2c_data);
		info->i2c_data = kmalloc(cmdLength + 1, GFP_KERNEL);
		if (!info->i2c_data) {
			info->i2c_data_len = 0;
			return -ENOMEM;
		}
		info->i2c_data_len = cmdLength + 1;
		buf = info->i2c_data;
	}

	I2CMsg[0].addr = (__u16)I2CSAD;
	I2CMsg[0].flags = (__u16)0;
	I2CMsg[0].len = (__u16)cmdLength;
	I2CMsg[0].buf = (__u8 *)cmd;
	I2CMsg[0].buf = buf;

	memcpy(buf, cmd, cmdLength);

	if (client == NULL)
		return ERROR_I2C_O;
@@ -164,11 +204,29 @@ int fts_writeFwCmd(u8 *cmd, int cmdLength)
	int ret2 = -1;
	int retry = 0;
	struct i2c_msg I2CMsg[1];
	struct fts_ts_info *info = i2c_get_clientdata(client);
	uint8_t *buf = info->i2c_data;

	/*
	 * Reassign memory for i2c_data in case length is greater than 32 bytes
	 */
	if (info->i2c_data_len < cmdLength + 1) {
		kfree(info->i2c_data);
		info->i2c_data = kmalloc(cmdLength + 1, GFP_KERNEL);
		if (!info->i2c_data) {
			info->i2c_data_len = 0;
			return -ENOMEM;
		}
		info->i2c_data_len = cmdLength + 1;
		buf = info->i2c_data;
	}

	I2CMsg[0].addr = (__u16)I2CSAD;
	I2CMsg[0].flags = (__u16)0;
	I2CMsg[0].len = (__u16)cmdLength;
	I2CMsg[0].buf = (__u8 *)cmd;
	I2CMsg[0].buf = buf;

	memcpy(buf, cmd, cmdLength);

	if (client == NULL)
		return ERROR_I2C_O;
@@ -201,23 +259,44 @@ int writeReadCmd(u8 *writeCmd1, int writeCmdLength, u8 *readCmd1,
	int ret = -1;
	int retry = 0;
	struct i2c_msg I2CMsg[3];
	struct fts_ts_info *info = i2c_get_clientdata(client);
	uint8_t *buf = info->i2c_data;
	uint8_t wr_len = writeCmdLength + readCmdLength + byteToRead;

	/*
	 * Reassign memory for i2c_data in case length is greater than 32 bytes
	 */
	if (info->i2c_data_len < wr_len + 1) {
		kfree(info->i2c_data);
		info->i2c_data = kmalloc(wr_len + 1, GFP_KERNEL);
		if (!info->i2c_data) {
			info->i2c_data_len = 0;
			return -ENOMEM;
		}
		info->i2c_data_len = wr_len + 1;
		buf = info->i2c_data;
	}

	//write msg
	I2CMsg[0].addr = (__u16)I2CSAD;
	I2CMsg[0].flags = (__u16)0;
	I2CMsg[0].len = (__u16)writeCmdLength;
	I2CMsg[0].buf = (__u8 *)writeCmd1;
	I2CMsg[0].buf = buf;

	//write msg
	I2CMsg[1].addr = (__u16)I2CSAD;
	I2CMsg[1].flags = (__u16)0;
	I2CMsg[1].len = (__u16)readCmdLength;
	I2CMsg[1].buf = (__u8 *)readCmd1;
	I2CMsg[1].buf = buf + writeCmdLength;

	//read msg
	I2CMsg[2].addr = (__u16)I2CSAD;
	I2CMsg[2].flags = I2C_M_RD;
	I2CMsg[2].len = byteToRead;
	I2CMsg[2].buf = (__u8 *)outBuf;
	I2CMsg[2].buf = buf + writeCmdLength + readCmdLength;

	memcpy(buf, writeCmd1, writeCmdLength);
	memcpy(buf + writeCmdLength, readCmd1, readCmdLength);

	if (client == NULL)
		return ERROR_I2C_O;
@@ -233,6 +312,9 @@ int writeReadCmd(u8 *writeCmd1, int writeCmdLength, u8 *readCmd1,
			tag, __func__, ERROR_I2C_WR);
		return ERROR_I2C_WR;
	}

	memcpy(outBuf, buf + writeCmdLength + readCmdLength, byteToRead);

	return OK;
}