diff --git a/drivers/input/touchscreen/sec_mmi/sec_ts_mmi_class.c b/drivers/input/touchscreen/sec_mmi/sec_ts_mmi_class.c index e7ea30f7be6f..f7abb5009f6e 100644 --- a/drivers/input/touchscreen/sec_mmi/sec_ts_mmi_class.c +++ b/drivers/input/touchscreen/sec_mmi/sec_ts_mmi_class.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include "sec_ts.h" @@ -127,7 +126,7 @@ static int sec_mmi_extend_attribute_group(struct device *dev, struct attribute_g if (ts->plat_data->hold_grip_ctrl) ADD_ATTR(hold_grip); - if (strncmp(bi_bootmode(), "mot-factory", strlen("mot-factory")) == 0) { + if (strncmp(mmi_bl_bootmode(), "mot-factory", strlen("mot-factory")) == 0) { ADD_ATTR(address); ADD_ATTR(size); ADD_ATTR(data); diff --git a/drivers/input/touchscreen/touchscreen_mmi/touchscreen_mmi_class.c b/drivers/input/touchscreen/touchscreen_mmi/touchscreen_mmi_class.c index d5751ca427f6..423fe30cc5ed 100644 --- a/drivers/input/touchscreen/touchscreen_mmi/touchscreen_mmi_class.c +++ b/drivers/input/touchscreen/touchscreen_mmi/touchscreen_mmi_class.c @@ -28,6 +28,7 @@ #include #include #include +#include #define FMT_STRING "%s" #define FMT_INTEGER "%d" @@ -536,6 +537,40 @@ static int ts_mmi_default_pinctrl(struct device *parent, int on) return 0; } +#define BOOTMODE_MAX_LEN 64 +const char *mmi_bl_bootmode(void) +{ + const char *bootargs = NULL; + char *end = NULL; + char *idx = NULL; + struct device_node *np; + static char bootmode[BOOTMODE_MAX_LEN] = {'\0'}; + + if (bootmode[0] != '\0') + return bootmode; + + np = of_find_node_by_path("/chosen"); + if (np == NULL) + return NULL; + + if (of_property_read_string(np, "bootargs", &bootargs) != 0) + goto putnode; + + idx = strstr(bootargs, "androidboot.mode="); + if (idx) { + end = strpbrk(idx, " "); + idx = strpbrk(idx, "="); + if (idx && end > idx) + strlcpy(bootmode, idx + 1, end - idx); + } + +putnode: + of_node_put(np); + return bootmode; +} + +EXPORT_SYMBOL(mmi_bl_bootmode); + /** * ts_mmi_dev_register - register a new object of ts_mmi_dev class. * @parent: The device to register. diff --git a/include/linux/touchscreen_mmi.h b/include/linux/touchscreen_mmi.h index 22b9b51d6bf8..ccd4a8dd1912 100644 --- a/include/linux/touchscreen_mmi.h +++ b/include/linux/touchscreen_mmi.h @@ -472,4 +472,5 @@ int ts_mmi_check_drm_panel(struct device_node *of_node); /*sensor*/ extern bool ts_mmi_is_sensor_enable(void); +extern const char *mmi_bl_bootmode(void); #endif /* __LINUX_TOUCHSCREEN_MMI_H_ */