diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-10-30 20:37:44 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-10-30 20:37:44 -0500 |
commit | 9e0cb06b17be7e562cbdaba2768649f025826dc6 (patch) | |
tree | aaf5ef8c6cd11764d222df9c446ad9af17e0020e /drivers | |
parent | 23da0c20ef1c1f0432f373e0e2233a6b6ab2678f (diff) | |
parent | 6e9d6b8ee4e0c37d3952256e6472c57490d6780d (diff) |
Merge branch 'master'
Diffstat (limited to 'drivers')
29 files changed, 696 insertions, 272 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/pci/quirks.c b/drivers/pci/quirks.c index bbd9c2323d8c..5627ce1d2b32 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -356,7 +356,7 @@ static void piix4_mem_quirk(struct pci_dev *dev, const char *name, unsigned int | |||
356 | /* | 356 | /* |
357 | * PIIX4 ACPI: Two IO regions pointed to by longwords at | 357 | * PIIX4 ACPI: Two IO regions pointed to by longwords at |
358 | * 0x40 (64 bytes of ACPI registers) | 358 | * 0x40 (64 bytes of ACPI registers) |
359 | * 0x90 (32 bytes of SMB registers) | 359 | * 0x90 (16 bytes of SMB registers) |
360 | * and a few strange programmable PIIX4 device resources. | 360 | * and a few strange programmable PIIX4 device resources. |
361 | */ | 361 | */ |
362 | static void __devinit quirk_piix4_acpi(struct pci_dev *dev) | 362 | static void __devinit quirk_piix4_acpi(struct pci_dev *dev) |
@@ -366,7 +366,7 @@ static void __devinit quirk_piix4_acpi(struct pci_dev *dev) | |||
366 | pci_read_config_dword(dev, 0x40, ®ion); | 366 | pci_read_config_dword(dev, 0x40, ®ion); |
367 | quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES, "PIIX4 ACPI"); | 367 | quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES, "PIIX4 ACPI"); |
368 | pci_read_config_dword(dev, 0x90, ®ion); | 368 | pci_read_config_dword(dev, 0x90, ®ion); |
369 | quirk_io_region(dev, region, 32, PCI_BRIDGE_RESOURCES+1, "PIIX4 SMB"); | 369 | quirk_io_region(dev, region, 16, PCI_BRIDGE_RESOURCES+1, "PIIX4 SMB"); |
370 | 370 | ||
371 | /* Device resource A has enables for some of the other ones */ | 371 | /* Device resource A has enables for some of the other ones */ |
372 | pci_read_config_dword(dev, 0x5c, &res_a); | 372 | pci_read_config_dword(dev, 0x5c, &res_a); |
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index fe8187d6f58b..e2a5657d5fdb 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/interrupt.h> | 41 | #include <linux/interrupt.h> |
42 | #include <linux/sched.h> | 42 | #include <linux/sched.h> |
43 | #include <linux/dma-mapping.h> | 43 | #include <linux/dma-mapping.h> |
44 | #include <linux/device.h> | ||
44 | #include "scsi.h" | 45 | #include "scsi.h" |
45 | #include <scsi/scsi_host.h> | 46 | #include <scsi/scsi_host.h> |
46 | #include <linux/libata.h> | 47 | #include <linux/libata.h> |
@@ -192,7 +193,6 @@ static void ahci_port_stop(struct ata_port *ap); | |||
192 | static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf); | 193 | static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf); |
193 | static void ahci_qc_prep(struct ata_queued_cmd *qc); | 194 | static void ahci_qc_prep(struct ata_queued_cmd *qc); |
194 | static u8 ahci_check_status(struct ata_port *ap); | 195 | static u8 ahci_check_status(struct ata_port *ap); |
195 | static u8 ahci_check_err(struct ata_port *ap); | ||
196 | static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); | 196 | static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); |
197 | static void ahci_remove_one (struct pci_dev *pdev); | 197 | static void ahci_remove_one (struct pci_dev *pdev); |
198 | 198 | ||
@@ -221,7 +221,6 @@ static const struct ata_port_operations ahci_ops = { | |||
221 | 221 | ||
222 | .check_status = ahci_check_status, | 222 | .check_status = ahci_check_status, |
223 | .check_altstatus = ahci_check_status, | 223 | .check_altstatus = ahci_check_status, |
224 | .check_err = ahci_check_err, | ||
225 | .dev_select = ata_noop_dev_select, | 224 | .dev_select = ata_noop_dev_select, |
226 | 225 | ||
227 | .tf_read = ahci_tf_read, | 226 | .tf_read = ahci_tf_read, |
@@ -458,13 +457,6 @@ static u8 ahci_check_status(struct ata_port *ap) | |||
458 | return readl(mmio + PORT_TFDATA) & 0xFF; | 457 | return readl(mmio + PORT_TFDATA) & 0xFF; |
459 | } | 458 | } |
460 | 459 | ||
461 | static u8 ahci_check_err(struct ata_port *ap) | ||
462 | { | ||
463 | void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr; | ||
464 | |||
465 | return (readl(mmio + PORT_TFDATA) >> 8) & 0xFF; | ||
466 | } | ||
467 | |||
468 | static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | 460 | static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf) |
469 | { | 461 | { |
470 | struct ahci_port_priv *pp = ap->private_data; | 462 | struct ahci_port_priv *pp = ap->private_data; |
@@ -609,7 +601,7 @@ static void ahci_eng_timeout(struct ata_port *ap) | |||
609 | * not being called from the SCSI EH. | 601 | * not being called from the SCSI EH. |
610 | */ | 602 | */ |
611 | qc->scsidone = scsi_finish_command; | 603 | qc->scsidone = scsi_finish_command; |
612 | ata_qc_complete(qc, ATA_ERR); | 604 | ata_qc_complete(qc, AC_ERR_OTHER); |
613 | } | 605 | } |
614 | 606 | ||
615 | spin_unlock_irqrestore(&host_set->lock, flags); | 607 | spin_unlock_irqrestore(&host_set->lock, flags); |
@@ -638,7 +630,7 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) | |||
638 | if (status & PORT_IRQ_FATAL) { | 630 | if (status & PORT_IRQ_FATAL) { |
639 | ahci_intr_error(ap, status); | 631 | ahci_intr_error(ap, status); |
640 | if (qc) | 632 | if (qc) |
641 | ata_qc_complete(qc, ATA_ERR); | 633 | ata_qc_complete(qc, AC_ERR_OTHER); |
642 | } | 634 | } |
643 | 635 | ||
644 | return 1; | 636 | return 1; |
@@ -683,10 +675,10 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs * | |||
683 | if (!ahci_host_intr(ap, qc)) | 675 | if (!ahci_host_intr(ap, qc)) |
684 | if (ata_ratelimit()) { | 676 | if (ata_ratelimit()) { |
685 | struct pci_dev *pdev = | 677 | struct pci_dev *pdev = |
686 | to_pci_dev(ap->host_set->dev); | 678 | to_pci_dev(ap->host_set->dev); |
687 | printk(KERN_WARNING | 679 | dev_printk(KERN_WARNING, &pdev->dev, |
688 | "ahci(%s): unhandled interrupt on port %u\n", | 680 | "unhandled interrupt on port %u\n", |
689 | pci_name(pdev), i); | 681 | i); |
690 | } | 682 | } |
691 | 683 | ||
692 | VPRINTK("port %u\n", i); | 684 | VPRINTK("port %u\n", i); |
@@ -694,10 +686,9 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs * | |||
694 | VPRINTK("port %u (no irq)\n", i); | 686 | VPRINTK("port %u (no irq)\n", i); |
695 | if (ata_ratelimit()) { | 687 | if (ata_ratelimit()) { |
696 | struct pci_dev *pdev = | 688 | struct pci_dev *pdev = |
697 | to_pci_dev(ap->host_set->dev); | 689 | to_pci_dev(ap->host_set->dev); |
698 | printk(KERN_WARNING | 690 | dev_printk(KERN_WARNING, &pdev->dev, |
699 | "ahci(%s): interrupt on disabled port %u\n", | 691 | "interrupt on disabled port %u\n", i); |
700 | pci_name(pdev), i); | ||
701 | } | 692 | } |
702 | } | 693 | } |
703 | 694 | ||
@@ -769,8 +760,8 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent) | |||
769 | 760 | ||
770 | tmp = readl(mmio + HOST_CTL); | 761 | tmp = readl(mmio + HOST_CTL); |
771 | if (tmp & HOST_RESET) { | 762 | if (tmp & HOST_RESET) { |
772 | printk(KERN_ERR DRV_NAME "(%s): controller reset failed (0x%x)\n", | 763 | dev_printk(KERN_ERR, &pdev->dev, |
773 | pci_name(pdev), tmp); | 764 | "controller reset failed (0x%x)\n", tmp); |
774 | return -EIO; | 765 | return -EIO; |
775 | } | 766 | } |
776 | 767 | ||
@@ -798,22 +789,22 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent) | |||
798 | if (rc) { | 789 | if (rc) { |
799 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | 790 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); |
800 | if (rc) { | 791 | if (rc) { |
801 | printk(KERN_ERR DRV_NAME "(%s): 64-bit DMA enable failed\n", | 792 | dev_printk(KERN_ERR, &pdev->dev, |
802 | pci_name(pdev)); | 793 | "64-bit DMA enable failed\n"); |
803 | return rc; | 794 | return rc; |
804 | } | 795 | } |
805 | } | 796 | } |
806 | } else { | 797 | } else { |
807 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 798 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
808 | if (rc) { | 799 | if (rc) { |
809 | printk(KERN_ERR DRV_NAME "(%s): 32-bit DMA enable failed\n", | 800 | dev_printk(KERN_ERR, &pdev->dev, |
810 | pci_name(pdev)); | 801 | "32-bit DMA enable failed\n"); |
811 | return rc; | 802 | return rc; |
812 | } | 803 | } |
813 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | 804 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); |
814 | if (rc) { | 805 | if (rc) { |
815 | printk(KERN_ERR DRV_NAME "(%s): 32-bit consistent DMA enable failed\n", | 806 | dev_printk(KERN_ERR, &pdev->dev, |
816 | pci_name(pdev)); | 807 | "32-bit consistent DMA enable failed\n"); |
817 | return rc; | 808 | return rc; |
818 | } | 809 | } |
819 | } | 810 | } |
@@ -916,10 +907,10 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent) | |||
916 | else | 907 | else |
917 | scc_s = "unknown"; | 908 | scc_s = "unknown"; |
918 | 909 | ||
919 | printk(KERN_INFO DRV_NAME "(%s) AHCI %02x%02x.%02x%02x " | 910 | dev_printk(KERN_INFO, &pdev->dev, |
911 | "AHCI %02x%02x.%02x%02x " | ||
920 | "%u slots %u ports %s Gbps 0x%x impl %s mode\n" | 912 | "%u slots %u ports %s Gbps 0x%x impl %s mode\n" |
921 | , | 913 | , |
922 | pci_name(pdev), | ||
923 | 914 | ||
924 | (vers >> 24) & 0xff, | 915 | (vers >> 24) & 0xff, |
925 | (vers >> 16) & 0xff, | 916 | (vers >> 16) & 0xff, |
@@ -932,11 +923,11 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent) | |||
932 | impl, | 923 | impl, |
933 | scc_s); | 924 | scc_s); |
934 | 925 | ||
935 | printk(KERN_INFO DRV_NAME "(%s) flags: " | 926 | dev_printk(KERN_INFO, &pdev->dev, |
927 | "flags: " | ||
936 | "%s%s%s%s%s%s" | 928 | "%s%s%s%s%s%s" |
937 | "%s%s%s%s%s%s%s\n" | 929 | "%s%s%s%s%s%s%s\n" |
938 | , | 930 | , |
939 | pci_name(pdev), | ||
940 | 931 | ||
941 | cap & (1 << 31) ? "64bit " : "", | 932 | cap & (1 << 31) ? "64bit " : "", |
942 | cap & (1 << 30) ? "ncq " : "", | 933 | cap & (1 << 30) ? "ncq " : "", |
@@ -969,7 +960,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
969 | VPRINTK("ENTER\n"); | 960 | VPRINTK("ENTER\n"); |
970 | 961 | ||
971 | if (!printed_version++) | 962 | if (!printed_version++) |
972 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); | 963 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
973 | 964 | ||
974 | rc = pci_enable_device(pdev); | 965 | rc = pci_enable_device(pdev); |
975 | if (rc) | 966 | if (rc) |
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/ata_piix.c b/drivers/scsi/ata_piix.c index be021478f416..7f8aa1b552ce 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/init.h> | 45 | #include <linux/init.h> |
46 | #include <linux/blkdev.h> | 46 | #include <linux/blkdev.h> |
47 | #include <linux/delay.h> | 47 | #include <linux/delay.h> |
48 | #include <linux/device.h> | ||
48 | #include "scsi.h" | 49 | #include "scsi.h" |
49 | #include <scsi/scsi_host.h> | 50 | #include <scsi/scsi_host.h> |
50 | #include <linux/libata.h> | 51 | #include <linux/libata.h> |
@@ -621,18 +622,19 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
621 | { | 622 | { |
622 | static int printed_version; | 623 | static int printed_version; |
623 | struct ata_port_info *port_info[2]; | 624 | struct ata_port_info *port_info[2]; |
624 | unsigned int combined = 0, n_ports = 1; | 625 | unsigned int combined = 0; |
625 | unsigned int pata_chan = 0, sata_chan = 0; | 626 | unsigned int pata_chan = 0, sata_chan = 0; |
626 | 627 | ||
627 | if (!printed_version++) | 628 | if (!printed_version++) |
628 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); | 629 | dev_printk(KERN_DEBUG, &pdev->dev, |
630 | "version " DRV_VERSION "\n"); | ||
629 | 631 | ||
630 | /* no hotplugging support (FIXME) */ | 632 | /* no hotplugging support (FIXME) */ |
631 | if (!in_module_init) | 633 | if (!in_module_init) |
632 | return -ENODEV; | 634 | return -ENODEV; |
633 | 635 | ||
634 | port_info[0] = &piix_port_info[ent->driver_data]; | 636 | port_info[0] = &piix_port_info[ent->driver_data]; |
635 | port_info[1] = NULL; | 637 | port_info[1] = &piix_port_info[ent->driver_data]; |
636 | 638 | ||
637 | if (port_info[0]->host_flags & PIIX_FLAG_AHCI) { | 639 | if (port_info[0]->host_flags & PIIX_FLAG_AHCI) { |
638 | u8 tmp; | 640 | u8 tmp; |
@@ -670,12 +672,13 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
670 | port_info[sata_chan] = &piix_port_info[ent->driver_data]; | 672 | port_info[sata_chan] = &piix_port_info[ent->driver_data]; |
671 | port_info[sata_chan]->host_flags |= ATA_FLAG_SLAVE_POSS; | 673 | port_info[sata_chan]->host_flags |= ATA_FLAG_SLAVE_POSS; |
672 | port_info[pata_chan] = &piix_port_info[ich5_pata]; | 674 | port_info[pata_chan] = &piix_port_info[ich5_pata]; |
673 | n_ports++; | ||
674 | 675 | ||
675 | printk(KERN_WARNING DRV_NAME ": combined mode detected\n"); | 676 | dev_printk(KERN_WARNING, &pdev->dev, |
677 | "combined mode detected (p=%u, s=%u)\n", | ||
678 | pata_chan, sata_chan); | ||
676 | } | 679 | } |
677 | 680 | ||
678 | return ata_pci_init_one(pdev, port_info, n_ports); | 681 | return ata_pci_init_one(pdev, port_info, 2); |
679 | } | 682 | } |
680 | 683 | ||
681 | static int __init piix_init(void) | 684 | static int __init piix_init(void) |
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index b1b1c6f01419..8be7dc0b47b8 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" |
@@ -371,7 +372,7 @@ static void ata_tf_read_pio(struct ata_port *ap, struct ata_taskfile *tf) | |||
371 | struct ata_ioports *ioaddr = &ap->ioaddr; | 372 | struct ata_ioports *ioaddr = &ap->ioaddr; |
372 | 373 | ||
373 | tf->command = ata_check_status(ap); | 374 | tf->command = ata_check_status(ap); |
374 | tf->feature = ata_chk_err(ap); | 375 | tf->feature = inb(ioaddr->error_addr); |
375 | tf->nsect = inb(ioaddr->nsect_addr); | 376 | tf->nsect = inb(ioaddr->nsect_addr); |
376 | tf->lbal = inb(ioaddr->lbal_addr); | 377 | tf->lbal = inb(ioaddr->lbal_addr); |
377 | tf->lbam = inb(ioaddr->lbam_addr); | 378 | tf->lbam = inb(ioaddr->lbam_addr); |
@@ -405,7 +406,7 @@ static void ata_tf_read_mmio(struct ata_port *ap, struct ata_taskfile *tf) | |||
405 | struct ata_ioports *ioaddr = &ap->ioaddr; | 406 | struct ata_ioports *ioaddr = &ap->ioaddr; |
406 | 407 | ||
407 | tf->command = ata_check_status(ap); | 408 | tf->command = ata_check_status(ap); |
408 | tf->feature = ata_chk_err(ap); | 409 | tf->feature = readb((void __iomem *)ioaddr->error_addr); |
409 | tf->nsect = readb((void __iomem *)ioaddr->nsect_addr); | 410 | tf->nsect = readb((void __iomem *)ioaddr->nsect_addr); |
410 | tf->lbal = readb((void __iomem *)ioaddr->lbal_addr); | 411 | tf->lbal = readb((void __iomem *)ioaddr->lbal_addr); |
411 | tf->lbam = readb((void __iomem *)ioaddr->lbam_addr); | 412 | tf->lbam = readb((void __iomem *)ioaddr->lbam_addr); |
@@ -526,30 +527,6 @@ u8 ata_altstatus(struct ata_port *ap) | |||
526 | 527 | ||
527 | 528 | ||
528 | /** | 529 | /** |
529 | * ata_chk_err - Read device error reg | ||
530 | * @ap: port where the device is | ||
531 | * | ||
532 | * Reads ATA taskfile error register for | ||
533 | * currently-selected device and return its value. | ||
534 | * | ||
535 | * Note: may NOT be used as the check_err() entry in | ||
536 | * ata_port_operations. | ||
537 | * | ||
538 | * LOCKING: | ||
539 | * Inherited from caller. | ||
540 | */ | ||
541 | u8 ata_chk_err(struct ata_port *ap) | ||
542 | { | ||
543 | if (ap->ops->check_err) | ||
544 | return ap->ops->check_err(ap); | ||
545 | |||
546 | if (ap->flags & ATA_FLAG_MMIO) { | ||
547 | return readb((void __iomem *) ap->ioaddr.error_addr); | ||
548 | } | ||
549 | return inb(ap->ioaddr.error_addr); | ||
550 | } | ||
551 | |||
552 | /** | ||
553 | * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure | 530 | * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure |
554 | * @tf: Taskfile to convert | 531 | * @tf: Taskfile to convert |
555 | * @fis: Buffer into which data will output | 532 | * @fis: Buffer into which data will output |
@@ -901,8 +878,8 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device) | |||
901 | 878 | ||
902 | memset(&tf, 0, sizeof(tf)); | 879 | memset(&tf, 0, sizeof(tf)); |
903 | 880 | ||
904 | err = ata_chk_err(ap); | ||
905 | ap->ops->tf_read(ap, &tf); | 881 | ap->ops->tf_read(ap, &tf); |
882 | err = tf.feature; | ||
906 | 883 | ||
907 | dev->class = ATA_DEV_NONE; | 884 | dev->class = ATA_DEV_NONE; |
908 | 885 | ||
@@ -1139,7 +1116,6 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) | |||
1139 | unsigned int major_version; | 1116 | unsigned int major_version; |
1140 | u16 tmp; | 1117 | u16 tmp; |
1141 | unsigned long xfer_modes; | 1118 | unsigned long xfer_modes; |
1142 | u8 status; | ||
1143 | unsigned int using_edd; | 1119 | unsigned int using_edd; |
1144 | DECLARE_COMPLETION(wait); | 1120 | DECLARE_COMPLETION(wait); |
1145 | struct ata_queued_cmd *qc; | 1121 | struct ata_queued_cmd *qc; |
@@ -1193,8 +1169,11 @@ retry: | |||
1193 | else | 1169 | else |
1194 | wait_for_completion(&wait); | 1170 | wait_for_completion(&wait); |
1195 | 1171 | ||
1196 | status = ata_chk_status(ap); | 1172 | spin_lock_irqsave(&ap->host_set->lock, flags); |
1197 | if (status & ATA_ERR) { | 1173 | ap->ops->tf_read(ap, &qc->tf); |
1174 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
1175 | |||
1176 | if (qc->tf.command & ATA_ERR) { | ||
1198 | /* | 1177 | /* |
1199 | * arg! EDD works for all test cases, but seems to return | 1178 | * arg! EDD works for all test cases, but seems to return |
1200 | * the ATA signature for some ATAPI devices. Until the | 1179 | * the ATA signature for some ATAPI devices. Until the |
@@ -1207,7 +1186,7 @@ retry: | |||
1207 | * to have this problem. | 1186 | * to have this problem. |
1208 | */ | 1187 | */ |
1209 | if ((using_edd) && (qc->tf.command == ATA_CMD_ID_ATA)) { | 1188 | if ((using_edd) && (qc->tf.command == ATA_CMD_ID_ATA)) { |
1210 | u8 err = ata_chk_err(ap); | 1189 | u8 err = qc->tf.feature; |
1211 | if (err & ATA_ABORTED) { | 1190 | if (err & ATA_ABORTED) { |
1212 | dev->class = ATA_DEV_ATAPI; | 1191 | dev->class = ATA_DEV_ATAPI; |
1213 | qc->cursg = 0; | 1192 | qc->cursg = 0; |
@@ -2576,19 +2555,12 @@ void ata_qc_prep(struct ata_queued_cmd *qc) | |||
2576 | 2555 | ||
2577 | 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) |
2578 | { | 2557 | { |
2579 | struct scatterlist *sg; | ||
2580 | |||
2581 | qc->flags |= ATA_QCFLAG_SINGLE; | 2558 | qc->flags |= ATA_QCFLAG_SINGLE; |
2582 | 2559 | ||
2583 | memset(&qc->sgent, 0, sizeof(qc->sgent)); | ||
2584 | qc->sg = &qc->sgent; | 2560 | qc->sg = &qc->sgent; |
2585 | qc->n_elem = 1; | 2561 | qc->n_elem = 1; |
2586 | qc->buf_virt = buf; | 2562 | qc->buf_virt = buf; |
2587 | 2563 | sg_init_one(qc->sg, buf, buflen); | |
2588 | sg = qc->sg; | ||
2589 | sg->page = virt_to_page(buf); | ||
2590 | sg->offset = (unsigned long) buf & ~PAGE_MASK; | ||
2591 | sg->length = buflen; | ||
2592 | } | 2564 | } |
2593 | 2565 | ||
2594 | /** | 2566 | /** |
@@ -2691,7 +2663,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
2691 | * None. (grabs host lock) | 2663 | * None. (grabs host lock) |
2692 | */ | 2664 | */ |
2693 | 2665 | ||
2694 | void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) | 2666 | void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) |
2695 | { | 2667 | { |
2696 | struct ata_port *ap = qc->ap; | 2668 | struct ata_port *ap = qc->ap; |
2697 | unsigned long flags; | 2669 | unsigned long flags; |
@@ -2699,7 +2671,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) | |||
2699 | spin_lock_irqsave(&ap->host_set->lock, flags); | 2671 | spin_lock_irqsave(&ap->host_set->lock, flags); |
2700 | ap->flags &= ~ATA_FLAG_NOINTR; | 2672 | ap->flags &= ~ATA_FLAG_NOINTR; |
2701 | ata_irq_on(ap); | 2673 | ata_irq_on(ap); |
2702 | ata_qc_complete(qc, drv_stat); | 2674 | ata_qc_complete(qc, err_mask); |
2703 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | 2675 | spin_unlock_irqrestore(&ap->host_set->lock, flags); |
2704 | } | 2676 | } |
2705 | 2677 | ||
@@ -2796,7 +2768,7 @@ static int ata_pio_complete (struct ata_port *ap) | |||
2796 | 2768 | ||
2797 | ap->hsm_task_state = HSM_ST_IDLE; | 2769 | ap->hsm_task_state = HSM_ST_IDLE; |
2798 | 2770 | ||
2799 | ata_poll_qc_complete(qc, drv_stat); | 2771 | ata_poll_qc_complete(qc, 0); |
2800 | 2772 | ||
2801 | /* another command may start at this point */ | 2773 | /* another command may start at this point */ |
2802 | 2774 | ||
@@ -3164,18 +3136,15 @@ static void ata_pio_block(struct ata_port *ap) | |||
3164 | static void ata_pio_error(struct ata_port *ap) | 3136 | static void ata_pio_error(struct ata_port *ap) |
3165 | { | 3137 | { |
3166 | struct ata_queued_cmd *qc; | 3138 | struct ata_queued_cmd *qc; |
3167 | u8 drv_stat; | 3139 | |
3140 | printk(KERN_WARNING "ata%u: PIO error\n", ap->id); | ||
3168 | 3141 | ||
3169 | qc = ata_qc_from_tag(ap, ap->active_tag); | 3142 | qc = ata_qc_from_tag(ap, ap->active_tag); |
3170 | assert(qc != NULL); | 3143 | assert(qc != NULL); |
3171 | 3144 | ||
3172 | drv_stat = ata_chk_status(ap); | ||
3173 | printk(KERN_WARNING "ata%u: PIO error, drv_stat 0x%x\n", | ||
3174 | ap->id, drv_stat); | ||
3175 | |||
3176 | ap->hsm_task_state = HSM_ST_IDLE; | 3145 | ap->hsm_task_state = HSM_ST_IDLE; |
3177 | 3146 | ||
3178 | ata_poll_qc_complete(qc, drv_stat | ATA_ERR); | 3147 | ata_poll_qc_complete(qc, AC_ERR_ATA_BUS); |
3179 | } | 3148 | } |
3180 | 3149 | ||
3181 | static void ata_pio_task(void *_data) | 3150 | static void ata_pio_task(void *_data) |
@@ -3298,7 +3267,7 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc) | |||
3298 | ap->id, qc->tf.command, drv_stat, host_stat); | 3267 | ap->id, qc->tf.command, drv_stat, host_stat); |
3299 | 3268 | ||
3300 | /* complete taskfile transaction */ | 3269 | /* complete taskfile transaction */ |
3301 | ata_qc_complete(qc, drv_stat); | 3270 | ata_qc_complete(qc, ac_err_mask(drv_stat)); |
3302 | break; | 3271 | break; |
3303 | } | 3272 | } |
3304 | 3273 | ||
@@ -3403,7 +3372,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, | |||
3403 | return qc; | 3372 | return qc; |
3404 | } | 3373 | } |
3405 | 3374 | ||
3406 | int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat) | 3375 | int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask) |
3407 | { | 3376 | { |
3408 | return 0; | 3377 | return 0; |
3409 | } | 3378 | } |
@@ -3462,7 +3431,7 @@ void ata_qc_free(struct ata_queued_cmd *qc) | |||
3462 | * spin_lock_irqsave(host_set lock) | 3431 | * spin_lock_irqsave(host_set lock) |
3463 | */ | 3432 | */ |
3464 | 3433 | ||
3465 | void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) | 3434 | void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) |
3466 | { | 3435 | { |
3467 | int rc; | 3436 | int rc; |
3468 | 3437 | ||
@@ -3479,7 +3448,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) | |||
3479 | qc->flags &= ~ATA_QCFLAG_ACTIVE; | 3448 | qc->flags &= ~ATA_QCFLAG_ACTIVE; |
3480 | 3449 | ||
3481 | /* call completion callback */ | 3450 | /* call completion callback */ |
3482 | rc = qc->complete_fn(qc, drv_stat); | 3451 | rc = qc->complete_fn(qc, err_mask); |
3483 | 3452 | ||
3484 | /* if callback indicates not to complete command (non-zero), | 3453 | /* if callback indicates not to complete command (non-zero), |
3485 | * return immediately | 3454 | * return immediately |
@@ -3917,7 +3886,7 @@ inline unsigned int ata_host_intr (struct ata_port *ap, | |||
3917 | ap->ops->irq_clear(ap); | 3886 | ap->ops->irq_clear(ap); |
3918 | 3887 | ||
3919 | /* complete taskfile transaction */ | 3888 | /* complete taskfile transaction */ |
3920 | ata_qc_complete(qc, status); | 3889 | ata_qc_complete(qc, ac_err_mask(status)); |
3921 | break; | 3890 | break; |
3922 | 3891 | ||
3923 | default: | 3892 | default: |
@@ -4012,7 +3981,7 @@ static void atapi_packet_task(void *_data) | |||
4012 | /* sleep-wait for BSY to clear */ | 3981 | /* sleep-wait for BSY to clear */ |
4013 | DPRINTK("busy wait\n"); | 3982 | DPRINTK("busy wait\n"); |
4014 | if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) | 3983 | if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) |
4015 | goto err_out; | 3984 | goto err_out_status; |
4016 | 3985 | ||
4017 | /* make sure DRQ is set */ | 3986 | /* make sure DRQ is set */ |
4018 | status = ata_chk_status(ap); | 3987 | status = ata_chk_status(ap); |
@@ -4049,8 +4018,10 @@ static void atapi_packet_task(void *_data) | |||
4049 | 4018 | ||
4050 | return; | 4019 | return; |
4051 | 4020 | ||
4021 | err_out_status: | ||
4022 | status = ata_chk_status(ap); | ||
4052 | err_out: | 4023 | err_out: |
4053 | ata_poll_qc_complete(qc, ATA_ERR); | 4024 | ata_poll_qc_complete(qc, __ac_err_mask(status)); |
4054 | } | 4025 | } |
4055 | 4026 | ||
4056 | 4027 | ||
@@ -4556,11 +4527,11 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int | |||
4556 | return probe_ent; | 4527 | return probe_ent; |
4557 | } | 4528 | } |
4558 | 4529 | ||
4559 | static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, struct ata_port_info **port, int port_num) | 4530 | static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, struct ata_port_info *port, int port_num) |
4560 | { | 4531 | { |
4561 | struct ata_probe_ent *probe_ent; | 4532 | struct ata_probe_ent *probe_ent; |
4562 | 4533 | ||
4563 | probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]); | 4534 | probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port); |
4564 | if (!probe_ent) | 4535 | if (!probe_ent) |
4565 | return NULL; | 4536 | return NULL; |
4566 | 4537 | ||
@@ -4707,9 +4678,9 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
4707 | 4678 | ||
4708 | if (legacy_mode) { | 4679 | if (legacy_mode) { |
4709 | if (legacy_mode & (1 << 0)) | 4680 | if (legacy_mode & (1 << 0)) |
4710 | probe_ent = ata_pci_init_legacy_port(pdev, port, 0); | 4681 | probe_ent = ata_pci_init_legacy_port(pdev, port[0], 0); |
4711 | if (legacy_mode & (1 << 1)) | 4682 | if (legacy_mode & (1 << 1)) |
4712 | probe_ent2 = ata_pci_init_legacy_port(pdev, port, 1); | 4683 | probe_ent2 = ata_pci_init_legacy_port(pdev, port[1], 1); |
4713 | } else { | 4684 | } else { |
4714 | if (n_ports == 2) | 4685 | if (n_ports == 2) |
4715 | probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); | 4686 | probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); |
@@ -4873,7 +4844,6 @@ EXPORT_SYMBOL_GPL(ata_tf_to_fis); | |||
4873 | EXPORT_SYMBOL_GPL(ata_tf_from_fis); | 4844 | EXPORT_SYMBOL_GPL(ata_tf_from_fis); |
4874 | EXPORT_SYMBOL_GPL(ata_check_status); | 4845 | EXPORT_SYMBOL_GPL(ata_check_status); |
4875 | EXPORT_SYMBOL_GPL(ata_altstatus); | 4846 | EXPORT_SYMBOL_GPL(ata_altstatus); |
4876 | EXPORT_SYMBOL_GPL(ata_chk_err); | ||
4877 | EXPORT_SYMBOL_GPL(ata_exec_command); | 4847 | EXPORT_SYMBOL_GPL(ata_exec_command); |
4878 | EXPORT_SYMBOL_GPL(ata_port_start); | 4848 | EXPORT_SYMBOL_GPL(ata_port_start); |
4879 | EXPORT_SYMBOL_GPL(ata_port_stop); | 4849 | EXPORT_SYMBOL_GPL(ata_port_stop); |
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 89a04b1a5a0e..1e3792f86fcf 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -560,7 +560,7 @@ void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc) | |||
560 | * Use ata_to_sense_error() to map status register bits | 560 | * Use ata_to_sense_error() to map status register bits |
561 | * onto sense key, asc & ascq. | 561 | * onto sense key, asc & ascq. |
562 | */ | 562 | */ |
563 | if (unlikely(tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ))) { | 563 | if (tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { |
564 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, | 564 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, |
565 | &sb[1], &sb[2], &sb[3]); | 565 | &sb[1], &sb[2], &sb[3]); |
566 | sb[1] &= 0x0f; | 566 | sb[1] &= 0x0f; |
@@ -635,7 +635,7 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc) | |||
635 | * Use ata_to_sense_error() to map status register bits | 635 | * Use ata_to_sense_error() to map status register bits |
636 | * onto sense key, asc & ascq. | 636 | * onto sense key, asc & ascq. |
637 | */ | 637 | */ |
638 | if (unlikely(tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ))) { | 638 | if (tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { |
639 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, | 639 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, |
640 | &sb[2], &sb[12], &sb[13]); | 640 | &sb[2], &sb[12], &sb[13]); |
641 | sb[2] &= 0x0f; | 641 | sb[2] &= 0x0f; |
@@ -644,7 +644,11 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc) | |||
644 | sb[0] = 0x70; | 644 | sb[0] = 0x70; |
645 | sb[7] = 0x0a; | 645 | sb[7] = 0x0a; |
646 | 646 | ||
647 | if (tf->flags & ATA_TFLAG_LBA && !(tf->flags & ATA_TFLAG_LBA48)) { | 647 | if (tf->flags & ATA_TFLAG_LBA48) { |
648 | /* TODO: find solution for LBA48 descriptors */ | ||
649 | } | ||
650 | |||
651 | else if (tf->flags & ATA_TFLAG_LBA) { | ||
648 | /* A small (28b) LBA will fit in the 32b info field */ | 652 | /* A small (28b) LBA will fit in the 32b info field */ |
649 | sb[0] |= 0x80; /* set valid bit */ | 653 | sb[0] |= 0x80; /* set valid bit */ |
650 | sb[3] = tf->device & 0x0f; | 654 | sb[3] = tf->device & 0x0f; |
@@ -652,6 +656,10 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc) | |||
652 | sb[5] = tf->lbam; | 656 | sb[5] = tf->lbam; |
653 | sb[6] = tf->lbal; | 657 | sb[6] = tf->lbal; |
654 | } | 658 | } |
659 | |||
660 | else { | ||
661 | /* TODO: C/H/S */ | ||
662 | } | ||
655 | } | 663 | } |
656 | 664 | ||
657 | /** | 665 | /** |
@@ -1199,10 +1207,12 @@ nothing_to_do: | |||
1199 | return 1; | 1207 | return 1; |
1200 | } | 1208 | } |
1201 | 1209 | ||
1202 | static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) | 1210 | static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, |
1211 | unsigned int err_mask) | ||
1203 | { | 1212 | { |
1204 | struct scsi_cmnd *cmd = qc->scsicmd; | 1213 | struct scsi_cmnd *cmd = qc->scsicmd; |
1205 | int need_sense = drv_stat & (ATA_ERR | ATA_BUSY | ATA_DRQ); | 1214 | u8 *cdb = cmd->cmnd; |
1215 | int need_sense = (err_mask != 0); | ||
1206 | 1216 | ||
1207 | /* For ATA pass thru (SAT) commands, generate a sense block if | 1217 | /* For ATA pass thru (SAT) commands, generate a sense block if |
1208 | * user mandated it or if there's an error. Note that if we | 1218 | * user mandated it or if there's an error. Note that if we |
@@ -1211,8 +1221,8 @@ static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) | |||
1211 | * whether the command completed successfully or not. If there | 1221 | * whether the command completed successfully or not. If there |
1212 | * was no error, SK, ASC and ASCQ will all be zero. | 1222 | * was no error, SK, ASC and ASCQ will all be zero. |
1213 | */ | 1223 | */ |
1214 | if (((cmd->cmnd[0] == ATA_16) || (cmd->cmnd[0] == ATA_12)) && | 1224 | if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) && |
1215 | ((cmd->cmnd[2] & 0x20) || need_sense)) { | 1225 | ((cdb[2] & 0x20) || need_sense)) { |
1216 | ata_gen_ata_desc_sense(qc); | 1226 | ata_gen_ata_desc_sense(qc); |
1217 | } else { | 1227 | } else { |
1218 | if (!need_sense) { | 1228 | if (!need_sense) { |
@@ -1995,21 +2005,13 @@ void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, | |||
1995 | DPRINTK("EXIT\n"); | 2005 | DPRINTK("EXIT\n"); |
1996 | } | 2006 | } |
1997 | 2007 | ||
1998 | static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) | 2008 | static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) |
1999 | { | 2009 | { |
2000 | struct scsi_cmnd *cmd = qc->scsicmd; | 2010 | struct scsi_cmnd *cmd = qc->scsicmd; |
2001 | 2011 | ||
2002 | VPRINTK("ENTER, drv_stat == 0x%x\n", drv_stat); | 2012 | VPRINTK("ENTER, err_mask 0x%X\n", err_mask); |
2003 | |||
2004 | if (unlikely(drv_stat & (ATA_BUSY | ATA_DRQ))) | ||
2005 | /* FIXME: not quite right; we don't want the | ||
2006 | * translation of taskfile registers into | ||
2007 | * a sense descriptors, since that's only | ||
2008 | * correct for ATA, not ATAPI | ||
2009 | */ | ||
2010 | ata_gen_ata_desc_sense(qc); | ||
2011 | 2013 | ||
2012 | else if (unlikely(drv_stat & ATA_ERR)) { | 2014 | if (unlikely(err_mask & AC_ERR_DEV)) { |
2013 | DPRINTK("request check condition\n"); | 2015 | DPRINTK("request check condition\n"); |
2014 | 2016 | ||
2015 | /* FIXME: command completion with check condition | 2017 | /* FIXME: command completion with check condition |
@@ -2026,6 +2028,14 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) | |||
2026 | return 1; | 2028 | return 1; |
2027 | } | 2029 | } |
2028 | 2030 | ||
2031 | else if (unlikely(err_mask)) | ||
2032 | /* FIXME: not quite right; we don't want the | ||
2033 | * translation of taskfile registers into | ||
2034 | * a sense descriptors, since that's only | ||
2035 | * correct for ATA, not ATAPI | ||
2036 | */ | ||
2037 | ata_gen_ata_desc_sense(qc); | ||
2038 | |||
2029 | else { | 2039 | else { |
2030 | u8 *scsicmd = cmd->cmnd; | 2040 | u8 *scsicmd = cmd->cmnd; |
2031 | 2041 | ||
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index 65c264b91136..10ecd9e15e4f 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h | |||
@@ -39,7 +39,7 @@ struct ata_scsi_args { | |||
39 | 39 | ||
40 | /* libata-core.c */ | 40 | /* libata-core.c */ |
41 | extern int atapi_enabled; | 41 | extern int atapi_enabled; |
42 | extern int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat); | 42 | extern int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask); |
43 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, | 43 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, |
44 | struct ata_device *dev); | 44 | struct ata_device *dev); |
45 | extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc); | 45 | extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc); |
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c index af99feb9d237..665017eda8a6 100644 --- a/drivers/scsi/pdc_adma.c +++ b/drivers/scsi/pdc_adma.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/delay.h> | 40 | #include <linux/delay.h> |
41 | #include <linux/interrupt.h> | 41 | #include <linux/interrupt.h> |
42 | #include <linux/sched.h> | 42 | #include <linux/sched.h> |
43 | #include <linux/device.h> | ||
43 | #include "scsi.h" | 44 | #include "scsi.h" |
44 | #include <scsi/scsi_host.h> | 45 | #include <scsi/scsi_host.h> |
45 | #include <asm/io.h> | 46 | #include <asm/io.h> |
@@ -451,7 +452,7 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set) | |||
451 | struct adma_port_priv *pp; | 452 | struct adma_port_priv *pp; |
452 | struct ata_queued_cmd *qc; | 453 | struct ata_queued_cmd *qc; |
453 | void __iomem *chan = ADMA_REGS(mmio_base, port_no); | 454 | void __iomem *chan = ADMA_REGS(mmio_base, port_no); |
454 | u8 drv_stat = 0, status = readb(chan + ADMA_STATUS); | 455 | u8 status = readb(chan + ADMA_STATUS); |
455 | 456 | ||
456 | if (status == 0) | 457 | if (status == 0) |
457 | continue; | 458 | continue; |
@@ -464,11 +465,14 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set) | |||
464 | continue; | 465 | continue; |
465 | qc = ata_qc_from_tag(ap, ap->active_tag); | 466 | qc = ata_qc_from_tag(ap, ap->active_tag); |
466 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) { | 467 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) { |
468 | unsigned int err_mask = 0; | ||
469 | |||
467 | if ((status & (aPERR | aPSD | aUIRQ))) | 470 | if ((status & (aPERR | aPSD | aUIRQ))) |
468 | drv_stat = ATA_ERR; | 471 | err_mask = AC_ERR_OTHER; |
469 | else if (pp->pkt[0] != cDONE) | 472 | else if (pp->pkt[0] != cDONE) |
470 | drv_stat = ATA_ERR; | 473 | err_mask = AC_ERR_OTHER; |
471 | ata_qc_complete(qc, drv_stat); | 474 | |
475 | ata_qc_complete(qc, err_mask); | ||
472 | } | 476 | } |
473 | } | 477 | } |
474 | return handled; | 478 | return handled; |
@@ -498,7 +502,7 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set) | |||
498 | 502 | ||
499 | /* complete taskfile transaction */ | 503 | /* complete taskfile transaction */ |
500 | pp->state = adma_state_idle; | 504 | pp->state = adma_state_idle; |
501 | ata_qc_complete(qc, status); | 505 | ata_qc_complete(qc, ac_err_mask(status)); |
502 | handled = 1; | 506 | handled = 1; |
503 | } | 507 | } |
504 | } | 508 | } |
@@ -623,16 +627,14 @@ static int adma_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base) | |||
623 | 627 | ||
624 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 628 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
625 | if (rc) { | 629 | if (rc) { |
626 | printk(KERN_ERR DRV_NAME | 630 | dev_printk(KERN_ERR, &pdev->dev, |
627 | "(%s): 32-bit DMA enable failed\n", | 631 | "32-bit DMA enable failed\n"); |
628 | pci_name(pdev)); | ||
629 | return rc; | 632 | return rc; |
630 | } | 633 | } |
631 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | 634 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); |
632 | if (rc) { | 635 | if (rc) { |
633 | printk(KERN_ERR DRV_NAME | 636 | dev_printk(KERN_ERR, &pdev->dev, |
634 | "(%s): 32-bit consistent DMA enable failed\n", | 637 | "32-bit consistent DMA enable failed\n"); |
635 | pci_name(pdev)); | ||
636 | return rc; | 638 | return rc; |
637 | } | 639 | } |
638 | return 0; | 640 | return 0; |
@@ -648,7 +650,7 @@ static int adma_ata_init_one(struct pci_dev *pdev, | |||
648 | int rc, port_no; | 650 | int rc, port_no; |
649 | 651 | ||
650 | if (!printed_version++) | 652 | if (!printed_version++) |
651 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); | 653 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
652 | 654 | ||
653 | rc = pci_enable_device(pdev); | 655 | rc = pci_enable_device(pdev); |
654 | if (rc) | 656 | if (rc) |
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c index 422e0b6f603a..46dbdee79f77 100644 --- a/drivers/scsi/sata_mv.c +++ b/drivers/scsi/sata_mv.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
30 | #include <linux/sched.h> | 30 | #include <linux/sched.h> |
31 | #include <linux/dma-mapping.h> | 31 | #include <linux/dma-mapping.h> |
32 | #include <linux/device.h> | ||
32 | #include "scsi.h" | 33 | #include "scsi.h" |
33 | #include <scsi/scsi_host.h> | 34 | #include <scsi/scsi_host.h> |
34 | #include <linux/libata.h> | 35 | #include <linux/libata.h> |
@@ -258,7 +259,6 @@ struct mv_host_priv { | |||
258 | static void mv_irq_clear(struct ata_port *ap); | 259 | static void mv_irq_clear(struct ata_port *ap); |
259 | static u32 mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in); | 260 | static u32 mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in); |
260 | static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); | 261 | static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); |
261 | static u8 mv_check_err(struct ata_port *ap); | ||
262 | static void mv_phy_reset(struct ata_port *ap); | 262 | static void mv_phy_reset(struct ata_port *ap); |
263 | static void mv_host_stop(struct ata_host_set *host_set); | 263 | static void mv_host_stop(struct ata_host_set *host_set); |
264 | static int mv_port_start(struct ata_port *ap); | 264 | static int mv_port_start(struct ata_port *ap); |
@@ -296,7 +296,6 @@ static const struct ata_port_operations mv_ops = { | |||
296 | .tf_load = ata_tf_load, | 296 | .tf_load = ata_tf_load, |
297 | .tf_read = ata_tf_read, | 297 | .tf_read = ata_tf_read, |
298 | .check_status = ata_check_status, | 298 | .check_status = ata_check_status, |
299 | .check_err = mv_check_err, | ||
300 | .exec_command = ata_exec_command, | 299 | .exec_command = ata_exec_command, |
301 | .dev_select = ata_std_dev_select, | 300 | .dev_select = ata_std_dev_select, |
302 | 301 | ||
@@ -1067,6 +1066,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, | |||
1067 | struct ata_queued_cmd *qc; | 1066 | struct ata_queued_cmd *qc; |
1068 | u32 hc_irq_cause; | 1067 | u32 hc_irq_cause; |
1069 | int shift, port, port0, hard_port, handled; | 1068 | int shift, port, port0, hard_port, handled; |
1069 | unsigned int err_mask; | ||
1070 | u8 ata_status = 0; | 1070 | u8 ata_status = 0; |
1071 | 1071 | ||
1072 | if (hc == 0) { | 1072 | if (hc == 0) { |
@@ -1102,15 +1102,15 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, | |||
1102 | handled++; | 1102 | handled++; |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | err_mask = ac_err_mask(ata_status); | ||
1106 | |||
1105 | shift = port << 1; /* (port * 2) */ | 1107 | shift = port << 1; /* (port * 2) */ |
1106 | if (port >= MV_PORTS_PER_HC) { | 1108 | if (port >= MV_PORTS_PER_HC) { |
1107 | shift++; /* skip bit 8 in the HC Main IRQ reg */ | 1109 | shift++; /* skip bit 8 in the HC Main IRQ reg */ |
1108 | } | 1110 | } |
1109 | if ((PORT0_ERR << shift) & relevant) { | 1111 | if ((PORT0_ERR << shift) & relevant) { |
1110 | mv_err_intr(ap); | 1112 | mv_err_intr(ap); |
1111 | /* OR in ATA_ERR to ensure libata knows we took one */ | 1113 | err_mask |= AC_ERR_OTHER; |
1112 | ata_status = readb((void __iomem *) | ||
1113 | ap->ioaddr.status_addr) | ATA_ERR; | ||
1114 | handled++; | 1114 | handled++; |
1115 | } | 1115 | } |
1116 | 1116 | ||
@@ -1120,7 +1120,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, | |||
1120 | VPRINTK("port %u IRQ found for qc, " | 1120 | VPRINTK("port %u IRQ found for qc, " |
1121 | "ata_status 0x%x\n", port,ata_status); | 1121 | "ata_status 0x%x\n", port,ata_status); |
1122 | /* mark qc status appropriately */ | 1122 | /* mark qc status appropriately */ |
1123 | ata_qc_complete(qc, ata_status); | 1123 | ata_qc_complete(qc, err_mask); |
1124 | } | 1124 | } |
1125 | } | 1125 | } |
1126 | } | 1126 | } |
@@ -1185,22 +1185,6 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance, | |||
1185 | } | 1185 | } |
1186 | 1186 | ||
1187 | /** | 1187 | /** |
1188 | * mv_check_err - Return the error shadow register to caller. | ||
1189 | * @ap: ATA channel to manipulate | ||
1190 | * | ||
1191 | * Marvell requires DMA to be stopped before accessing shadow | ||
1192 | * registers. So we do that, then return the needed register. | ||
1193 | * | ||
1194 | * LOCKING: | ||
1195 | * Inherited from caller. FIXME: protect mv_stop_dma with lock? | ||
1196 | */ | ||
1197 | static u8 mv_check_err(struct ata_port *ap) | ||
1198 | { | ||
1199 | mv_stop_dma(ap); /* can't read shadow regs if DMA on */ | ||
1200 | return readb((void __iomem *) ap->ioaddr.error_addr); | ||
1201 | } | ||
1202 | |||
1203 | /** | ||
1204 | * mv_phy_reset - Perform eDMA reset followed by COMRESET | 1188 | * mv_phy_reset - Perform eDMA reset followed by COMRESET |
1205 | * @ap: ATA channel to manipulate | 1189 | * @ap: ATA channel to manipulate |
1206 | * | 1190 | * |
@@ -1312,7 +1296,7 @@ static void mv_eng_timeout(struct ata_port *ap) | |||
1312 | */ | 1296 | */ |
1313 | spin_lock_irqsave(&ap->host_set->lock, flags); | 1297 | spin_lock_irqsave(&ap->host_set->lock, flags); |
1314 | qc->scsidone = scsi_finish_command; | 1298 | qc->scsidone = scsi_finish_command; |
1315 | ata_qc_complete(qc, ATA_ERR); | 1299 | ata_qc_complete(qc, AC_ERR_OTHER); |
1316 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | 1300 | spin_unlock_irqrestore(&ap->host_set->lock, flags); |
1317 | } | 1301 | } |
1318 | } | 1302 | } |
@@ -1454,9 +1438,9 @@ static void mv_print_info(struct ata_probe_ent *probe_ent) | |||
1454 | else | 1438 | else |
1455 | scc_s = "unknown"; | 1439 | scc_s = "unknown"; |
1456 | 1440 | ||
1457 | printk(KERN_INFO DRV_NAME | 1441 | dev_printk(KERN_INFO, &pdev->dev, |
1458 | "(%s) %u slots %u ports %s mode IRQ via %s\n", | 1442 | "%u slots %u ports %s mode IRQ via %s\n", |
1459 | pci_name(pdev), (unsigned)MV_MAX_Q_DEPTH, probe_ent->n_ports, | 1443 | (unsigned)MV_MAX_Q_DEPTH, probe_ent->n_ports, |
1460 | scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx"); | 1444 | scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx"); |
1461 | } | 1445 | } |
1462 | 1446 | ||
@@ -1477,9 +1461,8 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1477 | void __iomem *mmio_base; | 1461 | void __iomem *mmio_base; |
1478 | int pci_dev_busy = 0, rc; | 1462 | int pci_dev_busy = 0, rc; |
1479 | 1463 | ||
1480 | if (!printed_version++) { | 1464 | if (!printed_version++) |
1481 | printk(KERN_INFO DRV_NAME " version " DRV_VERSION "\n"); | 1465 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); |
1482 | } | ||
1483 | 1466 | ||
1484 | rc = pci_enable_device(pdev); | 1467 | rc = pci_enable_device(pdev); |
1485 | if (rc) { | 1468 | if (rc) { |
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c index 1a56d6c79ddd..d573888eda76 100644 --- a/drivers/scsi/sata_nv.c +++ b/drivers/scsi/sata_nv.c | |||
@@ -61,6 +61,7 @@ | |||
61 | #include <linux/blkdev.h> | 61 | #include <linux/blkdev.h> |
62 | #include <linux/delay.h> | 62 | #include <linux/delay.h> |
63 | #include <linux/interrupt.h> | 63 | #include <linux/interrupt.h> |
64 | #include <linux/device.h> | ||
64 | #include "scsi.h" | 65 | #include "scsi.h" |
65 | #include <scsi/scsi_host.h> | 66 | #include <scsi/scsi_host.h> |
66 | #include <linux/libata.h> | 67 | #include <linux/libata.h> |
@@ -383,7 +384,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
383 | return -ENODEV; | 384 | return -ENODEV; |
384 | 385 | ||
385 | if (!printed_version++) | 386 | if (!printed_version++) |
386 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); | 387 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
387 | 388 | ||
388 | rc = pci_enable_device(pdev); | 389 | rc = pci_enable_device(pdev); |
389 | if (rc) | 390 | if (rc) |
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index 63911f16b6ec..b41c977d6fab 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/delay.h> | 38 | #include <linux/delay.h> |
39 | #include <linux/interrupt.h> | 39 | #include <linux/interrupt.h> |
40 | #include <linux/sched.h> | 40 | #include <linux/sched.h> |
41 | #include <linux/device.h> | ||
41 | #include "scsi.h" | 42 | #include "scsi.h" |
42 | #include <scsi/scsi_host.h> | 43 | #include <scsi/scsi_host.h> |
43 | #include <linux/libata.h> | 44 | #include <linux/libata.h> |
@@ -399,7 +400,8 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
399 | case ATA_PROT_DMA: | 400 | case ATA_PROT_DMA: |
400 | case ATA_PROT_NODATA: | 401 | case ATA_PROT_NODATA: |
401 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); | 402 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); |
402 | ata_qc_complete(qc, ata_wait_idle(ap) | ATA_ERR); | 403 | drv_stat = ata_wait_idle(ap); |
404 | ata_qc_complete(qc, __ac_err_mask(drv_stat)); | ||
403 | break; | 405 | break; |
404 | 406 | ||
405 | default: | 407 | default: |
@@ -408,7 +410,7 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
408 | printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", | 410 | printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", |
409 | ap->id, qc->tf.command, drv_stat); | 411 | ap->id, qc->tf.command, drv_stat); |
410 | 412 | ||
411 | ata_qc_complete(qc, drv_stat); | 413 | ata_qc_complete(qc, ac_err_mask(drv_stat)); |
412 | break; | 414 | break; |
413 | } | 415 | } |
414 | 416 | ||
@@ -420,24 +422,21 @@ out: | |||
420 | static inline unsigned int pdc_host_intr( struct ata_port *ap, | 422 | static inline unsigned int pdc_host_intr( struct ata_port *ap, |
421 | struct ata_queued_cmd *qc) | 423 | struct ata_queued_cmd *qc) |
422 | { | 424 | { |
423 | u8 status; | 425 | unsigned int handled = 0, err_mask = 0; |
424 | unsigned int handled = 0, have_err = 0; | ||
425 | u32 tmp; | 426 | u32 tmp; |
426 | void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL; | 427 | void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL; |
427 | 428 | ||
428 | tmp = readl(mmio); | 429 | tmp = readl(mmio); |
429 | if (tmp & PDC_ERR_MASK) { | 430 | if (tmp & PDC_ERR_MASK) { |
430 | have_err = 1; | 431 | err_mask = AC_ERR_DEV; |
431 | pdc_reset_port(ap); | 432 | pdc_reset_port(ap); |
432 | } | 433 | } |
433 | 434 | ||
434 | switch (qc->tf.protocol) { | 435 | switch (qc->tf.protocol) { |
435 | case ATA_PROT_DMA: | 436 | case ATA_PROT_DMA: |
436 | case ATA_PROT_NODATA: | 437 | case ATA_PROT_NODATA: |
437 | status = ata_wait_idle(ap); | 438 | err_mask |= ac_err_mask(ata_wait_idle(ap)); |
438 | if (have_err) | 439 | ata_qc_complete(qc, err_mask); |
439 | status |= ATA_ERR; | ||
440 | ata_qc_complete(qc, status); | ||
441 | handled = 1; | 440 | handled = 1; |
442 | break; | 441 | break; |
443 | 442 | ||
@@ -635,7 +634,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
635 | int rc; | 634 | int rc; |
636 | 635 | ||
637 | if (!printed_version++) | 636 | if (!printed_version++) |
638 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); | 637 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
639 | 638 | ||
640 | /* | 639 | /* |
641 | * If this driver happens to only be useful on Apple's K2, then | 640 | * If this driver happens to only be useful on Apple's K2, then |
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c index 1aaf3304d397..9938dae782b6 100644 --- a/drivers/scsi/sata_qstor.c +++ b/drivers/scsi/sata_qstor.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/interrupt.h> | 36 | #include <linux/interrupt.h> |
37 | #include <linux/sched.h> | 37 | #include <linux/sched.h> |
38 | #include <linux/device.h> | ||
38 | #include "scsi.h" | 39 | #include "scsi.h" |
39 | #include <scsi/scsi_host.h> | 40 | #include <scsi/scsi_host.h> |
40 | #include <asm/io.h> | 41 | #include <asm/io.h> |
@@ -400,11 +401,12 @@ static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set) | |||
400 | qc = ata_qc_from_tag(ap, ap->active_tag); | 401 | qc = ata_qc_from_tag(ap, ap->active_tag); |
401 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) { | 402 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) { |
402 | switch (sHST) { | 403 | switch (sHST) { |
403 | case 0: /* sucessful CPB */ | 404 | case 0: /* successful CPB */ |
404 | case 3: /* device error */ | 405 | case 3: /* device error */ |
405 | pp->state = qs_state_idle; | 406 | pp->state = qs_state_idle; |
406 | qs_enter_reg_mode(qc->ap); | 407 | qs_enter_reg_mode(qc->ap); |
407 | ata_qc_complete(qc, sDST); | 408 | ata_qc_complete(qc, |
409 | ac_err_mask(sDST)); | ||
408 | break; | 410 | break; |
409 | default: | 411 | default: |
410 | break; | 412 | break; |
@@ -441,7 +443,7 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set) | |||
441 | 443 | ||
442 | /* complete taskfile transaction */ | 444 | /* complete taskfile transaction */ |
443 | pp->state = qs_state_idle; | 445 | pp->state = qs_state_idle; |
444 | ata_qc_complete(qc, status); | 446 | ata_qc_complete(qc, ac_err_mask(status)); |
445 | handled = 1; | 447 | handled = 1; |
446 | } | 448 | } |
447 | } | 449 | } |
@@ -599,25 +601,22 @@ static int qs_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base) | |||
599 | if (rc) { | 601 | if (rc) { |
600 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | 602 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); |
601 | if (rc) { | 603 | if (rc) { |
602 | printk(KERN_ERR DRV_NAME | 604 | dev_printk(KERN_ERR, &pdev->dev, |
603 | "(%s): 64-bit DMA enable failed\n", | 605 | "64-bit DMA enable failed\n"); |
604 | pci_name(pdev)); | ||
605 | return rc; | 606 | return rc; |
606 | } | 607 | } |
607 | } | 608 | } |
608 | } else { | 609 | } else { |
609 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 610 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
610 | if (rc) { | 611 | if (rc) { |
611 | printk(KERN_ERR DRV_NAME | 612 | dev_printk(KERN_ERR, &pdev->dev, |
612 | "(%s): 32-bit DMA enable failed\n", | 613 | "32-bit DMA enable failed\n"); |
613 | pci_name(pdev)); | ||
614 | return rc; | 614 | return rc; |
615 | } | 615 | } |
616 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | 616 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); |
617 | if (rc) { | 617 | if (rc) { |
618 | printk(KERN_ERR DRV_NAME | 618 | dev_printk(KERN_ERR, &pdev->dev, |
619 | "(%s): 32-bit consistent DMA enable failed\n", | 619 | "32-bit consistent DMA enable failed\n"); |
620 | pci_name(pdev)); | ||
621 | return rc; | 620 | return rc; |
622 | } | 621 | } |
623 | } | 622 | } |
@@ -634,7 +633,7 @@ static int qs_ata_init_one(struct pci_dev *pdev, | |||
634 | int rc, port_no; | 633 | int rc, port_no; |
635 | 634 | ||
636 | if (!printed_version++) | 635 | if (!printed_version++) |
637 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); | 636 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
638 | 637 | ||
639 | rc = pci_enable_device(pdev); | 638 | rc = pci_enable_device(pdev); |
640 | if (rc) | 639 | if (rc) |
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c index 3a056173fb95..435f7e0085ec 100644 --- a/drivers/scsi/sata_sil.c +++ b/drivers/scsi/sata_sil.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/blkdev.h> | 41 | #include <linux/blkdev.h> |
42 | #include <linux/delay.h> | 42 | #include <linux/delay.h> |
43 | #include <linux/interrupt.h> | 43 | #include <linux/interrupt.h> |
44 | #include <linux/device.h> | ||
44 | #include "scsi.h" | 45 | #include "scsi.h" |
45 | #include <scsi/scsi_host.h> | 46 | #include <scsi/scsi_host.h> |
46 | #include <linux/libata.h> | 47 | #include <linux/libata.h> |
@@ -386,7 +387,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
386 | u8 cls; | 387 | u8 cls; |
387 | 388 | ||
388 | if (!printed_version++) | 389 | if (!printed_version++) |
389 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); | 390 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
390 | 391 | ||
391 | /* | 392 | /* |
392 | * If this driver happens to only be useful on Apple's K2, then | 393 | * If this driver happens to only be useful on Apple's K2, then |
@@ -463,8 +464,8 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
463 | writeb(cls, mmio_base + SIL_FIFO_W3); | 464 | writeb(cls, mmio_base + SIL_FIFO_W3); |
464 | } | 465 | } |
465 | } else | 466 | } else |
466 | printk(KERN_WARNING DRV_NAME "(%s): cache line size not set. Driver may not function\n", | 467 | dev_printk(KERN_WARNING, &pdev->dev, |
467 | pci_name(pdev)); | 468 | "cache line size not set. Driver may not function\n"); |
468 | 469 | ||
469 | if (ent->driver_data == sil_3114) { | 470 | if (ent->driver_data == sil_3114) { |
470 | irq_mask = SIL_MASK_4PORT; | 471 | irq_mask = SIL_MASK_4PORT; |
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c index 51855d3bac64..c66548025657 100644 --- a/drivers/scsi/sata_sil24.c +++ b/drivers/scsi/sata_sil24.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/interrupt.h> | 36 | #include <linux/interrupt.h> |
37 | #include <linux/dma-mapping.h> | 37 | #include <linux/dma-mapping.h> |
38 | #include <linux/device.h> | ||
38 | #include <scsi/scsi_host.h> | 39 | #include <scsi/scsi_host.h> |
39 | #include "scsi.h" | 40 | #include "scsi.h" |
40 | #include <linux/libata.h> | 41 | #include <linux/libata.h> |
@@ -225,7 +226,6 @@ struct sil24_host_priv { | |||
225 | }; | 226 | }; |
226 | 227 | ||
227 | static u8 sil24_check_status(struct ata_port *ap); | 228 | static u8 sil24_check_status(struct ata_port *ap); |
228 | static u8 sil24_check_err(struct ata_port *ap); | ||
229 | static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg); | 229 | static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg); |
230 | static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val); | 230 | static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val); |
231 | static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf); | 231 | static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf); |
@@ -280,7 +280,6 @@ static const struct ata_port_operations sil24_ops = { | |||
280 | 280 | ||
281 | .check_status = sil24_check_status, | 281 | .check_status = sil24_check_status, |
282 | .check_altstatus = sil24_check_status, | 282 | .check_altstatus = sil24_check_status, |
283 | .check_err = sil24_check_err, | ||
284 | .dev_select = ata_noop_dev_select, | 283 | .dev_select = ata_noop_dev_select, |
285 | 284 | ||
286 | .tf_read = sil24_tf_read, | 285 | .tf_read = sil24_tf_read, |
@@ -363,12 +362,6 @@ static u8 sil24_check_status(struct ata_port *ap) | |||
363 | return pp->tf.command; | 362 | return pp->tf.command; |
364 | } | 363 | } |
365 | 364 | ||
366 | static u8 sil24_check_err(struct ata_port *ap) | ||
367 | { | ||
368 | struct sil24_port_priv *pp = ap->private_data; | ||
369 | return pp->tf.feature; | ||
370 | } | ||
371 | |||
372 | static int sil24_scr_map[] = { | 365 | static int sil24_scr_map[] = { |
373 | [SCR_CONTROL] = 0, | 366 | [SCR_CONTROL] = 0, |
374 | [SCR_STATUS] = 1, | 367 | [SCR_STATUS] = 1, |
@@ -506,7 +499,7 @@ static void sil24_eng_timeout(struct ata_port *ap) | |||
506 | 499 | ||
507 | qc = ata_qc_from_tag(ap, ap->active_tag); | 500 | qc = ata_qc_from_tag(ap, ap->active_tag); |
508 | if (!qc) { | 501 | if (!qc) { |
509 | printk(KERN_ERR "ata%u: BUG: tiemout without command\n", | 502 | printk(KERN_ERR "ata%u: BUG: timeout without command\n", |
510 | ap->id); | 503 | ap->id); |
511 | return; | 504 | return; |
512 | } | 505 | } |
@@ -520,7 +513,7 @@ static void sil24_eng_timeout(struct ata_port *ap) | |||
520 | */ | 513 | */ |
521 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); | 514 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); |
522 | qc->scsidone = scsi_finish_command; | 515 | qc->scsidone = scsi_finish_command; |
523 | ata_qc_complete(qc, ATA_ERR); | 516 | ata_qc_complete(qc, AC_ERR_OTHER); |
524 | 517 | ||
525 | sil24_reset_controller(ap); | 518 | sil24_reset_controller(ap); |
526 | } | 519 | } |
@@ -531,6 +524,7 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat) | |||
531 | struct sil24_port_priv *pp = ap->private_data; | 524 | struct sil24_port_priv *pp = ap->private_data; |
532 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; | 525 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; |
533 | u32 irq_stat, cmd_err, sstatus, serror; | 526 | u32 irq_stat, cmd_err, sstatus, serror; |
527 | unsigned int err_mask; | ||
534 | 528 | ||
535 | irq_stat = readl(port + PORT_IRQ_STAT); | 529 | irq_stat = readl(port + PORT_IRQ_STAT); |
536 | writel(irq_stat, port + PORT_IRQ_STAT); /* clear irq */ | 530 | writel(irq_stat, port + PORT_IRQ_STAT); /* clear irq */ |
@@ -558,17 +552,18 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat) | |||
558 | * Device is reporting error, tf registers are valid. | 552 | * Device is reporting error, tf registers are valid. |
559 | */ | 553 | */ |
560 | sil24_update_tf(ap); | 554 | sil24_update_tf(ap); |
555 | err_mask = ac_err_mask(pp->tf.command); | ||
561 | } else { | 556 | } else { |
562 | /* | 557 | /* |
563 | * Other errors. libata currently doesn't have any | 558 | * Other errors. libata currently doesn't have any |
564 | * mechanism to report these errors. Just turn on | 559 | * mechanism to report these errors. Just turn on |
565 | * ATA_ERR. | 560 | * ATA_ERR. |
566 | */ | 561 | */ |
567 | pp->tf.command = ATA_ERR; | 562 | err_mask = AC_ERR_OTHER; |
568 | } | 563 | } |
569 | 564 | ||
570 | if (qc) | 565 | if (qc) |
571 | ata_qc_complete(qc, pp->tf.command); | 566 | ata_qc_complete(qc, err_mask); |
572 | 567 | ||
573 | sil24_reset_controller(ap); | 568 | sil24_reset_controller(ap); |
574 | } | 569 | } |
@@ -593,7 +588,7 @@ static inline void sil24_host_intr(struct ata_port *ap) | |||
593 | sil24_update_tf(ap); | 588 | sil24_update_tf(ap); |
594 | 589 | ||
595 | if (qc) | 590 | if (qc) |
596 | ata_qc_complete(qc, pp->tf.command); | 591 | ata_qc_complete(qc, ac_err_mask(pp->tf.command)); |
597 | } else | 592 | } else |
598 | sil24_error_intr(ap, slot_stat); | 593 | sil24_error_intr(ap, slot_stat); |
599 | } | 594 | } |
@@ -696,7 +691,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
696 | int i, rc; | 691 | int i, rc; |
697 | 692 | ||
698 | if (!printed_version++) | 693 | if (!printed_version++) |
699 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); | 694 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
700 | 695 | ||
701 | rc = pci_enable_device(pdev); | 696 | rc = pci_enable_device(pdev); |
702 | if (rc) | 697 | if (rc) |
@@ -756,14 +751,14 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
756 | */ | 751 | */ |
757 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 752 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
758 | if (rc) { | 753 | if (rc) { |
759 | printk(KERN_ERR DRV_NAME "(%s): 32-bit DMA enable failed\n", | 754 | dev_printk(KERN_ERR, &pdev->dev, |
760 | pci_name(pdev)); | 755 | "32-bit DMA enable failed\n"); |
761 | goto out_free; | 756 | goto out_free; |
762 | } | 757 | } |
763 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | 758 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); |
764 | if (rc) { | 759 | if (rc) { |
765 | printk(KERN_ERR DRV_NAME "(%s): 32-bit consistent DMA enable failed\n", | 760 | dev_printk(KERN_ERR, &pdev->dev, |
766 | pci_name(pdev)); | 761 | "32-bit consistent DMA enable failed\n"); |
767 | goto out_free; | 762 | goto out_free; |
768 | } | 763 | } |
769 | 764 | ||
@@ -799,9 +794,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
799 | break; | 794 | break; |
800 | } | 795 | } |
801 | if (tmp & PORT_CS_PORT_RST) | 796 | if (tmp & PORT_CS_PORT_RST) |
802 | printk(KERN_ERR DRV_NAME | 797 | dev_printk(KERN_ERR, &pdev->dev, |
803 | "(%s): failed to clear port RST\n", | 798 | "failed to clear port RST\n"); |
804 | pci_name(pdev)); | ||
805 | } | 799 | } |
806 | 800 | ||
807 | /* Zero error counters. */ | 801 | /* Zero error counters. */ |
@@ -830,9 +824,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
830 | 824 | ||
831 | /* Reset itself */ | 825 | /* Reset itself */ |
832 | if (__sil24_reset_controller(port)) | 826 | if (__sil24_reset_controller(port)) |
833 | printk(KERN_ERR DRV_NAME | 827 | dev_printk(KERN_ERR, &pdev->dev, |
834 | "(%s): failed to reset controller\n", | 828 | "failed to reset controller\n"); |
835 | pci_name(pdev)); | ||
836 | } | 829 | } |
837 | 830 | ||
838 | /* Turn on interrupts */ | 831 | /* Turn on interrupts */ |
diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c index 057f7b98b6c4..42288be0e561 100644 --- a/drivers/scsi/sata_sis.c +++ b/drivers/scsi/sata_sis.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/blkdev.h> | 38 | #include <linux/blkdev.h> |
39 | #include <linux/delay.h> | 39 | #include <linux/delay.h> |
40 | #include <linux/interrupt.h> | 40 | #include <linux/interrupt.h> |
41 | #include <linux/device.h> | ||
41 | #include "scsi.h" | 42 | #include "scsi.h" |
42 | #include <scsi/scsi_host.h> | 43 | #include <scsi/scsi_host.h> |
43 | #include <linux/libata.h> | 44 | #include <linux/libata.h> |
@@ -237,6 +238,7 @@ static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) | |||
237 | 238 | ||
238 | static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 239 | static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
239 | { | 240 | { |
241 | static int printed_version; | ||
240 | struct ata_probe_ent *probe_ent = NULL; | 242 | struct ata_probe_ent *probe_ent = NULL; |
241 | int rc; | 243 | int rc; |
242 | u32 genctl; | 244 | u32 genctl; |
@@ -245,6 +247,9 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
245 | u8 pmr; | 247 | u8 pmr; |
246 | u8 port2_start; | 248 | u8 port2_start; |
247 | 249 | ||
250 | if (!printed_version++) | ||
251 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); | ||
252 | |||
248 | rc = pci_enable_device(pdev); | 253 | rc = pci_enable_device(pdev); |
249 | if (rc) | 254 | if (rc) |
250 | return rc; | 255 | return rc; |
@@ -288,16 +293,18 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
288 | pci_read_config_byte(pdev, SIS_PMR, &pmr); | 293 | pci_read_config_byte(pdev, SIS_PMR, &pmr); |
289 | if (ent->device != 0x182) { | 294 | if (ent->device != 0x182) { |
290 | if ((pmr & SIS_PMR_COMBINED) == 0) { | 295 | if ((pmr & SIS_PMR_COMBINED) == 0) { |
291 | printk(KERN_INFO "sata_sis: Detected SiS 180/181 chipset in SATA mode\n"); | 296 | dev_printk(KERN_INFO, &pdev->dev, |
297 | "Detected SiS 180/181 chipset in SATA mode\n"); | ||
292 | port2_start = 64; | 298 | port2_start = 64; |
293 | } | 299 | } |
294 | else { | 300 | else { |
295 | printk(KERN_INFO "sata_sis: Detected SiS 180/181 chipset in combined mode\n"); | 301 | dev_printk(KERN_INFO, &pdev->dev, |
302 | "Detected SiS 180/181 chipset in combined mode\n"); | ||
296 | port2_start=0; | 303 | port2_start=0; |
297 | } | 304 | } |
298 | } | 305 | } |
299 | else { | 306 | else { |
300 | printk(KERN_INFO "sata_sis: Detected SiS 182 chipset\n"); | 307 | dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 182 chipset\n"); |
301 | port2_start = 0x20; | 308 | port2_start = 0x20; |
302 | } | 309 | } |
303 | 310 | ||
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c index 46208f52d0e1..db615ff794d8 100644 --- a/drivers/scsi/sata_svw.c +++ b/drivers/scsi/sata_svw.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/blkdev.h> | 44 | #include <linux/blkdev.h> |
45 | #include <linux/delay.h> | 45 | #include <linux/delay.h> |
46 | #include <linux/interrupt.h> | 46 | #include <linux/interrupt.h> |
47 | #include <linux/device.h> | ||
47 | #include "scsi.h" | 48 | #include "scsi.h" |
48 | #include <scsi/scsi_host.h> | 49 | #include <scsi/scsi_host.h> |
49 | #include <linux/libata.h> | 50 | #include <linux/libata.h> |
@@ -362,7 +363,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
362 | int i; | 363 | int i; |
363 | 364 | ||
364 | if (!printed_version++) | 365 | if (!printed_version++) |
365 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); | 366 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
366 | 367 | ||
367 | /* | 368 | /* |
368 | * If this driver happens to only be useful on Apple's K2, then | 369 | * If this driver happens to only be useful on Apple's K2, then |
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c index af08f4f650c1..0ec21e09f5d8 100644 --- a/drivers/scsi/sata_sx4.c +++ b/drivers/scsi/sata_sx4.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/delay.h> | 38 | #include <linux/delay.h> |
39 | #include <linux/interrupt.h> | 39 | #include <linux/interrupt.h> |
40 | #include <linux/sched.h> | 40 | #include <linux/sched.h> |
41 | #include <linux/device.h> | ||
41 | #include "scsi.h" | 42 | #include "scsi.h" |
42 | #include <scsi/scsi_host.h> | 43 | #include <scsi/scsi_host.h> |
43 | #include <linux/libata.h> | 44 | #include <linux/libata.h> |
@@ -718,7 +719,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | |||
718 | VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id, | 719 | VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id, |
719 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); | 720 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); |
720 | /* get drive status; clear intr; complete txn */ | 721 | /* get drive status; clear intr; complete txn */ |
721 | ata_qc_complete(qc, ata_wait_idle(ap)); | 722 | ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap))); |
722 | pdc20621_pop_hdma(qc); | 723 | pdc20621_pop_hdma(qc); |
723 | } | 724 | } |
724 | 725 | ||
@@ -756,7 +757,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | |||
756 | VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id, | 757 | VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id, |
757 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); | 758 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); |
758 | /* get drive status; clear intr; complete txn */ | 759 | /* get drive status; clear intr; complete txn */ |
759 | ata_qc_complete(qc, ata_wait_idle(ap)); | 760 | ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap))); |
760 | pdc20621_pop_hdma(qc); | 761 | pdc20621_pop_hdma(qc); |
761 | } | 762 | } |
762 | handled = 1; | 763 | handled = 1; |
@@ -766,7 +767,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | |||
766 | 767 | ||
767 | status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); | 768 | status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); |
768 | DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status); | 769 | DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status); |
769 | ata_qc_complete(qc, status); | 770 | ata_qc_complete(qc, ac_err_mask(status)); |
770 | handled = 1; | 771 | handled = 1; |
771 | 772 | ||
772 | } else { | 773 | } else { |
@@ -881,7 +882,7 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
881 | case ATA_PROT_DMA: | 882 | case ATA_PROT_DMA: |
882 | case ATA_PROT_NODATA: | 883 | case ATA_PROT_NODATA: |
883 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); | 884 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); |
884 | ata_qc_complete(qc, ata_wait_idle(ap) | ATA_ERR); | 885 | ata_qc_complete(qc, __ac_err_mask(ata_wait_idle(ap))); |
885 | break; | 886 | break; |
886 | 887 | ||
887 | default: | 888 | default: |
@@ -890,7 +891,7 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
890 | printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", | 891 | printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", |
891 | ap->id, qc->tf.command, drv_stat); | 892 | ap->id, qc->tf.command, drv_stat); |
892 | 893 | ||
893 | ata_qc_complete(qc, drv_stat); | 894 | ata_qc_complete(qc, ac_err_mask(drv_stat)); |
894 | break; | 895 | break; |
895 | } | 896 | } |
896 | 897 | ||
@@ -1385,7 +1386,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * | |||
1385 | int rc; | 1386 | int rc; |
1386 | 1387 | ||
1387 | if (!printed_version++) | 1388 | if (!printed_version++) |
1388 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); | 1389 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
1389 | 1390 | ||
1390 | /* | 1391 | /* |
1391 | * If this driver happens to only be useful on Apple's K2, then | 1392 | * If this driver happens to only be useful on Apple's K2, then |
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c index d68dc7d3422c..a5e245c098e1 100644 --- a/drivers/scsi/sata_uli.c +++ b/drivers/scsi/sata_uli.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/blkdev.h> | 32 | #include <linux/blkdev.h> |
33 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
34 | #include <linux/interrupt.h> | 34 | #include <linux/interrupt.h> |
35 | #include <linux/device.h> | ||
35 | #include "scsi.h" | 36 | #include "scsi.h" |
36 | #include <scsi/scsi_host.h> | 37 | #include <scsi/scsi_host.h> |
37 | #include <linux/libata.h> | 38 | #include <linux/libata.h> |
@@ -178,12 +179,16 @@ static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) | |||
178 | 179 | ||
179 | static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 180 | static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
180 | { | 181 | { |
182 | static int printed_version; | ||
181 | struct ata_probe_ent *probe_ent; | 183 | struct ata_probe_ent *probe_ent; |
182 | struct ata_port_info *ppi; | 184 | struct ata_port_info *ppi; |
183 | int rc; | 185 | int rc; |
184 | unsigned int board_idx = (unsigned int) ent->driver_data; | 186 | unsigned int board_idx = (unsigned int) ent->driver_data; |
185 | int pci_dev_busy = 0; | 187 | int pci_dev_busy = 0; |
186 | 188 | ||
189 | if (!printed_version++) | ||
190 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); | ||
191 | |||
187 | rc = pci_enable_device(pdev); | 192 | rc = pci_enable_device(pdev); |
188 | if (rc) | 193 | if (rc) |
189 | return rc; | 194 | return rc; |
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c index 80e291a909a9..b3ecdbe400e9 100644 --- a/drivers/scsi/sata_via.c +++ b/drivers/scsi/sata_via.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/init.h> | 41 | #include <linux/init.h> |
42 | #include <linux/blkdev.h> | 42 | #include <linux/blkdev.h> |
43 | #include <linux/delay.h> | 43 | #include <linux/delay.h> |
44 | #include <linux/device.h> | ||
44 | #include "scsi.h" | 45 | #include "scsi.h" |
45 | #include <scsi/scsi_host.h> | 46 | #include <scsi/scsi_host.h> |
46 | #include <linux/libata.h> | 47 | #include <linux/libata.h> |
@@ -259,15 +260,15 @@ static void svia_configure(struct pci_dev *pdev) | |||
259 | u8 tmp8; | 260 | u8 tmp8; |
260 | 261 | ||
261 | pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, &tmp8); | 262 | pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, &tmp8); |
262 | printk(KERN_INFO DRV_NAME "(%s): routed to hard irq line %d\n", | 263 | dev_printk(KERN_INFO, &pdev->dev, "routed to hard irq line %d\n", |
263 | pci_name(pdev), | ||
264 | (int) (tmp8 & 0xf0) == 0xf0 ? 0 : tmp8 & 0x0f); | 264 | (int) (tmp8 & 0xf0) == 0xf0 ? 0 : tmp8 & 0x0f); |
265 | 265 | ||
266 | /* make sure SATA channels are enabled */ | 266 | /* make sure SATA channels are enabled */ |
267 | pci_read_config_byte(pdev, SATA_CHAN_ENAB, &tmp8); | 267 | pci_read_config_byte(pdev, SATA_CHAN_ENAB, &tmp8); |
268 | if ((tmp8 & ALL_PORTS) != ALL_PORTS) { | 268 | if ((tmp8 & ALL_PORTS) != ALL_PORTS) { |
269 | printk(KERN_DEBUG DRV_NAME "(%s): enabling SATA channels (0x%x)\n", | 269 | dev_printk(KERN_DEBUG, &pdev->dev, |
270 | pci_name(pdev), (int) tmp8); | 270 | "enabling SATA channels (0x%x)\n", |
271 | (int) tmp8); | ||
271 | tmp8 |= ALL_PORTS; | 272 | tmp8 |= ALL_PORTS; |
272 | pci_write_config_byte(pdev, SATA_CHAN_ENAB, tmp8); | 273 | pci_write_config_byte(pdev, SATA_CHAN_ENAB, tmp8); |
273 | } | 274 | } |
@@ -275,8 +276,9 @@ static void svia_configure(struct pci_dev *pdev) | |||
275 | /* make sure interrupts for each channel sent to us */ | 276 | /* make sure interrupts for each channel sent to us */ |
276 | pci_read_config_byte(pdev, SATA_INT_GATE, &tmp8); | 277 | pci_read_config_byte(pdev, SATA_INT_GATE, &tmp8); |
277 | if ((tmp8 & ALL_PORTS) != ALL_PORTS) { | 278 | if ((tmp8 & ALL_PORTS) != ALL_PORTS) { |
278 | printk(KERN_DEBUG DRV_NAME "(%s): enabling SATA channel interrupts (0x%x)\n", | 279 | dev_printk(KERN_DEBUG, &pdev->dev, |
279 | pci_name(pdev), (int) tmp8); | 280 | "enabling SATA channel interrupts (0x%x)\n", |
281 | (int) tmp8); | ||
280 | tmp8 |= ALL_PORTS; | 282 | tmp8 |= ALL_PORTS; |
281 | pci_write_config_byte(pdev, SATA_INT_GATE, tmp8); | 283 | pci_write_config_byte(pdev, SATA_INT_GATE, tmp8); |
282 | } | 284 | } |
@@ -284,8 +286,9 @@ static void svia_configure(struct pci_dev *pdev) | |||
284 | /* make sure native mode is enabled */ | 286 | /* make sure native mode is enabled */ |
285 | pci_read_config_byte(pdev, SATA_NATIVE_MODE, &tmp8); | 287 | pci_read_config_byte(pdev, SATA_NATIVE_MODE, &tmp8); |
286 | if ((tmp8 & NATIVE_MODE_ALL) != NATIVE_MODE_ALL) { | 288 | if ((tmp8 & NATIVE_MODE_ALL) != NATIVE_MODE_ALL) { |
287 | printk(KERN_DEBUG DRV_NAME "(%s): enabling SATA channel native mode (0x%x)\n", | 289 | dev_printk(KERN_DEBUG, &pdev->dev, |
288 | pci_name(pdev), (int) tmp8); | 290 | "enabling SATA channel native mode (0x%x)\n", |
291 | (int) tmp8); | ||
289 | tmp8 |= NATIVE_MODE_ALL; | 292 | tmp8 |= NATIVE_MODE_ALL; |
290 | pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8); | 293 | pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8); |
291 | } | 294 | } |
@@ -303,7 +306,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
303 | u8 tmp8; | 306 | u8 tmp8; |
304 | 307 | ||
305 | if (!printed_version++) | 308 | if (!printed_version++) |
306 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); | 309 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
307 | 310 | ||
308 | rc = pci_enable_device(pdev); | 311 | rc = pci_enable_device(pdev); |
309 | if (rc) | 312 | if (rc) |
@@ -318,8 +321,9 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
318 | if (board_id == vt6420) { | 321 | if (board_id == vt6420) { |
319 | pci_read_config_byte(pdev, SATA_PATA_SHARING, &tmp8); | 322 | pci_read_config_byte(pdev, SATA_PATA_SHARING, &tmp8); |
320 | if (tmp8 & SATA_2DEV) { | 323 | if (tmp8 & SATA_2DEV) { |
321 | printk(KERN_ERR DRV_NAME "(%s): SATA master/slave not supported (0x%x)\n", | 324 | dev_printk(KERN_ERR, &pdev->dev, |
322 | pci_name(pdev), (int) tmp8); | 325 | "SATA master/slave not supported (0x%x)\n", |
326 | (int) tmp8); | ||
323 | rc = -EIO; | 327 | rc = -EIO; |
324 | goto err_out_regions; | 328 | goto err_out_regions; |
325 | } | 329 | } |
@@ -332,10 +336,11 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
332 | for (i = 0; i < ARRAY_SIZE(svia_bar_sizes); i++) | 336 | for (i = 0; i < ARRAY_SIZE(svia_bar_sizes); i++) |
333 | if ((pci_resource_start(pdev, i) == 0) || | 337 | if ((pci_resource_start(pdev, i) == 0) || |
334 | (pci_resource_len(pdev, i) < bar_sizes[i])) { | 338 | (pci_resource_len(pdev, i) < bar_sizes[i])) { |
335 | printk(KERN_ERR DRV_NAME "(%s): invalid PCI BAR %u (sz 0x%lx, val 0x%lx)\n", | 339 | dev_printk(KERN_ERR, &pdev->dev, |
336 | pci_name(pdev), i, | 340 | "invalid PCI BAR %u (sz 0x%lx, val 0x%lx)\n", |
337 | pci_resource_start(pdev, i), | 341 | i, |
338 | pci_resource_len(pdev, i)); | 342 | pci_resource_start(pdev, i), |
343 | pci_resource_len(pdev, i)); | ||
339 | rc = -ENODEV; | 344 | rc = -ENODEV; |
340 | goto err_out_regions; | 345 | goto err_out_regions; |
341 | } | 346 | } |
@@ -353,8 +358,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
353 | probe_ent = vt6421_init_probe_ent(pdev); | 358 | probe_ent = vt6421_init_probe_ent(pdev); |
354 | 359 | ||
355 | if (!probe_ent) { | 360 | if (!probe_ent) { |
356 | printk(KERN_ERR DRV_NAME "(%s): out of memory\n", | 361 | dev_printk(KERN_ERR, &pdev->dev, "out of memory\n"); |
357 | pci_name(pdev)); | ||
358 | rc = -ENOMEM; | 362 | rc = -ENOMEM; |
359 | goto err_out_regions; | 363 | goto err_out_regions; |
360 | } | 364 | } |
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c index 54273e0063c7..bb84ba0c7e83 100644 --- a/drivers/scsi/sata_vsc.c +++ b/drivers/scsi/sata_vsc.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/delay.h> | 42 | #include <linux/delay.h> |
43 | #include <linux/interrupt.h> | 43 | #include <linux/interrupt.h> |
44 | #include <linux/dma-mapping.h> | 44 | #include <linux/dma-mapping.h> |
45 | #include <linux/device.h> | ||
45 | #include "scsi.h" | 46 | #include "scsi.h" |
46 | #include <scsi/scsi_host.h> | 47 | #include <scsi/scsi_host.h> |
47 | #include <linux/libata.h> | 48 | #include <linux/libata.h> |
@@ -295,7 +296,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d | |||
295 | int rc; | 296 | int rc; |
296 | 297 | ||
297 | if (!printed_version++) | 298 | if (!printed_version++) |
298 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); | 299 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
299 | 300 | ||
300 | rc = pci_enable_device(pdev); | 301 | rc = pci_enable_device(pdev); |
301 | if (rc) | 302 | if (rc) |
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; |