summaryrefslogtreecommitdiff
path: root/drivers/staging/batman-adv/bat_debugfs.c
diff options
context:
space:
mode:
authorSven Eckelmann <sven.eckelmann@gmx.de>2010-11-21 23:56:01 (GMT)
committerGreg Kroah-Hartman <gregkh@suse.de>2010-11-29 19:09:13 (GMT)
commit7a18deb7b03e4112af5add8498889f9b2b36d59f (patch)
tree5981a5f191de7268371120a2b700bfcf8aa33809 /drivers/staging/batman-adv/bat_debugfs.c
parentbd204952cf161404eae0aa6478fb1b4c586ac678 (diff)
downloadlinux-fsl-qoriq-7a18deb7b03e4112af5add8498889f9b2b36d59f.tar.xz
Staging: batman-adv: Limit spin_locks to spin_lock_bh
spin_lock_irqsave disables the IRQs and stores them inside the flags provided by the caller. This is needed to protect a bottom half handler or a user context critical section from being interrupted by an interrupt handler which also tries to acquire the spinlock and locks forever. The linux device drivers will receive the packets inside an interrupt handler and the network infrastructure will process them inside bottom half. Thus batman-adv will only run in user context and bottom half handlers. We can conclude that batman-adv doesn't share its own spinlocks with real interrupt handlers. This makes it possible to exchange the quite complex spin_lock_irqsave with spin_lock_bh which only stops bottom halves from running on the current cpu, but allows interrupt handlers to take over to keep the interrupt latency low. Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/batman-adv/bat_debugfs.c')
-rw-r--r--drivers/staging/batman-adv/bat_debugfs.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/staging/batman-adv/bat_debugfs.c b/drivers/staging/batman-adv/bat_debugfs.c
index 22f3eb9..cbac1a5 100644
--- a/drivers/staging/batman-adv/bat_debugfs.c
+++ b/drivers/staging/batman-adv/bat_debugfs.c
@@ -54,12 +54,11 @@ static int fdebug_log(struct debug_log *debug_log, char *fmt, ...)
va_list args;
static char debug_log_buf[256];
char *p;
- unsigned long flags;
if (!debug_log)
return 0;
- spin_lock_irqsave(&debug_log->lock, flags);
+ spin_lock_bh(&debug_log->lock);
va_start(args, fmt);
printed_len = vscnprintf(debug_log_buf, sizeof(debug_log_buf),
fmt, args);
@@ -68,7 +67,7 @@ static int fdebug_log(struct debug_log *debug_log, char *fmt, ...)
for (p = debug_log_buf; *p != 0; p++)
emit_log_char(debug_log, *p);
- spin_unlock_irqrestore(&debug_log->lock, flags);
+ spin_unlock_bh(&debug_log->lock);
wake_up(&debug_log->queue_wait);
@@ -110,7 +109,6 @@ static ssize_t log_read(struct file *file, char __user *buf,
struct debug_log *debug_log = bat_priv->debug_log;
int error, i = 0;
char c;
- unsigned long flags;
if ((file->f_flags & O_NONBLOCK) &&
!(debug_log->log_end - debug_log->log_start))
@@ -131,7 +129,7 @@ static ssize_t log_read(struct file *file, char __user *buf,
if (error)
return error;
- spin_lock_irqsave(&debug_log->lock, flags);
+ spin_lock_bh(&debug_log->lock);
while ((!error) && (i < count) &&
(debug_log->log_start != debug_log->log_end)) {
@@ -139,18 +137,18 @@ static ssize_t log_read(struct file *file, char __user *buf,
debug_log->log_start++;
- spin_unlock_irqrestore(&debug_log->lock, flags);
+ spin_unlock_bh(&debug_log->lock);
error = __put_user(c, buf);
- spin_lock_irqsave(&debug_log->lock, flags);
+ spin_lock_bh(&debug_log->lock);
buf++;
i++;
}
- spin_unlock_irqrestore(&debug_log->lock, flags);
+ spin_unlock_bh(&debug_log->lock);
if (!error)
return i;