type
stringclasses
5 values
content
stringlengths
9
163k
defines
#define STM_RSP_NUM_BYTES 10
defines
#define SMD_DRAIN_BUF_SIZE 4096
defines
#define N_LEGACY_WRITE (driver->poolsize + 6)
defines
#define N_LEGACY_WRITE_CMD ((N_LEGACY_WRITE) + 4)
defines
#define N_LEGACY_READ 1
structs
struct data_header { uint8_t control_char; uint8_t version; uint16_t length; };
functions
void encode_rsp_and_send(int buf_length) { struct diag_send_desc_type send = { NULL, NULL, DIAG_STATE_START, 0 }
functions
int has_device_tree(void) { struct device_node *node; node = of_find_node_by_path("/"); if (node) { of_node_put(node); return 1; }
functions
int has_device_tree(void) { return 0; }
functions
int chk_config_get_id(void) { /* For all Fusion targets, Modem will always be present */ if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) return 0; if (driver->use_device_tree) { if (machine_is_msm8974()) return MSM8974_TOOLS_ID; else return 0; }
functions
int chk_apps_only(void) { if (driver->use_device_tree) return 1; switch (socinfo_get_msm_cpu()) { case MSM_CPU_8960: case MSM_CPU_8960AB: case MSM_CPU_8064: case MSM_CPU_8064AB: case MSM_CPU_8064AA: case MSM_CPU_8930: case MSM_CPU_8930AA: case MSM_CPU_8930AB: case MSM_CPU_8627: case MSM_CPU_9615: case M...
functions
int chk_apps_master(void) { if (driver->use_device_tree) return 1; else if (soc_class_is_msm8960() || soc_class_is_msm8930() || soc_class_is_apq8064() || cpu_is_msm9615()) return 1; else return 0; }
functions
int chk_polling_response(void) { if (!(driver->polling_reg_flag) && chk_apps_master()) /* * If the apps processor is master and no other processor * has registered to respond for polling */ return 1; else if (!(driver->smd_data[MODEM_DATA].ch) && !(chk_apps_master())) /* * If the apps processor...
functions
void chk_logging_wakeup(void) { int i; /* Find the index of the logging process */ for (i = 0; i < driver->num_clients; i++) if (driver->client_map[i].pid == driver->logging_process_id) break; if (i < driver->num_clients) { /* At very high logging rates a race condition can * occur where the buffers ...
functions
int diag_add_hdlc_encoding(struct diag_smd_info *smd_info, void *buf, int total_recd, uint8_t *encode_buf, int *encoded_length) { struct diag_send_desc_type send = { NULL, NULL, DIAG_STATE_START, 0 }
functions
int check_bufsize_for_encoding(struct diag_smd_info *smd_info, void *buf, int total_recd) { int buf_size = IN_BUF_SIZE; int max_size = 2 * total_recd + 3; unsigned char *temp_buf; if (max_size > IN_BUF_SIZE) { if (max_size > MAX_IN_BUF_SIZE) { pr_err_ratelimited("diag: In %s, SMD sending packet of %d byt...
functions
void process_lock_enabling(struct diag_nrt_wake_lock *lock, int real_time) { unsigned long read_lock_flags; spin_lock_irqsave(&lock->read_spinlock, read_lock_flags); if (real_time) lock->enabled = 0; else lock->enabled = 1; lock->ref_count = 0; lock->copy_count = 0; wake_unlock(&lock->read_lock); spin_unlo...
functions
void process_lock_on_notify(struct diag_nrt_wake_lock *lock) { unsigned long read_lock_flags; spin_lock_irqsave(&lock->read_spinlock, read_lock_flags); /* * Do not work with ref_count here in case * of spurious interrupt */ if (lock->enabled) wake_lock(&lock->read_lock); spin_unlock_irqrestore(&lock->read...
functions
void process_lock_on_read(struct diag_nrt_wake_lock *lock, int pkt_len) { unsigned long read_lock_flags; spin_lock_irqsave(&lock->read_spinlock, read_lock_flags); if (lock->enabled) { if (pkt_len > 0) { /* * We have an data that is read that * needs to be processed, make sure the * processor does n...
functions
void process_lock_on_copy(struct diag_nrt_wake_lock *lock) { unsigned long read_lock_flags; spin_lock_irqsave(&lock->read_spinlock, read_lock_flags); if (lock->enabled) lock->copy_count++; spin_unlock_irqrestore(&lock->read_spinlock, read_lock_flags); }
functions
void process_lock_on_copy_complete(struct diag_nrt_wake_lock *lock) { unsigned long read_lock_flags; spin_lock_irqsave(&lock->read_spinlock, read_lock_flags); if (lock->enabled) { lock->ref_count -= lock->copy_count; if (lock->ref_count < 1) { wake_unlock(&lock->read_lock); lock->ref_count = 0; }
functions
int diag_process_smd_read_data(struct diag_smd_info *smd_info, void *buf, int total_recd) { struct diag_request *write_ptr_modem = NULL; int *in_busy_ptr = 0; int err = 0; /* * Do not process data on command channel if the * channel is not designated to do so */ if ((smd_info->type == SMD_CMD_TYPE...
functions
else if (smd_info->buf_in_2 == buf) { write_ptr_modem = smd_info->write_ptr_2; in_busy_ptr = &smd_info->in_busy_2; }
functions
else if (smd_info->buf_in_2_raw == buf) { write_ptr_modem = smd_info->write_ptr_2; in_busy_ptr = &smd_info->in_busy_2; }
functions
int diag_smd_resize_buf(struct diag_smd_info *smd_info, void **buf, unsigned int *buf_size, unsigned int requested_size) { int success = 0; void *temp_buf = NULL; unsigned int new_buf_size = requested_size; if (!smd_info) return success; if (requested_size <= MAX_IN_BUF_SIZE) { pr_debug("...
functions
else if (*buf == smd_info->buf_in_2_raw) { smd_info->buf_in_2_raw = temp_buf; smd_info->buf_in_2_raw_size = new_buf_size; temp_hdlc = krealloc(smd_info->buf_in_2, MAX_IN_BUF_SIZE, GFP_KERNEL); if (temp_hdlc) { smd_info->buf_in_2 = temp_hdlc; smd_info->buf_in_2_size = MAX_I...
functions
else if (*buf == smd_info->buf_in_2) { smd_info->buf_in_2 = temp_buf; smd_info->buf_in_2_size = new_buf_size; }
functions
void diag_smd_send_req(struct diag_smd_info *smd_info) { void *buf = NULL, *temp_buf = NULL; int total_recd = 0, r = 0, pkt_len; int loop_count = 0; int notify = 0; int buf_size = 0; int resize_success = 0; int buf_full = 0; if (!smd_info) { pr_err("diag: In %s, no smd info. Not able to read.\n", __func__...
functions
else if (!smd_info->in_busy_2) { buf = smd_info->buf_in_2_raw; buf_size = smd_info->buf_in_2_raw_size; }
functions
else if (!smd_info->in_busy_2) { buf = smd_info->buf_in_2; buf_size = smd_info->buf_in_2_size; }
functions
else if (smd_info->type == SMD_CMD_TYPE) { /* If the data is raw and not hdlc encoded */ if (smd_info->encode_hdlc) { if (!smd_info->in_busy_1) { buf = smd_info->buf_in_1_raw; buf_size = smd_info->buf_in_1_raw_size; }
functions
else if (!smd_info->in_busy_1) { buf = smd_info->buf_in_1; buf_size = smd_info->buf_in_1_size; }
functions
else if (smd_info->process_smd_read_data) { /* * If the buffer was totally filled, reset * total_recd appropriately */ if (buf_full) total_recd = buf_size; notify = smd_info->process_smd_read_data( smd_info, buf, total_recd); /* Poll SMD channels to check for data */ if (n...
functions
void diag_read_smd_work_fn(struct work_struct *work) { struct diag_smd_info *smd_info = container_of(work, struct diag_smd_info, diag_read_smd_work); diag_smd_send_req(smd_info); }
functions
int diag_device_write(void *buf, int data_type, struct diag_request *write_ptr) { int i, err = 0, index; index = 0; if (driver->logging_mode == MEMORY_DEVICE_MODE) { if (data_type == APPS_DATA) { for (i = 0; i < driver->buf_tbl_size; i++) if (driver->buf_tbl[i].length == 0) { driver->buf_tbl[i].buf = ...
functions
else if (data_type == HSIC_DATA || data_type == HSIC_2_DATA) { unsigned long flags; int foundIndex = -1; index = data_type - HSIC_DATA; spin_lock_irqsave(&diag_hsic[index].hsic_spinlock, flags); for (i = 0; i < diag_hsic[index].poolsize_hsic_write; i++) { if (diag_hsic[index].hsic_b...
functions
else if (driver->logging_mode == NO_LOGGING_MODE) { if ((data_type >= MODEM_DATA) && (data_type <= WCNSS_DATA)) { driver->smd_data[data_type].in_busy_1 = 0; driver->smd_data[data_type].in_busy_2 = 0; queue_work(driver->smd_data[data_type].wq, &(driver->smd_data[data_type]. diag_read_smd_work)); ...
functions
else if (data_type == SDIO_DATA) { driver->in_busy_sdio = 0; queue_work(driver->diag_sdio_wq, &(driver->diag_read_sdio_work)); }
functions
else if (data_type == HSIC_DATA || data_type == HSIC_2_DATA) { index = data_type - HSIC_DATA; if (diag_hsic[index].hsic_ch) queue_work(diag_bridge[index].wq, &(diag_hsic[index]. diag_read_hsic_work)); }
functions
else if (driver->logging_mode == USB_MODE) { if (data_type == APPS_DATA) { driver->write_ptr_svc = (struct diag_request *) (diagmem_alloc(driver, sizeof(struct diag_request), POOL_TYPE_WRITE_STRUCT)); if (driver->write_ptr_svc) { driver->write_ptr_svc->length = driver->used; driver->write_ptr_sv...
functions
else if (data_type == SDIO_DATA) { if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa()) { write_ptr->buf = buf; err = usb_diag_write(driver->mdm_ch, write_ptr); }
functions
else if (data_type == HSIC_DATA || data_type == HSIC_2_DATA) { index = data_type - HSIC_DATA; if (diag_hsic[index].hsic_device_enabled) { struct diag_request *write_ptr_mdm; write_ptr_mdm = (struct diag_request *) diagmem_alloc(driver, sizeof(struct diag_request), index + POOL_TY...
functions
else if (data_type == SMUX_DATA) { write_ptr->buf = buf; write_ptr->context = (void *)SMUX; pr_debug("diag: writing SMUX data\n"); err = usb_diag_write(diag_bridge[SMUX].ch, write_ptr); }
functions
void diag_update_pkt_buffer(unsigned char *buf) { unsigned char *ptr = driver->pkt_buf; unsigned char *temp = buf; mutex_lock(&driver->diagchar_mutex); if (CHK_OVERFLOW(ptr, ptr, ptr + PKT_SIZE, driver->pkt_length)) { memcpy(ptr, temp , driver->pkt_length); driver->in_busy_pktdata = 1; }
functions
void diag_update_userspace_clients(unsigned int type) { int i; mutex_lock(&driver->diagchar_mutex); for (i = 0; i < driver->num_clients; i++) if (driver->client_map[i].pid != 0) driver->data_ready[i] |= type; wake_up_interruptible(&driver->wait_q); mutex_unlock(&driver->diagchar_mutex); }
functions
void diag_update_sleeping_process(int process_id, int data_type) { int i; mutex_lock(&driver->diagchar_mutex); for (i = 0; i < driver->num_clients; i++) if (driver->client_map[i].pid == process_id) { driver->data_ready[i] |= data_type; break; }
functions
int diag_check_mode_reset(unsigned char *buf) { int is_mode_reset = 0; if (chk_apps_master() && (int)(*(char *)buf) == MODE_CMD) if ((int)(*(char *)(buf+1)) == RESET_ID) is_mode_reset = 1; return is_mode_reset; }
functions
void diag_send_data(struct diag_master_table entry, unsigned char *buf, int len, int type) { driver->pkt_length = len; /* If the process_id corresponds to an apps process */ if (entry.process_id != NON_APPS_PROC) { /* If the message is to be sent to the apps process */ if (type != MODEM_DATA) { diag_up...
functions
void diag_process_stm_mask(uint8_t cmd, uint8_t data_mask, int data_type, uint8_t *rsp_supported, uint8_t *rsp_smd_comply) { int status = 0; if (data_type >= MODEM_DATA && data_type <= WCNSS_DATA) { if (driver->peripheral_supports_stm[data_type]) { status = diag_send_stm_state( &driver->smd_cntl[data_ty...
functions
else if (driver->smd_cntl[data_type].ch) { *rsp_smd_comply |= data_mask; }
functions
else if (data_type == APPS_DATA) { *rsp_supported |= data_mask; *rsp_smd_comply |= data_mask; driver->stm_state[data_type] = cmd; driver->stm_state_requested[data_type] = cmd; }
functions
int diag_process_stm_cmd(unsigned char *buf) { uint8_t version = *(buf+STM_CMD_VERSION_OFFSET); uint8_t mask = *(buf+STM_CMD_MASK_OFFSET); uint8_t cmd = *(buf+STM_CMD_DATA_OFFSET); uint8_t rsp_supported = 0; uint8_t rsp_smd_comply = 0; int valid_command = 1; int i; /* Check if command is valid */ if ((version...
functions
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 ...
functions
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; }
functions
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; }
functions
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 ...
functions
void diag_send_error_rsp(int index) { int i; /* -1 to accomodate the first byte 0x13 */ if (index > APPS_BUF_SIZE-1) { pr_err("diag: cannot send err rsp, huge length: %d\n", index); return; }
functions
void diag_send_error_rsp(int index) {}
functions
void diag_process_hdlc(void *data, unsigned len) { struct diag_hdlc_decode_type hdlc; int ret, type = 0, crc_chk = 0; mutex_lock(&driver->diag_hdlc_mutex); 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.sr...
functions
else if (driver->debug_flag) { pr_err("diag: In %s, partial packet received, dropping packet, len: %d\n", __func__, len); print_hex_dump(KERN_DEBUG, "Dropped Packet Data: ", 16, 1, DUMP_PREFIX_ADDRESS, data, len, 1); driver->debug_flag = 0; }
functions
void diag_reset_smd_data(int queue) { int i; for (i = 0; i < NUM_SMD_DATA_CHANNELS; i++) { driver->smd_data[i].in_busy_1 = 0; driver->smd_data[i].in_busy_2 = 0; if (queue) /* Poll SMD data channels to check for data */ queue_work(driver->smd_data[i].wq, &(driver->smd_data[i].diag_read_smd_work)); }
functions
void diag_usb_connect_work_fn(struct work_struct *w) { diagfwd_connect(); }
functions
void diag_usb_disconnect_work_fn(struct work_struct *w) { diagfwd_disconnect(); }
functions
int diagfwd_connect(void) { int err; int i; printk(KERN_DEBUG "diag: USB connected\n"); err = usb_diag_alloc_req(driver->legacy_ch, (driver->supports_separate_cmdrsp ? N_LEGACY_WRITE_CMD : N_LEGACY_WRITE), N_LEGACY_READ); if (err) printk(KERN_ERR "diag: unable to alloc USB req on legacy ch"); driver-...
functions
int diagfwd_disconnect(void) { int i; printk(KERN_DEBUG "diag: USB disconnected\n"); driver->usb_connected = 0; driver->debug_flag = 1; usb_diag_free_req(driver->legacy_ch); if (driver->logging_mode == USB_MODE) { for (i = 0; i < NUM_SMD_DATA_CHANNELS; i++) { driver->smd_data[i].in_busy_1 = 1; driver->sm...
functions
int diagfwd_check_buf_match(int num_channels, struct diag_smd_info *data, unsigned char *buf) { int i; int found_it = 0; for (i = 0; i < num_channels; i++) { if (buf == (void *)data[i].buf_in_1) { data[i].in_busy_1 = 0; found_it = 1; break; }
functions
int diagfwd_write_complete(struct diag_request *diag_write_ptr) { unsigned char *buf = diag_write_ptr->buf; int found_it = 0; /* Determine if the write complete is for data from modem/apps/q6 */ found_it = diagfwd_check_buf_match(NUM_SMD_DATA_CHANNELS, driver->smd_data, buf); if (!found_it && driver->suppo...
functions
endif if (!found_it) { if (driver->logging_mode != USB_MODE) pr_debug("diag: freeing buffer when not in usb mode\n"); diagmem_free(driver, (unsigned char *)buf, POOL_TYPE_HDLC); diagmem_free(driver, (unsigned char *)diag_write_ptr, POOL_TYPE_WRITE_STRUCT); }
functions
int diagfwd_read_complete(struct diag_request *diag_read_ptr) { int status = diag_read_ptr->status; unsigned char *buf = diag_read_ptr->buf; /* Determine if the read complete is for data on legacy/mdm ch */ if (buf == (void *)driver->usb_buf_out) { driver->read_len_legacy = diag_read_ptr->actual; APPEND_DEBUG(...
functions
void diag_read_work_fn(struct work_struct *work) { APPEND_DEBUG('d'); driver->usb_read_ptr->buf = driver->usb_buf_out; driver->usb_read_ptr->length = USB_MAX_OUT_BUF; usb_diag_read(driver->legacy_ch, driver->usb_read_ptr); APPEND_DEBUG('e'); }
functions
void diag_process_hdlc_fn(struct work_struct *work) { APPEND_DEBUG('D'); diag_process_hdlc(driver->usb_buf_out, driver->read_len_legacy); diag_read_work_fn(work); APPEND_DEBUG('E'); }
functions
void diag_usb_legacy_notifier(void *priv, unsigned event, struct diag_request *d_req) { switch (event) { case USB_DIAG_CONNECT: queue_work(driver->diag_wq, &driver->diag_usb_connect_work); break; case USB_DIAG_DISCONNECT: queue_work(driver->diag_wq, &driver->diag_usb_disconnect_work); break; case...
functions
void diag_smd_notify(void *ctxt, unsigned event) { struct diag_smd_info *smd_info = (struct diag_smd_info *)ctxt; if (!smd_info) return; if (event == SMD_EVENT_CLOSE) { smd_info->ch = 0; wake_up(&driver->smd_wait_q); if (smd_info->type == SMD_DATA_TYPE) { smd_info->notify_context = event; queue_work(d...
functions
else if (smd_info->type == SMD_DCI_TYPE) { /* Notify the clients of the close */ diag_dci_notify_client(smd_info->peripheral_mask, DIAG_STATUS_CLOSED); }
functions
else if (smd_info->type == SMD_CNTL_TYPE) { diag_cntl_stm_notify(smd_info, CLEAR_PERIPHERAL_STM_STATE); }
functions
else if (event == SMD_EVENT_OPEN) { if (smd_info->ch_save) smd_info->ch = smd_info->ch_save; if (smd_info->type == SMD_CNTL_TYPE) { smd_info->notify_context = event; queue_work(driver->diag_cntl_wq, &(smd_info->diag_notify_update_smd_work)); }
functions
else if (smd_info->type == SMD_DCI_TYPE) { smd_info->notify_context = event; queue_work(driver->diag_dci_wq, &(smd_info->diag_notify_update_smd_work)); /* Notify the clients of the open */ diag_dci_notify_client(smd_info->peripheral_mask, DIAG_STATUS_OPEN); }
functions
else if (event == SMD_EVENT_DATA && !driver->real_time_mode && smd_info->type == SMD_DATA_TYPE) { process_lock_on_notify(&smd_info->nrt_lock); }
functions
else if (smd_info->type == SMD_DATA_TYPE) { queue_work(smd_info->wq, &(smd_info->diag_read_smd_work)); }
functions
int diag_smd_probe(struct platform_device *pdev) { int r = 0; int index = -1; const char *channel_name = NULL; if (pdev->id == SMD_APPS_MODEM) { index = MODEM_DATA; channel_name = "DIAG"; }
functions
else if (pdev->id == SMD_APPS_QDSP) { index = LPASS_DATA; channel_name = "DIAG"; }
functions
else if (pdev->id == SMD_APPS_WCNSS) { index = WCNSS_DATA; channel_name = "APPS_RIVA_DATA"; }
functions
int diag_smd_cmd_probe(struct platform_device *pdev) { int r = 0; int index = -1; const char *channel_name = NULL; if (!driver->supports_separate_cmdrsp) return 0; if (pdev->id == SMD_APPS_MODEM) { index = MODEM_DATA; channel_name = "DIAG_CMD"; }
functions
int diag_smd_runtime_suspend(struct device *dev) { dev_dbg(dev, "pm_runtime: suspending...\n"); return 0; }
functions
int diag_smd_runtime_resume(struct device *dev) { dev_dbg(dev, "pm_runtime: resuming...\n"); return 0; }
functions
int device_supports_separate_cmdrsp(void) { return driver->use_device_tree; }
functions
void diag_smd_destructor(struct diag_smd_info *smd_info) { if (smd_info->type == SMD_DATA_TYPE) { wake_lock_destroy(&smd_info->nrt_lock.read_lock); destroy_workqueue(smd_info->wq); }
functions
int diag_smd_constructor(struct diag_smd_info *smd_info, int peripheral, int type) { smd_info->peripheral = peripheral; smd_info->type = type; smd_info->encode_hdlc = 0; mutex_init(&smd_info->smd_ch_mutex); switch (peripheral) { case MODEM_DATA: smd_info->peripheral_mask = DIAG_CON_MPSS; break; case LP...
functions
void diagfwd_init(void) { int success; int i; wrap_enabled = 0; wrap_count = 0; diag_debug_buf_idx = 0; driver->read_len_legacy = 0; driver->use_device_tree = has_device_tree(); driver->real_time_mode = 1; /* * The number of entries in table of buffers * should not be any smaller than hdlc poolsize. */ ...
functions
void diagfwd_exit(void) { int i; for (i = 0; i < NUM_SMD_DATA_CHANNELS; i++) diag_smd_destructor(&driver->smd_data[i]); #ifdef CONFIG_DIAG_OVER_USB if (driver->usb_connected) usb_diag_free_req(driver->legacy_ch); usb_diag_close(driver->legacy_ch); #endif platform_driver_unregister(&msm_smd_ch1_driver); plat...
includes
#include <sys/stat.h>
includes
#include <errno.h>
includes
#include <fcntl.h>
includes
#include <stdio.h>
includes
#include <stdlib.h>
includes
#include <string.h>
includes
#include <unistd.h>
defines
#define BUFFSIZE 64
defines
#define COMMENT "\n/* Just another comment. */\n"
defines
#define SOURCE "./rwex.c"