diff options
Diffstat (limited to 'drivers/base/memory.c')
| -rw-r--r-- | drivers/base/memory.c | 31 | 
1 files changed, 27 insertions, 4 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 44e7de6ce69..86c88216a50 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -275,13 +275,11 @@ memory_block_action(unsigned long phys_index, unsigned long action)  	return ret;  } -static int memory_block_change_state(struct memory_block *mem, +static int __memory_block_change_state(struct memory_block *mem,  		unsigned long to_state, unsigned long from_state_req)  {  	int ret = 0; -	mutex_lock(&mem->state_mutex); -  	if (mem->state != from_state_req) {  		ret = -EINVAL;  		goto out; @@ -309,10 +307,20 @@ static int memory_block_change_state(struct memory_block *mem,  		break;  	}  out: -	mutex_unlock(&mem->state_mutex);  	return ret;  } +static int memory_block_change_state(struct memory_block *mem, +		unsigned long to_state, unsigned long from_state_req) +{ +	int ret; + +	mutex_lock(&mem->state_mutex); +	ret = __memory_block_change_state(mem, to_state, from_state_req); +	mutex_unlock(&mem->state_mutex); + +	return ret; +}  static ssize_t  store_mem_state(struct device *dev,  		struct device_attribute *attr, const char *buf, size_t count) @@ -653,6 +661,21 @@ int unregister_memory_section(struct mem_section *section)  }  /* + * offline one memory block. If the memory block has been offlined, do nothing. + */ +int offline_memory_block(struct memory_block *mem) +{ +	int ret = 0; + +	mutex_lock(&mem->state_mutex); +	if (mem->state != MEM_OFFLINE) +		ret = __memory_block_change_state(mem, MEM_OFFLINE, MEM_ONLINE); +	mutex_unlock(&mem->state_mutex); + +	return ret; +} + +/*   * Initialize the sysfs support for memory devices...   */  int __init memory_dev_init(void)  |