From 4b881a0efd67deaff3ee59011e699677ba2b638b Mon Sep 17 00:00:00 2001 From: litong Date: Fri, 21 Aug 2020 19:25:26 +0800 Subject: [PATCH] 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 Submit-Approved: Jira Key --- drivers/input/touchscreen/sec_mmi/sec_ts.c | 5 ++++ .../touchscreen_mmi/touchscreen_mmi_class.c | 24 +++++++++++++++++++ include/linux/touchscreen_mmi.h | 1 + 3 files changed, 30 insertions(+) diff --git a/drivers/input/touchscreen/sec_mmi/sec_ts.c b/drivers/input/touchscreen/sec_mmi/sec_ts.c index 75d03e157a4b..fb0393bacf4b 100644 --- a/drivers/input/touchscreen/sec_mmi/sec_ts.c +++ b/drivers/input/touchscreen/sec_mmi/sec_ts.c @@ -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); diff --git a/drivers/input/touchscreen/touchscreen_mmi/touchscreen_mmi_class.c b/drivers/input/touchscreen/touchscreen_mmi/touchscreen_mmi_class.c index f9d94fb4a417..0ee075a3cfea 100644 --- a/drivers/input/touchscreen/touchscreen_mmi/touchscreen_mmi_class.c +++ b/drivers/input/touchscreen/touchscreen_mmi/touchscreen_mmi_class.c @@ -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; diff --git a/include/linux/touchscreen_mmi.h b/include/linux/touchscreen_mmi.h index 81de35269ef7..e016376c597f 100644 --- a/include/linux/touchscreen_mmi.h +++ b/include/linux/touchscreen_mmi.h @@ -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);