Check if i2c device available before add driver

TP:
Check if i2c device available before add driver.

Change-Id: Ia53cf3f952c5742632c0e105db95e19e4d02ce31
Signed-off-by: Wenge Zhu <zhuwg1@motorola.com>
Reviewed-on: https://gerrit.mot.com/2565327
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Tao Sun <suntao2@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
Wenge Zhu 2023-04-04 21:00:14 +08:00 • committed by zhuwg1
commit 6f245b1a79
4 changed files with 15 additions and 6 deletions

View file

@ -5,6 +5,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := zinitix_ztw62x_mmi.ko
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
LOCAL_ADDITIONAL_DEPENDENCIES += $(KERNEL_MODULES_OUT)/mmi_info.ko
ifeq ($(DRM_PANEL_EVENT_NOTIFICATIONS),true)
KBUILD_OPTIONS += CONFIG_DRM_PANEL_EVENT_NOTIFICATIONS=y

View file

@ -25,3 +25,4 @@ ifneq ($(filter m y,$(CONFIG_GTP_LIMIT_USE_SUPPLIER)),)
endif
KBUILD_EXTRA_SYMBOLS += $(CURDIR)/$(KBUILD_EXTMOD)/../touchscreen_mmi/$(GKI_OBJ_MODULE_DIR)/Module.symvers
KBUILD_EXTRA_SYMBOLS += $(CURDIR)/$(KBUILD_EXTMOD)/../../../mmi_info/$(GKI_OBJ_MODULE_DIR)/Module.symvers

View file

@ -14,3 +14,4 @@ clean:
rm -rf .tmp_versions
KBUILD_EXTRA_SYMBOLS += $(M)/../touchscreen_mmi/$(GKI_OBJ_MODULE_DIR)/Module.symvers
KBUILD_EXTRA_SYMBOLS += $(M)/../../../mmi_info/$(GKI_OBJ_MODULE_DIR)/Module.symvers

View file

@ -57,6 +57,7 @@
#elif defined(CONFIG_HAS_EARLYSUSPEND)
#include <linux/earlysuspend.h>
#endif
#include <linux/mmi_device.h>
#include "zinitix_touch.h"
#include "zinitix_ts_mmi.h"
@ -5534,12 +5535,16 @@ static int zinitix_power_init(struct bt541_ts_info *data, bool on)
return 0;
reg_vcc_i2c_put:
regulator_put(data->vcc_i2c);
if (!IS_ERR_OR_NULL(data->vcc_i2c))
regulator_put(data->vcc_i2c);
reg_vdd_set_vtg:
if (regulator_count_voltages(data->vdd) > 0)
regulator_set_voltage(data->vdd, 0, FT_VTG_MAX_UV);
if (!IS_ERR_OR_NULL(data->vdd)) {
if (regulator_count_voltages(data->vdd) > 0)
regulator_set_voltage(data->vdd, 0, FT_VTG_MAX_UV);
}
reg_vdd_put:
regulator_put(data->vdd);
if (!IS_ERR_OR_NULL(data->vdd))
regulator_put(data->vdd);
return rc;
pwr_deinit:
@ -6448,8 +6453,9 @@ static struct i2c_driver bt541_ts_driver = {
static int __init bt541_ts_init(void)
{
zinitix_printk("[TSP]: %s\n", __func__);
return i2c_add_driver(&bt541_ts_driver);
if (mmi_check_dynamic_device_node("bt541_ts_device"))
return i2c_add_driver(&bt541_ts_driver);
return -ENODEV;
}
static void __exit bt541_ts_exit(void)