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

Commit ad13dafc authored by Fei Mao's avatar Fei Mao
Browse files

input: touchscreen: Check default touch



Check if it is the default touch driver.
And defer driver probe function again if fail.

Change-Id: I850139fd3c3e0dffd22180dc3af4ebed40c0d6b2
Signed-off-by: default avatarFei Mao <feim1@codeaurora.org>
parent 6a39b7be
Loading
Loading
Loading
Loading
+48 −5
Original line number Diff line number Diff line
@@ -4537,7 +4537,36 @@ static int check_dt(struct device_node *np)
	return -ENODEV;
}

static int fts_probe(struct i2c_client *client,
static int check_default_tp(struct device_node *dt, const char *prop)
{
	const char *active_tp;
	const char *compatible;
	char *start;
	int ret;

	ret = of_property_read_string(dt->parent, prop, &active_tp);
	if (ret) {
		pr_err(" %s:fail to read %s %d\n", __func__, prop, ret);
		return -ENODEV;
	}

	ret = of_property_read_string(dt, "compatible", &compatible);
	if (ret < 0) {
		pr_err(" %s:fail to read %s %d\n", __func__, "compatible", ret);
		return -ENODEV;
	}

	start = strnstr(active_tp, compatible, strlen(active_tp));
	if (start == NULL) {
		pr_err(" %s:no match compatible, %s, %s\n",
			__func__, compatible, active_tp);
		ret = -ENODEV;
	}

	return ret;
}

static int fts_probe_internal(struct i2c_client *client,
		const struct i2c_device_id *idp)
{
	struct fts_ts_info *info = NULL;
@@ -4548,10 +4577,7 @@ static int fts_probe(struct i2c_client *client,

	logError(0, "%s %s: driver probe begin!\n", tag, __func__);

	error = check_dt(dp);

	if (error != OK ||
		!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		logError(1, "%s Unsupported I2C functionality\n", tag);
		error = -EIO;
		goto ProbeErrorExit_0;
@@ -4928,6 +4954,23 @@ static int fts_probe(struct i2c_client *client,
	return error;
}

static int fts_probe(struct i2c_client *client, const struct i2c_device_id *idp)
{
	int error = 0;
	struct device_node *dp = client->dev.of_node;

	if (check_dt(dp)) {
		if (!check_default_tp(dp, "qcom,i2c-touch-active"))
			error = -EPROBE_DEFER;
		else
			error = -ENODEV;

		return error;
	}

	return fts_probe_internal(client, idp);
}

static int fts_remove(struct i2c_client *client)
{
	struct fts_ts_info *info = i2c_get_clientdata(client);
+39 −3
Original line number Diff line number Diff line
@@ -451,7 +451,7 @@ static int synaptics_rmi4_i2c_write(struct synaptics_rmi4_data *rmi4_data,
	return retval;
}

int check_dt(struct device_node *np)
static int check_dt(struct device_node *np)
{
	int i;
	int count;
@@ -475,6 +475,35 @@ int check_dt(struct device_node *np)
	return -ENODEV;
}

static int check_default_tp(struct device_node *dt, const char *prop)
{
	const char *active_tp;
	const char *compatible;
	char *start;
	int ret;

	ret = of_property_read_string(dt->parent, prop, &active_tp);
	if (ret) {
		pr_err(" %s:fail to read %s %d\n", __func__, prop, ret);
		return -ENODEV;
	}

	ret = of_property_read_string(dt, "compatible", &compatible);
	if (ret < 0) {
		pr_err(" %s:fail to read %s %d\n", __func__, "compatible", ret);
		return -ENODEV;
	}

	start = strnstr(active_tp, compatible, strlen(active_tp));
	if (start == NULL) {
		pr_err(" %s:no match compatible, %s, %s\n",
			__func__, compatible, active_tp);
		ret = -ENODEV;
	}

	return ret;
}

static struct synaptics_dsx_bus_access bus_access = {
	.type = BUS_I2C,
	.read = synaptics_rmi4_i2c_read,
@@ -490,9 +519,16 @@ static int synaptics_rmi4_i2c_probe(struct i2c_client *client,
		const struct i2c_device_id *dev_id)
{
	int retval;
	struct device_node *dp = client->dev.of_node;

	if (check_dt(client->dev.of_node))
		return -ENODEV;
	if (check_dt(dp)) {
		if (!check_default_tp(dp, "qcom,i2c-touch-active"))
			retval = -EPROBE_DEFER;
		else
			retval = -ENODEV;

		return retval;
	}

	if (!i2c_check_functionality(client->adapter,
			I2C_FUNC_SMBUS_BYTE_DATA)) {