aboutsummaryrefslogtreecommitdiffstats
path: root/lib/idr.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/idr.c')
-rw-r--r--lib/idr.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/idr.c b/lib/idr.c
index bbf211aea4eb..ed055b297c81 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -944,6 +944,7 @@ int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end,
944{ 944{
945 int ret, id; 945 int ret, id;
946 unsigned int max; 946 unsigned int max;
947 unsigned long flags;
947 948
948 BUG_ON((int)start < 0); 949 BUG_ON((int)start < 0);
949 BUG_ON((int)end < 0); 950 BUG_ON((int)end < 0);
@@ -959,7 +960,7 @@ again:
959 if (!ida_pre_get(ida, gfp_mask)) 960 if (!ida_pre_get(ida, gfp_mask))
960 return -ENOMEM; 961 return -ENOMEM;
961 962
962 spin_lock(&simple_ida_lock); 963 spin_lock_irqsave(&simple_ida_lock, flags);
963 ret = ida_get_new_above(ida, start, &id); 964 ret = ida_get_new_above(ida, start, &id);
964 if (!ret) { 965 if (!ret) {
965 if (id > max) { 966 if (id > max) {
@@ -969,7 +970,7 @@ again:
969 ret = id; 970 ret = id;
970 } 971 }
971 } 972 }
972 spin_unlock(&simple_ida_lock); 973 spin_unlock_irqrestore(&simple_ida_lock, flags);
973 974
974 if (unlikely(ret == -EAGAIN)) 975 if (unlikely(ret == -EAGAIN))
975 goto again; 976 goto again;
@@ -985,10 +986,12 @@ EXPORT_SYMBOL(ida_simple_get);
985 */ 986 */
986void ida_simple_remove(struct ida *ida, unsigned int id) 987void ida_simple_remove(struct ida *ida, unsigned int id)
987{ 988{
989 unsigned long flags;
990
988 BUG_ON((int)id < 0); 991 BUG_ON((int)id < 0);
989 spin_lock(&simple_ida_lock); 992 spin_lock_irqsave(&simple_ida_lock, flags);
990 ida_remove(ida, id); 993 ida_remove(ida, id);
991 spin_unlock(&simple_ida_lock); 994 spin_unlock_irqrestore(&simple_ida_lock, flags);
992} 995}
993EXPORT_SYMBOL(ida_simple_remove); 996EXPORT_SYMBOL(ida_simple_remove);
994 997