static int proc_write_val(struct file *file, const char *buffer, unsigned long count, void *data) { #ifdef CONFIG_SUPPORT_FTS_CTP_UPG int ret = 0;//ZTE_TS_XYM_20110830 #endif unsigned long val; sscanf(buffer, "%lu", &val); //pr_info(%s called!\n", __func__); #ifdef CONFIG_SUPPORT_FTS_CTP_UPG { printk("Fts Upgrade Start\n"); update_result_flag=0; fts_ctpm_fw_upgrade(update_client, CTPM_FW, sizeof(CTPM_FW)); //fts_ctpm_fw_upgrade_with_i_file(ts->client);//Update the CTPM firmware if need update_result_flag=2; } ret = Fts_i2c_read(update_client, FT5X0X_REG_FIRMID, &fwVer,1) ;//ZTE_TS_XYM_20110830 printk("%s: New Fts FW ID read ID = 0x%x, ret = 0x%x\n", __FUNCTION__, fwVer, ret);//ZTE_TS_XYM_20110830 #endif return -EINVAL; }
static ssize_t ft5x0x_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int ret = 0, i = 0, send_len = 0; static size_t length; E_UPGRADE_ERR_TYPE err = ERR_REV_FILE_FAIL; static FTS_BYTE *to_buf = NULL, *pre_to_buf = NULL, *free_to_buf = NULL; if (!strcmp(attr->attr.name, "ft5x0xPrintFlag")) { printk("buf[0]=%d, buf[1]=%d\n", buf[0], buf[1]); if (buf[0] == '0') ft5x0x_printk_enable_flag = 0; if (buf[0] == '1') ft5x0x_printk_enable_flag = 1; if (buf[0] == '2') { ft5x0x_printk_enable_flag=2; if(focaltechPdata2->power){ focaltechPdata2->power(0); msleep(50); focaltechPdata2->power(1); msleep(200); } } if (buf[0] == '3') { u8 data; ft5x0x_write_reg(0xa5, 0x03); printk("set reg[0xa5] = 0x03\n"); msleep(20); ft5x0x_read_reg(0xa5, &data); printk("read back: reg[0xa5] = %d\n", data); } } else if (!strcmp(attr->attr.name, "effect")) { printk("buf[0]=%d, buf[1]=%d\n", buf[0], buf[1]); } else if (!strcmp(attr->attr.name, "upgrade")) { if (length == 0) { if (free_to_buf == NULL) free_to_buf = (FTS_BYTE *)kmalloc((128*1024-20)*sizeof(FTS_BYTE), GFP_KERNEL); printk("start free_to_buf = 0x%x.\n", free_to_buf); if (free_to_buf == NULL) { printk("Insufficient memory in upgrade!\n"); length = 0; upgrade_result = ERR_REV_FILE_FAIL; return -ERR_REV_FILE_FAIL; } pre_to_buf = free_to_buf; to_buf = pre_to_buf; upgrade_result = ERR_IN_UPGRADE; } memcpy(to_buf, buf, count); to_buf += count; length += count; // printk("upgrade data count = %d.\n", count); // printk("upgrade data length = %d.\n", length); if (length > (128*1024-25)) { upgrade_result = ERR_REV_FILE_FAIL; printk("upgrade_result = %d.\n", ERR_REV_FILE_FAIL); printk("end free_to_buf = 0x%x.\n", free_to_buf); length = 0; if (free_to_buf != NULL) { kfree(free_to_buf); free_to_buf = NULL; } return ERR_REV_FILE_FAIL; } if ((to_buf != NULL) && (*(to_buf-1)=='d') && (*(to_buf-2)=='n') && (*(to_buf-3)=='e')) { for (i=0; i<length-3;) { if ((*pre_to_buf=='0') && (*(pre_to_buf+1)=='x')) { if ((*(pre_to_buf+3)==',') && (*(pre_to_buf+4)==' ')) free_to_buf[send_len++] = char_to_hex('0', *(pre_to_buf+2)); else free_to_buf[send_len++] = char_to_hex(*(pre_to_buf+2), *(pre_to_buf+3)); pre_to_buf += 5; i += 5; } else { pre_to_buf++; i++; } } for (i=0; i<10; i++) { printk("free_to_buf[%d] = 0x%x.\n", i, free_to_buf[i]); } for (i=send_len-1; i>=send_len-10; i--) { printk("free_to_buf[%d] = 0x%x.\n", i, free_to_buf[i]); } for (i=0; i<5; i++) { err = fts_ctpm_fw_upgrade(free_to_buf, send_len); if (err == 0) break; } upgrade_result = err; printk("upgrade status is %d.\n", err); printk("upgrade data send_len = %d.\n", send_len); printk("end free_to_buf = 0x%x.\n", free_to_buf); if (free_to_buf != NULL) { kfree(free_to_buf); free_to_buf = NULL; } length = 0; } // #endif } return count; }