synaptics_mmi: enable erase_all in factory mode

Recent build issue with absent touch firmware prompted to add a new
test case. As erasing firmware is potentially dangerous, erase_all
will be only enabled in factory mode for TCMD to access.

Change-Id: Ia27593f85dd4d83cc327a81ded9ac7a4410e3220
Signed-off-by: Konstantin Makariev <hcv867@motorola.com>
Reviewed-on: https://gerrit.mot.com/1307995
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Tiago Ganselli <ganselli@motorola.com>
Reviewed-by: Konstantin Makariev <kmakariev@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
Konstantin Makariev 2019-02-12 17:46:38 -06:00 • committed by Konstantin Makariev
commit 6d73ebc640
2 changed files with 24 additions and 5 deletions

View file

@ -151,10 +151,10 @@ static ssize_t fwu_sysfs_guest_code_block_count_show(struct device *dev,
static ssize_t fwu_sysfs_write_guest_code_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count);
#endif
static ssize_t fwu_sysfs_erase_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count);
#endif
static ssize_t fwu_sysfs_do_reflash_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count);
@ -345,9 +345,6 @@ static struct device_attribute attrs[] = {
__ATTR(writeguestcode, S_IWUSR | S_IWGRP,
synaptics_rmi4_show_error,
fwu_sysfs_write_guest_code_store),
__ATTR(erase, S_IWUSR | S_IWGRP,
synaptics_rmi4_show_error,
fwu_sysfs_erase_store),
#endif
__ATTR(doreflash, S_IWUSR | S_IWGRP,
synaptics_rmi4_show_error,
@ -357,6 +354,14 @@ static struct device_attribute attrs[] = {
fwu_sysfs_force_reflash_store),
};
#include <soc/qcom/mmi_boot_info.h>
static struct device_attribute erase_attr[] = {
__ATTR(erase_all, S_IWUSR | S_IWGRP,
synaptics_rmi4_show_error,
fwu_sysfs_erase_store),
};
static inline void sema_clear(struct semaphore *sem)
{
do {
@ -4062,6 +4067,7 @@ exit:
fwu->image = NULL;
return retval;
}
#endif
static ssize_t fwu_sysfs_erase_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
@ -4119,7 +4125,6 @@ reset_and_exit:
return count;
}
#endif
static void synaptics_rmi4_fwu_attn(struct synaptics_rmi4_data *rmi4_data,
unsigned char intr_mask)
@ -4218,6 +4223,16 @@ static int synaptics_rmi4_fwu_init(struct synaptics_rmi4_data *rmi4_data)
}
}
if (strncmp(bi_bootmode(), "mot-factory", strlen("mot-factory")) == 0) {
retval = sysfs_create_file(SYSFS_KOBJ, &erase_attr[0].attr);
if (retval < 0) {
dev_err(LOGDEV,
"%s: Failed to create erase sysfs attributes\n",
__func__);
} else
fwu->has_erase_all = true;
}
rmi4_data->fwu_data = (void *)fwu;
return 0;
@ -4253,6 +4268,9 @@ static void synaptics_rmi4_fwu_remove(struct synaptics_rmi4_data *rmi4_data)
sysfs_remove_file(SYSFS_KOBJ, &attrs[attr_count].attr);
}
if (fwu->has_erase_all)
sysfs_remove_file(SYSFS_KOBJ, &erase_attr[0].attr);
#ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_DSX_FW_UPDATE_EXTRA_SYSFS_MMI
sysfs_remove_bin_file(SYSFS_KOBJ, &dev_attr_data);
#endif

View file

@ -883,6 +883,7 @@ struct synaptics_rmi4_fwu_handle {
bool do_lockdown;
bool has_guest_code;
bool new_partition_table;
bool has_erase_all;
unsigned int data_pos;
unsigned char *ext_data_source;
unsigned char *read_config_buf;