memory.c (540557b9439ec19668553830c90222f9fb0c2e95) memory.c (7b78d335ac15b10bbcb0397c635d7f0d569b0270)
1/*
2 * drivers/base/memory.c - basic Memory class support
3 *
4 * Written by Matt Tolentino <matthew.e.tolentino@intel.com>
5 * Dave Hansen <haveblue@us.ibm.com>
6 *
7 * This file provides the necessary infrastructure to represent
8 * a SPARSEMEM-memory-model system's physical memory in /sysfs.

--- 123 unchanged lines hidden (view full) ---

132 mem->state);
133 WARN_ON(1);
134 break;
135 }
136
137 return len;
138}
139
1/*
2 * drivers/base/memory.c - basic Memory class support
3 *
4 * Written by Matt Tolentino <matthew.e.tolentino@intel.com>
5 * Dave Hansen <haveblue@us.ibm.com>
6 *
7 * This file provides the necessary infrastructure to represent
8 * a SPARSEMEM-memory-model system's physical memory in /sysfs.

--- 123 unchanged lines hidden (view full) ---

132 mem->state);
133 WARN_ON(1);
134 break;
135 }
136
137 return len;
138}
139
140static inline int memory_notify(unsigned long val, void *v)
140int memory_notify(unsigned long val, void *v)
141{
142 return blocking_notifier_call_chain(&memory_chain, val, v);
143}
144
145/*
146 * MEMORY_HOTPLUG depends on SPARSEMEM in mm/Kconfig, so it is
147 * OK to have direct references to sparsemem variables in here.
148 */

--- 29 unchanged lines hidden (view full) ---

178
179 switch (action) {
180 case MEM_ONLINE:
181 start_pfn = page_to_pfn(first_page);
182 ret = online_pages(start_pfn, PAGES_PER_SECTION);
183 break;
184 case MEM_OFFLINE:
185 mem->state = MEM_GOING_OFFLINE;
141{
142 return blocking_notifier_call_chain(&memory_chain, val, v);
143}
144
145/*
146 * MEMORY_HOTPLUG depends on SPARSEMEM in mm/Kconfig, so it is
147 * OK to have direct references to sparsemem variables in here.
148 */

--- 29 unchanged lines hidden (view full) ---

178
179 switch (action) {
180 case MEM_ONLINE:
181 start_pfn = page_to_pfn(first_page);
182 ret = online_pages(start_pfn, PAGES_PER_SECTION);
183 break;
184 case MEM_OFFLINE:
185 mem->state = MEM_GOING_OFFLINE;
186 memory_notify(MEM_GOING_OFFLINE, NULL);
187 start_paddr = page_to_pfn(first_page) << PAGE_SHIFT;
188 ret = remove_memory(start_paddr,
189 PAGES_PER_SECTION << PAGE_SHIFT);
190 if (ret) {
191 mem->state = old_state;
192 break;
193 }
186 start_paddr = page_to_pfn(first_page) << PAGE_SHIFT;
187 ret = remove_memory(start_paddr,
188 PAGES_PER_SECTION << PAGE_SHIFT);
189 if (ret) {
190 mem->state = old_state;
191 break;
192 }
194 memory_notify(MEM_MAPPING_INVALID, NULL);
195 break;
196 default:
197 printk(KERN_WARNING "%s(%p, %ld) unknown action: %ld\n",
198 __FUNCTION__, mem, action, action);
199 WARN_ON(1);
200 ret = -EINVAL;
201 }
193 break;
194 default:
195 printk(KERN_WARNING "%s(%p, %ld) unknown action: %ld\n",
196 __FUNCTION__, mem, action, action);
197 WARN_ON(1);
198 ret = -EINVAL;
199 }
202 /*
203 * For now, only notify on successful memory operations
204 */
205 if (!ret)
206 memory_notify(action, NULL);
207
208 return ret;
209}
210
211static int memory_block_change_state(struct memory_block *mem,
212 unsigned long to_state, unsigned long from_state_req)
213{
214 int ret = 0;

--- 249 unchanged lines hidden ---
200
201 return ret;
202}
203
204static int memory_block_change_state(struct memory_block *mem,
205 unsigned long to_state, unsigned long from_state_req)
206{
207 int ret = 0;

--- 249 unchanged lines hidden ---