summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRam Chandrasekar <rkumbako@codeaurora.org>2015-10-27 17:32:09 -0600
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 21:15:28 -0700
commit4f9f3cdabfa0740ac074f4970390c5f625f7e8f9 (patch)
treecc804fc0bac6ce10a37b22021729d9087db6eb49
parentff6a8d71234c32d4824c9fa74c14b0bbe7f02425 (diff)
msm: limits: Add support to handle data greater than PAGE_SIZE
Debug data read was not handling the buffer overflow case when the data to write is greater than PAGE_SIZE. This resulted in calling the hardware for new data multiple times. Returning success when buffer overflowed will cause the sequence traverse function to call again with a new buffer with increased size. This process will go on until the buffer size is big enough to hold the data. But limits data read function couldn't distinguish if the call is a retry or a new call and will initiate a new data fetch from hardware and re-populate with new data. Modify debug read interface to immediately return success when overflow happens. The debug read function now can distinguish between a sequence retry call by retaining the data buffer in a static if overflow happens. When called again, debug read now will avoid calling the hardware for new data and instead will populate the new sequence buffer with the previously fetched data. Change-Id: Icc0eb035047ab734d2eb5366cade4ec187747379 Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
-rw-r--r--drivers/thermal/lmh_interface.c47
1 files changed, 34 insertions, 13 deletions
diff --git a/drivers/thermal/lmh_interface.c b/drivers/thermal/lmh_interface.c
index ce3854cba1c5..5266a4e64914 100644
--- a/drivers/thermal/lmh_interface.c
+++ b/drivers/thermal/lmh_interface.c
@@ -970,23 +970,44 @@ static ssize_t lmh_dbgfs_config_write(struct file *file,
static int lmh_dbgfs_data_read(struct seq_file *seq_fp, void *data)
{
- uint32_t *read_buf = NULL;
- int ret = 0, i = 0;
-
- ret = lmh_mon_data->debug_ops->debug_read(lmh_mon_data->debug_ops,
- &read_buf);
- if (ret <= 0 || !read_buf)
- goto dfs_read_exit;
+ static uint32_t *read_buf;
+ static int read_buf_size;
+ int idx = 0, ret = 0, print_ret = 0;
+
+ if (!read_buf_size) {
+ ret = lmh_mon_data->debug_ops->debug_read(
+ lmh_mon_data->debug_ops, &read_buf);
+ if (ret <= 0)
+ goto dfs_read_exit;
+ if (!read_buf || ret < sizeof(uint32_t)) {
+ ret = -EINVAL;
+ goto dfs_read_exit;
+ }
+ read_buf_size = ret;
+ ret = 0;
+ }
do {
- seq_printf(seq_fp, "0x%x ", read_buf[i]);
- i++;
- if ((i % LMH_READ_LINE_LENGTH) == 0)
- seq_puts(seq_fp, "\n");
- } while (i < (ret / sizeof(uint32_t)));
+ print_ret = seq_printf(seq_fp, "0x%x ", read_buf[idx]);
+ if (print_ret) {
+ pr_err("Seq print error. idx:%d err:%d\n",
+ idx, print_ret);
+ goto dfs_read_exit;
+ }
+ idx++;
+ if ((idx % LMH_READ_LINE_LENGTH) == 0) {
+ print_ret = seq_puts(seq_fp, "\n");
+ if (print_ret) {
+ pr_err("Seq print error. err:%d\n", print_ret);
+ goto dfs_read_exit;
+ }
+ }
+ } while (idx < (read_buf_size / sizeof(uint32_t)));
+ read_buf_size = 0;
+ read_buf = NULL;
dfs_read_exit:
- return (ret < 0) ? ret : 0;
+ return ret;
}
static ssize_t lmh_dbgfs_data_write(struct file *file,