diff options
-rw-r--r-- | drivers/i2c/i2c-core.c | 2 | ||||
-rw-r--r-- | drivers/infiniband/core/cm.c | 2 | ||||
-rw-r--r-- | drivers/infiniband/hw/mlx4/cm.c | 2 | ||||
-rw-r--r-- | drivers/pps/pps.c | 2 | ||||
-rw-r--r-- | drivers/thermal/thermal_sys.c | 2 | ||||
-rw-r--r-- | fs/super.c | 2 | ||||
-rw-r--r-- | include/linux/idr.h | 10 | ||||
-rw-r--r-- | lib/idr.c | 32 |
8 files changed, 27 insertions, 27 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 2091ae8f539a..2421d95130d4 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -982,7 +982,7 @@ int i2c_add_numbered_adapter(struct i2c_adapter *adap) | |||
982 | 982 | ||
983 | if (adap->nr == -1) /* -1 means dynamically assign bus id */ | 983 | if (adap->nr == -1) /* -1 means dynamically assign bus id */ |
984 | return i2c_add_adapter(adap); | 984 | return i2c_add_adapter(adap); |
985 | if (adap->nr & ~MAX_ID_MASK) | 985 | if (adap->nr & ~MAX_IDR_MASK) |
986 | return -EINVAL; | 986 | return -EINVAL; |
987 | 987 | ||
988 | retry: | 988 | retry: |
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index d67999f6e34a..394fea2ba1bc 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c | |||
@@ -390,7 +390,7 @@ static int cm_alloc_id(struct cm_id_private *cm_id_priv) | |||
390 | ret = idr_get_new_above(&cm.local_id_table, cm_id_priv, | 390 | ret = idr_get_new_above(&cm.local_id_table, cm_id_priv, |
391 | next_id, &id); | 391 | next_id, &id); |
392 | if (!ret) | 392 | if (!ret) |
393 | next_id = ((unsigned) id + 1) & MAX_ID_MASK; | 393 | next_id = ((unsigned) id + 1) & MAX_IDR_MASK; |
394 | spin_unlock_irqrestore(&cm.lock, flags); | 394 | spin_unlock_irqrestore(&cm.lock, flags); |
395 | } while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) ); | 395 | } while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) ); |
396 | 396 | ||
diff --git a/drivers/infiniband/hw/mlx4/cm.c b/drivers/infiniband/hw/mlx4/cm.c index e25e4dafb8a8..80079e5a2e30 100644 --- a/drivers/infiniband/hw/mlx4/cm.c +++ b/drivers/infiniband/hw/mlx4/cm.c | |||
@@ -225,7 +225,7 @@ id_map_alloc(struct ib_device *ibdev, int slave_id, u32 sl_cm_id) | |||
225 | ret = idr_get_new_above(&sriov->pv_id_table, ent, | 225 | ret = idr_get_new_above(&sriov->pv_id_table, ent, |
226 | next_id, &id); | 226 | next_id, &id); |
227 | if (!ret) { | 227 | if (!ret) { |
228 | next_id = ((unsigned) id + 1) & MAX_ID_MASK; | 228 | next_id = ((unsigned) id + 1) & MAX_IDR_MASK; |
229 | ent->pv_cm_id = (u32)id; | 229 | ent->pv_cm_id = (u32)id; |
230 | sl_id_map_add(ibdev, ent); | 230 | sl_id_map_add(ibdev, ent); |
231 | } | 231 | } |
diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c index e771487132f7..2420d5af0583 100644 --- a/drivers/pps/pps.c +++ b/drivers/pps/pps.c | |||
@@ -306,7 +306,7 @@ int pps_register_cdev(struct pps_device *pps) | |||
306 | if (err < 0) | 306 | if (err < 0) |
307 | return err; | 307 | return err; |
308 | 308 | ||
309 | pps->id &= MAX_ID_MASK; | 309 | pps->id &= MAX_IDR_MASK; |
310 | if (pps->id >= PPS_MAX_SOURCES) { | 310 | if (pps->id >= PPS_MAX_SOURCES) { |
311 | pr_err("%s: too many PPS sources in the system\n", | 311 | pr_err("%s: too many PPS sources in the system\n", |
312 | pps->info.name); | 312 | pps->info.name); |
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 67789b8345d2..efd81bb25e01 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c | |||
@@ -78,7 +78,7 @@ again: | |||
78 | else if (unlikely(err)) | 78 | else if (unlikely(err)) |
79 | return err; | 79 | return err; |
80 | 80 | ||
81 | *id = *id & MAX_ID_MASK; | 81 | *id = *id & MAX_IDR_MASK; |
82 | return 0; | 82 | return 0; |
83 | } | 83 | } |
84 | 84 | ||
diff --git a/fs/super.c b/fs/super.c index 5fdf7ff32c4e..a3bc935069d9 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -865,7 +865,7 @@ int get_anon_bdev(dev_t *p) | |||
865 | else if (error) | 865 | else if (error) |
866 | return -EAGAIN; | 866 | return -EAGAIN; |
867 | 867 | ||
868 | if ((dev & MAX_ID_MASK) == (1 << MINORBITS)) { | 868 | if ((dev & MAX_IDR_MASK) == (1 << MINORBITS)) { |
869 | spin_lock(&unnamed_dev_lock); | 869 | spin_lock(&unnamed_dev_lock); |
870 | ida_remove(&unnamed_dev_ida, dev); | 870 | ida_remove(&unnamed_dev_ida, dev); |
871 | if (unnamed_dev_start > dev) | 871 | if (unnamed_dev_start > dev) |
diff --git a/include/linux/idr.h b/include/linux/idr.h index 255491cf522e..87259a44c251 100644 --- a/include/linux/idr.h +++ b/include/linux/idr.h | |||
@@ -38,15 +38,15 @@ | |||
38 | #define IDR_SIZE (1 << IDR_BITS) | 38 | #define IDR_SIZE (1 << IDR_BITS) |
39 | #define IDR_MASK ((1 << IDR_BITS)-1) | 39 | #define IDR_MASK ((1 << IDR_BITS)-1) |
40 | 40 | ||
41 | #define MAX_ID_SHIFT (sizeof(int)*8 - 1) | 41 | #define MAX_IDR_SHIFT (sizeof(int)*8 - 1) |
42 | #define MAX_ID_BIT (1U << MAX_ID_SHIFT) | 42 | #define MAX_IDR_BIT (1U << MAX_IDR_SHIFT) |
43 | #define MAX_ID_MASK (MAX_ID_BIT - 1) | 43 | #define MAX_IDR_MASK (MAX_IDR_BIT - 1) |
44 | 44 | ||
45 | /* Leave the possibility of an incomplete final layer */ | 45 | /* Leave the possibility of an incomplete final layer */ |
46 | #define MAX_LEVEL (MAX_ID_SHIFT + IDR_BITS - 1) / IDR_BITS | 46 | #define MAX_IDR_LEVEL ((MAX_IDR_SHIFT + IDR_BITS - 1) / IDR_BITS) |
47 | 47 | ||
48 | /* Number of id_layer structs to leave in free list */ | 48 | /* Number of id_layer structs to leave in free list */ |
49 | #define IDR_FREE_MAX MAX_LEVEL + MAX_LEVEL | 49 | #define MAX_IDR_FREE (MAX_IDR_LEVEL * 2) |
50 | 50 | ||
51 | struct idr_layer { | 51 | struct idr_layer { |
52 | unsigned long bitmap; /* A zero bit means "space here" */ | 52 | unsigned long bitmap; /* A zero bit means "space here" */ |
@@ -20,7 +20,7 @@ | |||
20 | * that id to this code and it returns your pointer. | 20 | * that id to this code and it returns your pointer. |
21 | 21 | ||
22 | * You can release ids at any time. When all ids are released, most of | 22 | * You can release ids at any time. When all ids are released, most of |
23 | * the memory is returned (we keep IDR_FREE_MAX) in a local pool so we | 23 | * the memory is returned (we keep MAX_IDR_FREE) in a local pool so we |
24 | * don't need to go to the memory "store" during an id allocate, just | 24 | * don't need to go to the memory "store" during an id allocate, just |
25 | * so you don't need to be too concerned about locking and conflicts | 25 | * so you don't need to be too concerned about locking and conflicts |
26 | * with the slab allocator. | 26 | * with the slab allocator. |
@@ -122,7 +122,7 @@ static void idr_mark_full(struct idr_layer **pa, int id) | |||
122 | */ | 122 | */ |
123 | int idr_pre_get(struct idr *idp, gfp_t gfp_mask) | 123 | int idr_pre_get(struct idr *idp, gfp_t gfp_mask) |
124 | { | 124 | { |
125 | while (idp->id_free_cnt < IDR_FREE_MAX) { | 125 | while (idp->id_free_cnt < MAX_IDR_FREE) { |
126 | struct idr_layer *new; | 126 | struct idr_layer *new; |
127 | new = kmem_cache_zalloc(idr_layer_cache, gfp_mask); | 127 | new = kmem_cache_zalloc(idr_layer_cache, gfp_mask); |
128 | if (new == NULL) | 128 | if (new == NULL) |
@@ -179,7 +179,7 @@ static int sub_alloc(struct idr *idp, int *starting_id, struct idr_layer **pa) | |||
179 | sh = IDR_BITS*l; | 179 | sh = IDR_BITS*l; |
180 | id = ((id >> sh) ^ n ^ m) << sh; | 180 | id = ((id >> sh) ^ n ^ m) << sh; |
181 | } | 181 | } |
182 | if ((id >= MAX_ID_BIT) || (id < 0)) | 182 | if ((id >= MAX_IDR_BIT) || (id < 0)) |
183 | return IDR_NOMORE_SPACE; | 183 | return IDR_NOMORE_SPACE; |
184 | if (l == 0) | 184 | if (l == 0) |
185 | break; | 185 | break; |
@@ -223,7 +223,7 @@ build_up: | |||
223 | * Add a new layer to the top of the tree if the requested | 223 | * Add a new layer to the top of the tree if the requested |
224 | * id is larger than the currently allocated space. | 224 | * id is larger than the currently allocated space. |
225 | */ | 225 | */ |
226 | while ((layers < (MAX_LEVEL - 1)) && (id >= (1 << (layers*IDR_BITS)))) { | 226 | while ((layers < (MAX_IDR_LEVEL - 1)) && (id >= (1 << (layers*IDR_BITS)))) { |
227 | layers++; | 227 | layers++; |
228 | if (!p->count) { | 228 | if (!p->count) { |
229 | /* special case: if the tree is currently empty, | 229 | /* special case: if the tree is currently empty, |
@@ -265,7 +265,7 @@ build_up: | |||
265 | 265 | ||
266 | static int idr_get_new_above_int(struct idr *idp, void *ptr, int starting_id) | 266 | static int idr_get_new_above_int(struct idr *idp, void *ptr, int starting_id) |
267 | { | 267 | { |
268 | struct idr_layer *pa[MAX_LEVEL]; | 268 | struct idr_layer *pa[MAX_IDR_LEVEL]; |
269 | int id; | 269 | int id; |
270 | 270 | ||
271 | id = idr_get_empty_slot(idp, starting_id, pa); | 271 | id = idr_get_empty_slot(idp, starting_id, pa); |
@@ -357,7 +357,7 @@ static void idr_remove_warning(int id) | |||
357 | static void sub_remove(struct idr *idp, int shift, int id) | 357 | static void sub_remove(struct idr *idp, int shift, int id) |
358 | { | 358 | { |
359 | struct idr_layer *p = idp->top; | 359 | struct idr_layer *p = idp->top; |
360 | struct idr_layer **pa[MAX_LEVEL]; | 360 | struct idr_layer **pa[MAX_IDR_LEVEL]; |
361 | struct idr_layer ***paa = &pa[0]; | 361 | struct idr_layer ***paa = &pa[0]; |
362 | struct idr_layer *to_free; | 362 | struct idr_layer *to_free; |
363 | int n; | 363 | int n; |
@@ -402,7 +402,7 @@ void idr_remove(struct idr *idp, int id) | |||
402 | struct idr_layer *to_free; | 402 | struct idr_layer *to_free; |
403 | 403 | ||
404 | /* Mask off upper bits we don't use for the search. */ | 404 | /* Mask off upper bits we don't use for the search. */ |
405 | id &= MAX_ID_MASK; | 405 | id &= MAX_IDR_MASK; |
406 | 406 | ||
407 | sub_remove(idp, (idp->layers - 1) * IDR_BITS, id); | 407 | sub_remove(idp, (idp->layers - 1) * IDR_BITS, id); |
408 | if (idp->top && idp->top->count == 1 && (idp->layers > 1) && | 408 | if (idp->top && idp->top->count == 1 && (idp->layers > 1) && |
@@ -420,7 +420,7 @@ void idr_remove(struct idr *idp, int id) | |||
420 | to_free->bitmap = to_free->count = 0; | 420 | to_free->bitmap = to_free->count = 0; |
421 | free_layer(to_free); | 421 | free_layer(to_free); |
422 | } | 422 | } |
423 | while (idp->id_free_cnt >= IDR_FREE_MAX) { | 423 | while (idp->id_free_cnt >= MAX_IDR_FREE) { |
424 | p = get_from_free_list(idp); | 424 | p = get_from_free_list(idp); |
425 | /* | 425 | /* |
426 | * Note: we don't call the rcu callback here, since the only | 426 | * Note: we don't call the rcu callback here, since the only |
@@ -451,7 +451,7 @@ void idr_remove_all(struct idr *idp) | |||
451 | int n, id, max; | 451 | int n, id, max; |
452 | int bt_mask; | 452 | int bt_mask; |
453 | struct idr_layer *p; | 453 | struct idr_layer *p; |
454 | struct idr_layer *pa[MAX_LEVEL]; | 454 | struct idr_layer *pa[MAX_IDR_LEVEL]; |
455 | struct idr_layer **paa = &pa[0]; | 455 | struct idr_layer **paa = &pa[0]; |
456 | 456 | ||
457 | n = idp->layers * IDR_BITS; | 457 | n = idp->layers * IDR_BITS; |
@@ -517,7 +517,7 @@ void *idr_find(struct idr *idp, int id) | |||
517 | n = (p->layer+1) * IDR_BITS; | 517 | n = (p->layer+1) * IDR_BITS; |
518 | 518 | ||
519 | /* Mask off upper bits we don't use for the search. */ | 519 | /* Mask off upper bits we don't use for the search. */ |
520 | id &= MAX_ID_MASK; | 520 | id &= MAX_IDR_MASK; |
521 | 521 | ||
522 | if (id >= (1 << n)) | 522 | if (id >= (1 << n)) |
523 | return NULL; | 523 | return NULL; |
@@ -555,7 +555,7 @@ int idr_for_each(struct idr *idp, | |||
555 | { | 555 | { |
556 | int n, id, max, error = 0; | 556 | int n, id, max, error = 0; |
557 | struct idr_layer *p; | 557 | struct idr_layer *p; |
558 | struct idr_layer *pa[MAX_LEVEL]; | 558 | struct idr_layer *pa[MAX_IDR_LEVEL]; |
559 | struct idr_layer **paa = &pa[0]; | 559 | struct idr_layer **paa = &pa[0]; |
560 | 560 | ||
561 | n = idp->layers * IDR_BITS; | 561 | n = idp->layers * IDR_BITS; |
@@ -601,7 +601,7 @@ EXPORT_SYMBOL(idr_for_each); | |||
601 | */ | 601 | */ |
602 | void *idr_get_next(struct idr *idp, int *nextidp) | 602 | void *idr_get_next(struct idr *idp, int *nextidp) |
603 | { | 603 | { |
604 | struct idr_layer *p, *pa[MAX_LEVEL]; | 604 | struct idr_layer *p, *pa[MAX_IDR_LEVEL]; |
605 | struct idr_layer **paa = &pa[0]; | 605 | struct idr_layer **paa = &pa[0]; |
606 | int id = *nextidp; | 606 | int id = *nextidp; |
607 | int n, max; | 607 | int n, max; |
@@ -659,7 +659,7 @@ void *idr_replace(struct idr *idp, void *ptr, int id) | |||
659 | 659 | ||
660 | n = (p->layer+1) * IDR_BITS; | 660 | n = (p->layer+1) * IDR_BITS; |
661 | 661 | ||
662 | id &= MAX_ID_MASK; | 662 | id &= MAX_IDR_MASK; |
663 | 663 | ||
664 | if (id >= (1 << n)) | 664 | if (id >= (1 << n)) |
665 | return ERR_PTR(-EINVAL); | 665 | return ERR_PTR(-EINVAL); |
@@ -780,7 +780,7 @@ EXPORT_SYMBOL(ida_pre_get); | |||
780 | */ | 780 | */ |
781 | int ida_get_new_above(struct ida *ida, int starting_id, int *p_id) | 781 | int ida_get_new_above(struct ida *ida, int starting_id, int *p_id) |
782 | { | 782 | { |
783 | struct idr_layer *pa[MAX_LEVEL]; | 783 | struct idr_layer *pa[MAX_IDR_LEVEL]; |
784 | struct ida_bitmap *bitmap; | 784 | struct ida_bitmap *bitmap; |
785 | unsigned long flags; | 785 | unsigned long flags; |
786 | int idr_id = starting_id / IDA_BITMAP_BITS; | 786 | int idr_id = starting_id / IDA_BITMAP_BITS; |
@@ -793,7 +793,7 @@ int ida_get_new_above(struct ida *ida, int starting_id, int *p_id) | |||
793 | if (t < 0) | 793 | if (t < 0) |
794 | return _idr_rc_to_errno(t); | 794 | return _idr_rc_to_errno(t); |
795 | 795 | ||
796 | if (t * IDA_BITMAP_BITS >= MAX_ID_BIT) | 796 | if (t * IDA_BITMAP_BITS >= MAX_IDR_BIT) |
797 | return -ENOSPC; | 797 | return -ENOSPC; |
798 | 798 | ||
799 | if (t != idr_id) | 799 | if (t != idr_id) |
@@ -827,7 +827,7 @@ int ida_get_new_above(struct ida *ida, int starting_id, int *p_id) | |||
827 | } | 827 | } |
828 | 828 | ||
829 | id = idr_id * IDA_BITMAP_BITS + t; | 829 | id = idr_id * IDA_BITMAP_BITS + t; |
830 | if (id >= MAX_ID_BIT) | 830 | if (id >= MAX_IDR_BIT) |
831 | return -ENOSPC; | 831 | return -ENOSPC; |
832 | 832 | ||
833 | __set_bit(t, bitmap->bitmap); | 833 | __set_bit(t, bitmap->bitmap); |