Determine whether to load by "mmi,panel_name"

Because there is no contains function on kernel 5.4, and we have no way
to modify the kernel code. So "mmi,panel_name" is used to determine
whether to probe this driver.

Change-Id: I956b6ce1d463cbe472b80599c954dd06bd633082
Reviewed-on: https://gerrit.mot.com/1728590
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Konstantin Makariev <kmakariev@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
litong 2020-08-21 19:25:26 +08:00 • committed by litong20
commit 4b881a0efd
3 changed files with 30 additions and 0 deletions

View file

@ -2671,6 +2671,11 @@ static int __init sec_ts_init(void)
return -ENODEV;
}
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
if (!ts_mmi_is_panel_match("mmi,panel_name", "lsi"))
return false;
#endif
pr_err("%s\n", __func__);
return i2c_add_driver(&sec_ts_driver);

View file

@ -787,6 +787,30 @@ void ts_mmi_dev_unregister(struct device *parent)
}
EXPORT_SYMBOL(ts_mmi_dev_unregister);
bool ts_mmi_is_panel_match(const char *panel_node, char *touch_ic_name)
{
struct device_node *of_chosen;
const char *panel_name;
of_chosen = of_find_node_by_path("/chosen");
if (of_chosen == NULL)
of_chosen = of_find_node_by_path("/chosen@0");
if (of_chosen == NULL)
return false;
if (of_property_read_string(of_chosen, panel_node, &panel_name)) {
pr_err("%s: Failed to get %s", __func__, panel_node);
return false;
}
if (strstr(panel_name, touch_ic_name))
return true;
return false;
}
EXPORT_SYMBOL(ts_mmi_is_panel_match);
static int __init touchscreens_init(void)
{
int error = 0;

View file

@ -468,6 +468,7 @@ extern int ts_mmi_gesture_suspend(struct ts_mmi_dev *touch_cdev);
#ifdef CONFIG_DRM_PANEL_NOTIFICATIONS
int ts_mmi_check_drm_panel(struct device_node *of_node);
#endif
extern bool ts_mmi_is_panel_match(const char *panel_node, char *touch_ic_name);
/*sensor*/
extern bool ts_mmi_is_sensor_enable(void);