35 static struct dentry *batadv_debugfs;
37 #ifdef CONFIG_BATMAN_ADV_DEBUG
38 #define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1)
45 return &debug_log->
log_buff[idx & BATADV_LOG_BUFF_MASK];
52 char_addr = batadv_log_char_addr(debug_log, debug_log->
log_end);
65 static char debug_log_buf[256];
71 spin_lock_bh(&debug_log->lock);
73 vscnprintf(debug_log_buf,
sizeof(debug_log_buf), fmt, args);
76 for (p = debug_log_buf; *p != 0; p++)
77 batadv_emit_log_char(debug_log, *p);
79 spin_unlock_bh(&debug_log->lock);
81 wake_up(&debug_log->queue_wait);
89 char tmp_log_buf[256];
92 vscnprintf(tmp_log_buf,
sizeof(tmp_log_buf), fmt, args);
93 batadv_fdebug_log(bat_priv->
debug_log,
"[%10u] %s",
120 size_t count, loff_t *ppos)
141 (!batadv_log_empty(debug_log)));
146 spin_lock_bh(&debug_log->
lock);
148 while ((!error) && (i < count) &&
150 char_addr = batadv_log_char_addr(debug_log,
156 spin_unlock_bh(&debug_log->
lock);
160 spin_lock_bh(&debug_log->
lock);
167 spin_unlock_bh(&debug_log->
lock);
175 static unsigned int batadv_log_poll(
struct file *file,
poll_table *
wait)
180 poll_wait(file, &debug_log->
queue_wait, wait);
182 if (!batadv_log_empty(debug_log))
189 .
open = batadv_log_open,
190 .release = batadv_log_release,
191 .read = batadv_log_read,
192 .poll = batadv_log_poll,
196 static int batadv_debug_log_setup(
struct batadv_priv *bat_priv)
222 static void batadv_debug_log_cleanup(
struct batadv_priv *bat_priv)
228 static int batadv_debug_log_setup(
struct batadv_priv *bat_priv)
234 static void batadv_debug_log_cleanup(
struct batadv_priv *bat_priv)
240 static int batadv_algorithms_open(
struct inode *
inode,
struct file *file)
245 static int batadv_originators_open(
struct inode *
inode,
struct file *file)
251 static int batadv_gateways_open(
struct inode *inode,
struct file *file)
257 static int batadv_transtable_global_open(
struct inode *inode,
struct file *file)
263 #ifdef CONFIG_BATMAN_ADV_BLA
264 static int batadv_bla_claim_table_open(
struct inode *inode,
struct file *file)
271 static int batadv_bla_backbone_table_open(
struct inode *inode,
281 static int batadv_transtable_local_open(
struct inode *inode,
struct file *file)
287 static int batadv_vis_data_open(
struct inode *inode,
struct file *file)
298 #define BATADV_DEBUGINFO(_name, _mode, _open) \
299 struct batadv_debuginfo batadv_debuginfo_##_name = { \
300 .attr = { .name = __stringify(_name), \
302 .fops = { .owner = THIS_MODULE, \
305 .llseek = seq_lseek, \
306 .release = single_release, \
314 batadv_transtable_global_open);
315 #ifdef CONFIG_BATMAN_ADV_BLA
318 batadv_bla_backbone_table_open);
321 batadv_transtable_local_open);
325 &batadv_debuginfo_originators,
326 &batadv_debuginfo_gateways,
327 &batadv_debuginfo_transtable_global,
328 #ifdef CONFIG_BATMAN_ADV_BLA
329 &batadv_debuginfo_bla_claim_table,
330 &batadv_debuginfo_bla_backbone_table,
332 &batadv_debuginfo_transtable_local,
333 &batadv_debuginfo_vis_data,
343 if (batadv_debugfs == ERR_PTR(-
ENODEV))
344 batadv_debugfs =
NULL;
349 bat_debug = &batadv_debuginfo_routing_algos;
352 batadv_debugfs,
NULL, &bat_debug->
fops);
354 pr_err(
"Can't add debugfs file: %s\n", bat_debug->
attr.name);
362 if (batadv_debugfs) {
364 batadv_debugfs =
NULL;
384 if (batadv_debug_log_setup(bat_priv) < 0)
387 for (bat_debug = batadv_mesh_debuginfos; *bat_debug; ++bat_debug) {
389 S_IFREG | ((*bat_debug)->attr).mode,
391 dev, &(*bat_debug)->fops);
393 batadv_err(dev,
"Can't add debugfs file: %s/%s\n",
394 dev->
name, ((*bat_debug)->attr).name);
404 #ifdef CONFIG_DEBUG_FS
415 batadv_debug_log_cleanup(bat_priv);
417 if (batadv_debugfs) {