From 6385fec1b7e6e532f89abaf8a360b5d50d827854 Mon Sep 17 00:00:00 2001 From: Fei Mao Date: Wed, 1 Jul 2020 11:11:03 +0800 Subject: [PATCH] input: touchscreen: focaltech_touch: Remove vfs_read() To request a firmware file by request_firmware() is preferred. Change-Id: I99d408793a3d52a664828cc35494d740531b0c68 Signed-off-by: Fei Mao --- .../focaltech_touch/focaltech_ex_fun.c | 67 ---------- .../focaltech_touch/focaltech_flash.c | 121 ------------------ 2 files changed, 188 deletions(-) diff --git a/drivers/input/touchscreen/focaltech_touch/focaltech_ex_fun.c b/drivers/input/touchscreen/focaltech_touch/focaltech_ex_fun.c index b9ae3f1246f9..00abd44983e1 100644 --- a/drivers/input/touchscreen/focaltech_touch/focaltech_ex_fun.c +++ b/drivers/input/touchscreen/focaltech_touch/focaltech_ex_fun.c @@ -905,68 +905,6 @@ exit: return count; } -/* fts_upgrade_bin interface */ -static ssize_t fts_fwupgradebin_show( - struct device *dev, struct device_attribute *attr, char *buf) -{ - return -EPERM; -} - -static ssize_t fts_fwupgradebin_store( - struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - char fwname[FILE_NAME_LENGTH] = { 0 }; - struct input_dev *input_dev = fts_data->input_dev; - - if ((count <= 1) || (count >= FILE_NAME_LENGTH - 32)) { - FTS_ERROR("fw bin name's length(%d) fail", (int)count); - return -EINVAL; - } - - memset(fwname, 0, sizeof(fwname)); - snprintf(fwname, FILE_NAME_LENGTH, "%s", buf); - fwname[count - 1] = '\0'; - - FTS_INFO("upgrade with bin file through sysfs node"); - mutex_lock(&input_dev->mutex); - fts_upgrade_bin(fwname, 0); - mutex_unlock(&input_dev->mutex); - - return count; -} - -/* fts_force_upgrade interface */ -static ssize_t fts_fwforceupg_show( - struct device *dev, struct device_attribute *attr, char *buf) -{ - return -EPERM; -} - -static ssize_t fts_fwforceupg_store( - struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - char fwname[FILE_NAME_LENGTH]; - struct input_dev *input_dev = fts_data->input_dev; - - if ((count <= 1) || (count >= FILE_NAME_LENGTH - 32)) { - FTS_ERROR("fw bin name's length(%d) fail", (int)count); - return -EINVAL; - } - - memset(fwname, 0, sizeof(fwname)); - snprintf(fwname, FILE_NAME_LENGTH, "%s", buf); - fwname[count - 1] = '\0'; - - FTS_INFO("force upgrade through sysfs node"); - mutex_lock(&input_dev->mutex); - fts_upgrade_bin(fwname, 1); - mutex_unlock(&input_dev->mutex); - - return count; -} - /* fts_driver_info interface */ static ssize_t fts_driverinfo_show( struct device *dev, struct device_attribute *attr, char *buf) @@ -1137,9 +1075,6 @@ static DEVICE_ATTR(fts_fw_version, S_IRUGO | S_IWUSR, fts_tpfwver_show, fts_tpfw * cat rw_reg */ static DEVICE_ATTR(fts_rw_reg, S_IRUGO | S_IWUSR, fts_tprwreg_show, fts_tprwreg_store); -/* upgrade from fw bin file example:echo "*.bin" > fts_upgrade_bin */ -static DEVICE_ATTR(fts_upgrade_bin, S_IRUGO | S_IWUSR, fts_fwupgradebin_show, fts_fwupgradebin_store); -static DEVICE_ATTR(fts_force_upgrade, S_IRUGO | S_IWUSR, fts_fwforceupg_show, fts_fwforceupg_store); static DEVICE_ATTR(fts_driver_info, S_IRUGO | S_IWUSR, fts_driverinfo_show, fts_driverinfo_store); static DEVICE_ATTR(fts_dump_reg, S_IRUGO | S_IWUSR, fts_dumpreg_show, fts_dumpreg_store); static DEVICE_ATTR(fts_hw_reset, S_IRUGO | S_IWUSR, fts_hw_reset_show, fts_hw_reset_store); @@ -1153,8 +1088,6 @@ static struct attribute *fts_attributes[] = { &dev_attr_fts_fw_version.attr, &dev_attr_fts_rw_reg.attr, &dev_attr_fts_dump_reg.attr, - &dev_attr_fts_upgrade_bin.attr, - &dev_attr_fts_force_upgrade.attr, &dev_attr_fts_driver_info.attr, &dev_attr_fts_hw_reset.attr, &dev_attr_fts_irq.attr, diff --git a/drivers/input/touchscreen/focaltech_touch/focaltech_flash.c b/drivers/input/touchscreen/focaltech_touch/focaltech_flash.c index 51c56220c613..62a074f349d4 100644 --- a/drivers/input/touchscreen/focaltech_touch/focaltech_flash.c +++ b/drivers/input/touchscreen/focaltech_touch/focaltech_flash.c @@ -1023,127 +1023,6 @@ read_flash_err: return ret; } -static int fts_read_file(char *file_name, u8 **file_buf) -{ - int ret = 0; - char file_path[FILE_NAME_LENGTH] = { 0 }; - struct file *filp = NULL; - struct inode *inode; - mm_segment_t old_fs; - loff_t pos; - loff_t file_len = 0; - - if ((NULL == file_name) || (NULL == file_buf)) { - FTS_ERROR("filename/filebuf is NULL"); - return -EINVAL; - } - - snprintf(file_path, FILE_NAME_LENGTH, "%s%s", FTS_FW_BIN_FILEPATH, file_name); - filp = filp_open(file_path, O_RDONLY, 0); - if (IS_ERR(filp)) { - FTS_ERROR("open %s file fail", file_path); - return -ENOENT; - } - -#if 1 - inode = filp->f_inode; -#else - /* reserved for linux earlier verion */ - inode = filp->f_dentry->d_inode; -#endif - - file_len = inode->i_size; - *file_buf = (u8 *)vmalloc(file_len); - if (NULL == *file_buf) { - FTS_ERROR("file buf malloc fail"); - filp_close(filp, NULL); - return -ENOMEM; - } - old_fs = get_fs(); - set_fs(KERNEL_DS); - pos = 0; - ret = vfs_read(filp, *file_buf, file_len , &pos); - if (ret < 0) - FTS_ERROR("read file fail"); - FTS_INFO("file len:%d read len:%d pos:%d", (u32)file_len, ret, (u32)pos); - filp_close(filp, NULL); - set_fs(old_fs); - - return ret; -} - -int fts_upgrade_bin(char *fw_name, bool force) -{ - int ret = 0; - u32 fw_file_len = 0; - u8 *fw_file_buf = NULL; - struct fts_upgrade *upg = fwupgrade; - - FTS_INFO("start upgrade with fw bin"); - if ((!upg) || (!upg->func) || !upg->ts_data) { - FTS_ERROR("upgrade/func/ts_data is null"); - return -EINVAL; - } - - upg->ts_data->fw_loading = 1; - fts_irq_disable(); -#if FTS_ESDCHECK_EN - fts_esdcheck_switch(DISABLE); -#endif - - ret = fts_read_file(fw_name, &fw_file_buf); - if ((ret < 0) || (ret < FTS_MIN_LEN) || (ret > FTS_MAX_LEN_FILE)) { - FTS_ERROR("read fw bin file(sdcard) fail, len:%d", fw_file_len); - goto err_bin; - } - - fw_file_len = ret; - FTS_INFO("fw bin file len:%d", fw_file_len); - if (force) { - if (upg->func->force_upgrade) { - ret = upg->func->force_upgrade(fw_file_buf, fw_file_len); - } else { - FTS_INFO("force_upgrade function is null, no upgrade"); - goto err_bin; - } - } else { -#if FTS_AUTO_LIC_UPGRADE_EN - if (upg->func->lic_upgrade) { - ret = upg->func->lic_upgrade(fw_file_buf, fw_file_len); - } else { - FTS_INFO("lic_upgrade function is null, no upgrade"); - } -#endif - if (upg->func->upgrade) { - ret = upg->func->upgrade(fw_file_buf, fw_file_len); - } else { - FTS_INFO("upgrade function is null, no upgrade"); - } - } - - if (ret < 0) { - FTS_ERROR("upgrade fw bin failed"); - fts_fwupg_reset_in_boot(); - goto err_bin; - } - - FTS_INFO("upgrade fw bin success"); - ret = 0; - -err_bin: -#if FTS_ESDCHECK_EN - fts_esdcheck_switch(ENABLE); -#endif - fts_irq_enable(); - upg->ts_data->fw_loading = 0; - - if (fw_file_buf) { - vfree(fw_file_buf); - fw_file_buf = NULL; - } - return ret; -} - int fts_enter_test_environment(bool test_state) { return 0;