2 * Copyright 2012 Hauke Mehrtens <hauke@hauke-m.de>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * Compatibility file for Linux wireless for kernels 3.1.
11 #ifndef CONFIG_COMPAT_SLES_11_3
12 #if ! defined(RHEL_MINOR) || (RHEL_MINOR < 3)
13 #include <linux/idr.h>
15 static DEFINE_SPINLOCK(simple_ida_lock);
18 * ida_simple_get - get a new id.
19 * @ida: the (initialized) ida.
20 * @start: the minimum id (inclusive, < 0x8000000)
21 * @end: the maximum id (exclusive, < 0x8000000 or 0)
22 * @gfp_mask: memory allocation flags
24 * Allocates an id in the range start <= id < end, or returns -ENOSPC.
25 * On memory allocation failure, returns -ENOMEM.
27 * Use ida_simple_remove() to get rid of an id.
29 int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end,
36 BUG_ON((int)start < 0);
47 if (!ida_pre_get(ida, gfp_mask))
50 spin_lock_irqsave(&simple_ida_lock, flags);
51 ret = ida_get_new_above(ida, start, &id);
60 spin_unlock_irqrestore(&simple_ida_lock, flags);
62 if (unlikely(ret == -EAGAIN))
67 EXPORT_SYMBOL(ida_simple_get);
70 * ida_simple_remove - remove an allocated id.
71 * @ida: the (initialized) ida.
72 * @id: the id returned by ida_simple_get.
74 void ida_simple_remove(struct ida *ida, unsigned int id)
79 spin_lock_irqsave(&simple_ida_lock, flags);
81 spin_unlock_irqrestore(&simple_ida_lock, flags);
83 EXPORT_SYMBOL(ida_simple_remove);
84 /* source lib/idr.c */
86 #endif /* CONFIG_COMPAT_SLES_11_3 */