diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-10-30 01:56:31 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-10-30 01:56:31 -0500 |
commit | 81cfb8864c73230eb1c37753aba517db15cf4d8f (patch) | |
tree | 649ff25543834cf9983ea41b93126bea97d75475 /drivers | |
parent | 0169e284f6b6b263cc7c2ed25986b96cd6fda610 (diff) | |
parent | 9f75e1eff3edb2bb07349b94c28f4f2a6c66ca43 (diff) |
Merge branch 'master'
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/acpi/acpi_memhotplug.c | 5 | ||||
-rw-r--r-- | drivers/base/Makefile | 1 | ||||
-rw-r--r-- | drivers/base/init.c | 2 | ||||
-rw-r--r-- | drivers/base/memory.c | 452 | ||||
-rw-r--r-- | drivers/md/dm-crypt.c | 12 | ||||
-rw-r--r-- | drivers/net/wireless/airo.c | 7 | ||||
-rw-r--r-- | drivers/scsi/arm/scsi.h | 6 | ||||
-rw-r--r-- | drivers/scsi/libata-core.c | 10 | ||||
-rw-r--r-- | drivers/scsi/sg.c | 17 | ||||
-rw-r--r-- | drivers/scsi/st.c | 10 | ||||
-rw-r--r-- | drivers/usb/misc/usbtest.c | 7 |
11 files changed, 488 insertions, 41 deletions
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 01a1bd239263..2143609d2936 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c | |||
@@ -200,8 +200,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) | |||
200 | * Note: Assume that this function returns zero on success | 200 | * Note: Assume that this function returns zero on success |
201 | */ | 201 | */ |
202 | result = add_memory(mem_device->start_addr, | 202 | result = add_memory(mem_device->start_addr, |
203 | (mem_device->end_addr - mem_device->start_addr) + 1, | 203 | (mem_device->end_addr - mem_device->start_addr) + 1); |
204 | mem_device->read_write_attribute); | ||
205 | if (result) { | 204 | if (result) { |
206 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "\nadd_memory failed\n")); | 205 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "\nadd_memory failed\n")); |
207 | mem_device->state = MEMORY_INVALID_STATE; | 206 | mem_device->state = MEMORY_INVALID_STATE; |
@@ -259,7 +258,7 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device) | |||
259 | * Ask the VM to offline this memory range. | 258 | * Ask the VM to offline this memory range. |
260 | * Note: Assume that this function returns zero on success | 259 | * Note: Assume that this function returns zero on success |
261 | */ | 260 | */ |
262 | result = remove_memory(start, len, attr); | 261 | result = remove_memory(start, len); |
263 | if (result) { | 262 | if (result) { |
264 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Hot-Remove failed.\n")); | 263 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Hot-Remove failed.\n")); |
265 | return_VALUE(result); | 264 | return_VALUE(result); |
diff --git a/drivers/base/Makefile b/drivers/base/Makefile index 66d9c4643fc1..f12898d53078 100644 --- a/drivers/base/Makefile +++ b/drivers/base/Makefile | |||
@@ -7,6 +7,7 @@ obj-y := core.o sys.o bus.o dd.o \ | |||
7 | obj-y += power/ | 7 | obj-y += power/ |
8 | obj-$(CONFIG_FW_LOADER) += firmware_class.o | 8 | obj-$(CONFIG_FW_LOADER) += firmware_class.o |
9 | obj-$(CONFIG_NUMA) += node.o | 9 | obj-$(CONFIG_NUMA) += node.o |
10 | obj-$(CONFIG_MEMORY_HOTPLUG) += memory.o | ||
10 | 11 | ||
11 | ifeq ($(CONFIG_DEBUG_DRIVER),y) | 12 | ifeq ($(CONFIG_DEBUG_DRIVER),y) |
12 | EXTRA_CFLAGS += -DDEBUG | 13 | EXTRA_CFLAGS += -DDEBUG |
diff --git a/drivers/base/init.c b/drivers/base/init.c index 84e604e25c4f..c648914b9cde 100644 --- a/drivers/base/init.c +++ b/drivers/base/init.c | |||
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | #include <linux/device.h> | 10 | #include <linux/device.h> |
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/memory.h> | ||
12 | 13 | ||
13 | #include "base.h" | 14 | #include "base.h" |
14 | 15 | ||
@@ -33,5 +34,6 @@ void __init driver_init(void) | |||
33 | platform_bus_init(); | 34 | platform_bus_init(); |
34 | system_bus_init(); | 35 | system_bus_init(); |
35 | cpu_dev_init(); | 36 | cpu_dev_init(); |
37 | memory_dev_init(); | ||
36 | attribute_container_init(); | 38 | attribute_container_init(); |
37 | } | 39 | } |
diff --git a/drivers/base/memory.c b/drivers/base/memory.c new file mode 100644 index 000000000000..b7ddd651d664 --- /dev/null +++ b/drivers/base/memory.c | |||
@@ -0,0 +1,452 @@ | |||
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. | ||
9 | * All arch-independent code that assumes MEMORY_HOTPLUG requires | ||
10 | * SPARSEMEM should be contained here, or in mm/memory_hotplug.c. | ||
11 | */ | ||
12 | |||
13 | #include <linux/sysdev.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/sched.h> /* capable() */ | ||
17 | #include <linux/topology.h> | ||
18 | #include <linux/device.h> | ||
19 | #include <linux/memory.h> | ||
20 | #include <linux/kobject.h> | ||
21 | #include <linux/memory_hotplug.h> | ||
22 | #include <linux/mm.h> | ||
23 | #include <asm/atomic.h> | ||
24 | #include <asm/uaccess.h> | ||
25 | |||
26 | #define MEMORY_CLASS_NAME "memory" | ||
27 | |||
28 | static struct sysdev_class memory_sysdev_class = { | ||
29 | set_kset_name(MEMORY_CLASS_NAME), | ||
30 | }; | ||
31 | EXPORT_SYMBOL(memory_sysdev_class); | ||
32 | |||
33 | static char *memory_hotplug_name(struct kset *kset, struct kobject *kobj) | ||
34 | { | ||
35 | return MEMORY_CLASS_NAME; | ||
36 | } | ||
37 | |||
38 | static int memory_hotplug(struct kset *kset, struct kobject *kobj, char **envp, | ||
39 | int num_envp, char *buffer, int buffer_size) | ||
40 | { | ||
41 | int retval = 0; | ||
42 | |||
43 | return retval; | ||
44 | } | ||
45 | |||
46 | static struct kset_hotplug_ops memory_hotplug_ops = { | ||
47 | .name = memory_hotplug_name, | ||
48 | .hotplug = memory_hotplug, | ||
49 | }; | ||
50 | |||
51 | static struct notifier_block *memory_chain; | ||
52 | |||
53 | static int register_memory_notifier(struct notifier_block *nb) | ||
54 | { | ||
55 | return notifier_chain_register(&memory_chain, nb); | ||
56 | } | ||
57 | |||
58 | static void unregister_memory_notifier(struct notifier_block *nb) | ||
59 | { | ||
60 | notifier_chain_unregister(&memory_chain, nb); | ||
61 | } | ||
62 | |||
63 | /* | ||
64 | * register_memory - Setup a sysfs device for a memory block | ||
65 | */ | ||
66 | static int | ||
67 | register_memory(struct memory_block *memory, struct mem_section *section, | ||
68 | struct node *root) | ||
69 | { | ||
70 | int error; | ||
71 | |||
72 | memory->sysdev.cls = &memory_sysdev_class; | ||
73 | memory->sysdev.id = __section_nr(section); | ||
74 | |||
75 | error = sysdev_register(&memory->sysdev); | ||
76 | |||
77 | if (root && !error) | ||
78 | error = sysfs_create_link(&root->sysdev.kobj, | ||
79 | &memory->sysdev.kobj, | ||
80 | kobject_name(&memory->sysdev.kobj)); | ||
81 | |||
82 | return error; | ||
83 | } | ||
84 | |||
85 | static void | ||
86 | unregister_memory(struct memory_block *memory, struct mem_section *section, | ||
87 | struct node *root) | ||
88 | { | ||
89 | BUG_ON(memory->sysdev.cls != &memory_sysdev_class); | ||
90 | BUG_ON(memory->sysdev.id != __section_nr(section)); | ||
91 | |||
92 | sysdev_unregister(&memory->sysdev); | ||
93 | if (root) | ||
94 | sysfs_remove_link(&root->sysdev.kobj, | ||
95 | kobject_name(&memory->sysdev.kobj)); | ||
96 | } | ||
97 | |||
98 | /* | ||
99 | * use this as the physical section index that this memsection | ||
100 | * uses. | ||
101 | */ | ||
102 | |||
103 | static ssize_t show_mem_phys_index(struct sys_device *dev, char *buf) | ||
104 | { | ||
105 | struct memory_block *mem = | ||
106 | container_of(dev, struct memory_block, sysdev); | ||
107 | return sprintf(buf, "%08lx\n", mem->phys_index); | ||
108 | } | ||
109 | |||
110 | /* | ||
111 | * online, offline, going offline, etc. | ||
112 | */ | ||
113 | static ssize_t show_mem_state(struct sys_device *dev, char *buf) | ||
114 | { | ||
115 | struct memory_block *mem = | ||
116 | container_of(dev, struct memory_block, sysdev); | ||
117 | ssize_t len = 0; | ||
118 | |||
119 | /* | ||
120 | * We can probably put these states in a nice little array | ||
121 | * so that they're not open-coded | ||
122 | */ | ||
123 | switch (mem->state) { | ||
124 | case MEM_ONLINE: | ||
125 | len = sprintf(buf, "online\n"); | ||
126 | break; | ||
127 | case MEM_OFFLINE: | ||
128 | len = sprintf(buf, "offline\n"); | ||
129 | break; | ||
130 | case MEM_GOING_OFFLINE: | ||
131 | len = sprintf(buf, "going-offline\n"); | ||
132 | break; | ||
133 | default: | ||
134 | len = sprintf(buf, "ERROR-UNKNOWN-%ld\n", | ||
135 | mem->state); | ||
136 | WARN_ON(1); | ||
137 | break; | ||
138 | } | ||
139 | |||
140 | return len; | ||
141 | } | ||
142 | |||
143 | static inline int memory_notify(unsigned long val, void *v) | ||
144 | { | ||
145 | return notifier_call_chain(&memory_chain, val, v); | ||
146 | } | ||
147 | |||
148 | /* | ||
149 | * MEMORY_HOTPLUG depends on SPARSEMEM in mm/Kconfig, so it is | ||
150 | * OK to have direct references to sparsemem variables in here. | ||
151 | */ | ||
152 | static int | ||
153 | memory_block_action(struct memory_block *mem, unsigned long action) | ||
154 | { | ||
155 | int i; | ||
156 | unsigned long psection; | ||
157 | unsigned long start_pfn, start_paddr; | ||
158 | struct page *first_page; | ||
159 | int ret; | ||
160 | int old_state = mem->state; | ||
161 | |||
162 | psection = mem->phys_index; | ||
163 | first_page = pfn_to_page(psection << PFN_SECTION_SHIFT); | ||
164 | |||
165 | /* | ||
166 | * The probe routines leave the pages reserved, just | ||
167 | * as the bootmem code does. Make sure they're still | ||
168 | * that way. | ||
169 | */ | ||
170 | if (action == MEM_ONLINE) { | ||
171 | for (i = 0; i < PAGES_PER_SECTION; i++) { | ||
172 | if (PageReserved(first_page+i)) | ||
173 | continue; | ||
174 | |||
175 | printk(KERN_WARNING "section number %ld page number %d " | ||
176 | "not reserved, was it already online? \n", | ||
177 | psection, i); | ||
178 | return -EBUSY; | ||
179 | } | ||
180 | } | ||
181 | |||
182 | switch (action) { | ||
183 | case MEM_ONLINE: | ||
184 | start_pfn = page_to_pfn(first_page); | ||
185 | ret = online_pages(start_pfn, PAGES_PER_SECTION); | ||
186 | break; | ||
187 | case MEM_OFFLINE: | ||
188 | mem->state = MEM_GOING_OFFLINE; | ||
189 | memory_notify(MEM_GOING_OFFLINE, NULL); | ||
190 | start_paddr = page_to_pfn(first_page) << PAGE_SHIFT; | ||
191 | ret = remove_memory(start_paddr, | ||
192 | PAGES_PER_SECTION << PAGE_SHIFT); | ||
193 | if (ret) { | ||
194 | mem->state = old_state; | ||
195 | break; | ||
196 | } | ||
197 | memory_notify(MEM_MAPPING_INVALID, NULL); | ||
198 | break; | ||
199 | default: | ||
200 | printk(KERN_WARNING "%s(%p, %ld) unknown action: %ld\n", | ||
201 | __FUNCTION__, mem, action, action); | ||
202 | WARN_ON(1); | ||
203 | ret = -EINVAL; | ||
204 | } | ||
205 | /* | ||
206 | * For now, only notify on successful memory operations | ||
207 | */ | ||
208 | if (!ret) | ||
209 | memory_notify(action, NULL); | ||
210 | |||
211 | return ret; | ||
212 | } | ||
213 | |||
214 | static int memory_block_change_state(struct memory_block *mem, | ||
215 | unsigned long to_state, unsigned long from_state_req) | ||
216 | { | ||
217 | int ret = 0; | ||
218 | down(&mem->state_sem); | ||
219 | |||
220 | if (mem->state != from_state_req) { | ||
221 | ret = -EINVAL; | ||
222 | goto out; | ||
223 | } | ||
224 | |||
225 | ret = memory_block_action(mem, to_state); | ||
226 | if (!ret) | ||
227 | mem->state = to_state; | ||
228 | |||
229 | out: | ||
230 | up(&mem->state_sem); | ||
231 | return ret; | ||
232 | } | ||
233 | |||
234 | static ssize_t | ||
235 | store_mem_state(struct sys_device *dev, const char *buf, size_t count) | ||
236 | { | ||
237 | struct memory_block *mem; | ||
238 | unsigned int phys_section_nr; | ||
239 | int ret = -EINVAL; | ||
240 | |||
241 | mem = container_of(dev, struct memory_block, sysdev); | ||
242 | phys_section_nr = mem->phys_index; | ||
243 | |||
244 | if (!valid_section_nr(phys_section_nr)) | ||
245 | goto out; | ||
246 | |||
247 | if (!strncmp(buf, "online", min((int)count, 6))) | ||
248 | ret = memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE); | ||
249 | else if(!strncmp(buf, "offline", min((int)count, 7))) | ||
250 | ret = memory_block_change_state(mem, MEM_OFFLINE, MEM_ONLINE); | ||
251 | out: | ||
252 | if (ret) | ||
253 | return ret; | ||
254 | return count; | ||
255 | } | ||
256 | |||
257 | /* | ||
258 | * phys_device is a bad name for this. What I really want | ||
259 | * is a way to differentiate between memory ranges that | ||
260 | * are part of physical devices that constitute | ||
261 | * a complete removable unit or fru. | ||
262 | * i.e. do these ranges belong to the same physical device, | ||
263 | * s.t. if I offline all of these sections I can then | ||
264 | * remove the physical device? | ||
265 | */ | ||
266 | static ssize_t show_phys_device(struct sys_device *dev, char *buf) | ||
267 | { | ||
268 | struct memory_block *mem = | ||
269 | container_of(dev, struct memory_block, sysdev); | ||
270 | return sprintf(buf, "%d\n", mem->phys_device); | ||
271 | } | ||
272 | |||
273 | static SYSDEV_ATTR(phys_index, 0444, show_mem_phys_index, NULL); | ||
274 | static SYSDEV_ATTR(state, 0644, show_mem_state, store_mem_state); | ||
275 | static SYSDEV_ATTR(phys_device, 0444, show_phys_device, NULL); | ||
276 | |||
277 | #define mem_create_simple_file(mem, attr_name) \ | ||
278 | sysdev_create_file(&mem->sysdev, &attr_##attr_name) | ||
279 | #define mem_remove_simple_file(mem, attr_name) \ | ||
280 | sysdev_remove_file(&mem->sysdev, &attr_##attr_name) | ||
281 | |||
282 | /* | ||
283 | * Block size attribute stuff | ||
284 | */ | ||
285 | static ssize_t | ||
286 | print_block_size(struct class *class, char *buf) | ||
287 | { | ||
288 | return sprintf(buf, "%lx\n", (unsigned long)PAGES_PER_SECTION * PAGE_SIZE); | ||
289 | } | ||
290 | |||
291 | static CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL); | ||
292 | |||
293 | static int block_size_init(void) | ||
294 | { | ||
295 | sysfs_create_file(&memory_sysdev_class.kset.kobj, | ||
296 | &class_attr_block_size_bytes.attr); | ||
297 | return 0; | ||
298 | } | ||
299 | |||
300 | /* | ||
301 | * Some architectures will have custom drivers to do this, and | ||
302 | * will not need to do it from userspace. The fake hot-add code | ||
303 | * as well as ppc64 will do all of their discovery in userspace | ||
304 | * and will require this interface. | ||
305 | */ | ||
306 | #ifdef CONFIG_ARCH_MEMORY_PROBE | ||
307 | static ssize_t | ||
308 | memory_probe_store(struct class *class, const char __user *buf, size_t count) | ||
309 | { | ||
310 | u64 phys_addr; | ||
311 | int ret; | ||
312 | |||
313 | phys_addr = simple_strtoull(buf, NULL, 0); | ||
314 | |||
315 | ret = add_memory(phys_addr, PAGES_PER_SECTION << PAGE_SHIFT); | ||
316 | |||
317 | if (ret) | ||
318 | count = ret; | ||
319 | |||
320 | return count; | ||
321 | } | ||
322 | static CLASS_ATTR(probe, 0700, NULL, memory_probe_store); | ||
323 | |||
324 | static int memory_probe_init(void) | ||
325 | { | ||
326 | sysfs_create_file(&memory_sysdev_class.kset.kobj, | ||
327 | &class_attr_probe.attr); | ||
328 | return 0; | ||
329 | } | ||
330 | #else | ||
331 | #define memory_probe_init(...) do {} while (0) | ||
332 | #endif | ||
333 | |||
334 | /* | ||
335 | * Note that phys_device is optional. It is here to allow for | ||
336 | * differentiation between which *physical* devices each | ||
337 | * section belongs to... | ||
338 | */ | ||
339 | |||
340 | static int add_memory_block(unsigned long node_id, struct mem_section *section, | ||
341 | unsigned long state, int phys_device) | ||
342 | { | ||
343 | struct memory_block *mem = kzalloc(sizeof(*mem), GFP_KERNEL); | ||
344 | int ret = 0; | ||
345 | |||
346 | if (!mem) | ||
347 | return -ENOMEM; | ||
348 | |||
349 | mem->phys_index = __section_nr(section); | ||
350 | mem->state = state; | ||
351 | init_MUTEX(&mem->state_sem); | ||
352 | mem->phys_device = phys_device; | ||
353 | |||
354 | ret = register_memory(mem, section, NULL); | ||
355 | if (!ret) | ||
356 | ret = mem_create_simple_file(mem, phys_index); | ||
357 | if (!ret) | ||
358 | ret = mem_create_simple_file(mem, state); | ||
359 | if (!ret) | ||
360 | ret = mem_create_simple_file(mem, phys_device); | ||
361 | |||
362 | return ret; | ||
363 | } | ||
364 | |||
365 | /* | ||
366 | * For now, we have a linear search to go find the appropriate | ||
367 | * memory_block corresponding to a particular phys_index. If | ||
368 | * this gets to be a real problem, we can always use a radix | ||
369 | * tree or something here. | ||
370 | * | ||
371 | * This could be made generic for all sysdev classes. | ||
372 | */ | ||
373 | static struct memory_block *find_memory_block(struct mem_section *section) | ||
374 | { | ||
375 | struct kobject *kobj; | ||
376 | struct sys_device *sysdev; | ||
377 | struct memory_block *mem; | ||
378 | char name[sizeof(MEMORY_CLASS_NAME) + 9 + 1]; | ||
379 | |||
380 | /* | ||
381 | * This only works because we know that section == sysdev->id | ||
382 | * slightly redundant with sysdev_register() | ||
383 | */ | ||
384 | sprintf(&name[0], "%s%d", MEMORY_CLASS_NAME, __section_nr(section)); | ||
385 | |||
386 | kobj = kset_find_obj(&memory_sysdev_class.kset, name); | ||
387 | if (!kobj) | ||
388 | return NULL; | ||
389 | |||
390 | sysdev = container_of(kobj, struct sys_device, kobj); | ||
391 | mem = container_of(sysdev, struct memory_block, sysdev); | ||
392 | |||
393 | return mem; | ||
394 | } | ||
395 | |||
396 | int remove_memory_block(unsigned long node_id, struct mem_section *section, | ||
397 | int phys_device) | ||
398 | { | ||
399 | struct memory_block *mem; | ||
400 | |||
401 | mem = find_memory_block(section); | ||
402 | mem_remove_simple_file(mem, phys_index); | ||
403 | mem_remove_simple_file(mem, state); | ||
404 | mem_remove_simple_file(mem, phys_device); | ||
405 | unregister_memory(mem, section, NULL); | ||
406 | |||
407 | return 0; | ||
408 | } | ||
409 | |||
410 | /* | ||
411 | * need an interface for the VM to add new memory regions, | ||
412 | * but without onlining it. | ||
413 | */ | ||
414 | int register_new_memory(struct mem_section *section) | ||
415 | { | ||
416 | return add_memory_block(0, section, MEM_OFFLINE, 0); | ||
417 | } | ||
418 | |||
419 | int unregister_memory_section(struct mem_section *section) | ||
420 | { | ||
421 | if (!valid_section(section)) | ||
422 | return -EINVAL; | ||
423 | |||
424 | return remove_memory_block(0, section, 0); | ||
425 | } | ||
426 | |||
427 | /* | ||
428 | * Initialize the sysfs support for memory devices... | ||
429 | */ | ||
430 | int __init memory_dev_init(void) | ||
431 | { | ||
432 | unsigned int i; | ||
433 | int ret; | ||
434 | |||
435 | memory_sysdev_class.kset.hotplug_ops = &memory_hotplug_ops; | ||
436 | ret = sysdev_class_register(&memory_sysdev_class); | ||
437 | |||
438 | /* | ||
439 | * Create entries for memory sections that were found | ||
440 | * during boot and have been initialized | ||
441 | */ | ||
442 | for (i = 0; i < NR_MEM_SECTIONS; i++) { | ||
443 | if (!valid_section_nr(i)) | ||
444 | continue; | ||
445 | add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0); | ||
446 | } | ||
447 | |||
448 | memory_probe_init(); | ||
449 | block_size_init(); | ||
450 | |||
451 | return ret; | ||
452 | } | ||
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 28c1a628621f..cf6631056683 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/crypto.h> | 15 | #include <linux/crypto.h> |
16 | #include <linux/workqueue.h> | 16 | #include <linux/workqueue.h> |
17 | #include <asm/atomic.h> | 17 | #include <asm/atomic.h> |
18 | #include <asm/scatterlist.h> | 18 | #include <linux/scatterlist.h> |
19 | #include <asm/page.h> | 19 | #include <asm/page.h> |
20 | 20 | ||
21 | #include "dm.h" | 21 | #include "dm.h" |
@@ -164,9 +164,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, | |||
164 | return -ENOMEM; | 164 | return -ENOMEM; |
165 | } | 165 | } |
166 | 166 | ||
167 | sg.page = virt_to_page(cc->key); | 167 | sg_set_buf(&sg, cc->key, cc->key_size); |
168 | sg.offset = offset_in_page(cc->key); | ||
169 | sg.length = cc->key_size; | ||
170 | crypto_digest_digest(hash_tfm, &sg, 1, salt); | 168 | crypto_digest_digest(hash_tfm, &sg, 1, salt); |
171 | crypto_free_tfm(hash_tfm); | 169 | crypto_free_tfm(hash_tfm); |
172 | 170 | ||
@@ -207,14 +205,12 @@ static void crypt_iv_essiv_dtr(struct crypt_config *cc) | |||
207 | 205 | ||
208 | static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, sector_t sector) | 206 | static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, sector_t sector) |
209 | { | 207 | { |
210 | struct scatterlist sg = { NULL, }; | 208 | struct scatterlist sg; |
211 | 209 | ||
212 | memset(iv, 0, cc->iv_size); | 210 | memset(iv, 0, cc->iv_size); |
213 | *(u64 *)iv = cpu_to_le64(sector); | 211 | *(u64 *)iv = cpu_to_le64(sector); |
214 | 212 | ||
215 | sg.page = virt_to_page(iv); | 213 | sg_set_buf(&sg, iv, cc->iv_size); |
216 | sg.offset = offset_in_page(iv); | ||
217 | sg.length = cc->iv_size; | ||
218 | crypto_cipher_encrypt((struct crypto_tfm *)cc->iv_gen_private, | 214 | crypto_cipher_encrypt((struct crypto_tfm *)cc->iv_gen_private, |
219 | &sg, &sg, cc->iv_size); | 215 | &sg, &sg, cc->iv_size); |
220 | 216 | ||
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 4c11699bad91..750c0167539c 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/interrupt.h> | 35 | #include <linux/interrupt.h> |
36 | #include <linux/in.h> | 36 | #include <linux/in.h> |
37 | #include <linux/bitops.h> | 37 | #include <linux/bitops.h> |
38 | #include <linux/scatterlist.h> | ||
38 | #include <asm/io.h> | 39 | #include <asm/io.h> |
39 | #include <asm/system.h> | 40 | #include <asm/system.h> |
40 | 41 | ||
@@ -1590,11 +1591,9 @@ static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct | |||
1590 | aes_counter[12] = (u8)(counter >> 24); | 1591 | aes_counter[12] = (u8)(counter >> 24); |
1591 | counter++; | 1592 | counter++; |
1592 | memcpy (plain, aes_counter, 16); | 1593 | memcpy (plain, aes_counter, 16); |
1593 | sg[0].page = virt_to_page(plain); | 1594 | sg_set_buf(sg, plain, 16); |
1594 | sg[0].offset = ((long) plain & ~PAGE_MASK); | ||
1595 | sg[0].length = 16; | ||
1596 | crypto_cipher_encrypt(tfm, sg, sg, 16); | 1595 | crypto_cipher_encrypt(tfm, sg, sg, 16); |
1597 | cipher = kmap(sg[0].page) + sg[0].offset; | 1596 | cipher = kmap(sg->page) + sg->offset; |
1598 | for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) { | 1597 | for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) { |
1599 | context->coeff[i++] = ntohl(*(u32 *)&cipher[j]); | 1598 | context->coeff[i++] = ntohl(*(u32 *)&cipher[j]); |
1600 | j += 4; | 1599 | j += 4; |
diff --git a/drivers/scsi/arm/scsi.h b/drivers/scsi/arm/scsi.h index 48e1c4d9738b..19937640e2e7 100644 --- a/drivers/scsi/arm/scsi.h +++ b/drivers/scsi/arm/scsi.h | |||
@@ -10,6 +10,8 @@ | |||
10 | * Commonly used scsi driver functions. | 10 | * Commonly used scsi driver functions. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/scatterlist.h> | ||
14 | |||
13 | #define BELT_AND_BRACES | 15 | #define BELT_AND_BRACES |
14 | 16 | ||
15 | /* | 17 | /* |
@@ -22,9 +24,7 @@ static inline int copy_SCp_to_sg(struct scatterlist *sg, Scsi_Pointer *SCp, int | |||
22 | 24 | ||
23 | BUG_ON(bufs + 1 > max); | 25 | BUG_ON(bufs + 1 > max); |
24 | 26 | ||
25 | sg->page = virt_to_page(SCp->ptr); | 27 | sg_set_buf(sg, SCp->ptr, SCp->this_residual); |
26 | sg->offset = offset_in_page(SCp->ptr); | ||
27 | sg->length = SCp->this_residual; | ||
28 | 28 | ||
29 | if (bufs) | 29 | if (bufs) |
30 | memcpy(sg + 1, SCp->buffer + 1, | 30 | memcpy(sg + 1, SCp->buffer + 1, |
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index d2f71a2331bb..771bc7d376bc 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <linux/suspend.h> | 49 | #include <linux/suspend.h> |
50 | #include <linux/workqueue.h> | 50 | #include <linux/workqueue.h> |
51 | #include <linux/jiffies.h> | 51 | #include <linux/jiffies.h> |
52 | #include <linux/scatterlist.h> | ||
52 | #include <scsi/scsi.h> | 53 | #include <scsi/scsi.h> |
53 | #include "scsi.h" | 54 | #include "scsi.h" |
54 | #include "scsi_priv.h" | 55 | #include "scsi_priv.h" |
@@ -2554,19 +2555,12 @@ void ata_qc_prep(struct ata_queued_cmd *qc) | |||
2554 | 2555 | ||
2555 | void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) | 2556 | void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) |
2556 | { | 2557 | { |
2557 | struct scatterlist *sg; | ||
2558 | |||
2559 | qc->flags |= ATA_QCFLAG_SINGLE; | 2558 | qc->flags |= ATA_QCFLAG_SINGLE; |
2560 | 2559 | ||
2561 | memset(&qc->sgent, 0, sizeof(qc->sgent)); | ||
2562 | qc->sg = &qc->sgent; | 2560 | qc->sg = &qc->sgent; |
2563 | qc->n_elem = 1; | 2561 | qc->n_elem = 1; |
2564 | qc->buf_virt = buf; | 2562 | qc->buf_virt = buf; |
2565 | 2563 | sg_init_one(qc->sg, buf, buflen); | |
2566 | sg = qc->sg; | ||
2567 | sg->page = virt_to_page(buf); | ||
2568 | sg->offset = (unsigned long) buf & ~PAGE_MASK; | ||
2569 | sg->length = buflen; | ||
2570 | } | 2564 | } |
2571 | 2565 | ||
2572 | /** | 2566 | /** |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 861e51375d70..d86d5c26061d 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -49,6 +49,7 @@ static int sg_version_num = 30533; /* 2 digits for each component */ | |||
49 | #include <linux/seq_file.h> | 49 | #include <linux/seq_file.h> |
50 | #include <linux/blkdev.h> | 50 | #include <linux/blkdev.h> |
51 | #include <linux/delay.h> | 51 | #include <linux/delay.h> |
52 | #include <linux/scatterlist.h> | ||
52 | 53 | ||
53 | #include "scsi.h" | 54 | #include "scsi.h" |
54 | #include <scsi/scsi_dbg.h> | 55 | #include <scsi/scsi_dbg.h> |
@@ -1886,13 +1887,17 @@ st_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_pages, | |||
1886 | int i; | 1887 | int i; |
1887 | 1888 | ||
1888 | for (i=0; i < nr_pages; i++) { | 1889 | for (i=0; i < nr_pages; i++) { |
1889 | if (dirtied && !PageReserved(sgl[i].page)) | 1890 | struct page *page = sgl[i].page; |
1890 | SetPageDirty(sgl[i].page); | 1891 | |
1891 | /* unlock_page(sgl[i].page); */ | 1892 | /* XXX: just for debug. Remove when PageReserved is removed */ |
1893 | BUG_ON(PageReserved(page)); | ||
1894 | if (dirtied) | ||
1895 | SetPageDirty(page); | ||
1896 | /* unlock_page(page); */ | ||
1892 | /* FIXME: cache flush missing for rw==READ | 1897 | /* FIXME: cache flush missing for rw==READ |
1893 | * FIXME: call the correct reference counting function | 1898 | * FIXME: call the correct reference counting function |
1894 | */ | 1899 | */ |
1895 | page_cache_release(sgl[i].page); | 1900 | page_cache_release(page); |
1896 | } | 1901 | } |
1897 | 1902 | ||
1898 | return 0; | 1903 | return 0; |
@@ -1992,9 +1997,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) | |||
1992 | if (!p) | 1997 | if (!p) |
1993 | break; | 1998 | break; |
1994 | } | 1999 | } |
1995 | sclp->page = virt_to_page(p); | 2000 | sg_set_buf(sclp, p, ret_sz); |
1996 | sclp->offset = offset_in_page(p); | ||
1997 | sclp->length = ret_sz; | ||
1998 | 2001 | ||
1999 | SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n", | 2002 | SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n", |
2000 | k, sg_scatg2virt(sclp), ret_sz)); | 2003 | k, sg_scatg2virt(sclp), ret_sz)); |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 5eb54d8019b4..da9766283bd7 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -4526,12 +4526,16 @@ static int sgl_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_p | |||
4526 | int i; | 4526 | int i; |
4527 | 4527 | ||
4528 | for (i=0; i < nr_pages; i++) { | 4528 | for (i=0; i < nr_pages; i++) { |
4529 | if (dirtied && !PageReserved(sgl[i].page)) | 4529 | struct page *page = sgl[i].page; |
4530 | SetPageDirty(sgl[i].page); | 4530 | |
4531 | /* XXX: just for debug. Remove when PageReserved is removed */ | ||
4532 | BUG_ON(PageReserved(page)); | ||
4533 | if (dirtied) | ||
4534 | SetPageDirty(page); | ||
4531 | /* FIXME: cache flush missing for rw==READ | 4535 | /* FIXME: cache flush missing for rw==READ |
4532 | * FIXME: call the correct reference counting function | 4536 | * FIXME: call the correct reference counting function |
4533 | */ | 4537 | */ |
4534 | page_cache_release(sgl[i].page); | 4538 | page_cache_release(page); |
4535 | } | 4539 | } |
4536 | 4540 | ||
4537 | return 0; | 4541 | return 0; |
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 90a96257d6ce..2997f558159b 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -9,7 +9,7 @@ | |||
9 | #include <linux/mm.h> | 9 | #include <linux/mm.h> |
10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
11 | #include <linux/moduleparam.h> | 11 | #include <linux/moduleparam.h> |
12 | #include <asm/scatterlist.h> | 12 | #include <linux/scatterlist.h> |
13 | 13 | ||
14 | #include <linux/usb.h> | 14 | #include <linux/usb.h> |
15 | 15 | ||
@@ -381,7 +381,6 @@ alloc_sglist (int nents, int max, int vary) | |||
381 | sg = kmalloc (nents * sizeof *sg, SLAB_KERNEL); | 381 | sg = kmalloc (nents * sizeof *sg, SLAB_KERNEL); |
382 | if (!sg) | 382 | if (!sg) |
383 | return NULL; | 383 | return NULL; |
384 | memset (sg, 0, nents * sizeof *sg); | ||
385 | 384 | ||
386 | for (i = 0; i < nents; i++) { | 385 | for (i = 0; i < nents; i++) { |
387 | char *buf; | 386 | char *buf; |
@@ -394,9 +393,7 @@ alloc_sglist (int nents, int max, int vary) | |||
394 | memset (buf, 0, size); | 393 | memset (buf, 0, size); |
395 | 394 | ||
396 | /* kmalloc pages are always physically contiguous! */ | 395 | /* kmalloc pages are always physically contiguous! */ |
397 | sg [i].page = virt_to_page (buf); | 396 | sg_init_one(&sg[i], buf, size); |
398 | sg [i].offset = offset_in_page (buf); | ||
399 | sg [i].length = size; | ||
400 | 397 | ||
401 | if (vary) { | 398 | if (vary) { |
402 | size += vary; | 399 | size += vary; |