| .. | .. |
|---|
| 8 | 8 | #include <linux/uaccess.h> |
|---|
| 9 | 9 | #include <linux/debugfs.h> |
|---|
| 10 | 10 | #include <linux/module.h> |
|---|
| 11 | +#include <linux/vmalloc.h> |
|---|
| 11 | 12 | |
|---|
| 12 | 13 | #include "qedf.h" |
|---|
| 13 | 14 | #include "qedf_dbg.h" |
|---|
| .. | .. |
|---|
| 98 | 99 | qedf_dbg_fp_int_cmd_read(struct file *filp, char __user *buffer, size_t count, |
|---|
| 99 | 100 | loff_t *ppos) |
|---|
| 100 | 101 | { |
|---|
| 102 | + ssize_t ret; |
|---|
| 101 | 103 | size_t cnt = 0; |
|---|
| 104 | + char *cbuf; |
|---|
| 102 | 105 | int id; |
|---|
| 103 | 106 | struct qedf_fastpath *fp = NULL; |
|---|
| 104 | 107 | struct qedf_dbg_ctx *qedf_dbg = |
|---|
| .. | .. |
|---|
| 108 | 111 | |
|---|
| 109 | 112 | QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "entered\n"); |
|---|
| 110 | 113 | |
|---|
| 111 | | - cnt = sprintf(buffer, "\nFastpath I/O completions\n\n"); |
|---|
| 114 | + cbuf = vmalloc(QEDF_DEBUGFS_LOG_LEN); |
|---|
| 115 | + if (!cbuf) |
|---|
| 116 | + return 0; |
|---|
| 117 | + |
|---|
| 118 | + cnt += scnprintf(cbuf + cnt, QEDF_DEBUGFS_LOG_LEN - cnt, "\nFastpath I/O completions\n\n"); |
|---|
| 112 | 119 | |
|---|
| 113 | 120 | for (id = 0; id < qedf->num_queues; id++) { |
|---|
| 114 | 121 | fp = &(qedf->fp_array[id]); |
|---|
| 115 | 122 | if (fp->sb_id == QEDF_SB_ID_NULL) |
|---|
| 116 | 123 | continue; |
|---|
| 117 | | - cnt += sprintf((buffer + cnt), "#%d: %lu\n", id, |
|---|
| 118 | | - fp->completions); |
|---|
| 124 | + cnt += scnprintf(cbuf + cnt, QEDF_DEBUGFS_LOG_LEN - cnt, |
|---|
| 125 | + "#%d: %lu\n", id, fp->completions); |
|---|
| 119 | 126 | } |
|---|
| 120 | 127 | |
|---|
| 121 | | - cnt = min_t(int, count, cnt - *ppos); |
|---|
| 122 | | - *ppos += cnt; |
|---|
| 123 | | - return cnt; |
|---|
| 128 | + ret = simple_read_from_buffer(buffer, count, ppos, cbuf, cnt); |
|---|
| 129 | + |
|---|
| 130 | + vfree(cbuf); |
|---|
| 131 | + |
|---|
| 132 | + return ret; |
|---|
| 124 | 133 | } |
|---|
| 125 | 134 | |
|---|
| 126 | 135 | static ssize_t |
|---|
| .. | .. |
|---|
| 138 | 147 | loff_t *ppos) |
|---|
| 139 | 148 | { |
|---|
| 140 | 149 | int cnt; |
|---|
| 150 | + char cbuf[32]; |
|---|
| 141 | 151 | struct qedf_dbg_ctx *qedf_dbg = |
|---|
| 142 | 152 | (struct qedf_dbg_ctx *)filp->private_data; |
|---|
| 143 | 153 | |
|---|
| 144 | 154 | QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "debug mask=0x%x\n", qedf_debug); |
|---|
| 145 | | - cnt = sprintf(buffer, "debug mask = 0x%x\n", qedf_debug); |
|---|
| 155 | + cnt = scnprintf(cbuf, sizeof(cbuf), "debug mask = 0x%x\n", qedf_debug); |
|---|
| 146 | 156 | |
|---|
| 147 | | - cnt = min_t(int, count, cnt - *ppos); |
|---|
| 148 | | - *ppos += cnt; |
|---|
| 149 | | - return cnt; |
|---|
| 157 | + return simple_read_from_buffer(buffer, count, ppos, cbuf, cnt); |
|---|
| 150 | 158 | } |
|---|
| 151 | 159 | |
|---|
| 152 | 160 | static ssize_t |
|---|
| .. | .. |
|---|
| 185 | 193 | size_t count, loff_t *ppos) |
|---|
| 186 | 194 | { |
|---|
| 187 | 195 | int cnt; |
|---|
| 196 | + char cbuf[7]; |
|---|
| 188 | 197 | struct qedf_dbg_ctx *qedf_dbg = |
|---|
| 189 | 198 | (struct qedf_dbg_ctx *)filp->private_data; |
|---|
| 190 | 199 | struct qedf_ctx *qedf = container_of(qedf_dbg, |
|---|
| 191 | 200 | struct qedf_ctx, dbg_ctx); |
|---|
| 192 | 201 | |
|---|
| 193 | 202 | QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "entered\n"); |
|---|
| 194 | | - cnt = sprintf(buffer, "%s\n", |
|---|
| 203 | + cnt = scnprintf(cbuf, sizeof(cbuf), "%s\n", |
|---|
| 195 | 204 | qedf->stop_io_on_error ? "true" : "false"); |
|---|
| 196 | 205 | |
|---|
| 197 | | - cnt = min_t(int, count, cnt - *ppos); |
|---|
| 198 | | - *ppos += cnt; |
|---|
| 199 | | - return cnt; |
|---|
| 206 | + return simple_read_from_buffer(buffer, count, ppos, cbuf, cnt); |
|---|
| 200 | 207 | } |
|---|
| 201 | 208 | |
|---|
| 202 | 209 | static ssize_t |
|---|