Add mmi_bl_bootmode function to get boot mode.

In order to reduce the dependence on other modules, mmi_bl_bootmode is
added for touchscreen.

Change-Id: Ic77772fd155baf3b0af234141257e3062597b02e
Reviewed-on: https://gerrit.mot.com/1725851
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Jichao Zou <zoujc@motorola.com>
Reviewed-by: Konstantin Makariev <kmakariev@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
litong 2020-08-19 16:46:03 +08:00 • committed by litong20
commit eb09216ede
3 changed files with 37 additions and 2 deletions

View file

@ -28,7 +28,6 @@
#include <linux/of_gpio.h>
#include <linux/time.h>
#include <linux/vmalloc.h>
#include <soc/qcom/mmi_boot_info.h>
#include <linux/touchscreen_mmi.h>
#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);

View file

@ -28,6 +28,7 @@
#include <linux/major.h>
#include <linux/slab.h>
#include <linux/pinctrl/consumer.h>
#include <linux/of.h>
#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.

View file

@ -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_ */