/* Leave the possibility of an incomplete final layer */
#define MAX_LEVEL (BITS_PER_LONG - RESERVED_ID_BITS + IDR_BITS - 1) / IDR_BITS
#define MAX_ID_SHIFT (BITS_PER_LONG - RESERVED_ID_BITS)
-#define MAX_ID_BIT (1 << MAX_ID_SHIFT)
+#define MAX_ID_BIT (1L << MAX_ID_SHIFT)
#define MAX_ID_MASK (MAX_ID_BIT - 1)
/* Number of id_layer structs to leave in free list */
struct idr {
struct idr_layer *top;
int layers;
- int count;
+ long count;
struct idr_layer *id_free;
int id_free_cnt;
spinlock_t lock;
static inline int sub_alloc(struct idr *idp, int shift, void *ptr)
{
- int n, v = 0;
+ long n, v = 0;
struct idr_layer *p;
struct idr_layer **pa[MAX_LEVEL];
struct idr_layer ***paa = &pa[0];
int idr_get_new(struct idr *idp, void *ptr)
{
- int v;
+ long v;
if (idp->id_free_cnt < idp->layers + 1)
return (-1);
idp->count++;
v += (idp->count << MAX_ID_SHIFT);
if ( unlikely( v == -1 ))
- v += (1 << MAX_ID_SHIFT);
+ v += (1L << MAX_ID_SHIFT);
}
return(v);
}
p = p->ary[n];
shift -= IDR_BITS;
}
- if ( likely(p)){
+ if (likely(p != NULL)){
int n = id & IDR_MASK;
__clear_bit(n, &p->bitmap);
p->ary[n] = NULL;