diff options
Diffstat (limited to 'net/batman-adv/debugfs.c')
-rw-r--r-- | net/batman-adv/debugfs.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c index e45cf0e884cc..34fbb1667bcd 100644 --- a/net/batman-adv/debugfs.c +++ b/net/batman-adv/debugfs.c | |||
@@ -111,6 +111,11 @@ static int batadv_log_release(struct inode *inode, struct file *file) | |||
111 | return 0; | 111 | return 0; |
112 | } | 112 | } |
113 | 113 | ||
114 | static int batadv_log_empty(struct batadv_debug_log *debug_log) | ||
115 | { | ||
116 | return !(debug_log->log_start - debug_log->log_end); | ||
117 | } | ||
118 | |||
114 | static ssize_t batadv_log_read(struct file *file, char __user *buf, | 119 | static ssize_t batadv_log_read(struct file *file, char __user *buf, |
115 | size_t count, loff_t *ppos) | 120 | size_t count, loff_t *ppos) |
116 | { | 121 | { |
@@ -120,8 +125,7 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf, | |||
120 | char *char_addr; | 125 | char *char_addr; |
121 | char c; | 126 | char c; |
122 | 127 | ||
123 | if ((file->f_flags & O_NONBLOCK) && | 128 | if ((file->f_flags & O_NONBLOCK) && batadv_log_empty(debug_log)) |
124 | !(debug_log->log_end - debug_log->log_start)) | ||
125 | return -EAGAIN; | 129 | return -EAGAIN; |
126 | 130 | ||
127 | if (!buf) | 131 | if (!buf) |
@@ -134,7 +138,7 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf, | |||
134 | return -EFAULT; | 138 | return -EFAULT; |
135 | 139 | ||
136 | error = wait_event_interruptible(debug_log->queue_wait, | 140 | error = wait_event_interruptible(debug_log->queue_wait, |
137 | (debug_log->log_start - debug_log->log_end)); | 141 | (!batadv_log_empty(debug_log))); |
138 | 142 | ||
139 | if (error) | 143 | if (error) |
140 | return error; | 144 | return error; |
@@ -175,7 +179,7 @@ static unsigned int batadv_log_poll(struct file *file, poll_table *wait) | |||
175 | 179 | ||
176 | poll_wait(file, &debug_log->queue_wait, wait); | 180 | poll_wait(file, &debug_log->queue_wait, wait); |
177 | 181 | ||
178 | if (debug_log->log_end - debug_log->log_start) | 182 | if (!batadv_log_empty(debug_log)) |
179 | return POLLIN | POLLRDNORM; | 183 | return POLLIN | POLLRDNORM; |
180 | 184 | ||
181 | return 0; | 185 | return 0; |
@@ -370,9 +374,9 @@ int batadv_debugfs_add_meshif(struct net_device *dev) | |||
370 | 374 | ||
371 | for (bat_debug = batadv_mesh_debuginfos; *bat_debug; ++bat_debug) { | 375 | for (bat_debug = batadv_mesh_debuginfos; *bat_debug; ++bat_debug) { |
372 | file = debugfs_create_file(((*bat_debug)->attr).name, | 376 | file = debugfs_create_file(((*bat_debug)->attr).name, |
373 | S_IFREG | ((*bat_debug)->attr).mode, | 377 | S_IFREG | ((*bat_debug)->attr).mode, |
374 | bat_priv->debug_dir, | 378 | bat_priv->debug_dir, |
375 | dev, &(*bat_debug)->fops); | 379 | dev, &(*bat_debug)->fops); |
376 | if (!file) { | 380 | if (!file) { |
377 | batadv_err(dev, "Can't add debugfs file: %s/%s\n", | 381 | batadv_err(dev, "Can't add debugfs file: %s/%s\n", |
378 | dev->name, ((*bat_debug)->attr).name); | 382 | dev->name, ((*bat_debug)->attr).name); |