diff options
Diffstat (limited to 'lib/idr.c')
-rw-r--r-- | lib/idr.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -767,8 +767,8 @@ EXPORT_SYMBOL(ida_pre_get); | |||
767 | * @starting_id: id to start search at | 767 | * @starting_id: id to start search at |
768 | * @p_id: pointer to the allocated handle | 768 | * @p_id: pointer to the allocated handle |
769 | * | 769 | * |
770 | * Allocate new ID above or equal to @ida. It should be called with | 770 | * Allocate new ID above or equal to @starting_id. It should be called |
771 | * any required locks. | 771 | * with any required locks. |
772 | * | 772 | * |
773 | * If memory is required, it will return %-EAGAIN, you should unlock | 773 | * If memory is required, it will return %-EAGAIN, you should unlock |
774 | * and go back to the ida_pre_get() call. If the ida is full, it will | 774 | * and go back to the ida_pre_get() call. If the ida is full, it will |
@@ -860,7 +860,7 @@ EXPORT_SYMBOL(ida_get_new_above); | |||
860 | * and go back to the idr_pre_get() call. If the idr is full, it will | 860 | * and go back to the idr_pre_get() call. If the idr is full, it will |
861 | * return %-ENOSPC. | 861 | * return %-ENOSPC. |
862 | * | 862 | * |
863 | * @id returns a value in the range %0 ... %0x7fffffff. | 863 | * @p_id returns a value in the range %0 ... %0x7fffffff. |
864 | */ | 864 | */ |
865 | int ida_get_new(struct ida *ida, int *p_id) | 865 | int ida_get_new(struct ida *ida, int *p_id) |
866 | { | 866 | { |
@@ -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 | */ |
986 | void ida_simple_remove(struct ida *ida, unsigned int id) | 987 | void 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 | } |
993 | EXPORT_SYMBOL(ida_simple_remove); | 996 | EXPORT_SYMBOL(ida_simple_remove); |
994 | 997 | ||