aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/batman-adv/bat_debugfs.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/net/batman-adv/bat_debugfs.c b/net/batman-adv/bat_debugfs.c
index db7b9bf895aa..acf33e265f9c 100644
--- a/net/batman-adv/bat_debugfs.c
+++ b/net/batman-adv/bat_debugfs.c
@@ -36,13 +36,21 @@ static struct dentry *batadv_debugfs;
36 36
37#ifdef CONFIG_BATMAN_ADV_DEBUG 37#ifdef CONFIG_BATMAN_ADV_DEBUG
38#define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1) 38#define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1)
39#define BATADV_LOG_BUFF(idx) (debug_log->log_buff[(idx) & BATADV_LOG_BUFF_MASK])
40 39
41static int batadv_log_buff_len = BATADV_LOG_BUF_LEN; 40static const int batadv_log_buff_len = BATADV_LOG_BUF_LEN;
41
42static char *batadv_log_char_addr(struct batadv_debug_log *debug_log,
43 size_t idx)
44{
45 return &debug_log->log_buff[idx & BATADV_LOG_BUFF_MASK];
46}
42 47
43static void batadv_emit_log_char(struct batadv_debug_log *debug_log, char c) 48static void batadv_emit_log_char(struct batadv_debug_log *debug_log, char c)
44{ 49{
45 BATADV_LOG_BUFF(debug_log->log_end) = c; 50 char *char_addr;
51
52 char_addr = batadv_log_char_addr(debug_log, debug_log->log_end);
53 *char_addr = c;
46 debug_log->log_end++; 54 debug_log->log_end++;
47 55
48 if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len) 56 if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len)
@@ -109,6 +117,7 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf,
109 struct batadv_priv *bat_priv = file->private_data; 117 struct batadv_priv *bat_priv = file->private_data;
110 struct batadv_debug_log *debug_log = bat_priv->debug_log; 118 struct batadv_debug_log *debug_log = bat_priv->debug_log;
111 int error, i = 0; 119 int error, i = 0;
120 char *char_addr;
112 char c; 121 char c;
113 122
114 if ((file->f_flags & O_NONBLOCK) && 123 if ((file->f_flags & O_NONBLOCK) &&
@@ -134,7 +143,9 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf,
134 143
135 while ((!error) && (i < count) && 144 while ((!error) && (i < count) &&
136 (debug_log->log_start != debug_log->log_end)) { 145 (debug_log->log_start != debug_log->log_end)) {
137 c = BATADV_LOG_BUFF(debug_log->log_start); 146 char_addr = batadv_log_char_addr(debug_log,
147 debug_log->log_start);
148 c = *char_addr;
138 149
139 debug_log->log_start++; 150 debug_log->log_start++;
140 151