diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/atomic64_test.c | 3 | ||||
| -rw-r--r-- | lib/dynamic_debug.c | 2 | ||||
| -rw-r--r-- | lib/genalloc.c | 1 | ||||
| -rw-r--r-- | lib/idr.c | 4 | ||||
| -rw-r--r-- | lib/kobject_uevent.c | 3 | ||||
| -rw-r--r-- | lib/rbtree.c | 116 |
6 files changed, 80 insertions, 49 deletions
diff --git a/lib/atomic64_test.c b/lib/atomic64_test.c index 9087d71537dd..250ed11d3ed2 100644 --- a/lib/atomic64_test.c +++ b/lib/atomic64_test.c | |||
| @@ -113,7 +113,8 @@ static __init int test_atomic64(void) | |||
| 113 | r += one; | 113 | r += one; |
| 114 | BUG_ON(v.counter != r); | 114 | BUG_ON(v.counter != r); |
| 115 | 115 | ||
| 116 | #if defined(CONFIG_X86) || defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(_ASM_GENERIC_ATOMIC64_H) | 116 | #if defined(CONFIG_X86) || defined(CONFIG_MIPS) || defined(CONFIG_PPC) || \ |
| 117 | defined(CONFIG_S390) || defined(_ASM_GENERIC_ATOMIC64_H) | ||
| 117 | INIT(onestwos); | 118 | INIT(onestwos); |
| 118 | BUG_ON(atomic64_dec_if_positive(&v) != (onestwos - 1)); | 119 | BUG_ON(atomic64_dec_if_positive(&v) != (onestwos - 1)); |
| 119 | r -= one; | 120 | r -= one; |
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 3df8eb17a607..02afc2533728 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c | |||
| @@ -692,7 +692,7 @@ static void ddebug_table_free(struct ddebug_table *dt) | |||
| 692 | * Called in response to a module being unloaded. Removes | 692 | * Called in response to a module being unloaded. Removes |
| 693 | * any ddebug_table's which point at the module. | 693 | * any ddebug_table's which point at the module. |
| 694 | */ | 694 | */ |
| 695 | int ddebug_remove_module(char *mod_name) | 695 | int ddebug_remove_module(const char *mod_name) |
| 696 | { | 696 | { |
| 697 | struct ddebug_table *dt, *nextdt; | 697 | struct ddebug_table *dt, *nextdt; |
| 698 | int ret = -ENOENT; | 698 | int ret = -ENOENT; |
diff --git a/lib/genalloc.c b/lib/genalloc.c index 736c3b06398e..1923f1490e72 100644 --- a/lib/genalloc.c +++ b/lib/genalloc.c | |||
| @@ -128,7 +128,6 @@ unsigned long gen_pool_alloc(struct gen_pool *pool, size_t size) | |||
| 128 | chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk); | 128 | chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk); |
| 129 | 129 | ||
| 130 | end_bit = (chunk->end_addr - chunk->start_addr) >> order; | 130 | end_bit = (chunk->end_addr - chunk->start_addr) >> order; |
| 131 | end_bit -= nbits + 1; | ||
| 132 | 131 | ||
| 133 | spin_lock_irqsave(&chunk->lock, flags); | 132 | spin_lock_irqsave(&chunk->lock, flags); |
| 134 | start_bit = bitmap_find_next_zero_area(chunk->bits, end_bit, 0, | 133 | start_bit = bitmap_find_next_zero_area(chunk->bits, end_bit, 0, |
| @@ -602,7 +602,7 @@ void *idr_get_next(struct idr *idp, int *nextidp) | |||
| 602 | /* find first ent */ | 602 | /* find first ent */ |
| 603 | n = idp->layers * IDR_BITS; | 603 | n = idp->layers * IDR_BITS; |
| 604 | max = 1 << n; | 604 | max = 1 << n; |
| 605 | p = rcu_dereference(idp->top); | 605 | p = rcu_dereference_raw(idp->top); |
| 606 | if (!p) | 606 | if (!p) |
| 607 | return NULL; | 607 | return NULL; |
| 608 | 608 | ||
| @@ -610,7 +610,7 @@ void *idr_get_next(struct idr *idp, int *nextidp) | |||
| 610 | while (n > 0 && p) { | 610 | while (n > 0 && p) { |
| 611 | n -= IDR_BITS; | 611 | n -= IDR_BITS; |
| 612 | *paa++ = p; | 612 | *paa++ = p; |
| 613 | p = rcu_dereference(p->ary[(id >> n) & IDR_MASK]); | 613 | p = rcu_dereference_raw(p->ary[(id >> n) & IDR_MASK]); |
| 614 | } | 614 | } |
| 615 | 615 | ||
| 616 | if (p) { | 616 | if (p) { |
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index 59c15511d58a..b93579504dfa 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c | |||
| @@ -83,6 +83,7 @@ out: | |||
| 83 | return ret; | 83 | return ret; |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | #ifdef CONFIG_NET | ||
| 86 | static int kobj_bcast_filter(struct sock *dsk, struct sk_buff *skb, void *data) | 87 | static int kobj_bcast_filter(struct sock *dsk, struct sk_buff *skb, void *data) |
| 87 | { | 88 | { |
| 88 | struct kobject *kobj = data; | 89 | struct kobject *kobj = data; |
| @@ -98,6 +99,7 @@ static int kobj_bcast_filter(struct sock *dsk, struct sk_buff *skb, void *data) | |||
| 98 | 99 | ||
| 99 | return 0; | 100 | return 0; |
| 100 | } | 101 | } |
| 102 | #endif | ||
| 101 | 103 | ||
| 102 | static int kobj_usermode_filter(struct kobject *kobj) | 104 | static int kobj_usermode_filter(struct kobject *kobj) |
| 103 | { | 105 | { |
| @@ -378,6 +380,7 @@ static int uevent_net_init(struct net *net) | |||
| 378 | if (!ue_sk->sk) { | 380 | if (!ue_sk->sk) { |
| 379 | printk(KERN_ERR | 381 | printk(KERN_ERR |
| 380 | "kobject_uevent: unable to create netlink socket!\n"); | 382 | "kobject_uevent: unable to create netlink socket!\n"); |
| 383 | kfree(ue_sk); | ||
| 381 | return -ENODEV; | 384 | return -ENODEV; |
| 382 | } | 385 | } |
| 383 | mutex_lock(&uevent_sock_mutex); | 386 | mutex_lock(&uevent_sock_mutex); |
diff --git a/lib/rbtree.c b/lib/rbtree.c index 15e10b1afdd2..4693f79195d3 100644 --- a/lib/rbtree.c +++ b/lib/rbtree.c | |||
| @@ -44,11 +44,6 @@ static void __rb_rotate_left(struct rb_node *node, struct rb_root *root) | |||
| 44 | else | 44 | else |
| 45 | root->rb_node = right; | 45 | root->rb_node = right; |
| 46 | rb_set_parent(node, right); | 46 | rb_set_parent(node, right); |
| 47 | |||
| 48 | if (root->augment_cb) { | ||
| 49 | root->augment_cb(node); | ||
| 50 | root->augment_cb(right); | ||
| 51 | } | ||
| 52 | } | 47 | } |
| 53 | 48 | ||
| 54 | static void __rb_rotate_right(struct rb_node *node, struct rb_root *root) | 49 | static void __rb_rotate_right(struct rb_node *node, struct rb_root *root) |
| @@ -72,20 +67,12 @@ static void __rb_rotate_right(struct rb_node *node, struct rb_root *root) | |||
| 72 | else | 67 | else |
| 73 | root->rb_node = left; | 68 | root->rb_node = left; |
| 74 | rb_set_parent(node, left); | 69 | rb_set_parent(node, left); |
| 75 | |||
| 76 | if (root->augment_cb) { | ||
| 77 | root->augment_cb(node); | ||
| 78 | root->augment_cb(left); | ||
| 79 | } | ||
| 80 | } | 70 | } |
| 81 | 71 | ||
| 82 | void rb_insert_color(struct rb_node *node, struct rb_root *root) | 72 | void rb_insert_color(struct rb_node *node, struct rb_root *root) |
| 83 | { | 73 | { |
| 84 | struct rb_node *parent, *gparent; | 74 | struct rb_node *parent, *gparent; |
| 85 | 75 | ||
| 86 | if (root->augment_cb) | ||
| 87 | root->augment_cb(node); | ||
| 88 | |||
| 89 | while ((parent = rb_parent(node)) && rb_is_red(parent)) | 76 | while ((parent = rb_parent(node)) && rb_is_red(parent)) |
| 90 | { | 77 | { |
| 91 | gparent = rb_parent(parent); | 78 | gparent = rb_parent(parent); |
| @@ -240,15 +227,12 @@ void rb_erase(struct rb_node *node, struct rb_root *root) | |||
| 240 | else | 227 | else |
| 241 | { | 228 | { |
| 242 | struct rb_node *old = node, *left; | 229 | struct rb_node *old = node, *left; |
| 243 | int old_parent_cb = 0; | ||
| 244 | int successor_parent_cb = 0; | ||
| 245 | 230 | ||
| 246 | node = node->rb_right; | 231 | node = node->rb_right; |
| 247 | while ((left = node->rb_left) != NULL) | 232 | while ((left = node->rb_left) != NULL) |
| 248 | node = left; | 233 | node = left; |
| 249 | 234 | ||
| 250 | if (rb_parent(old)) { | 235 | if (rb_parent(old)) { |
| 251 | old_parent_cb = 1; | ||
| 252 | if (rb_parent(old)->rb_left == old) | 236 | if (rb_parent(old)->rb_left == old) |
| 253 | rb_parent(old)->rb_left = node; | 237 | rb_parent(old)->rb_left = node; |
| 254 | else | 238 | else |
| @@ -263,10 +247,8 @@ void rb_erase(struct rb_node *node, struct rb_root *root) | |||
| 263 | if (parent == old) { | 247 | if (parent == old) { |
| 264 | parent = node; | 248 | parent = node; |
| 265 | } else { | 249 | } else { |
| 266 | successor_parent_cb = 1; | ||
| 267 | if (child) | 250 | if (child) |
| 268 | rb_set_parent(child, parent); | 251 | rb_set_parent(child, parent); |
| 269 | |||
| 270 | parent->rb_left = child; | 252 | parent->rb_left = child; |
| 271 | 253 | ||
| 272 | node->rb_right = old->rb_right; | 254 | node->rb_right = old->rb_right; |
| @@ -277,24 +259,6 @@ void rb_erase(struct rb_node *node, struct rb_root *root) | |||
| 277 | node->rb_left = old->rb_left; | 259 | node->rb_left = old->rb_left; |
| 278 | rb_set_parent(old->rb_left, node); | 260 | rb_set_parent(old->rb_left, node); |
| 279 | 261 | ||
| 280 | if (root->augment_cb) { | ||
| 281 | /* | ||
| 282 | * Here, three different nodes can have new children. | ||
| 283 | * The parent of the successor node that was selected | ||
| 284 | * to replace the node to be erased. | ||
| 285 | * The node that is getting erased and is now replaced | ||
| 286 | * by its successor. | ||
| 287 | * The parent of the node getting erased-replaced. | ||
| 288 | */ | ||
| 289 | if (successor_parent_cb) | ||
| 290 | root->augment_cb(parent); | ||
| 291 | |||
| 292 | root->augment_cb(node); | ||
| 293 | |||
| 294 | if (old_parent_cb) | ||
| 295 | root->augment_cb(rb_parent(old)); | ||
| 296 | } | ||
| 297 | |||
| 298 | goto color; | 262 | goto color; |
| 299 | } | 263 | } |
| 300 | 264 | ||
| @@ -303,19 +267,15 @@ void rb_erase(struct rb_node *node, struct rb_root *root) | |||
| 303 | 267 | ||
| 304 | if (child) | 268 | if (child) |
| 305 | rb_set_parent(child, parent); | 269 | rb_set_parent(child, parent); |
| 306 | 270 | if (parent) | |
| 307 | if (parent) { | 271 | { |
| 308 | if (parent->rb_left == node) | 272 | if (parent->rb_left == node) |
| 309 | parent->rb_left = child; | 273 | parent->rb_left = child; |
| 310 | else | 274 | else |
| 311 | parent->rb_right = child; | 275 | parent->rb_right = child; |
| 312 | |||
| 313 | if (root->augment_cb) | ||
| 314 | root->augment_cb(parent); | ||
| 315 | |||
| 316 | } else { | ||
| 317 | root->rb_node = child; | ||
| 318 | } | 276 | } |
| 277 | else | ||
| 278 | root->rb_node = child; | ||
| 319 | 279 | ||
| 320 | color: | 280 | color: |
| 321 | if (color == RB_BLACK) | 281 | if (color == RB_BLACK) |
| @@ -323,6 +283,74 @@ void rb_erase(struct rb_node *node, struct rb_root *root) | |||
| 323 | } | 283 | } |
| 324 | EXPORT_SYMBOL(rb_erase); | 284 | EXPORT_SYMBOL(rb_erase); |
| 325 | 285 | ||
| 286 | static void rb_augment_path(struct rb_node *node, rb_augment_f func, void *data) | ||
| 287 | { | ||
| 288 | struct rb_node *parent; | ||
| 289 | |||
| 290 | up: | ||
| 291 | func(node, data); | ||
| 292 | parent = rb_parent(node); | ||
| 293 | if (!parent) | ||
| 294 | return; | ||
| 295 | |||
| 296 | if (node == parent->rb_left && parent->rb_right) | ||
| 297 | func(parent->rb_right, data); | ||
| 298 | else if (parent->rb_left) | ||
| 299 | func(parent->rb_left, data); | ||
| 300 | |||
| 301 | node = parent; | ||
| 302 | goto up; | ||
| 303 | } | ||
| 304 | |||
| 305 | /* | ||
| 306 | * after inserting @node into the tree, update the tree to account for | ||
| 307 | * both the new entry and any damage done by rebalance | ||
| 308 | */ | ||
| 309 | void rb_augment_insert(struct rb_node *node, rb_augment_f func, void *data) | ||
| 310 | { | ||
| 311 | if (node->rb_left) | ||
| 312 | node = node->rb_left; | ||
| 313 | else if (node->rb_right) | ||
| 314 | node = node->rb_right; | ||
| 315 | |||
| 316 | rb_augment_path(node, func, data); | ||
| 317 | } | ||
| 318 | |||
| 319 | /* | ||
| 320 | * before removing the node, find the deepest node on the rebalance path | ||
| 321 | * that will still be there after @node gets removed | ||
| 322 | */ | ||
| 323 | struct rb_node *rb_augment_erase_begin(struct rb_node *node) | ||
| 324 | { | ||
| 325 | struct rb_node *deepest; | ||
| 326 | |||
| 327 | if (!node->rb_right && !node->rb_left) | ||
| 328 | deepest = rb_parent(node); | ||
| 329 | else if (!node->rb_right) | ||
| 330 | deepest = node->rb_left; | ||
| 331 | else if (!node->rb_left) | ||
| 332 | deepest = node->rb_right; | ||
| 333 | else { | ||
| 334 | deepest = rb_next(node); | ||
| 335 | if (deepest->rb_right) | ||
| 336 | deepest = deepest->rb_right; | ||
| 337 | else if (rb_parent(deepest) != node) | ||
| 338 | deepest = rb_parent(deepest); | ||
| 339 | } | ||
| 340 | |||
| 341 | return deepest; | ||
| 342 | } | ||
| 343 | |||
| 344 | /* | ||
| 345 | * after removal, update the tree to account for the removed entry | ||
| 346 | * and any rebalance damage. | ||
| 347 | */ | ||
| 348 | void rb_augment_erase_end(struct rb_node *node, rb_augment_f func, void *data) | ||
| 349 | { | ||
| 350 | if (node) | ||
| 351 | rb_augment_path(node, func, data); | ||
| 352 | } | ||
| 353 | |||
| 326 | /* | 354 | /* |
| 327 | * This function returns the first node (in sort order) of the tree. | 355 | * This function returns the first node (in sort order) of the tree. |
| 328 | */ | 356 | */ |
