static int remove_memory_block(unsigned long node_id, struct mem_section *section, int phys_device) { struct memory_block *mem; mutex_lock(&mem_sysfs_mutex); mem = find_memory_block(section); unregister_mem_sect_under_nodes(mem, __section_nr(section)); mem->section_count--; if (mem->section_count == 0) unregister_memory(mem); else put_device(&mem->dev); mutex_unlock(&mem_sysfs_mutex); return 0; }
int remove_memory_block(unsigned long node_id, struct mem_section *section, int phys_device) { struct memory_block *mem; mutex_lock(&mem_sysfs_mutex); mem = find_memory_block(section); unregister_mem_sect_under_nodes(mem, __section_nr(section)); mem->section_count--; if (mem->section_count == 0) { mem_remove_simple_file(mem, phys_index); mem_remove_simple_file(mem, end_phys_index); mem_remove_simple_file(mem, state); mem_remove_simple_file(mem, phys_device); mem_remove_simple_file(mem, removable); unregister_memory(mem); kfree(mem); } else kobject_put(&mem->dev.kobj); mutex_unlock(&mem_sysfs_mutex); return 0; }