|
@@ -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)
|
|
@@ -652,6 +660,21 @@ int unregister_memory_section(struct mem_section *section)
|
|
|
return remove_memory_block(0, section, 0);
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+ * 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...
|
|
|
*/
|