diff options
| author | Chris Zankel <chris@zankel.net> | 2009-04-03 05:29:05 -0400 |
|---|---|---|
| committer | Chris Zankel <chris@zankel.net> | 2009-04-03 05:29:05 -0400 |
| commit | 65127d28e312bb6b38ce84a7bb71d762ef63ad4c (patch) | |
| tree | d5fdf52a2d0731f7fab0ce0ed394faac50b04fbc /lib | |
| parent | b8bb76713ec50df2f11efee386e16f93d51e1076 (diff) | |
| parent | 8fe74cf053de7ad2124a894996f84fa890a81093 (diff) | |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 into merge
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/cpumask.c | 4 | ||||
| -rw-r--r-- | lib/idr.c | 46 |
2 files changed, 48 insertions, 2 deletions
diff --git a/lib/cpumask.c b/lib/cpumask.c index 3389e2440da..1f71b97de0f 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c | |||
| @@ -109,10 +109,10 @@ bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node) | |||
| 109 | #endif | 109 | #endif |
| 110 | /* FIXME: Bandaid to save us from old primitives which go to NR_CPUS. */ | 110 | /* FIXME: Bandaid to save us from old primitives which go to NR_CPUS. */ |
| 111 | if (*mask) { | 111 | if (*mask) { |
| 112 | unsigned char *ptr = (unsigned char *)cpumask_bits(*mask); | ||
| 112 | unsigned int tail; | 113 | unsigned int tail; |
| 113 | tail = BITS_TO_LONGS(NR_CPUS - nr_cpumask_bits) * sizeof(long); | 114 | tail = BITS_TO_LONGS(NR_CPUS - nr_cpumask_bits) * sizeof(long); |
| 114 | memset(cpumask_bits(*mask) + cpumask_size() - tail, | 115 | memset(ptr + cpumask_size() - tail, 0, tail); |
| 115 | 0, tail); | ||
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | return *mask != NULL; | 118 | return *mask != NULL; |
| @@ -579,6 +579,52 @@ int idr_for_each(struct idr *idp, | |||
| 579 | EXPORT_SYMBOL(idr_for_each); | 579 | EXPORT_SYMBOL(idr_for_each); |
| 580 | 580 | ||
| 581 | /** | 581 | /** |
| 582 | * idr_get_next - lookup next object of id to given id. | ||
| 583 | * @idp: idr handle | ||
| 584 | * @id: pointer to lookup key | ||
| 585 | * | ||
| 586 | * Returns pointer to registered object with id, which is next number to | ||
| 587 | * given id. | ||
| 588 | */ | ||
| 589 | |||
| 590 | void *idr_get_next(struct idr *idp, int *nextidp) | ||
| 591 | { | ||
| 592 | struct idr_layer *p, *pa[MAX_LEVEL]; | ||
| 593 | struct idr_layer **paa = &pa[0]; | ||
| 594 | int id = *nextidp; | ||
| 595 | int n, max; | ||
| 596 | |||
| 597 | /* find first ent */ | ||
| 598 | n = idp->layers * IDR_BITS; | ||
| 599 | max = 1 << n; | ||
| 600 | p = rcu_dereference(idp->top); | ||
| 601 | if (!p) | ||
| 602 | return NULL; | ||
| 603 | |||
| 604 | while (id < max) { | ||
| 605 | while (n > 0 && p) { | ||
| 606 | n -= IDR_BITS; | ||
| 607 | *paa++ = p; | ||
| 608 | p = rcu_dereference(p->ary[(id >> n) & IDR_MASK]); | ||
| 609 | } | ||
| 610 | |||
| 611 | if (p) { | ||
| 612 | *nextidp = id; | ||
| 613 | return p; | ||
| 614 | } | ||
| 615 | |||
| 616 | id += 1 << n; | ||
| 617 | while (n < fls(id)) { | ||
| 618 | n += IDR_BITS; | ||
| 619 | p = *--paa; | ||
| 620 | } | ||
| 621 | } | ||
| 622 | return NULL; | ||
| 623 | } | ||
| 624 | |||
| 625 | |||
| 626 | |||
| 627 | /** | ||
| 582 | * idr_replace - replace pointer for given id | 628 | * idr_replace - replace pointer for given id |
| 583 | * @idp: idr handle | 629 | * @idp: idr handle |
| 584 | * @ptr: pointer you want associated with the id | 630 | * @ptr: pointer you want associated with the id |
