aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2011-11-02 13:38:46 -0700
committerZiyan <jaraidaniel@gmail.com>2016-01-08 10:36:49 +0100
commitfa515fd57674cb6501ac4e1ee34d63e2ce239209 (patch)
tree65c227d0271b023118bb7e41497f5d74810c6c4e
parenteb0721b01484f55fa812f888a7442e3fb0ada4e0 (diff)
downloadkernel_samsung_tuna-fa515fd57674cb6501ac4e1ee34d63e2ce239209.zip
kernel_samsung_tuna-fa515fd57674cb6501ac4e1ee34d63e2ce239209.tar.gz
kernel_samsung_tuna-fa515fd57674cb6501ac4e1ee34d63e2ce239209.tar.bz2
ida: make ida_simple_get/put() IRQ safe
It's often convenient to be able to release resource from IRQ context. Make ida_simple_*() use irqsave/restore spin ops so that they are IRQ safe. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--lib/idr.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/idr.c b/lib/idr.c
index 07cb4c80..f87af03 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -951,6 +951,7 @@ int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end,
{
int ret, id;
unsigned int max;
+ unsigned long flags;
BUG_ON((int)start < 0);
BUG_ON((int)end < 0);
@@ -966,7 +967,7 @@ again:
if (!ida_pre_get(ida, gfp_mask))
return -ENOMEM;
- spin_lock(&simple_ida_lock);
+ spin_lock_irqsave(&simple_ida_lock, flags);
ret = ida_get_new_above(ida, start, &id);
if (!ret) {
if (id > max) {
@@ -976,7 +977,7 @@ again:
ret = id;
}
}
- spin_unlock(&simple_ida_lock);
+ spin_unlock_irqrestore(&simple_ida_lock, flags);
if (unlikely(ret == -EAGAIN))
goto again;
@@ -992,10 +993,12 @@ EXPORT_SYMBOL(ida_simple_get);
*/
void ida_simple_remove(struct ida *ida, unsigned int id)
{
+ unsigned long flags;
+
BUG_ON((int)id < 0);
- spin_lock(&simple_ida_lock);
+ spin_lock_irqsave(&simple_ida_lock, flags);
ida_remove(ida, id);
- spin_unlock(&simple_ida_lock);
+ spin_unlock_irqrestore(&simple_ida_lock, flags);
}
EXPORT_SYMBOL(ida_simple_remove);