static void __exit diagchar_exit(void) { printk(KERN_INFO "diagchar exiting ..\n"); /* On Driver exit, send special pool type to ensure no memory leaks */ diagmem_exit(driver, POOL_TYPE_ALL); diagfwd_exit(); if (chk_config_get_id() == AO8960_TOOLS_ID) diagfwd_cntl_exit(); diag_sdio_fn(EXIT); diagchar_cleanup(); printk(KERN_INFO "done diagchar exit\n"); }
static int diag_smd_cntl_probe(struct platform_device *pdev) { int r = 0; /* open control ports only on 8960 */ if (chk_config_get_id() == AO8960_TOOLS_ID) { if (pdev->id == SMD_APPS_MODEM) r = smd_open("DIAG_CNTL", &driver->ch_cntl, driver, diag_smd_cntl_notify); if (pdev->id == SMD_APPS_QDSP) r = smd_named_open_on_edge("DIAG_CNTL", SMD_APPS_QDSP , &driver->chqdsp_cntl, driver, diag_smd_qdsp_cntl_notify); if (pdev->id == SMD_APPS_WCNSS) r = smd_named_open_on_edge("APPS_RIVA_CTRL", SMD_APPS_WCNSS, &driver->ch_wcnss_cntl, driver, diag_smd_wcnss_cntl_notify); pr_debug("diag: open CNTL port, ID = %d,r = %d\n", pdev->id, r); } return 0; }
int diagfwd_connect(void) { int err; printk(KERN_DEBUG "diag: USB connected\n"); err = usb_diag_alloc_req(driver->legacy_ch, N_LEGACY_WRITE, N_LEGACY_READ); if (err) printk(KERN_ERR "diag: unable to alloc USB req on legacy ch"); driver->usb_connected = 1; driver->in_busy_1 = 0; driver->in_busy_2 = 0; driver->in_busy_qdsp_1 = 0; driver->in_busy_qdsp_2 = 0; driver->in_busy_wcnss = 0; /* Poll SMD channels to check for data*/ queue_work(driver->diag_wq, &(driver->diag_read_smd_work)); queue_work(driver->diag_wq, &(driver->diag_read_smd_qdsp_work)); queue_work(driver->diag_wq, &(driver->diag_read_smd_wcnss_work)); if (chk_config_get_id() == AO8960_TOOLS_ID) { /* Poll SMD CNTL channels to check for data */ queue_work(driver->diag_wq, &(driver->diag_read_smd_cntl_work)); queue_work(driver->diag_wq, &(driver->diag_read_smd_qdsp_cntl_work)); queue_work(driver->diag_wq, &(driver->diag_read_smd_wcnss_cntl_work)); } /* Poll USB channel to check for data*/ queue_work(driver->diag_wq, &(driver->diag_read_work)); #ifdef CONFIG_DIAG_SDIO_PIPE if (diag_support_mdm9k) { if (driver->mdm_ch && !IS_ERR(driver->mdm_ch)) diagfwd_connect_sdio(); else printk(KERN_INFO "diag: No USB MDM ch"); } #endif return 0; }
void diag_process_hdlc(void *data, unsigned len) { struct diag_hdlc_decode_type hdlc; int ret, type = 0; #ifdef DIAG_DEBUG int i; #endif pr_debug("diag: HDLC decode fn, len of data %d\n", len); hdlc.dest_ptr = driver->hdlc_buf; hdlc.dest_size = USB_MAX_OUT_BUF; hdlc.src_ptr = data; hdlc.src_size = len; hdlc.src_idx = 0; hdlc.dest_idx = 0; hdlc.escaping = 0; ret = diag_hdlc_decode(&hdlc); if (ret) type = diag_process_apps_pkt(driver->hdlc_buf, hdlc.dest_idx - 3); else if (driver->debug_flag) { printk(KERN_ERR "Packet dropped due to bad HDLC coding/CRC" " errors or partial packet received, packet" " length = %d\n", len); print_hex_dump(KERN_DEBUG, "Dropped Packet Data: ", 16, 1, DUMP_PREFIX_ADDRESS, data, len, 1); driver->debug_flag = 0; } /* send error responses from APPS for Central Routing */ if (type == 1 && chk_config_get_id() == AO8960_TOOLS_ID) { diag_send_error_rsp(hdlc.dest_idx); type = 0; } /* implies this packet is NOT meant for apps */ if (!(driver->ch) && type == 1) { if (chk_config_get_id() == AO8960_TOOLS_ID) { diag_send_error_rsp(hdlc.dest_idx); } else { /* APQ 8060, Let Q6 respond */ if (driver->chqdsp) smd_write(driver->chqdsp, driver->hdlc_buf, hdlc.dest_idx - 3); } type = 0; } #ifdef DIAG_DEBUG pr_debug("diag: hdlc.dest_idx = %d", hdlc.dest_idx); for (i = 0; i < hdlc.dest_idx; i++) printk(KERN_DEBUG "\t%x", *(((unsigned char *) driver->hdlc_buf)+i)); #endif /* DIAG DEBUG */ /* ignore 2 bytes for CRC, one for 7E and send */ if ((driver->ch) && (ret) && (type) && (hdlc.dest_idx > 3)) { APPEND_DEBUG('g'); #ifdef CONFIG_MODEM_DIAG_MASTER smd_write(driver->ch, data, len); #else smd_write(driver->ch, driver->hdlc_buf, hdlc.dest_idx - 3); #endif APPEND_DEBUG('h'); #ifdef DIAG_DEBUG printk(KERN_INFO "writing data to SMD, pkt length %d\n", len); print_hex_dump(KERN_DEBUG, "Written Packet Data to SMD: ", 16, 1, DUMP_PREFIX_ADDRESS, data, len, 1); #endif /* DIAG DEBUG */ } }
static int diag_process_apps_pkt(unsigned char *buf, int len) { uint16_t subsys_cmd_code; int subsys_id, ssid_first, ssid_last, ssid_range; int packet_type = 1, i, cmd_code; unsigned char *temp = buf; int data_type; #if defined(CONFIG_DIAG_OVER_USB) int payload_length; unsigned char *ptr; #endif /* Check for registered clients and forward packet to apropriate proc */ cmd_code = (int)(*(char *)buf); temp++; subsys_id = (int)(*(char *)temp); temp++; subsys_cmd_code = *(uint16_t *)temp; temp += 2; data_type = APPS_DATA; /* Dont send any command other than mode reset */ if (cpu_is_msm8960() && cmd_code == MODE_CMD) { if (subsys_id != RESET_ID) data_type = MODEM_DATA; } pr_debug("diag: %d %d %d", cmd_code, subsys_id, subsys_cmd_code); for (i = 0; i < diag_max_registration; i++) { entry = driver->table[i]; if (entry.process_id != NO_PROCESS) { if (entry.cmd_code == cmd_code && entry.subsys_id == subsys_id && entry.cmd_code_lo <= subsys_cmd_code && entry.cmd_code_hi >= subsys_cmd_code) { diag_send_data(entry, buf, len, data_type); packet_type = 0; } else if (entry.cmd_code == 255 && cmd_code == 75) { if (entry.subsys_id == subsys_id && entry.cmd_code_lo <= subsys_cmd_code && entry.cmd_code_hi >= subsys_cmd_code) { diag_send_data(entry, buf, len, data_type); packet_type = 0; } } else if (entry.cmd_code == 255 && entry.subsys_id == 255) { if (entry.cmd_code_lo <= cmd_code && entry. cmd_code_hi >= cmd_code) { diag_send_data(entry, buf, len, data_type); packet_type = 0; } } } } /* set event mask */ if (*buf == 0x82) { buf += 4; diag_update_event_mask(buf, 1, *(uint16_t *)buf); diag_update_userspace_clients(EVENT_MASKS_TYPE); } /* event mask change */ else if ((*buf == 0x60) && (*(buf+1) == 0x0)) { diag_update_event_mask(buf+1, 0, 0); diag_update_userspace_clients(EVENT_MASKS_TYPE); #if defined(CONFIG_DIAG_OVER_USB) /* Check for Apps Only 8960 */ if (!(driver->ch) && (chk_config_get_id() == AO8960_TOOLS_ID)) { /* echo response back for apps only DIAG */ driver->apps_rsp_buf[0] = 0x60; driver->apps_rsp_buf[1] = 0x0; driver->apps_rsp_buf[2] = 0x0; ENCODE_RSP_AND_SEND(2); return 0; } #endif } /* Set log masks */ else if (*buf == 0x73 && *(int *)(buf+4) == 3) { buf += 8; /* Read Equip ID and pass as first param below*/ diag_update_log_mask(*(int *)buf, buf+8, *(int *)(buf+4)); diag_update_userspace_clients(LOG_MASKS_TYPE); #if defined(CONFIG_DIAG_OVER_USB) /* Check for Apps Only 8960 */ if (!(driver->ch) && (chk_config_get_id() == AO8960_TOOLS_ID)) { /* echo response back for Apps only DIAG */ driver->apps_rsp_buf[0] = 0x73; *(int *)(driver->apps_rsp_buf + 4) = 0x3; /* op. ID */ *(int *)(driver->apps_rsp_buf + 8) = 0x0; /* success */ payload_length = 8 + ((*(int *)(buf + 4)) + 7)/8; for (i = 0; i < payload_length; i++) *(int *)(driver->apps_rsp_buf+12+i) = *(buf+8+i); ENCODE_RSP_AND_SEND(12 + payload_length - 1); return 0; } #endif } /* Check for set message mask */ else if ((*buf == 0x7d) && (*(buf+1) == 0x4)) { ssid_first = *(uint16_t *)(buf + 2); ssid_last = *(uint16_t *)(buf + 4); ssid_range = 4 * (ssid_last - ssid_first + 1); diag_update_msg_mask(ssid_first, ssid_last , buf + 8); diag_update_userspace_clients(MSG_MASKS_TYPE); #if defined(CONFIG_DIAG_OVER_USB) if (!(driver->ch) && (chk_config_get_id() == AO8960_TOOLS_ID)) { /* echo response back for apps only DIAG */ for (i = 0; i < 8 + ssid_range; i++) *(driver->apps_rsp_buf + i) = *(buf+i); ENCODE_RSP_AND_SEND(8 + ssid_range - 1); return 0; } #endif } #if defined(CONFIG_DIAG_OVER_USB) /* Check for Apps Only 8960 & get event mask request */ else if (!(driver->ch) && (chk_config_get_id() == AO8960_TOOLS_ID) && *buf == 0x81) { driver->apps_rsp_buf[0] = 0x81; driver->apps_rsp_buf[1] = 0x0; *(uint16_t *)(driver->apps_rsp_buf + 2) = 0x0; *(uint16_t *)(driver->apps_rsp_buf + 4) = EVENT_LAST_ID + 1; for (i = 0; i < EVENT_LAST_ID/8 + 1; i++) *(unsigned char *)(driver->apps_rsp_buf + 6 + i) = 0x0; ENCODE_RSP_AND_SEND(6 + EVENT_LAST_ID/8); return 0; } /* Get log ID range & Check for Apps Only 8960 */ else if (!(driver->ch) && (chk_config_get_id() == AO8960_TOOLS_ID) && (*buf == 0x73) && *(int *)(buf+4) == 1) { driver->apps_rsp_buf[0] = 0x73; *(int *)(driver->apps_rsp_buf + 4) = 0x1; /* operation ID */ *(int *)(driver->apps_rsp_buf + 8) = 0x0; /* success code */ *(int *)(driver->apps_rsp_buf + 12) = LOG_GET_ITEM_NUM(LOG_0); *(int *)(driver->apps_rsp_buf + 16) = LOG_GET_ITEM_NUM(LOG_1); *(int *)(driver->apps_rsp_buf + 20) = LOG_GET_ITEM_NUM(LOG_2); *(int *)(driver->apps_rsp_buf + 24) = LOG_GET_ITEM_NUM(LOG_3); *(int *)(driver->apps_rsp_buf + 28) = LOG_GET_ITEM_NUM(LOG_4); *(int *)(driver->apps_rsp_buf + 32) = LOG_GET_ITEM_NUM(LOG_5); *(int *)(driver->apps_rsp_buf + 36) = LOG_GET_ITEM_NUM(LOG_6); *(int *)(driver->apps_rsp_buf + 40) = LOG_GET_ITEM_NUM(LOG_7); *(int *)(driver->apps_rsp_buf + 44) = LOG_GET_ITEM_NUM(LOG_8); *(int *)(driver->apps_rsp_buf + 48) = LOG_GET_ITEM_NUM(LOG_9); *(int *)(driver->apps_rsp_buf + 52) = LOG_GET_ITEM_NUM(LOG_10); *(int *)(driver->apps_rsp_buf + 56) = LOG_GET_ITEM_NUM(LOG_11); *(int *)(driver->apps_rsp_buf + 60) = LOG_GET_ITEM_NUM(LOG_12); *(int *)(driver->apps_rsp_buf + 64) = LOG_GET_ITEM_NUM(LOG_13); *(int *)(driver->apps_rsp_buf + 68) = LOG_GET_ITEM_NUM(LOG_14); *(int *)(driver->apps_rsp_buf + 72) = LOG_GET_ITEM_NUM(LOG_15); ENCODE_RSP_AND_SEND(75); return 0; } /* Respond to Get SSID Range request message */ else if (!(driver->ch) && (chk_config_get_id() == AO8960_TOOLS_ID) && (*buf == 0x7d) && (*(buf+1) == 0x1)) { driver->apps_rsp_buf[0] = 0x7d; driver->apps_rsp_buf[1] = 0x1; driver->apps_rsp_buf[2] = 0x1; driver->apps_rsp_buf[3] = 0x0; *(int *)(driver->apps_rsp_buf + 4) = MSG_MASK_TBL_CNT; *(uint16_t *)(driver->apps_rsp_buf + 8) = MSG_SSID_0; *(uint16_t *)(driver->apps_rsp_buf + 10) = MSG_SSID_0_LAST; *(uint16_t *)(driver->apps_rsp_buf + 12) = MSG_SSID_1; *(uint16_t *)(driver->apps_rsp_buf + 14) = MSG_SSID_1_LAST; *(uint16_t *)(driver->apps_rsp_buf + 16) = MSG_SSID_2; *(uint16_t *)(driver->apps_rsp_buf + 18) = MSG_SSID_2_LAST; *(uint16_t *)(driver->apps_rsp_buf + 20) = MSG_SSID_3; *(uint16_t *)(driver->apps_rsp_buf + 22) = MSG_SSID_3_LAST; *(uint16_t *)(driver->apps_rsp_buf + 24) = MSG_SSID_4; *(uint16_t *)(driver->apps_rsp_buf + 26) = MSG_SSID_4_LAST; *(uint16_t *)(driver->apps_rsp_buf + 28) = MSG_SSID_5; *(uint16_t *)(driver->apps_rsp_buf + 30) = MSG_SSID_5_LAST; *(uint16_t *)(driver->apps_rsp_buf + 32) = MSG_SSID_6; *(uint16_t *)(driver->apps_rsp_buf + 34) = MSG_SSID_6_LAST; *(uint16_t *)(driver->apps_rsp_buf + 36) = MSG_SSID_7; *(uint16_t *)(driver->apps_rsp_buf + 38) = MSG_SSID_7_LAST; *(uint16_t *)(driver->apps_rsp_buf + 40) = MSG_SSID_8; *(uint16_t *)(driver->apps_rsp_buf + 42) = MSG_SSID_8_LAST; *(uint16_t *)(driver->apps_rsp_buf + 44) = MSG_SSID_9; *(uint16_t *)(driver->apps_rsp_buf + 46) = MSG_SSID_9_LAST; *(uint16_t *)(driver->apps_rsp_buf + 48) = MSG_SSID_10; *(uint16_t *)(driver->apps_rsp_buf + 50) = MSG_SSID_10_LAST; *(uint16_t *)(driver->apps_rsp_buf + 52) = MSG_SSID_11; *(uint16_t *)(driver->apps_rsp_buf + 54) = MSG_SSID_11_LAST; *(uint16_t *)(driver->apps_rsp_buf + 56) = MSG_SSID_12; *(uint16_t *)(driver->apps_rsp_buf + 58) = MSG_SSID_12_LAST; *(uint16_t *)(driver->apps_rsp_buf + 60) = MSG_SSID_13; *(uint16_t *)(driver->apps_rsp_buf + 62) = MSG_SSID_13_LAST; *(uint16_t *)(driver->apps_rsp_buf + 64) = MSG_SSID_14; *(uint16_t *)(driver->apps_rsp_buf + 66) = MSG_SSID_14_LAST; *(uint16_t *)(driver->apps_rsp_buf + 68) = MSG_SSID_15; *(uint16_t *)(driver->apps_rsp_buf + 70) = MSG_SSID_15_LAST; *(uint16_t *)(driver->apps_rsp_buf + 72) = MSG_SSID_16; *(uint16_t *)(driver->apps_rsp_buf + 74) = MSG_SSID_16_LAST; *(uint16_t *)(driver->apps_rsp_buf + 76) = MSG_SSID_17; *(uint16_t *)(driver->apps_rsp_buf + 78) = MSG_SSID_17_LAST; *(uint16_t *)(driver->apps_rsp_buf + 80) = MSG_SSID_18; *(uint16_t *)(driver->apps_rsp_buf + 82) = MSG_SSID_18_LAST; ENCODE_RSP_AND_SEND(83); return 0; } /* Check for AO8960 Respond to Get Subsys Build mask */ else if (!(driver->ch) && (chk_config_get_id() == AO8960_TOOLS_ID) && (*buf == 0x7d) && (*(buf+1) == 0x2)) { ssid_first = *(uint16_t *)(buf + 2); ssid_last = *(uint16_t *)(buf + 4); ssid_range = 4 * (ssid_last - ssid_first + 1); /* frame response */ driver->apps_rsp_buf[0] = 0x7d; driver->apps_rsp_buf[1] = 0x2; *(uint16_t *)(driver->apps_rsp_buf + 2) = ssid_first; *(uint16_t *)(driver->apps_rsp_buf + 4) = ssid_last; driver->apps_rsp_buf[6] = 0x1; driver->apps_rsp_buf[7] = 0x0; ptr = driver->apps_rsp_buf + 8; /* bld time masks */ switch (ssid_first) { case MSG_SSID_0: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_0[i/4]; break; case MSG_SSID_1: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_1[i/4]; break; case MSG_SSID_2: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_2[i/4]; break; case MSG_SSID_3: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_3[i/4]; break; case MSG_SSID_4: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_4[i/4]; break; case MSG_SSID_5: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_5[i/4]; break; case MSG_SSID_6: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_6[i/4]; break; case MSG_SSID_7: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_7[i/4]; break; case MSG_SSID_8: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_8[i/4]; break; case MSG_SSID_9: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_9[i/4]; break; case MSG_SSID_10: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_10[i/4]; break; case MSG_SSID_11: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_11[i/4]; break; case MSG_SSID_12: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_12[i/4]; break; case MSG_SSID_13: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_13[i/4]; break; case MSG_SSID_14: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_14[i/4]; break; case MSG_SSID_15: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_15[i/4]; break; case MSG_SSID_16: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_16[i/4]; break; case MSG_SSID_17: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_17[i/4]; break; case MSG_SSID_18: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_18[i/4]; break; } ENCODE_RSP_AND_SEND(8 + ssid_range - 1); return 0; } /* Check for download command */ else if ((cpu_is_msm8x60() || cpu_is_msm8960()) && (*buf == 0x3A)) { /* send response back */ driver->apps_rsp_buf[0] = *buf; ENCODE_RSP_AND_SEND(0); msleep(5000); /* call download API */ msm_set_restart_mode(RESTART_DLOAD); printk(KERN_CRIT "diag: download mode set, Rebooting SoC..\n"); kernel_restart(NULL); /* Not required, represents that command isnt sent to modem */ return 0; } /* Check for ID for NO MODEM present */ else if (!(driver->ch)) { /* Respond to polling for Apps only DIAG */ if ((*buf == 0x4b) && (*(buf+1) == 0x32) && (*(buf+2) == 0x03)) { for (i = 0; i < 3; i++) driver->apps_rsp_buf[i] = *(buf+i); for (i = 0; i < 13; i++) driver->apps_rsp_buf[i+3] = 0; ENCODE_RSP_AND_SEND(15); return 0; } /* respond to 0x0 command */ else if (*buf == 0x00) { for (i = 0; i < 55; i++) driver->apps_rsp_buf[i] = 0; ENCODE_RSP_AND_SEND(54); return 0; } /* respond to 0x7c command */ else if (*buf == 0x7c) { driver->apps_rsp_buf[0] = 0x7c; for (i = 1; i < 8; i++) driver->apps_rsp_buf[i] = 0; /* Tools ID for APQ 8060 */ *(int *)(driver->apps_rsp_buf + 8) = chk_config_get_id(); *(unsigned char *)(driver->apps_rsp_buf + 12) = '\0'; *(unsigned char *)(driver->apps_rsp_buf + 13) = '\0'; ENCODE_RSP_AND_SEND(13); return 0; } } #endif return packet_type; }
void diagfwd_init(void) { diag_debug_buf_idx = 0; driver->read_len_legacy = 0; /* FIXME: there should be a better way to know if wcnss enabled */ if (chk_config_get_id() == AO8960_TOOLS_ID) { is_wcnss_used = 1; DIAGFWD_INFO("wcnss channel was enabled in the platform\n"); } else { is_wcnss_used = 0; DIAGFWD_INFO("wcnss channel was not enabled in the platform\n"); } if (driver->buf_in_1 == NULL) { driver->buf_in_1 = kzalloc(IN_BUF_SIZE, GFP_KERNEL); if (driver->buf_in_1 == NULL) goto err; } if (driver->buf_in_2 == NULL) { driver->buf_in_2 = kzalloc(IN_BUF_SIZE, GFP_KERNEL); if (driver->buf_in_2 == NULL) goto err; } if (driver->buf_in_qdsp_1 == NULL) { driver->buf_in_qdsp_1 = kzalloc(IN_BUF_SIZE, GFP_KERNEL); if (driver->buf_in_qdsp_1 == NULL) goto err; } if (driver->buf_in_qdsp_2 == NULL) { driver->buf_in_qdsp_2 = kzalloc(IN_BUF_SIZE, GFP_KERNEL); if (driver->buf_in_qdsp_2 == NULL) goto err; } if (is_wcnss_used && driver->buf_in_wcnss == NULL) { driver->buf_in_wcnss = kzalloc(IN_BUF_SIZE, GFP_KERNEL); if (driver->buf_in_wcnss == NULL) goto err; } if (driver->usb_buf_out == NULL && (driver->usb_buf_out = kzalloc(USB_MAX_OUT_BUF, GFP_KERNEL)) == NULL) goto err; if (driver->hdlc_buf == NULL && (driver->hdlc_buf = kzalloc(HDLC_MAX, GFP_KERNEL)) == NULL) goto err; if (driver->user_space_data == NULL) driver->user_space_data = kzalloc(USER_SPACE_DATA, GFP_KERNEL); if (driver->user_space_data == NULL) goto err; if (driver->msg_masks == NULL && (driver->msg_masks = kzalloc(MSG_MASK_SIZE, GFP_KERNEL)) == NULL) goto err; if (driver->log_masks == NULL && (driver->log_masks = kzalloc(LOG_MASK_SIZE, GFP_KERNEL)) == NULL) goto err; driver->log_masks_length = 8*MAX_EQUIP_ID; if (driver->event_masks == NULL && (driver->event_masks = kzalloc(EVENT_MASK_SIZE, GFP_KERNEL)) == NULL) goto err; if (driver->client_map == NULL && (driver->client_map = kzalloc ((driver->num_clients) * sizeof(struct diag_client_map), GFP_KERNEL)) == NULL) goto err; #ifdef CONFIG_DIAG_SDIO_PIPE if (driver->mdmclient_map == NULL && (driver->mdmclient_map = kzalloc ((driver->num_mdmclients) * sizeof(struct diag_client_map), GFP_KERNEL)) == NULL) goto err; #endif if (driver->buf_tbl == NULL) driver->buf_tbl = kzalloc(buf_tbl_size * sizeof(struct diag_write_device), GFP_KERNEL); if (driver->buf_tbl == NULL) goto err; if (driver->data_ready == NULL && (driver->data_ready = kzalloc(driver->num_clients * sizeof(int) , GFP_KERNEL)) == NULL) goto err; #ifdef CONFIG_DIAG_SDIO_PIPE if (driver->mdmdata_ready == NULL && (driver->mdmdata_ready = kzalloc(driver->num_mdmclients * sizeof(struct diag_client_map), GFP_KERNEL)) == NULL) goto err; #endif if (driver->table == NULL && (driver->table = kzalloc(diag_max_registration* sizeof(struct diag_master_table), GFP_KERNEL)) == NULL) goto err; if (driver->write_ptr_1 == NULL) { driver->write_ptr_1 = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->write_ptr_1 == NULL) goto err; } if (driver->write_ptr_2 == NULL) { driver->write_ptr_2 = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->write_ptr_2 == NULL) goto err; } if (driver->write_ptr_qdsp_1 == NULL) { driver->write_ptr_qdsp_1 = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->write_ptr_qdsp_1 == NULL) goto err; } if (driver->write_ptr_qdsp_2 == NULL) { driver->write_ptr_qdsp_2 = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->write_ptr_qdsp_2 == NULL) goto err; } if (driver->write_ptr_wcnss == NULL) { driver->write_ptr_wcnss = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->write_ptr_wcnss == NULL) goto err; } if (driver->usb_read_ptr == NULL) { driver->usb_read_ptr = kzalloc( sizeof(struct diag_request), GFP_KERNEL); if (driver->usb_read_ptr == NULL) goto err; } if (driver->pkt_buf == NULL && (driver->pkt_buf = kzalloc(PKT_SIZE, GFP_KERNEL)) == NULL) goto err; if (driver->apps_rsp_buf == NULL) { driver->apps_rsp_buf = kzalloc(500, GFP_KERNEL); if (driver->apps_rsp_buf == NULL) goto err; } driver->diag_wq = create_singlethread_workqueue("diag_wq"); #ifdef CONFIG_DIAG_OVER_USB INIT_WORK(&(driver->diag_proc_hdlc_work), diag_process_hdlc_fn); INIT_WORK(&(driver->diag_read_work), diag_read_work_fn); driver->legacy_ch = usb_diag_open(DIAG_LEGACY, driver, diag_usb_legacy_notifier); if (IS_ERR(driver->legacy_ch)) { printk(KERN_ERR "Unable to open USB diag legacy channel\n"); goto err; } #endif #if DIAG_XPST mutex_init(&driver->smd_lock); #endif platform_driver_register(&msm_smd_ch1_driver); platform_driver_register(&diag_smd_lite_driver); return; err: pr_err("diag: Could not initialize diag buffers"); kfree(driver->buf_in_1); kfree(driver->buf_in_2); kfree(driver->buf_in_qdsp_1); kfree(driver->buf_in_qdsp_2); kfree(driver->buf_in_wcnss); kfree(driver->usb_buf_out); kfree(driver->hdlc_buf); kfree(driver->msg_masks); kfree(driver->log_masks); kfree(driver->event_masks); kfree(driver->client_map); kfree(driver->buf_tbl); kfree(driver->data_ready); kfree(driver->table); kfree(driver->pkt_buf); kfree(driver->write_ptr_1); kfree(driver->write_ptr_2); kfree(driver->write_ptr_qdsp_1); kfree(driver->write_ptr_qdsp_2); kfree(driver->write_ptr_wcnss); kfree(driver->usb_read_ptr); kfree(driver->apps_rsp_buf); kfree(driver->user_space_data); if (driver->diag_wq) destroy_workqueue(driver->diag_wq); }
static ssize_t diag_dbgfs_read_status(struct file *file, char __user *ubuf, size_t count, loff_t *ppos) { char *buf; int ret; buf = kzalloc(sizeof(char) * DEBUG_BUF_SIZE, GFP_KERNEL); if (!buf) { pr_err("diag: %s, Error allocating memory\n", __func__); return -ENOMEM; } ret = scnprintf(buf, DEBUG_BUF_SIZE, "modem ch: 0x%x\n" "lpass ch: 0x%x\n" "riva ch: 0x%x\n" "dci ch: 0x%x\n" "modem cntl_ch: 0x%x\n" "lpass cntl_ch: 0x%x\n" "riva cntl_ch: 0x%x\n" "modem cmd ch: 0x%x\n" "dci cmd ch: 0x%x\n" "CPU Tools id: %d\n" "Apps only: %d\n" "Apps master: %d\n" "Check Polling Response: %d\n" "polling_reg_flag: %d\n" "uses device tree: %d\n" "supports separate cmdrsp: %d\n" "Modem separate cmdrsp: %d\n" "LPASS separate cmdrsp: %d\n" "RIVA separate cmdrsp: %d\n" "Modem in_busy_1: %d\n" "Modem in_busy_2: %d\n" "LPASS in_busy_1: %d\n" "LPASS in_busy_2: %d\n" "RIVA in_busy_1: %d\n" "RIVA in_busy_2: %d\n" "DCI Modem in_busy_1: %d\n" "Modem CMD in_busy_1: %d\n" "Modem CMD in_busy_2: %d\n" "DCI CMD Modem in_busy_1: %d\n" "logging_mode: %d\n", (unsigned int)driver->smd_data[MODEM_DATA].ch, (unsigned int)driver->smd_data[LPASS_DATA].ch, (unsigned int)driver->smd_data[WCNSS_DATA].ch, (unsigned int)driver->smd_dci[MODEM_DATA].ch, (unsigned int)driver->smd_cntl[MODEM_DATA].ch, (unsigned int)driver->smd_cntl[LPASS_DATA].ch, (unsigned int)driver->smd_cntl[WCNSS_DATA].ch, (unsigned int)driver->smd_cmd[MODEM_DATA].ch, (unsigned int)driver->smd_dci_cmd[MODEM_DATA].ch, chk_config_get_id(), chk_apps_only(), chk_apps_master(), chk_polling_response(), driver->polling_reg_flag, driver->use_device_tree, driver->supports_separate_cmdrsp, driver->separate_cmdrsp[MODEM_DATA], driver->separate_cmdrsp[LPASS_DATA], driver->separate_cmdrsp[WCNSS_DATA], driver->smd_data[MODEM_DATA].in_busy_1, driver->smd_data[MODEM_DATA].in_busy_2, driver->smd_data[LPASS_DATA].in_busy_1, driver->smd_data[LPASS_DATA].in_busy_2, driver->smd_data[WCNSS_DATA].in_busy_1, driver->smd_data[WCNSS_DATA].in_busy_2, driver->smd_dci[MODEM_DATA].in_busy_1, driver->smd_cmd[MODEM_DATA].in_busy_1, driver->smd_cmd[MODEM_DATA].in_busy_2, driver->smd_dci_cmd[MODEM_DATA].in_busy_1, driver->logging_mode); #ifdef CONFIG_DIAG_OVER_USB ret += scnprintf(buf+ret, DEBUG_BUF_SIZE, "usb_connected: %d\n", driver->usb_connected); #endif ret = simple_read_from_buffer(ubuf, count, ppos, buf, ret); kfree(buf); return ret; }
static int __init diagchar_init(void) { dev_t dev; int error; DIAG_INFO("diagfwd initializing ..\n"); driver = kzalloc(sizeof(struct diagchar_dev) + 5, GFP_KERNEL); if (driver) { driver->used = 0; timer_in_progress = 0; driver->debug_flag = 1; setup_timer(&drain_timer, drain_timer_func, 1234); driver->itemsize = itemsize; driver->poolsize = poolsize; driver->itemsize_hdlc = itemsize_hdlc; driver->poolsize_hdlc = poolsize_hdlc; driver->itemsize_write_struct = itemsize_write_struct; driver->poolsize_write_struct = poolsize_write_struct; driver->num_clients = max_clients; driver->logging_mode = USB_MODE; mutex_init(&driver->diagchar_mutex); init_waitqueue_head(&driver->wait_q); wake_lock_init(&driver->wake_lock, WAKE_LOCK_SUSPEND, "diagchar"); INIT_WORK(&(driver->diag_drain_work), diag_drain_work_fn); INIT_WORK(&(driver->diag_read_smd_work), diag_read_smd_work_fn); INIT_WORK(&(driver->diag_read_smd_cntl_work), diag_read_smd_cntl_work_fn); INIT_WORK(&(driver->diag_read_smd_qdsp_work), diag_read_smd_qdsp_work_fn); INIT_WORK(&(driver->diag_read_smd_qdsp_cntl_work), diag_read_smd_qdsp_cntl_work_fn); INIT_WORK(&(driver->diag_read_smd_wcnss_work), diag_read_smd_wcnss_work_fn); INIT_WORK(&(driver->diag_read_smd_wcnss_cntl_work), diag_read_smd_wcnss_cntl_work_fn); #if defined(CONFIG_MACH_MECHA) INIT_WORK(&(driver->diag_read_smd_mdm_work), sdio_diag_read_data); driver->in_busy_mdm_1 = 0; driver->in_busy_mdm_2 = 0; #endif #ifdef CONFIG_DIAG_SDIO_PIPE driver->num_mdmclients = 1; init_waitqueue_head(&driver->mdmwait_q); spin_lock_init(&driver->diagchar_lock); mutex_init(&driver->diagcharmdm_mutex); driver->num = 2; #else driver->num = 1; #endif diagfwd_init(); if (chk_config_get_id() == AO8960_TOOLS_ID) { diagfwd_cntl_init(); DIAGFWD_INFO("CNTL channel was enabled in the platform\n"); } else DIAGFWD_INFO("CNTL channel was not enabled in the platform\n"); diag_sdio_fn(INIT); pr_debug("diagchar initializing ..\n"); driver->name = ((void *)driver) + sizeof(struct diagchar_dev); strlcpy(driver->name, "diag", 4); /* Get major number from kernel and initialize */ error = alloc_chrdev_region(&dev, driver->minor_start, driver->num, driver->name); if (!error) { driver->major = MAJOR(dev); driver->minor_start = MINOR(dev); } else { printk(KERN_INFO "Major number not allocated\n"); goto fail; } driver->cdev = cdev_alloc(); #ifdef CONFIG_DIAG_SDIO_PIPE driver->cdev_mdm = cdev_alloc(); #endif error = diagchar_setup_cdev(dev); if (error) goto fail; } else { printk(KERN_INFO "kzalloc failed\n"); goto fail; } DIAG_INFO("diagchar initialized\n"); return 0; fail: diagchar_cleanup(); diagfwd_exit(); diagfwd_cntl_exit(); diag_sdio_fn(EXIT); return -1; }
static ssize_t diag_dbgfs_read_status(struct file *file, char __user *ubuf, size_t count, loff_t *ppos) { char *buf; int ret, i; unsigned int buf_size; buf = kzalloc(sizeof(char) * DEBUG_BUF_SIZE, GFP_KERNEL); if (!buf) { pr_err("diag: %s, Error allocating memory\n", __func__); return -ENOMEM; } buf_size = ksize(buf); ret = scnprintf(buf, buf_size, "modem ch: 0x%p\n" "lpass ch: 0x%p\n" "riva ch: 0x%p\n" "sensors ch: 0x%p\n" "modem dci ch: 0x%p\n" "lpass dci ch: 0x%p\n" "riva dci ch: 0x%p\n" "sensors dci ch: 0x%p\n" "modem cntl_ch: 0x%p\n" "lpass cntl_ch: 0x%p\n" "riva cntl_ch: 0x%p\n" "sensors cntl_ch: 0x%p\n" "modem cmd ch: 0x%p\n" "adsp cmd ch: 0x%p\n" "riva cmd ch: 0x%p\n" "sensors cmd ch: 0x%p\n" "modem dci cmd ch: 0x%p\n" "lpass dci cmd ch: 0x%p\n" "riva dci cmd ch: 0x%p\n" "sensors dci cmd ch: 0x%p\n" "CPU Tools id: %d\n" "Apps only: %d\n" "Apps master: %d\n" "Check Polling Response: %d\n" "polling_reg_flag: %d\n" "uses device tree: %d\n" "supports separate cmdrsp: %d\n" "Modem separate cmdrsp: %d\n" "LPASS separate cmdrsp: %d\n" "RIVA separate cmdrsp: %d\n" "SENSORS separate cmdrsp: %d\n" "Modem in_busy_1: %d\n" "Modem in_busy_2: %d\n" "LPASS in_busy_1: %d\n" "LPASS in_busy_2: %d\n" "RIVA in_busy_1: %d\n" "RIVA in_busy_2: %d\n" "SENSORS in_busy_1: %d\n" "SENSORS in_busy_2: %d\n" "DCI Modem in_busy_1: %d\n" "DCI LPASS in_busy_1: %d\n" "DCI WCNSS in_busy_1: %d\n" "DCI SENSORS in_busy_1: %d\n" "Modem CMD in_busy_1: %d\n" "Modem CMD in_busy_2: %d\n" "DCI CMD Modem in_busy_1: %d\n" "DCI CMD LPASS in_busy_1: %d\n" "DCI CMD WCNSS in_busy_1: %d\n" "DCI CMD SENSORS in_busy_1: %d\n" "ADSP CMD in_busy_1: %d\n" "ADSP CMD in_busy_2: %d\n" "RIVA CMD in_busy_1: %d\n" "RIVA CMD in_busy_2: %d\n" "SENSORS CMD in_busy_1: %d\n" "SENSORS CMD in_busy_2: %d\n" "Modem supports STM: %d\n" "LPASS supports STM: %d\n" "RIVA supports STM: %d\n" "SENSORS supports STM: %d\n" "Modem STM state: %d\n" "LPASS STM state: %d\n" "RIVA STM state: %d\n" "SENSORS STM state: %d\n" "APPS STM state: %d\n" "Modem STM requested state: %d\n" "LPASS STM requested state: %d\n" "RIVA STM requested state: %d\n" "SENSORS STM requested state: %d\n" "APPS STM requested state: %d\n" "supports apps hdlc encoding: %d\n" "Modem hdlc encoding: %d\n" "Lpass hdlc encoding: %d\n" "RIVA hdlc encoding: %d\n" "SENSORS hdlc encoding: %d\n" "Modem CMD hdlc encoding: %d\n" "ADSP CMD hdlc encoding: %d\n" "RIVA CMD hdlc encoding: %d\n" "SENSORS CMD hdlc encoding: %d\n" "Modem DATA in_buf_1_size: %d\n" "Modem DATA in_buf_2_size: %d\n" "ADSP DATA in_buf_1_size: %d\n" "ADSP DATA in_buf_2_size: %d\n" "RIVA DATA in_buf_1_size: %d\n" "RIVA DATA in_buf_2_size: %d\n" "SENSORS DATA in_buf_1_size: %d\n" "SENSORS DATA in_buf_2_size: %d\n" "Modem DATA in_buf_1_raw_size: %d\n" "Modem DATA in_buf_2_raw_size: %d\n" "ADSP DATA in_buf_1_raw_size: %d\n" "ADSP DATA in_buf_2_raw_size: %d\n" "RIVA DATA in_buf_1_raw_size: %d\n" "RIVA DATA in_buf_2_raw_size: %d\n" "SENSORS DATA in_buf_1_raw_size: %d\n" "SENSORS DATA in_buf_2_raw_size: %d\n" "Modem CMD in_buf_1_size: %d\n" "Modem CMD in_buf_1_raw_size: %d\n" "ADSP CMD in_buf_1_size: %d\n" "ADSP CMD in_buf_1_raw_size: %d\n" "RIVA CMD in_buf_1_size: %d\n" "RIVA CMD in_buf_1_raw_size: %d\n" "SENSORS CMD in_buf_1_size: %d\n" "SENSORS CMD in_buf_1_raw_size: %d\n" "Modem CNTL in_buf_1_size: %d\n" "ADSP CNTL in_buf_1_size: %d\n" "RIVA CNTL in_buf_1_size: %d\n" "SENSORS CNTL in_buf_1_size: %d\n" "Modem DCI in_buf_1_size: %d\n" "Modem DCI CMD in_buf_1_size: %d\n" "LPASS DCI in_buf_1_size: %d\n" "LPASS DCI CMD in_buf_1_size: %d\n" "WCNSS DCI in_buf_1_size: %d\n" "WCNSS DCI CMD in_buf_1_size: %d\n" "SENSORS DCI in_buf_1_size: %d\n" "SENSORS DCI CMD in_buf_1_size: %d\n" "Received Feature mask from Modem: %d\n" "Received Feature mask from LPASS: %d\n" "Received Feature mask from WCNSS: %d\n" "Received Feature mask from SENSORS: %d\n" "Mask Centralization Support on Modem: %d\n" "Mask Centralization Support on LPASS: %d\n" "Mask Centralization Support on WCNSS: %d\n" "Mask Centralization Support on SENSORS: %d\n" "logging_mode: %d\n" "rsp_in_busy: %d\n", driver->smd_data[MODEM_DATA].ch, driver->smd_data[LPASS_DATA].ch, driver->smd_data[WCNSS_DATA].ch, driver->smd_data[SENSORS_DATA].ch, driver->smd_dci[MODEM_DATA].ch, driver->smd_dci[LPASS_DATA].ch, driver->smd_dci[WCNSS_DATA].ch, driver->smd_dci[SENSORS_DATA].ch, driver->smd_cntl[MODEM_DATA].ch, driver->smd_cntl[LPASS_DATA].ch, driver->smd_cntl[WCNSS_DATA].ch, driver->smd_cntl[SENSORS_DATA].ch, driver->smd_cmd[MODEM_DATA].ch, driver->smd_cmd[LPASS_DATA].ch, driver->smd_cmd[WCNSS_DATA].ch, driver->smd_cmd[SENSORS_DATA].ch, driver->smd_dci_cmd[MODEM_DATA].ch, driver->smd_dci_cmd[LPASS_DATA].ch, driver->smd_dci_cmd[WCNSS_DATA].ch, driver->smd_dci_cmd[SENSORS_DATA].ch, chk_config_get_id(), chk_apps_only(), chk_apps_master(), chk_polling_response(), driver->polling_reg_flag, driver->use_device_tree, driver->supports_separate_cmdrsp, driver->separate_cmdrsp[MODEM_DATA], driver->separate_cmdrsp[LPASS_DATA], driver->separate_cmdrsp[WCNSS_DATA], driver->separate_cmdrsp[SENSORS_DATA], driver->smd_data[MODEM_DATA].in_busy_1, driver->smd_data[MODEM_DATA].in_busy_2, driver->smd_data[LPASS_DATA].in_busy_1, driver->smd_data[LPASS_DATA].in_busy_2, driver->smd_data[WCNSS_DATA].in_busy_1, driver->smd_data[WCNSS_DATA].in_busy_2, driver->smd_data[SENSORS_DATA].in_busy_1, driver->smd_data[SENSORS_DATA].in_busy_2, driver->smd_dci[MODEM_DATA].in_busy_1, driver->smd_dci[LPASS_DATA].in_busy_1, driver->smd_dci[WCNSS_DATA].in_busy_1, driver->smd_dci[SENSORS_DATA].in_busy_1, driver->smd_cmd[MODEM_DATA].in_busy_1, driver->smd_cmd[MODEM_DATA].in_busy_2, driver->smd_cmd[LPASS_DATA].in_busy_1, driver->smd_cmd[LPASS_DATA].in_busy_2, driver->smd_cmd[WCNSS_DATA].in_busy_1, driver->smd_cmd[WCNSS_DATA].in_busy_2, driver->smd_cmd[SENSORS_DATA].in_busy_1, driver->smd_cmd[SENSORS_DATA].in_busy_2, driver->smd_dci_cmd[MODEM_DATA].in_busy_1, driver->smd_dci_cmd[LPASS_DATA].in_busy_1, driver->smd_dci_cmd[WCNSS_DATA].in_busy_1, driver->smd_dci_cmd[SENSORS_DATA].in_busy_1, driver->peripheral_supports_stm[MODEM_DATA], driver->peripheral_supports_stm[LPASS_DATA], driver->peripheral_supports_stm[WCNSS_DATA], driver->peripheral_supports_stm[SENSORS_DATA], driver->stm_state[MODEM_DATA], driver->stm_state[LPASS_DATA], driver->stm_state[WCNSS_DATA], driver->stm_state[SENSORS_DATA], driver->stm_state[APPS_DATA], driver->stm_state_requested[MODEM_DATA], driver->stm_state_requested[LPASS_DATA], driver->stm_state_requested[WCNSS_DATA], driver->stm_state_requested[SENSORS_DATA], driver->stm_state_requested[APPS_DATA], driver->supports_apps_hdlc_encoding, driver->smd_data[MODEM_DATA].encode_hdlc, driver->smd_data[LPASS_DATA].encode_hdlc, driver->smd_data[WCNSS_DATA].encode_hdlc, driver->smd_data[SENSORS_DATA].encode_hdlc, driver->smd_cmd[MODEM_DATA].encode_hdlc, driver->smd_cmd[LPASS_DATA].encode_hdlc, driver->smd_cmd[WCNSS_DATA].encode_hdlc, driver->smd_cmd[SENSORS_DATA].encode_hdlc, (unsigned int)driver->smd_data[MODEM_DATA].buf_in_1_size, (unsigned int)driver->smd_data[MODEM_DATA].buf_in_2_size, (unsigned int)driver->smd_data[LPASS_DATA].buf_in_1_size, (unsigned int)driver->smd_data[LPASS_DATA].buf_in_2_size, (unsigned int)driver->smd_data[WCNSS_DATA].buf_in_1_size, (unsigned int)driver->smd_data[WCNSS_DATA].buf_in_2_size, (unsigned int)driver->smd_data[SENSORS_DATA].buf_in_1_size, (unsigned int)driver->smd_data[SENSORS_DATA].buf_in_2_size, (unsigned int)driver->smd_data[MODEM_DATA].buf_in_1_raw_size, (unsigned int)driver->smd_data[MODEM_DATA].buf_in_2_raw_size, (unsigned int)driver->smd_data[LPASS_DATA].buf_in_1_raw_size, (unsigned int)driver->smd_data[LPASS_DATA].buf_in_2_raw_size, (unsigned int)driver->smd_data[WCNSS_DATA].buf_in_1_raw_size, (unsigned int)driver->smd_data[WCNSS_DATA].buf_in_2_raw_size, (unsigned int)driver->smd_data[SENSORS_DATA].buf_in_1_raw_size, (unsigned int)driver->smd_data[SENSORS_DATA].buf_in_2_raw_size, (unsigned int)driver->smd_cmd[MODEM_DATA].buf_in_1_size, (unsigned int)driver->smd_cmd[MODEM_DATA].buf_in_1_raw_size, (unsigned int)driver->smd_cmd[LPASS_DATA].buf_in_1_size, (unsigned int)driver->smd_cmd[LPASS_DATA].buf_in_1_raw_size, (unsigned int)driver->smd_cmd[WCNSS_DATA].buf_in_1_size, (unsigned int)driver->smd_cmd[WCNSS_DATA].buf_in_1_raw_size, (unsigned int)driver->smd_cmd[SENSORS_DATA].buf_in_1_size, (unsigned int)driver->smd_cmd[SENSORS_DATA].buf_in_1_raw_size, (unsigned int)driver->smd_cntl[MODEM_DATA].buf_in_1_size, (unsigned int)driver->smd_cntl[LPASS_DATA].buf_in_1_size, (unsigned int)driver->smd_cntl[WCNSS_DATA].buf_in_1_size, (unsigned int)driver->smd_cntl[SENSORS_DATA].buf_in_1_size, (unsigned int)driver->smd_dci[MODEM_DATA].buf_in_1_size, (unsigned int)driver->smd_dci_cmd[MODEM_DATA].buf_in_1_size, (unsigned int)driver->smd_dci[LPASS_DATA].buf_in_1_size, (unsigned int)driver->smd_dci_cmd[LPASS_DATA].buf_in_1_size, (unsigned int)driver->smd_dci[WCNSS_DATA].buf_in_1_size, (unsigned int)driver->smd_dci_cmd[WCNSS_DATA].buf_in_1_size, (unsigned int)driver->smd_dci[SENSORS_DATA].buf_in_1_size, (unsigned int)driver->smd_dci_cmd[SENSORS_DATA].buf_in_1_size, driver->rcvd_feature_mask[MODEM_DATA], driver->rcvd_feature_mask[LPASS_DATA], driver->rcvd_feature_mask[WCNSS_DATA], driver->rcvd_feature_mask[SENSORS_DATA], driver->mask_centralization[MODEM_DATA], driver->mask_centralization[LPASS_DATA], driver->mask_centralization[WCNSS_DATA], driver->mask_centralization[SENSORS_DATA], driver->logging_mode, driver->rsp_buf_busy); #ifdef CONFIG_DIAG_OVER_USB ret += scnprintf(buf+ret, buf_size-ret, "usb_connected: %d\n", driver->usb_connected); #endif for (i = 0; i < DIAG_NUM_PROC; i++) { ret += scnprintf(buf+ret, buf_size-ret, "real_time proc: %d: %d\n", i, driver->real_time_mode[i]); } ret = simple_read_from_buffer(ubuf, count, ppos, buf, ret); kfree(buf); return ret; }
void diag_process_hdlc(void *data, unsigned len) { struct diag_hdlc_decode_type hdlc; int ret, type = 0; #ifdef CONFIG_LGE_DIAG unsigned int nTempLen = 0; #endif // LGE_CHANGE [2011.07.22] M3S : for remove compile warnig //#if defined(DIAG_DEBUG) || defined(CONFIG_DIAG_OVER_USB) #if defined(DIAG_DEBUD) int i; pr_debug("\n HDLC decode function, len of data %d\n", len); #endif hdlc.dest_ptr = driver->hdlc_buf; hdlc.dest_size = USB_MAX_OUT_BUF; hdlc.src_ptr = data; hdlc.src_size = len; hdlc.src_idx = 0; hdlc.dest_idx = 0; hdlc.escaping = 0; #ifdef CONFIG_LGE_DIAG if( len > 2 ) { if( hdlc.src_ptr[len -1] == 0x7E && hdlc.src_ptr[len -2] == 0x7E) { len--; hdlc.src_size--; } } do { ret = diag_hdlc_decode(&hdlc); nTempLen = hdlc.dest_idx; if(ret) { hdlc.dest_idx = 0; /* Initialize for the next packet */ } if( hdlc.src_idx >= hdlc.src_size) { //ret = 1; break; } else { if(nTempLen > 1) break; ret = 0; } }while ( ret == 0 ); if (ret) { type = diag_process_apps_pkt(driver->hdlc_buf, nTempLen - 3); } /* ignore 2 bytes for CRC, one for 7E and send */ if ((driver->ch) && (ret) && (type) && (nTempLen > 3)) { smd_write(driver->ch, driver->hdlc_buf, nTempLen - 3); #ifdef DIAG_DEBUG printk(KERN_INFO "writing data to SMD, pkt length %d\n", len); print_hex_dump(KERN_DEBUG, "Written Packet Data to SMD: ", 16, 1, DUMP_PREFIX_ADDRESS, data, len, 1); #endif /* DIAG DEBUG */ } #else /*CONFIG_LGE_DIAG*/ ret = diag_hdlc_decode(&hdlc); if (ret) type = diag_process_apps_pkt(driver->hdlc_buf, hdlc.dest_idx - 3); else if (driver->debug_flag) { printk(KERN_ERR "Packet dropped due to bad HDLC coding/CRC" " errors or partial packet received, packet" " length = %d\n", len); print_hex_dump(KERN_DEBUG, "Dropped Packet Data: ", 16, 1, DUMP_PREFIX_ADDRESS, data, len, 1); driver->debug_flag = 0; } /* implies this packet is NOT meant for apps */ if (!(driver->ch) && type == 1 && chk_config_get_id()) { if (chk_config_get_id() == AO8960_TOOLS_ID) { #if defined(CONFIG_DIAG_OVER_USB) driver->apps_rsp_buf[0] = 0x13; for (i = 0; i < hdlc.dest_idx; i++) driver->apps_rsp_buf[i+1] = *(driver->hdlc_buf+i); ENCODE_RSP_AND_SEND(hdlc.dest_idx - 3); #endif } else { /* APQ 8060, Let Q6 respond */ if (driver->chqdsp) smd_write(driver->chqdsp, driver->hdlc_buf, hdlc.dest_idx - 3); } type = 0; } #ifdef DIAG_DEBUG printk(KERN_INFO "\n hdlc.dest_idx = %d", hdlc.dest_idx); for (i = 0; i < hdlc.dest_idx; i++) printk(KERN_DEBUG "\t%x", *(((unsigned char *) driver->hdlc_buf)+i)); #endif /* DIAG DEBUG */ /* ignore 2 bytes for CRC, one for 7E and send */ if ((driver->ch) && (ret) && (type) && (hdlc.dest_idx > 3)) { APPEND_DEBUG('g'); smd_write(driver->ch, driver->hdlc_buf, hdlc.dest_idx - 3); APPEND_DEBUG('h'); #ifdef DIAG_DEBUG printk(KERN_INFO "writing data to SMD, pkt length %d\n", len); print_hex_dump(KERN_DEBUG, "Written Packet Data to SMD: ", 16, 1, DUMP_PREFIX_ADDRESS, data, len, 1); #endif /* DIAG DEBUG */ } #endif /*CONFIG_LGE_DIAG*/ }
static ssize_t diag_dbgfs_read_status(struct file *file, char __user *ubuf, size_t count, loff_t *ppos) { char *buf; int ret; buf = kzalloc(sizeof(char) * DEBUG_BUF_SIZE, GFP_KERNEL); if (!buf) { pr_err("diag: %s, Error allocating memory\n", __func__); return -ENOMEM; } ret = scnprintf(buf, DEBUG_BUF_SIZE, "modem ch: 0x%x\n" "lpass ch: 0x%x\n" "riva ch: 0x%x\n" "dci ch: 0x%x\n" "modem cntl_ch: 0x%x\n" "lpass cntl_ch: 0x%x\n" "riva cntl_ch: 0x%x\n" "CPU Tools id: %d\n" "Apps only: %d\n" "Apps master: %d\n" "Check Polling Response: %d\n" "polling_reg_flag: %d\n" "uses device tree: %d\n" "in_busy_1: %d\n" "in_busy_2: %d\n" "in_busy_qdsp_1: %d\n" "in_busy_qdsp_2: %d\n" "in_busy_wcnss_1: %d\n" "in_busy_wcnss_2: %d\n" "in_busy_dci: %d\n", (unsigned int)driver->ch, (unsigned int)driver->chqdsp, (unsigned int)driver->ch_wcnss, (unsigned int)driver->ch_dci, (unsigned int)driver->ch_cntl, (unsigned int)driver->chqdsp_cntl, (unsigned int)driver->ch_wcnss_cntl, chk_config_get_id(), chk_apps_only(), chk_apps_master(), chk_polling_response(), driver->polling_reg_flag, driver->use_device_tree, driver->in_busy_1, driver->in_busy_2, driver->in_busy_qdsp_1, driver->in_busy_qdsp_2, driver->in_busy_wcnss_1, driver->in_busy_wcnss_2, driver->in_busy_dci); #ifdef CONFIG_DIAG_OVER_USB ret += scnprintf(buf+ret, DEBUG_BUF_SIZE, "usb_connected: %d\n", driver->usb_connected); #endif ret = simple_read_from_buffer(ubuf, count, ppos, buf, ret); kfree(buf); return ret; }
static int diag_process_apps_pkt(unsigned char *buf, int len) { uint16_t subsys_cmd_code; int subsys_id, ssid_first, ssid_last, ssid_range; int packet_type = 1, i, cmd_code; unsigned char *temp = buf; int data_type; int mask_ret; #if defined(CONFIG_DIAG_OVER_USB) unsigned char *ptr; #endif /* Check if the command is a supported mask command */ mask_ret = diag_process_apps_masks(buf, len); if (mask_ret <= 0) return mask_ret; /* Check for registered clients and forward packet to apropriate proc */ cmd_code = (int)(*(char *)buf); temp++; subsys_id = (int)(*(char *)temp); temp++; subsys_cmd_code = *(uint16_t *)temp; temp += 2; data_type = APPS_DATA; /* Dont send any command other than mode reset */ if (chk_apps_master() && cmd_code == MODE_CMD) { if (subsys_id != RESET_ID) data_type = MODEM_DATA; } pr_debug("diag: %d %d %d", cmd_code, subsys_id, subsys_cmd_code); for (i = 0; i < diag_max_reg; i++) { entry = driver->table[i]; if (entry.process_id != NO_PROCESS) { if (entry.cmd_code == cmd_code && entry.subsys_id == subsys_id && entry.cmd_code_lo <= subsys_cmd_code && entry.cmd_code_hi >= subsys_cmd_code) { diag_send_data(entry, buf, len, data_type); packet_type = 0; } else if (entry.cmd_code == 255 && cmd_code == 75) { if (entry.subsys_id == subsys_id && entry.cmd_code_lo <= subsys_cmd_code && entry.cmd_code_hi >= subsys_cmd_code) { diag_send_data(entry, buf, len, data_type); packet_type = 0; } } else if (entry.cmd_code == 255 && entry.subsys_id == 255) { if (entry.cmd_code_lo <= cmd_code && entry. cmd_code_hi >= cmd_code) { diag_send_data(entry, buf, len, data_type); packet_type = 0; } } } } #if defined(CONFIG_DIAG_OVER_USB) /* Check for the command/respond msg for the maximum packet length */ if ((*buf == 0x4b) && (*(buf+1) == 0x12) && (*(uint16_t *)(buf+2) == 0x0055)) { for (i = 0; i < 4; i++) *(driver->apps_rsp_buf+i) = *(buf+i); *(uint32_t *)(driver->apps_rsp_buf+4) = PKT_SIZE; encode_rsp_and_send(7); return 0; } /* Check for Apps Only & get event mask request */ else if (!(driver->smd_data[MODEM_DATA].ch) && chk_apps_only() && *buf == 0x81) { driver->apps_rsp_buf[0] = 0x81; driver->apps_rsp_buf[1] = 0x0; *(uint16_t *)(driver->apps_rsp_buf + 2) = 0x0; *(uint16_t *)(driver->apps_rsp_buf + 4) = EVENT_LAST_ID + 1; for (i = 0; i < EVENT_LAST_ID/8 + 1; i++) *(unsigned char *)(driver->apps_rsp_buf + 6 + i) = 0x0; encode_rsp_and_send(6 + EVENT_LAST_ID/8); return 0; } /* Get log ID range & Check for Apps Only */ else if (!(driver->smd_data[MODEM_DATA].ch) && chk_apps_only() && (*buf == 0x73) && *(int *)(buf+4) == 1) { driver->apps_rsp_buf[0] = 0x73; *(int *)(driver->apps_rsp_buf + 4) = 0x1; /* operation ID */ *(int *)(driver->apps_rsp_buf + 8) = 0x0; /* success code */ *(int *)(driver->apps_rsp_buf + 12) = LOG_GET_ITEM_NUM(LOG_0); *(int *)(driver->apps_rsp_buf + 16) = LOG_GET_ITEM_NUM(LOG_1); *(int *)(driver->apps_rsp_buf + 20) = LOG_GET_ITEM_NUM(LOG_2); *(int *)(driver->apps_rsp_buf + 24) = LOG_GET_ITEM_NUM(LOG_3); *(int *)(driver->apps_rsp_buf + 28) = LOG_GET_ITEM_NUM(LOG_4); *(int *)(driver->apps_rsp_buf + 32) = LOG_GET_ITEM_NUM(LOG_5); *(int *)(driver->apps_rsp_buf + 36) = LOG_GET_ITEM_NUM(LOG_6); *(int *)(driver->apps_rsp_buf + 40) = LOG_GET_ITEM_NUM(LOG_7); *(int *)(driver->apps_rsp_buf + 44) = LOG_GET_ITEM_NUM(LOG_8); *(int *)(driver->apps_rsp_buf + 48) = LOG_GET_ITEM_NUM(LOG_9); *(int *)(driver->apps_rsp_buf + 52) = LOG_GET_ITEM_NUM(LOG_10); *(int *)(driver->apps_rsp_buf + 56) = LOG_GET_ITEM_NUM(LOG_11); *(int *)(driver->apps_rsp_buf + 60) = LOG_GET_ITEM_NUM(LOG_12); *(int *)(driver->apps_rsp_buf + 64) = LOG_GET_ITEM_NUM(LOG_13); *(int *)(driver->apps_rsp_buf + 68) = LOG_GET_ITEM_NUM(LOG_14); *(int *)(driver->apps_rsp_buf + 72) = LOG_GET_ITEM_NUM(LOG_15); encode_rsp_and_send(75); return 0; } /* Respond to Get SSID Range request message */ else if (!(driver->smd_data[MODEM_DATA].ch) && chk_apps_only() && (*buf == 0x7d) && (*(buf+1) == 0x1)) { driver->apps_rsp_buf[0] = 0x7d; driver->apps_rsp_buf[1] = 0x1; driver->apps_rsp_buf[2] = 0x1; driver->apps_rsp_buf[3] = 0x0; /* -1 to un-account for OEM SSID range */ *(int *)(driver->apps_rsp_buf + 4) = MSG_MASK_TBL_CNT - 1; *(uint16_t *)(driver->apps_rsp_buf + 8) = MSG_SSID_0; *(uint16_t *)(driver->apps_rsp_buf + 10) = MSG_SSID_0_LAST; *(uint16_t *)(driver->apps_rsp_buf + 12) = MSG_SSID_1; *(uint16_t *)(driver->apps_rsp_buf + 14) = MSG_SSID_1_LAST; *(uint16_t *)(driver->apps_rsp_buf + 16) = MSG_SSID_2; *(uint16_t *)(driver->apps_rsp_buf + 18) = MSG_SSID_2_LAST; *(uint16_t *)(driver->apps_rsp_buf + 20) = MSG_SSID_3; *(uint16_t *)(driver->apps_rsp_buf + 22) = MSG_SSID_3_LAST; *(uint16_t *)(driver->apps_rsp_buf + 24) = MSG_SSID_4; *(uint16_t *)(driver->apps_rsp_buf + 26) = MSG_SSID_4_LAST; *(uint16_t *)(driver->apps_rsp_buf + 28) = MSG_SSID_5; *(uint16_t *)(driver->apps_rsp_buf + 30) = MSG_SSID_5_LAST; *(uint16_t *)(driver->apps_rsp_buf + 32) = MSG_SSID_6; *(uint16_t *)(driver->apps_rsp_buf + 34) = MSG_SSID_6_LAST; *(uint16_t *)(driver->apps_rsp_buf + 36) = MSG_SSID_7; *(uint16_t *)(driver->apps_rsp_buf + 38) = MSG_SSID_7_LAST; *(uint16_t *)(driver->apps_rsp_buf + 40) = MSG_SSID_8; *(uint16_t *)(driver->apps_rsp_buf + 42) = MSG_SSID_8_LAST; *(uint16_t *)(driver->apps_rsp_buf + 44) = MSG_SSID_9; *(uint16_t *)(driver->apps_rsp_buf + 46) = MSG_SSID_9_LAST; *(uint16_t *)(driver->apps_rsp_buf + 48) = MSG_SSID_10; *(uint16_t *)(driver->apps_rsp_buf + 50) = MSG_SSID_10_LAST; *(uint16_t *)(driver->apps_rsp_buf + 52) = MSG_SSID_11; *(uint16_t *)(driver->apps_rsp_buf + 54) = MSG_SSID_11_LAST; *(uint16_t *)(driver->apps_rsp_buf + 56) = MSG_SSID_12; *(uint16_t *)(driver->apps_rsp_buf + 58) = MSG_SSID_12_LAST; *(uint16_t *)(driver->apps_rsp_buf + 60) = MSG_SSID_13; *(uint16_t *)(driver->apps_rsp_buf + 62) = MSG_SSID_13_LAST; *(uint16_t *)(driver->apps_rsp_buf + 64) = MSG_SSID_14; *(uint16_t *)(driver->apps_rsp_buf + 66) = MSG_SSID_14_LAST; *(uint16_t *)(driver->apps_rsp_buf + 68) = MSG_SSID_15; *(uint16_t *)(driver->apps_rsp_buf + 70) = MSG_SSID_15_LAST; *(uint16_t *)(driver->apps_rsp_buf + 72) = MSG_SSID_16; *(uint16_t *)(driver->apps_rsp_buf + 74) = MSG_SSID_16_LAST; *(uint16_t *)(driver->apps_rsp_buf + 76) = MSG_SSID_17; *(uint16_t *)(driver->apps_rsp_buf + 78) = MSG_SSID_17_LAST; *(uint16_t *)(driver->apps_rsp_buf + 80) = MSG_SSID_18; *(uint16_t *)(driver->apps_rsp_buf + 82) = MSG_SSID_18_LAST; *(uint16_t *)(driver->apps_rsp_buf + 84) = MSG_SSID_19; *(uint16_t *)(driver->apps_rsp_buf + 86) = MSG_SSID_19_LAST; *(uint16_t *)(driver->apps_rsp_buf + 88) = MSG_SSID_20; *(uint16_t *)(driver->apps_rsp_buf + 90) = MSG_SSID_20_LAST; *(uint16_t *)(driver->apps_rsp_buf + 92) = MSG_SSID_21; *(uint16_t *)(driver->apps_rsp_buf + 94) = MSG_SSID_21_LAST; *(uint16_t *)(driver->apps_rsp_buf + 96) = MSG_SSID_22; *(uint16_t *)(driver->apps_rsp_buf + 98) = MSG_SSID_22_LAST; encode_rsp_and_send(99); return 0; } /* Check for Apps Only Respond to Get Subsys Build mask */ else if (!(driver->smd_data[MODEM_DATA].ch) && chk_apps_only() && (*buf == 0x7d) && (*(buf+1) == 0x2)) { ssid_first = *(uint16_t *)(buf + 2); ssid_last = *(uint16_t *)(buf + 4); ssid_range = 4 * (ssid_last - ssid_first + 1); /* frame response */ driver->apps_rsp_buf[0] = 0x7d; driver->apps_rsp_buf[1] = 0x2; *(uint16_t *)(driver->apps_rsp_buf + 2) = ssid_first; *(uint16_t *)(driver->apps_rsp_buf + 4) = ssid_last; driver->apps_rsp_buf[6] = 0x1; driver->apps_rsp_buf[7] = 0x0; ptr = driver->apps_rsp_buf + 8; /* bld time masks */ switch (ssid_first) { case MSG_SSID_0: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_0[i/4]; break; case MSG_SSID_1: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_1[i/4]; break; case MSG_SSID_2: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_2[i/4]; break; case MSG_SSID_3: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_3[i/4]; break; case MSG_SSID_4: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_4[i/4]; break; case MSG_SSID_5: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_5[i/4]; break; case MSG_SSID_6: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_6[i/4]; break; case MSG_SSID_7: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_7[i/4]; break; case MSG_SSID_8: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_8[i/4]; break; case MSG_SSID_9: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_9[i/4]; break; case MSG_SSID_10: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_10[i/4]; break; case MSG_SSID_11: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_11[i/4]; break; case MSG_SSID_12: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_12[i/4]; break; case MSG_SSID_13: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_13[i/4]; break; case MSG_SSID_14: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_14[i/4]; break; case MSG_SSID_15: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_15[i/4]; break; case MSG_SSID_16: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_16[i/4]; break; case MSG_SSID_17: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_17[i/4]; break; case MSG_SSID_18: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_18[i/4]; break; case MSG_SSID_19: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_19[i/4]; break; case MSG_SSID_20: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_20[i/4]; break; case MSG_SSID_21: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_21[i/4]; break; case MSG_SSID_22: for (i = 0; i < ssid_range; i += 4) *(int *)(ptr + i) = msg_bld_masks_22[i/4]; break; } encode_rsp_and_send(8 + ssid_range - 1); return 0; } /* Check for download command */ else if ((cpu_is_msm8x60() || chk_apps_master()) && (*buf == 0x3A)) { /* send response back */ driver->apps_rsp_buf[0] = *buf; encode_rsp_and_send(0); msleep(5000); /* call download API */ msm_set_restart_mode(RESTART_DLOAD); printk(KERN_CRIT "diag: download mode set 1, Rebooting SoC..\n"); kernel_restart(NULL); /* Not required, represents that command isnt sent to modem */ return 0; } /* Check for polling for Apps only DIAG */ else if ((*buf == 0x4b) && (*(buf+1) == 0x32) && (*(buf+2) == 0x03)) { /* If no one has registered for polling */ if (chk_polling_response()) { /* Respond to polling for Apps only DIAG */ for (i = 0; i < 3; i++) driver->apps_rsp_buf[i] = *(buf+i); for (i = 0; i < 13; i++) driver->apps_rsp_buf[i+3] = 0; encode_rsp_and_send(15); return 0; } } /* Return the Delayed Response Wrap Status */ else if ((*buf == 0x4b) && (*(buf+1) == 0x32) && (*(buf+2) == 0x04) && (*(buf+3) == 0x0)) { memcpy(driver->apps_rsp_buf, buf, 4); driver->apps_rsp_buf[4] = wrap_enabled; encode_rsp_and_send(4); return 0; } /* Wrap the Delayed Rsp ID */ else if ((*buf == 0x4b) && (*(buf+1) == 0x32) && (*(buf+2) == 0x05) && (*(buf+3) == 0x0)) { wrap_enabled = true; memcpy(driver->apps_rsp_buf, buf, 4); driver->apps_rsp_buf[4] = wrap_count; encode_rsp_and_send(5); return 0; } /* Check for ID for NO MODEM present */ else if (chk_polling_response()) { /* respond to 0x0 command */ if (*buf == 0x00) { for (i = 0; i < 55; i++) driver->apps_rsp_buf[i] = 0; encode_rsp_and_send(54); return 0; } /* respond to 0x7c command */ else if (*buf == 0x7c) { driver->apps_rsp_buf[0] = 0x7c; for (i = 1; i < 8; i++) driver->apps_rsp_buf[i] = 0; /* Tools ID for APQ 8060 */ *(int *)(driver->apps_rsp_buf + 8) = chk_config_get_id(); *(unsigned char *)(driver->apps_rsp_buf + 12) = '\0'; *(unsigned char *)(driver->apps_rsp_buf + 13) = '\0'; encode_rsp_and_send(13); return 0; } } #endif return packet_type; }