Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105959
b: refs/heads/master
c: 944ca05
h: refs/heads/master
i:
  105957: 52020e2
  105955: f02873b
  105951: 2bacdf3
v: v3
  • Loading branch information
Nadia Derbey authored and Linus Torvalds committed Jul 25, 2008
1 parent cbdad79 commit bde4956
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f098ad655f4dd8e3da98ffbeda9cedcc4459c01a
refs/heads/master: 944ca05c7b4972f2ebf37262e0f4933d178ad6db
6 changes: 6 additions & 0 deletions trunk/include/linux/idr.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ struct idr {
}
#define DEFINE_IDR(name) struct idr name = IDR_INIT(name)

/* Actions to be taken after a call to _idr_sub_alloc */
#define IDR_NEED_TO_GROW -2
#define IDR_NOMORE_SPACE -3

#define _idr_rc_to_errno(rc) ((rc) == -1 ? -EAGAIN : -ENOSPC)

/*
* This is what we export.
*/
Expand Down
30 changes: 9 additions & 21 deletions trunk/lib/idr.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ static int sub_alloc(struct idr *idp, int *starting_id, struct idr_layer **pa)
/* if already at the top layer, we need to grow */
if (!(p = pa[l])) {
*starting_id = id;
return -2;
return IDR_NEED_TO_GROW;
}

/* If we need to go up one layer, continue the
Expand All @@ -160,7 +160,7 @@ static int sub_alloc(struct idr *idp, int *starting_id, struct idr_layer **pa)
id = ((id >> sh) ^ n ^ m) << sh;
}
if ((id >= MAX_ID_BIT) || (id < 0))
return -3;
return IDR_NOMORE_SPACE;
if (l == 0)
break;
/*
Expand Down Expand Up @@ -229,7 +229,7 @@ static int idr_get_empty_slot(struct idr *idp, int starting_id,
idp->top = p;
idp->layers = layers;
v = sub_alloc(idp, &id, pa);
if (v == -2)
if (v == IDR_NEED_TO_GROW)
goto build_up;
return(v);
}
Expand Down Expand Up @@ -278,12 +278,8 @@ int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id)
* This is a cheap hack until the IDR code can be fixed to
* return proper error values.
*/
if (rv < 0) {
if (rv == -1)
return -EAGAIN;
else /* Will be -3 */
return -ENOSPC;
}
if (rv < 0)
return _idr_rc_to_errno(rv);
*id = rv;
return 0;
}
Expand Down Expand Up @@ -313,12 +309,8 @@ int idr_get_new(struct idr *idp, void *ptr, int *id)
* This is a cheap hack until the IDR code can be fixed to
* return proper error values.
*/
if (rv < 0) {
if (rv == -1)
return -EAGAIN;
else /* Will be -3 */
return -ENOSPC;
}
if (rv < 0)
return _idr_rc_to_errno(rv);
*id = rv;
return 0;
}
Expand Down Expand Up @@ -696,12 +688,8 @@ int ida_get_new_above(struct ida *ida, int starting_id, int *p_id)
restart:
/* get vacant slot */
t = idr_get_empty_slot(&ida->idr, idr_id, pa);
if (t < 0) {
if (t == -1)
return -EAGAIN;
else /* will be -3 */
return -ENOSPC;
}
if (t < 0)
return _idr_rc_to_errno(t);

if (t * IDA_BITMAP_BITS >= MAX_ID_BIT)
return -ENOSPC;
Expand Down

0 comments on commit bde4956

Please sign in to comment.