diff options
Diffstat (limited to 'drivers/base')
| -rw-r--r-- | drivers/base/memory.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 1f3801a8184d..7891f7c97267 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
| @@ -62,8 +62,8 @@ void unregister_memory_notifier(struct notifier_block *nb) | |||
| 62 | /* | 62 | /* |
| 63 | * register_memory - Setup a sysfs device for a memory block | 63 | * register_memory - Setup a sysfs device for a memory block |
| 64 | */ | 64 | */ |
| 65 | int register_memory(struct memory_block *memory, struct mem_section *section, | 65 | static |
| 66 | struct node *root) | 66 | int register_memory(struct memory_block *memory, struct mem_section *section) |
| 67 | { | 67 | { |
| 68 | int error; | 68 | int error; |
| 69 | 69 | ||
| @@ -71,26 +71,18 @@ int register_memory(struct memory_block *memory, struct mem_section *section, | |||
| 71 | memory->sysdev.id = __section_nr(section); | 71 | memory->sysdev.id = __section_nr(section); |
| 72 | 72 | ||
| 73 | error = sysdev_register(&memory->sysdev); | 73 | error = sysdev_register(&memory->sysdev); |
| 74 | |||
| 75 | if (root && !error) | ||
| 76 | error = sysfs_create_link(&root->sysdev.kobj, | ||
| 77 | &memory->sysdev.kobj, | ||
| 78 | kobject_name(&memory->sysdev.kobj)); | ||
| 79 | |||
| 80 | return error; | 74 | return error; |
| 81 | } | 75 | } |
| 82 | 76 | ||
| 83 | static void | 77 | static void |
| 84 | unregister_memory(struct memory_block *memory, struct mem_section *section, | 78 | unregister_memory(struct memory_block *memory, struct mem_section *section) |
| 85 | struct node *root) | ||
| 86 | { | 79 | { |
| 87 | BUG_ON(memory->sysdev.cls != &memory_sysdev_class); | 80 | BUG_ON(memory->sysdev.cls != &memory_sysdev_class); |
| 88 | BUG_ON(memory->sysdev.id != __section_nr(section)); | 81 | BUG_ON(memory->sysdev.id != __section_nr(section)); |
| 89 | 82 | ||
| 83 | /* drop the ref. we got in remove_memory_block() */ | ||
| 84 | kobject_put(&memory->sysdev.kobj); | ||
| 90 | sysdev_unregister(&memory->sysdev); | 85 | sysdev_unregister(&memory->sysdev); |
| 91 | if (root) | ||
| 92 | sysfs_remove_link(&root->sysdev.kobj, | ||
| 93 | kobject_name(&memory->sysdev.kobj)); | ||
| 94 | } | 86 | } |
| 95 | 87 | ||
| 96 | /* | 88 | /* |
| @@ -345,7 +337,7 @@ static int add_memory_block(unsigned long node_id, struct mem_section *section, | |||
| 345 | mutex_init(&mem->state_mutex); | 337 | mutex_init(&mem->state_mutex); |
| 346 | mem->phys_device = phys_device; | 338 | mem->phys_device = phys_device; |
| 347 | 339 | ||
| 348 | ret = register_memory(mem, section, NULL); | 340 | ret = register_memory(mem, section); |
| 349 | if (!ret) | 341 | if (!ret) |
| 350 | ret = mem_create_simple_file(mem, phys_index); | 342 | ret = mem_create_simple_file(mem, phys_index); |
| 351 | if (!ret) | 343 | if (!ret) |
| @@ -396,7 +388,7 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section, | |||
| 396 | mem_remove_simple_file(mem, phys_index); | 388 | mem_remove_simple_file(mem, phys_index); |
| 397 | mem_remove_simple_file(mem, state); | 389 | mem_remove_simple_file(mem, state); |
| 398 | mem_remove_simple_file(mem, phys_device); | 390 | mem_remove_simple_file(mem, phys_device); |
| 399 | unregister_memory(mem, section, NULL); | 391 | unregister_memory(mem, section); |
| 400 | 392 | ||
| 401 | return 0; | 393 | return 0; |
| 402 | } | 394 | } |
