diff options
Diffstat (limited to 'drivers/char/diag/diag_debugfs.c')
| -rw-r--r-- | drivers/char/diag/diag_debugfs.c | 65 |
1 files changed, 40 insertions, 25 deletions
diff --git a/drivers/char/diag/diag_debugfs.c b/drivers/char/diag/diag_debugfs.c index d63d34bda18..b1d867591ff 100644 --- a/drivers/char/diag/diag_debugfs.c +++ b/drivers/char/diag/diag_debugfs.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -33,14 +33,14 @@ static ssize_t diag_dbgfs_read_status(struct file *file, char __user *ubuf, { char *buf; int ret; - + 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; } - - ret = scnprintf(buf, DEBUG_BUF_SIZE, + buf_size = ksize(buf); + ret = scnprintf(buf, buf_size, "modem ch: 0x%p\n" "lpass ch: 0x%p\n" "riva ch: 0x%p\n" @@ -180,10 +180,10 @@ static ssize_t diag_dbgfs_read_status(struct file *file, char __user *ubuf, driver->rcvd_feature_mask[LPASS_DATA], driver->rcvd_feature_mask[WCNSS_DATA], driver->logging_mode, - driver->real_time_mode); + driver->real_time_mode[DIAG_LOCAL_PROC]); #ifdef CONFIG_DIAG_OVER_USB - ret += scnprintf(buf+ret, DEBUG_BUF_SIZE, + ret += scnprintf(buf+ret, buf_size-ret, "usb_connected: %d\n", driver->usb_connected); #endif @@ -199,8 +199,9 @@ static ssize_t diag_dbgfs_read_dcistats(struct file *file, char *buf = NULL; unsigned int bytes_remaining, bytes_written = 0; unsigned int bytes_in_buf = 0, i = 0; - struct diag_dci_data_info *temp_data = dci_data_smd; - int buf_size = (DEBUG_BUF_SIZE < count) ? DEBUG_BUF_SIZE : count; + struct diag_dci_data_info *temp_data = dci_traffic; + unsigned int buf_size; + buf_size = (DEBUG_BUF_SIZE < count) ? DEBUG_BUF_SIZE : count; if (diag_dbgfs_dci_finished) { diag_dbgfs_dci_finished = 0; @@ -213,6 +214,7 @@ static ssize_t diag_dbgfs_read_dcistats(struct file *file, return -ENOMEM; } + buf_size = ksize(buf); bytes_remaining = buf_size; if (diag_dbgfs_dci_data_index == 0) { @@ -223,7 +225,8 @@ static ssize_t diag_dbgfs_read_dcistats(struct file *file, "dci real time vote: %d\n", driver->num_dci_client, (driver->proc_active_mask & DIAG_PROC_DCI) ? 1 : 0, - (driver->proc_rt_vote_mask & DIAG_PROC_DCI) ? 1 : 0); + (driver->proc_rt_vote_mask[DIAG_LOCAL_PROC] & + DIAG_PROC_DCI) ? 1 : 0); bytes_in_buf += bytes_written; bytes_remaining -= bytes_written; #ifdef CONFIG_DIAG_OVER_USB @@ -252,11 +255,13 @@ static ssize_t diag_dbgfs_read_dcistats(struct file *file, "i %-5ld\t" "s %-5d\t" "p %-5d\t" + "r %-5d\t" "c %-5d\t" "t %-15s\n", temp_data->iteration, temp_data->data_size, temp_data->peripheral, + temp_data->proc, temp_data->ch_type, temp_data->time_stamp); bytes_in_buf += bytes_written; @@ -281,6 +286,7 @@ static ssize_t diag_dbgfs_read_workpending(struct file *file, { char *buf; int ret; + unsigned int buf_size; buf = kzalloc(sizeof(char) * DEBUG_BUF_SIZE, GFP_KERNEL); if (!buf) { @@ -288,7 +294,8 @@ static ssize_t diag_dbgfs_read_workpending(struct file *file, return -ENOMEM; } - ret = scnprintf(buf, DEBUG_BUF_SIZE, + buf_size = ksize(buf); + ret = scnprintf(buf, buf_size, "Pending status for work_stucts:\n" "diag_drain_work: %d\n" "Modem data diag_read_smd_work: %d\n" @@ -336,7 +343,7 @@ static ssize_t diag_dbgfs_read_workpending(struct file *file, diag_notify_update_smd_work))); #ifdef CONFIG_DIAG_OVER_USB - ret += scnprintf(buf+ret, DEBUG_BUF_SIZE, + ret += scnprintf(buf+ret, buf_size-ret, "diag_proc_hdlc_work: %d\n" "diag_read_work: %d\n", work_pending(&(driver->diag_proc_hdlc_work)), @@ -357,7 +364,8 @@ static ssize_t diag_dbgfs_read_table(struct file *file, char __user *ubuf, unsigned int bytes_remaining; unsigned int bytes_in_buffer = 0; unsigned int bytes_written; - int buf_size = (DEBUG_BUF_SIZE < count) ? DEBUG_BUF_SIZE : count; + unsigned int buf_size; + buf_size = (DEBUG_BUF_SIZE < count) ? DEBUG_BUF_SIZE : count; if (diag_dbgfs_table_index >= diag_max_reg) { /* Done. Reset to prepare for future requests */ @@ -370,7 +378,7 @@ static ssize_t diag_dbgfs_read_table(struct file *file, char __user *ubuf, pr_err("diag: %s, Error allocating memory\n", __func__); return -ENOMEM; } - + buf_size = ksize(buf); bytes_remaining = buf_size; if (diag_dbgfs_table_index == 0) { @@ -379,6 +387,7 @@ static ssize_t diag_dbgfs_read_table(struct file *file, char __user *ubuf, "WCNSS: %d, APPS: %d\n", MODEM_DATA, LPASS_DATA, WCNSS_DATA, APPS_DATA); bytes_in_buffer += bytes_written; + bytes_remaining -= bytes_written; } for (i = diag_dbgfs_table_index; i < diag_max_reg; i++) { @@ -422,14 +431,15 @@ static ssize_t diag_dbgfs_read_mempool(struct file *file, char __user *ubuf, { char *buf = NULL; int ret = 0, i = 0; - + unsigned int buf_size; buf = kzalloc(sizeof(char) * DEBUG_BUF_SIZE, GFP_KERNEL); if (ZERO_OR_NULL_PTR(buf)) { pr_err("diag: %s, Error allocating memory\n", __func__); return -ENOMEM; } + buf_size = ksize(buf); - ret = scnprintf(buf, DEBUG_BUF_SIZE, + ret = scnprintf(buf, buf_size, "POOL_TYPE_COPY: [0x%p : 0x%p] count = %d\n" "POOL_TYPE_HDLC: [0x%p : 0x%p] count = %d\n" "POOL_TYPE_USER: [0x%p : 0x%p] count = %d\n" @@ -451,10 +461,10 @@ static ssize_t diag_dbgfs_read_mempool(struct file *file, char __user *ubuf, diag_pools_array[POOL_DCI_IDX], driver->count_dci_pool); - for (i = 0; i < MAX_HSIC_CH; i++) { + for (i = 0; i < MAX_HSIC_DATA_CH; i++) { if (!diag_hsic[i].hsic_inited) continue; - ret += scnprintf(buf+ret, DEBUG_BUF_SIZE-ret, + ret += scnprintf(buf+ret, buf_size-ret, "POOL_TYPE_HSIC_%d: [0x%p : 0x%p] count = %d\n", i+1, diag_hsic[i].diag_hsic_pool, @@ -462,10 +472,10 @@ static ssize_t diag_dbgfs_read_mempool(struct file *file, char __user *ubuf, diag_hsic[i].count_hsic_pool); } - for (i = 0; i < MAX_HSIC_CH; i++) { + for (i = 0; i < MAX_HSIC_DATA_CH; i++) { if (!diag_hsic[i].hsic_inited) continue; - ret += scnprintf(buf+ret, DEBUG_BUF_SIZE-ret, + ret += scnprintf(buf+ret, buf_size-ret, "POOL_TYPE_HSIC_%d_WRITE: [0x%p : 0x%p] count = %d\n", i+1, diag_hsic[i].diag_hsic_write_pool, @@ -484,6 +494,7 @@ static ssize_t diag_dbgfs_read_mempool(struct file *file, char __user *ubuf, { char *buf = NULL; int ret = 0; + unsigned int buf_size; buf = kzalloc(sizeof(char) * DEBUG_BUF_SIZE, GFP_KERNEL); if (ZERO_OR_NULL_PTR(buf)) { @@ -491,7 +502,8 @@ static ssize_t diag_dbgfs_read_mempool(struct file *file, char __user *ubuf, return -ENOMEM; } - ret = scnprintf(buf, DEBUG_BUF_SIZE, + buf_size = ksize(buf); + ret = scnprintf(buf, buf_size, "POOL_TYPE_COPY: [0x%p : 0x%p] count = %d\n" "POOL_TYPE_HDLC: [0x%p : 0x%p] count = %d\n" "POOL_TYPE_USER: [0x%p : 0x%p] count = %d\n" @@ -530,10 +542,12 @@ static ssize_t diag_dbgfs_read_bridge(struct file *file, char __user *ubuf, unsigned int bytes_remaining; unsigned int bytes_in_buffer = 0; unsigned int bytes_written; - int buf_size = (DEBUG_BUF_SIZE < count) ? DEBUG_BUF_SIZE : count; + unsigned int buf_size; int bytes_hsic_inited = 45; int bytes_hsic_not_inited = 410; + buf_size = (DEBUG_BUF_SIZE < count) ? DEBUG_BUF_SIZE : count; + if (diag_dbgfs_finished) { diag_dbgfs_finished = 0; return 0; @@ -545,6 +559,7 @@ static ssize_t diag_dbgfs_read_bridge(struct file *file, char __user *ubuf, return -ENOMEM; } + buf_size = ksize(buf); bytes_remaining = buf_size; /* Only one smux for now */ @@ -569,7 +584,7 @@ static ssize_t diag_dbgfs_read_bridge(struct file *file, char __user *ubuf, bytes_in_buffer += bytes_written; bytes_remaining = buf_size - bytes_in_buffer; - for (i = 0; i < MAX_HSIC_CH; i++) { + for (i = 0; i < MAX_HSIC_DATA_CH; i++) { if (diag_hsic[i].hsic_inited) { /* Check if there is room to add another HSIC entry */ if (bytes_remaining < bytes_hsic_inited) @@ -696,9 +711,9 @@ void diag_debugfs_init(void) diag_dbgfs_dci_finished = 0; /* DCI related structures */ - dci_data_smd = kzalloc(sizeof(struct diag_dci_data_info) * + dci_traffic = kzalloc(sizeof(struct diag_dci_data_info) * DIAG_DCI_DEBUG_CNT, GFP_KERNEL); - if (ZERO_OR_NULL_PTR(dci_data_smd)) + if (ZERO_OR_NULL_PTR(dci_traffic)) pr_warn("diag: could not allocate memory for dci debug info\n"); mutex_init(&dci_stat_mutex); @@ -711,7 +726,7 @@ void diag_debugfs_cleanup(void) diag_dbgfs_dent = NULL; } - kfree(dci_data_smd); + kfree(dci_traffic); mutex_destroy(&dci_stat_mutex); } #else |
