Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 359358
b: refs/heads/master
c: 2fa532c
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo authored and Linus Torvalds committed Feb 28, 2013
1 parent e4ccb70 commit de1eda4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 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: ec09ebc143818c7bb255cf2b79d97dae02a2e635
refs/heads/master: 2fa532c5d5af8959d1b0ea369324f6d44183dba4
33 changes: 4 additions & 29 deletions trunk/drivers/net/ppp/ppp_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2953,46 +2953,21 @@ static void __exit ppp_cleanup(void)
* by holding all_ppp_mutex
*/

static int __unit_alloc(struct idr *p, void *ptr, int n)
{
int unit, err;

again:
if (!idr_pre_get(p, GFP_KERNEL)) {
pr_err("PPP: No free memory for idr\n");
return -ENOMEM;
}

err = idr_get_new_above(p, ptr, n, &unit);
if (err < 0) {
if (err == -EAGAIN)
goto again;
return err;
}

return unit;
}

/* associate pointer with specified number */
static int unit_set(struct idr *p, void *ptr, int n)
{
int unit;

unit = __unit_alloc(p, ptr, n);
if (unit < 0)
return unit;
else if (unit != n) {
idr_remove(p, unit);
return -EINVAL;
}

unit = idr_alloc(p, ptr, n, n + 1, GFP_KERNEL);
if (unit == -ENOSPC)
unit = -EINVAL;
return unit;
}

/* get new free unit number and associate pointer with it */
static int unit_get(struct idr *p, void *ptr)
{
return __unit_alloc(p, ptr, 0);
return idr_alloc(p, ptr, 0, 0, GFP_KERNEL);
}

/* put unit number back to a pool */
Expand Down

0 comments on commit de1eda4

Please sign in to comment.