diff options
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/memory.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 4d4e0e7b6e92..855ed1a9f97b 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -101,6 +101,21 @@ static ssize_t show_mem_phys_index(struct sys_device *dev, | |||
101 | } | 101 | } |
102 | 102 | ||
103 | /* | 103 | /* |
104 | * Show whether the section of memory is likely to be hot-removable | ||
105 | */ | ||
106 | static ssize_t show_mem_removable(struct sys_device *dev, char *buf) | ||
107 | { | ||
108 | unsigned long start_pfn; | ||
109 | int ret; | ||
110 | struct memory_block *mem = | ||
111 | container_of(dev, struct memory_block, sysdev); | ||
112 | |||
113 | start_pfn = section_nr_to_pfn(mem->phys_index); | ||
114 | ret = is_mem_section_removable(start_pfn, PAGES_PER_SECTION); | ||
115 | return sprintf(buf, "%d\n", ret); | ||
116 | } | ||
117 | |||
118 | /* | ||
104 | * online, offline, going offline, etc. | 119 | * online, offline, going offline, etc. |
105 | */ | 120 | */ |
106 | static ssize_t show_mem_state(struct sys_device *dev, | 121 | static ssize_t show_mem_state(struct sys_device *dev, |
@@ -262,6 +277,7 @@ static ssize_t show_phys_device(struct sys_device *dev, | |||
262 | static SYSDEV_ATTR(phys_index, 0444, show_mem_phys_index, NULL); | 277 | static SYSDEV_ATTR(phys_index, 0444, show_mem_phys_index, NULL); |
263 | static SYSDEV_ATTR(state, 0644, show_mem_state, store_mem_state); | 278 | static SYSDEV_ATTR(state, 0644, show_mem_state, store_mem_state); |
264 | static SYSDEV_ATTR(phys_device, 0444, show_phys_device, NULL); | 279 | static SYSDEV_ATTR(phys_device, 0444, show_phys_device, NULL); |
280 | static SYSDEV_ATTR(removable, 0444, show_mem_removable, NULL); | ||
265 | 281 | ||
266 | #define mem_create_simple_file(mem, attr_name) \ | 282 | #define mem_create_simple_file(mem, attr_name) \ |
267 | sysdev_create_file(&mem->sysdev, &attr_##attr_name) | 283 | sysdev_create_file(&mem->sysdev, &attr_##attr_name) |
@@ -350,6 +366,8 @@ static int add_memory_block(unsigned long node_id, struct mem_section *section, | |||
350 | ret = mem_create_simple_file(mem, state); | 366 | ret = mem_create_simple_file(mem, state); |
351 | if (!ret) | 367 | if (!ret) |
352 | ret = mem_create_simple_file(mem, phys_device); | 368 | ret = mem_create_simple_file(mem, phys_device); |
369 | if (!ret) | ||
370 | ret = mem_create_simple_file(mem, removable); | ||
353 | 371 | ||
354 | return ret; | 372 | return ret; |
355 | } | 373 | } |
@@ -394,6 +412,7 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section, | |||
394 | mem_remove_simple_file(mem, phys_index); | 412 | mem_remove_simple_file(mem, phys_index); |
395 | mem_remove_simple_file(mem, state); | 413 | mem_remove_simple_file(mem, state); |
396 | mem_remove_simple_file(mem, phys_device); | 414 | mem_remove_simple_file(mem, phys_device); |
415 | mem_remove_simple_file(mem, removable); | ||
397 | unregister_memory(mem, section); | 416 | unregister_memory(mem, section); |
398 | 417 | ||
399 | return 0; | 418 | return 0; |