diff options
105 files changed, 2249 insertions, 2483 deletions
diff --git a/Documentation/mips/AU1xxx_IDE.README b/Documentation/mips/AU1xxx_IDE.README index 5c8334123f4f..25a6ed1aaa5b 100644 --- a/Documentation/mips/AU1xxx_IDE.README +++ b/Documentation/mips/AU1xxx_IDE.README | |||
@@ -46,8 +46,6 @@ Two files are introduced: | |||
46 | 46 | ||
47 | a) 'include/asm-mips/mach-au1x00/au1xxx_ide.h' | 47 | a) 'include/asm-mips/mach-au1x00/au1xxx_ide.h' |
48 | containes : struct _auide_hwif | 48 | containes : struct _auide_hwif |
49 | struct drive_list_entry dma_white_list | ||
50 | struct drive_list_entry dma_black_list | ||
51 | timing parameters for PIO mode 0/1/2/3/4 | 49 | timing parameters for PIO mode 0/1/2/3/4 |
52 | timing parameters for MWDMA 0/1/2 | 50 | timing parameters for MWDMA 0/1/2 |
53 | 51 | ||
@@ -63,12 +61,6 @@ Four configs variables are introduced: | |||
63 | CONFIG_BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ - maximum transfer size | 61 | CONFIG_BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ - maximum transfer size |
64 | per descriptor | 62 | per descriptor |
65 | 63 | ||
66 | If MWDMA is enabled and the connected hard disc is not on the white list, the | ||
67 | kernel switches to a "safe mwdma mode" at boot time. In this mode the IDE | ||
68 | performance is substantial slower then in full speed mwdma. In this case | ||
69 | please add your hard disc to the white list (follow instruction from 'ADD NEW | ||
70 | HARD DISC TO WHITE OR BLACK LIST' section). | ||
71 | |||
72 | 64 | ||
73 | SUPPORTED IDE MODES | 65 | SUPPORTED IDE MODES |
74 | ------------------- | 66 | ------------------- |
@@ -120,44 +112,6 @@ CONFIG_IDEDMA_AUTO=y | |||
120 | Also undefine 'IDE_AU1XXX_BURSTMODE' in 'drivers/ide/mips/au1xxx-ide.c' to | 112 | Also undefine 'IDE_AU1XXX_BURSTMODE' in 'drivers/ide/mips/au1xxx-ide.c' to |
121 | disable the burst support on DBDMA controller. | 113 | disable the burst support on DBDMA controller. |
122 | 114 | ||
123 | ADD NEW HARD DISC TO WHITE OR BLACK LIST | ||
124 | ---------------------------------------- | ||
125 | |||
126 | Step 1 : detect the model name of your hard disc | ||
127 | |||
128 | a) connect your hard disc to the AU1XXX | ||
129 | |||
130 | b) boot your kernel and get the hard disc model. | ||
131 | |||
132 | Example boot log: | ||
133 | |||
134 | --snipped-- | ||
135 | Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2 | ||
136 | ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx | ||
137 | Au1xxx IDE(builtin) configured for MWDMA2 | ||
138 | Probing IDE interface ide0... | ||
139 | hda: Maxtor 6E040L0, ATA DISK drive | ||
140 | ide0 at 0xac800000-0xac800007,0xac8001c0 on irq 64 | ||
141 | hda: max request size: 64KiB | ||
142 | hda: 80293248 sectors (41110 MB) w/2048KiB Cache, CHS=65535/16/63, (U)DMA | ||
143 | --snipped-- | ||
144 | |||
145 | In this example 'Maxtor 6E040L0'. | ||
146 | |||
147 | Step 2 : edit 'include/asm-mips/mach-au1x00/au1xxx_ide.h' | ||
148 | |||
149 | Add your hard disc to the dma_white_list or dma_black_list structur. | ||
150 | |||
151 | Step 3 : Recompile the kernel | ||
152 | |||
153 | Enable MWDMA support in the kernel configuration. Recompile the kernel and | ||
154 | reboot. | ||
155 | |||
156 | Step 4 : Tests | ||
157 | |||
158 | If you have add a hard disc to the white list, please run some stress tests | ||
159 | for verification. | ||
160 | |||
161 | 115 | ||
162 | ACKNOWLEDGMENTS | 116 | ACKNOWLEDGMENTS |
163 | --------------- | 117 | --------------- |
diff --git a/arch/um/Kconfig.x86_64 b/arch/um/Kconfig.x86_64 index 3fbe69e359ed..5696e7b374b3 100644 --- a/arch/um/Kconfig.x86_64 +++ b/arch/um/Kconfig.x86_64 | |||
@@ -1,3 +1,10 @@ | |||
1 | |||
2 | menu "Host processor type and features" | ||
3 | |||
4 | source "arch/x86/Kconfig.cpu" | ||
5 | |||
6 | endmenu | ||
7 | |||
1 | config UML_X86 | 8 | config UML_X86 |
2 | bool | 9 | bool |
3 | default y | 10 | default y |
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c index f4bd349d4412..f25c29a12d00 100644 --- a/arch/um/os-Linux/helper.c +++ b/arch/um/os-Linux/helper.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include "os.h" | 14 | #include "os.h" |
15 | #include "um_malloc.h" | 15 | #include "um_malloc.h" |
16 | #include "user.h" | 16 | #include "user.h" |
17 | #include <linux/limits.h> | ||
17 | 18 | ||
18 | struct helper_data { | 19 | struct helper_data { |
19 | void (*pre_exec)(void*); | 20 | void (*pre_exec)(void*); |
diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile index 964dc1a04c37..598b5c1903af 100644 --- a/arch/um/sys-i386/Makefile +++ b/arch/um/sys-i386/Makefile | |||
@@ -6,7 +6,7 @@ obj-y = bug.o bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \ | |||
6 | ptrace_user.o setjmp.o signal.o stub.o stub_segv.o syscalls.o sysrq.o \ | 6 | ptrace_user.o setjmp.o signal.o stub.o stub_segv.o syscalls.o sysrq.o \ |
7 | sys_call_table.o tls.o | 7 | sys_call_table.o tls.o |
8 | 8 | ||
9 | subarch-obj-y = lib/bitops_32.o lib/semaphore_32.o lib/string_32.o | 9 | subarch-obj-y = lib/semaphore_32.o lib/string_32.o |
10 | subarch-obj-$(CONFIG_HIGHMEM) += mm/highmem_32.o | 10 | subarch-obj-$(CONFIG_HIGHMEM) += mm/highmem_32.o |
11 | subarch-obj-$(CONFIG_MODULES) += kernel/module_32.o | 11 | subarch-obj-$(CONFIG_MODULES) += kernel/module_32.o |
12 | 12 | ||
diff --git a/arch/um/sys-x86_64/Makefile b/arch/um/sys-x86_64/Makefile index 3c22de532088..c8b4cce9cfe1 100644 --- a/arch/um/sys-x86_64/Makefile +++ b/arch/um/sys-x86_64/Makefile | |||
@@ -10,7 +10,7 @@ obj-y = bug.o bugs.o delay.o fault.o ldt.o mem.o ptrace.o ptrace_user.o \ | |||
10 | 10 | ||
11 | obj-$(CONFIG_MODULES) += um_module.o | 11 | obj-$(CONFIG_MODULES) += um_module.o |
12 | 12 | ||
13 | subarch-obj-y = lib/bitops_64.o lib/csum-partial_64.o lib/memcpy_64.o lib/thunk_64.o | 13 | subarch-obj-y = lib/csum-partial_64.o lib/memcpy_64.o lib/thunk_64.o |
14 | subarch-obj-$(CONFIG_MODULES) += kernel/module_64.o | 14 | subarch-obj-$(CONFIG_MODULES) += kernel/module_64.o |
15 | 15 | ||
16 | ldt-y = ../sys-i386/ldt.o | 16 | ldt-y = ../sys-i386/ldt.o |
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu index 4da3cdb9c1b1..7ef18b01f0bc 100644 --- a/arch/x86/Kconfig.cpu +++ b/arch/x86/Kconfig.cpu | |||
@@ -278,6 +278,11 @@ config GENERIC_CPU | |||
278 | 278 | ||
279 | endchoice | 279 | endchoice |
280 | 280 | ||
281 | config X86_CPU | ||
282 | def_bool y | ||
283 | select GENERIC_FIND_FIRST_BIT | ||
284 | select GENERIC_FIND_NEXT_BIT | ||
285 | |||
281 | config X86_GENERIC | 286 | config X86_GENERIC |
282 | bool "Generic x86 support" | 287 | bool "Generic x86 support" |
283 | depends on X86_32 | 288 | depends on X86_32 |
@@ -398,7 +403,7 @@ config X86_TSC | |||
398 | # generates cmov. | 403 | # generates cmov. |
399 | config X86_CMOV | 404 | config X86_CMOV |
400 | def_bool y | 405 | def_bool y |
401 | depends on (MK7 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7) | 406 | depends on (MK7 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || X86_64) |
402 | 407 | ||
403 | config X86_MINIMUM_CPU_FAMILY | 408 | config X86_MINIMUM_CPU_FAMILY |
404 | int | 409 | int |
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index 25df1c1989fe..76f60f52a885 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile | |||
@@ -11,7 +11,7 @@ lib-y += memcpy_$(BITS).o | |||
11 | ifeq ($(CONFIG_X86_32),y) | 11 | ifeq ($(CONFIG_X86_32),y) |
12 | lib-y += checksum_32.o | 12 | lib-y += checksum_32.o |
13 | lib-y += strstr_32.o | 13 | lib-y += strstr_32.o |
14 | lib-y += bitops_32.o semaphore_32.o string_32.o | 14 | lib-y += semaphore_32.o string_32.o |
15 | 15 | ||
16 | lib-$(CONFIG_X86_USE_3DNOW) += mmx_32.o | 16 | lib-$(CONFIG_X86_USE_3DNOW) += mmx_32.o |
17 | else | 17 | else |
@@ -21,7 +21,6 @@ else | |||
21 | 21 | ||
22 | lib-y += csum-partial_64.o csum-copy_64.o csum-wrappers_64.o | 22 | lib-y += csum-partial_64.o csum-copy_64.o csum-wrappers_64.o |
23 | lib-y += thunk_64.o clear_page_64.o copy_page_64.o | 23 | lib-y += thunk_64.o clear_page_64.o copy_page_64.o |
24 | lib-y += bitops_64.o | ||
25 | lib-y += memmove_64.o memset_64.o | 24 | lib-y += memmove_64.o memset_64.o |
26 | lib-y += copy_user_64.o rwlock_64.o copy_user_nocache_64.o | 25 | lib-y += copy_user_64.o rwlock_64.o copy_user_nocache_64.o |
27 | endif | 26 | endif |
diff --git a/arch/x86/lib/bitops_32.c b/arch/x86/lib/bitops_32.c deleted file mode 100644 index b65440459859..000000000000 --- a/arch/x86/lib/bitops_32.c +++ /dev/null | |||
@@ -1,70 +0,0 @@ | |||
1 | #include <linux/bitops.h> | ||
2 | #include <linux/module.h> | ||
3 | |||
4 | /** | ||
5 | * find_next_bit - find the next set bit in a memory region | ||
6 | * @addr: The address to base the search on | ||
7 | * @offset: The bitnumber to start searching at | ||
8 | * @size: The maximum size to search | ||
9 | */ | ||
10 | int find_next_bit(const unsigned long *addr, int size, int offset) | ||
11 | { | ||
12 | const unsigned long *p = addr + (offset >> 5); | ||
13 | int set = 0, bit = offset & 31, res; | ||
14 | |||
15 | if (bit) { | ||
16 | /* | ||
17 | * Look for nonzero in the first 32 bits: | ||
18 | */ | ||
19 | __asm__("bsfl %1,%0\n\t" | ||
20 | "jne 1f\n\t" | ||
21 | "movl $32, %0\n" | ||
22 | "1:" | ||
23 | : "=r" (set) | ||
24 | : "r" (*p >> bit)); | ||
25 | if (set < (32 - bit)) | ||
26 | return set + offset; | ||
27 | set = 32 - bit; | ||
28 | p++; | ||
29 | } | ||
30 | /* | ||
31 | * No set bit yet, search remaining full words for a bit | ||
32 | */ | ||
33 | res = find_first_bit (p, size - 32 * (p - addr)); | ||
34 | return (offset + set + res); | ||
35 | } | ||
36 | EXPORT_SYMBOL(find_next_bit); | ||
37 | |||
38 | /** | ||
39 | * find_next_zero_bit - find the first zero bit in a memory region | ||
40 | * @addr: The address to base the search on | ||
41 | * @offset: The bitnumber to start searching at | ||
42 | * @size: The maximum size to search | ||
43 | */ | ||
44 | int find_next_zero_bit(const unsigned long *addr, int size, int offset) | ||
45 | { | ||
46 | const unsigned long *p = addr + (offset >> 5); | ||
47 | int set = 0, bit = offset & 31, res; | ||
48 | |||
49 | if (bit) { | ||
50 | /* | ||
51 | * Look for zero in the first 32 bits. | ||
52 | */ | ||
53 | __asm__("bsfl %1,%0\n\t" | ||
54 | "jne 1f\n\t" | ||
55 | "movl $32, %0\n" | ||
56 | "1:" | ||
57 | : "=r" (set) | ||
58 | : "r" (~(*p >> bit))); | ||
59 | if (set < (32 - bit)) | ||
60 | return set + offset; | ||
61 | set = 32 - bit; | ||
62 | p++; | ||
63 | } | ||
64 | /* | ||
65 | * No zero yet, search remaining full bytes for a zero | ||
66 | */ | ||
67 | res = find_first_zero_bit(p, size - 32 * (p - addr)); | ||
68 | return (offset + set + res); | ||
69 | } | ||
70 | EXPORT_SYMBOL(find_next_zero_bit); | ||
diff --git a/arch/x86/lib/bitops_64.c b/arch/x86/lib/bitops_64.c deleted file mode 100644 index 0e8f491e6ccc..000000000000 --- a/arch/x86/lib/bitops_64.c +++ /dev/null | |||
@@ -1,175 +0,0 @@ | |||
1 | #include <linux/bitops.h> | ||
2 | |||
3 | #undef find_first_zero_bit | ||
4 | #undef find_next_zero_bit | ||
5 | #undef find_first_bit | ||
6 | #undef find_next_bit | ||
7 | |||
8 | static inline long | ||
9 | __find_first_zero_bit(const unsigned long * addr, unsigned long size) | ||
10 | { | ||
11 | long d0, d1, d2; | ||
12 | long res; | ||
13 | |||
14 | /* | ||
15 | * We must test the size in words, not in bits, because | ||
16 | * otherwise incoming sizes in the range -63..-1 will not run | ||
17 | * any scasq instructions, and then the flags used by the je | ||
18 | * instruction will have whatever random value was in place | ||
19 | * before. Nobody should call us like that, but | ||
20 | * find_next_zero_bit() does when offset and size are at the | ||
21 | * same word and it fails to find a zero itself. | ||
22 | */ | ||
23 | size += 63; | ||
24 | size >>= 6; | ||
25 | if (!size) | ||
26 | return 0; | ||
27 | asm volatile( | ||
28 | " repe; scasq\n" | ||
29 | " je 1f\n" | ||
30 | " xorq -8(%%rdi),%%rax\n" | ||
31 | " subq $8,%%rdi\n" | ||
32 | " bsfq %%rax,%%rdx\n" | ||
33 | "1: subq %[addr],%%rdi\n" | ||
34 | " shlq $3,%%rdi\n" | ||
35 | " addq %%rdi,%%rdx" | ||
36 | :"=d" (res), "=&c" (d0), "=&D" (d1), "=&a" (d2) | ||
37 | :"0" (0ULL), "1" (size), "2" (addr), "3" (-1ULL), | ||
38 | [addr] "S" (addr) : "memory"); | ||
39 | /* | ||
40 | * Any register would do for [addr] above, but GCC tends to | ||
41 | * prefer rbx over rsi, even though rsi is readily available | ||
42 | * and doesn't have to be saved. | ||
43 | */ | ||
44 | return res; | ||
45 | } | ||
46 | |||
47 | /** | ||
48 | * find_first_zero_bit - find the first zero bit in a memory region | ||
49 | * @addr: The address to start the search at | ||
50 | * @size: The maximum size to search | ||
51 | * | ||
52 | * Returns the bit-number of the first zero bit, not the number of the byte | ||
53 | * containing a bit. | ||
54 | */ | ||
55 | long find_first_zero_bit(const unsigned long * addr, unsigned long size) | ||
56 | { | ||
57 | return __find_first_zero_bit (addr, size); | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * find_next_zero_bit - find the next zero bit in a memory region | ||
62 | * @addr: The address to base the search on | ||
63 | * @offset: The bitnumber to start searching at | ||
64 | * @size: The maximum size to search | ||
65 | */ | ||
66 | long find_next_zero_bit (const unsigned long * addr, long size, long offset) | ||
67 | { | ||
68 | const unsigned long * p = addr + (offset >> 6); | ||
69 | unsigned long set = 0; | ||
70 | unsigned long res, bit = offset&63; | ||
71 | |||
72 | if (bit) { | ||
73 | /* | ||
74 | * Look for zero in first word | ||
75 | */ | ||
76 | asm("bsfq %1,%0\n\t" | ||
77 | "cmoveq %2,%0" | ||
78 | : "=r" (set) | ||
79 | : "r" (~(*p >> bit)), "r"(64L)); | ||
80 | if (set < (64 - bit)) | ||
81 | return set + offset; | ||
82 | set = 64 - bit; | ||
83 | p++; | ||
84 | } | ||
85 | /* | ||
86 | * No zero yet, search remaining full words for a zero | ||
87 | */ | ||
88 | res = __find_first_zero_bit (p, size - 64 * (p - addr)); | ||
89 | |||
90 | return (offset + set + res); | ||
91 | } | ||
92 | |||
93 | static inline long | ||
94 | __find_first_bit(const unsigned long * addr, unsigned long size) | ||
95 | { | ||
96 | long d0, d1; | ||
97 | long res; | ||
98 | |||
99 | /* | ||
100 | * We must test the size in words, not in bits, because | ||
101 | * otherwise incoming sizes in the range -63..-1 will not run | ||
102 | * any scasq instructions, and then the flags used by the jz | ||
103 | * instruction will have whatever random value was in place | ||
104 | * before. Nobody should call us like that, but | ||
105 | * find_next_bit() does when offset and size are at the same | ||
106 | * word and it fails to find a one itself. | ||
107 | */ | ||
108 | size += 63; | ||
109 | size >>= 6; | ||
110 | if (!size) | ||
111 | return 0; | ||
112 | asm volatile( | ||
113 | " repe; scasq\n" | ||
114 | " jz 1f\n" | ||
115 | " subq $8,%%rdi\n" | ||
116 | " bsfq (%%rdi),%%rax\n" | ||
117 | "1: subq %[addr],%%rdi\n" | ||
118 | " shlq $3,%%rdi\n" | ||
119 | " addq %%rdi,%%rax" | ||
120 | :"=a" (res), "=&c" (d0), "=&D" (d1) | ||
121 | :"0" (0ULL), "1" (size), "2" (addr), | ||
122 | [addr] "r" (addr) : "memory"); | ||
123 | return res; | ||
124 | } | ||
125 | |||
126 | /** | ||
127 | * find_first_bit - find the first set bit in a memory region | ||
128 | * @addr: The address to start the search at | ||
129 | * @size: The maximum size to search | ||
130 | * | ||
131 | * Returns the bit-number of the first set bit, not the number of the byte | ||
132 | * containing a bit. | ||
133 | */ | ||
134 | long find_first_bit(const unsigned long * addr, unsigned long size) | ||
135 | { | ||
136 | return __find_first_bit(addr,size); | ||
137 | } | ||
138 | |||
139 | /** | ||
140 | * find_next_bit - find the first set bit in a memory region | ||
141 | * @addr: The address to base the search on | ||
142 | * @offset: The bitnumber to start searching at | ||
143 | * @size: The maximum size to search | ||
144 | */ | ||
145 | long find_next_bit(const unsigned long * addr, long size, long offset) | ||
146 | { | ||
147 | const unsigned long * p = addr + (offset >> 6); | ||
148 | unsigned long set = 0, bit = offset & 63, res; | ||
149 | |||
150 | if (bit) { | ||
151 | /* | ||
152 | * Look for nonzero in the first 64 bits: | ||
153 | */ | ||
154 | asm("bsfq %1,%0\n\t" | ||
155 | "cmoveq %2,%0\n\t" | ||
156 | : "=r" (set) | ||
157 | : "r" (*p >> bit), "r" (64L)); | ||
158 | if (set < (64 - bit)) | ||
159 | return set + offset; | ||
160 | set = 64 - bit; | ||
161 | p++; | ||
162 | } | ||
163 | /* | ||
164 | * No set bit yet, search remaining full words for a bit | ||
165 | */ | ||
166 | res = __find_first_bit (p, size - 64 * (p - addr)); | ||
167 | return (offset + set + res); | ||
168 | } | ||
169 | |||
170 | #include <linux/module.h> | ||
171 | |||
172 | EXPORT_SYMBOL(find_next_bit); | ||
173 | EXPORT_SYMBOL(find_first_bit); | ||
174 | EXPORT_SYMBOL(find_first_zero_bit); | ||
175 | EXPORT_SYMBOL(find_next_zero_bit); | ||
diff --git a/drivers/ide/arm/bast-ide.c b/drivers/ide/arm/bast-ide.c index a80b9574865e..d158f579bde2 100644 --- a/drivers/ide/arm/bast-ide.c +++ b/drivers/ide/arm/bast-ide.c | |||
@@ -55,8 +55,7 @@ static int __init bastide_register(unsigned int base, unsigned int aux, int irq) | |||
55 | ide_init_port_data(hwif, i); | 55 | ide_init_port_data(hwif, i); |
56 | 56 | ||
57 | ide_init_port_hw(hwif, &hw); | 57 | ide_init_port_hw(hwif, &hw); |
58 | hwif->mmio = 1; | 58 | hwif->port_ops = NULL; |
59 | hwif->quirkproc = NULL; | ||
60 | 59 | ||
61 | idx[0] = i; | 60 | idx[0] = i; |
62 | 61 | ||
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index fd12bbe93f11..7d642f44e35b 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c | |||
@@ -191,6 +191,10 @@ static void icside_maskproc(ide_drive_t *drive, int mask) | |||
191 | local_irq_restore(flags); | 191 | local_irq_restore(flags); |
192 | } | 192 | } |
193 | 193 | ||
194 | static const struct ide_port_ops icside_v6_no_dma_port_ops = { | ||
195 | .maskproc = icside_maskproc, | ||
196 | }; | ||
197 | |||
194 | #ifdef CONFIG_BLK_DEV_IDEDMA_ICS | 198 | #ifdef CONFIG_BLK_DEV_IDEDMA_ICS |
195 | /* | 199 | /* |
196 | * SG-DMA support. | 200 | * SG-DMA support. |
@@ -266,6 +270,11 @@ static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode) | |||
266 | ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data); | 270 | ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data); |
267 | } | 271 | } |
268 | 272 | ||
273 | static const struct ide_port_ops icside_v6_port_ops = { | ||
274 | .set_dma_mode = icside_set_dma_mode, | ||
275 | .maskproc = icside_maskproc, | ||
276 | }; | ||
277 | |||
269 | static void icside_dma_host_set(ide_drive_t *drive, int on) | 278 | static void icside_dma_host_set(ide_drive_t *drive, int on) |
270 | { | 279 | { |
271 | } | 280 | } |
@@ -375,25 +384,33 @@ static void icside_dma_lost_irq(ide_drive_t *drive) | |||
375 | printk(KERN_ERR "%s: IRQ lost\n", drive->name); | 384 | printk(KERN_ERR "%s: IRQ lost\n", drive->name); |
376 | } | 385 | } |
377 | 386 | ||
378 | static void icside_dma_init(ide_hwif_t *hwif) | 387 | static int icside_dma_init(ide_hwif_t *hwif, const struct ide_port_info *d) |
379 | { | 388 | { |
380 | hwif->dmatable_cpu = NULL; | 389 | hwif->dmatable_cpu = NULL; |
381 | hwif->dmatable_dma = 0; | 390 | hwif->dmatable_dma = 0; |
382 | hwif->set_dma_mode = icside_set_dma_mode; | 391 | |
383 | 392 | return 0; | |
384 | hwif->dma_host_set = icside_dma_host_set; | ||
385 | hwif->dma_setup = icside_dma_setup; | ||
386 | hwif->dma_exec_cmd = icside_dma_exec_cmd; | ||
387 | hwif->dma_start = icside_dma_start; | ||
388 | hwif->ide_dma_end = icside_dma_end; | ||
389 | hwif->ide_dma_test_irq = icside_dma_test_irq; | ||
390 | hwif->dma_timeout = icside_dma_timeout; | ||
391 | hwif->dma_lost_irq = icside_dma_lost_irq; | ||
392 | } | 393 | } |
394 | |||
395 | static const struct ide_dma_ops icside_v6_dma_ops = { | ||
396 | .dma_host_set = icside_dma_host_set, | ||
397 | .dma_setup = icside_dma_setup, | ||
398 | .dma_exec_cmd = icside_dma_exec_cmd, | ||
399 | .dma_start = icside_dma_start, | ||
400 | .dma_end = icside_dma_end, | ||
401 | .dma_test_irq = icside_dma_test_irq, | ||
402 | .dma_timeout = icside_dma_timeout, | ||
403 | .dma_lost_irq = icside_dma_lost_irq, | ||
404 | }; | ||
393 | #else | 405 | #else |
394 | #define icside_dma_init(hwif) (0) | 406 | #define icside_v6_dma_ops NULL |
395 | #endif | 407 | #endif |
396 | 408 | ||
409 | static int icside_dma_off_init(ide_hwif_t *hwif, const struct ide_port_info *d) | ||
410 | { | ||
411 | return -EOPNOTSUPP; | ||
412 | } | ||
413 | |||
397 | static ide_hwif_t * | 414 | static ide_hwif_t * |
398 | icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec) | 415 | icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec) |
399 | { | 416 | { |
@@ -408,7 +425,6 @@ icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *e | |||
408 | * Ensure we're using MMIO | 425 | * Ensure we're using MMIO |
409 | */ | 426 | */ |
410 | default_hwif_mmiops(hwif); | 427 | default_hwif_mmiops(hwif); |
411 | hwif->mmio = 1; | ||
412 | 428 | ||
413 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { | 429 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { |
414 | hwif->io_ports[i] = port; | 430 | hwif->io_ports[i] = port; |
@@ -416,7 +432,6 @@ icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *e | |||
416 | } | 432 | } |
417 | hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset; | 433 | hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset; |
418 | hwif->irq = ec->irq; | 434 | hwif->irq = ec->irq; |
419 | hwif->noprobe = 0; | ||
420 | hwif->chipset = ide_acorn; | 435 | hwif->chipset = ide_acorn; |
421 | hwif->gendev.parent = &ec->dev; | 436 | hwif->gendev.parent = &ec->dev; |
422 | hwif->dev = &ec->dev; | 437 | hwif->dev = &ec->dev; |
@@ -462,8 +477,10 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) | |||
462 | } | 477 | } |
463 | 478 | ||
464 | static const struct ide_port_info icside_v6_port_info __initdata = { | 479 | static const struct ide_port_info icside_v6_port_info __initdata = { |
480 | .init_dma = icside_dma_off_init, | ||
481 | .port_ops = &icside_v6_no_dma_port_ops, | ||
482 | .dma_ops = &icside_v6_dma_ops, | ||
465 | .host_flags = IDE_HFLAG_SERIALIZE | | 483 | .host_flags = IDE_HFLAG_SERIALIZE | |
466 | IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ | ||
467 | IDE_HFLAG_NO_AUTOTUNE, | 484 | IDE_HFLAG_NO_AUTOTUNE, |
468 | .mwdma_mask = ATA_MWDMA2, | 485 | .mwdma_mask = ATA_MWDMA2, |
469 | .swdma_mask = ATA_SWDMA2, | 486 | .swdma_mask = ATA_SWDMA2, |
@@ -526,7 +543,6 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
526 | state->hwif[0] = hwif; | 543 | state->hwif[0] = hwif; |
527 | state->hwif[1] = mate; | 544 | state->hwif[1] = mate; |
528 | 545 | ||
529 | hwif->maskproc = icside_maskproc; | ||
530 | hwif->hwif_data = state; | 546 | hwif->hwif_data = state; |
531 | hwif->config_data = (unsigned long)ioc_base; | 547 | hwif->config_data = (unsigned long)ioc_base; |
532 | hwif->select_data = sel; | 548 | hwif->select_data = sel; |
@@ -537,10 +553,10 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
537 | mate->select_data = sel | 1; | 553 | mate->select_data = sel | 1; |
538 | 554 | ||
539 | if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) { | 555 | if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) { |
540 | icside_dma_init(hwif); | 556 | d.init_dma = icside_dma_init; |
541 | icside_dma_init(mate); | 557 | d.port_ops = &icside_v6_dma_port_ops; |
542 | } else | 558 | d.dma_ops = NULL; |
543 | d.mwdma_mask = d.swdma_mask = 0; | 559 | } |
544 | 560 | ||
545 | idx[0] = hwif->index; | 561 | idx[0] = hwif->index; |
546 | idx[1] = mate->index; | 562 | idx[1] = mate->index; |
diff --git a/drivers/ide/arm/ide_arm.c b/drivers/ide/arm/ide_arm.c index 82643df7c49a..4263ffd4ab20 100644 --- a/drivers/ide/arm/ide_arm.c +++ b/drivers/ide/arm/ide_arm.c | |||
@@ -14,6 +14,8 @@ | |||
14 | #include <asm/mach-types.h> | 14 | #include <asm/mach-types.h> |
15 | #include <asm/irq.h> | 15 | #include <asm/irq.h> |
16 | 16 | ||
17 | #define DRV_NAME "ide_arm" | ||
18 | |||
17 | #ifdef CONFIG_ARCH_CLPS7500 | 19 | #ifdef CONFIG_ARCH_CLPS7500 |
18 | # include <asm/arch/hardware.h> | 20 | # include <asm/arch/hardware.h> |
19 | # | 21 | # |
@@ -28,10 +30,24 @@ static int __init ide_arm_init(void) | |||
28 | { | 30 | { |
29 | ide_hwif_t *hwif; | 31 | ide_hwif_t *hwif; |
30 | hw_regs_t hw; | 32 | hw_regs_t hw; |
33 | unsigned long base = IDE_ARM_IO, ctl = IDE_ARM_IO + 0x206; | ||
31 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 34 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
32 | 35 | ||
36 | if (!request_region(base, 8, DRV_NAME)) { | ||
37 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | ||
38 | DRV_NAME, base, base + 7); | ||
39 | return -EBUSY; | ||
40 | } | ||
41 | |||
42 | if (!request_region(ctl, 1, DRV_NAME)) { | ||
43 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", | ||
44 | DRV_NAME, ctl); | ||
45 | release_region(base, 8); | ||
46 | return -EBUSY; | ||
47 | } | ||
48 | |||
33 | memset(&hw, 0, sizeof(hw)); | 49 | memset(&hw, 0, sizeof(hw)); |
34 | ide_std_init_ports(&hw, IDE_ARM_IO, IDE_ARM_IO + 0x206); | 50 | ide_std_init_ports(&hw, base, ctl); |
35 | hw.irq = IDE_ARM_IRQ; | 51 | hw.irq = IDE_ARM_IRQ; |
36 | 52 | ||
37 | hwif = ide_find_port(); | 53 | hwif = ide_find_port(); |
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c index 666df779a5f4..8fa34e26443a 100644 --- a/drivers/ide/arm/palm_bk3710.c +++ b/drivers/ide/arm/palm_bk3710.c | |||
@@ -317,17 +317,31 @@ static u8 __devinit palm_bk3710_cable_detect(ide_hwif_t *hwif) | |||
317 | return ATA_CBL_PATA80; | 317 | return ATA_CBL_PATA80; |
318 | } | 318 | } |
319 | 319 | ||
320 | static void __devinit palm_bk3710_init_hwif(ide_hwif_t *hwif) | 320 | static int __devinit palm_bk3710_init_dma(ide_hwif_t *hwif, |
321 | const struct ide_port_info *d) | ||
321 | { | 322 | { |
322 | hwif->set_pio_mode = palm_bk3710_set_pio_mode; | 323 | unsigned long base = |
323 | hwif->set_dma_mode = palm_bk3710_set_dma_mode; | 324 | hwif->io_ports[IDE_DATA_OFFSET] - IDE_PALM_ATA_PRI_REG_OFFSET; |
324 | 325 | ||
325 | hwif->cable_detect = palm_bk3710_cable_detect; | 326 | printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); |
327 | |||
328 | if (ide_allocate_dma_engine(hwif)) | ||
329 | return -1; | ||
330 | |||
331 | ide_setup_dma(hwif, base); | ||
332 | |||
333 | return 0; | ||
326 | } | 334 | } |
327 | 335 | ||
336 | static const struct ide_port_ops palm_bk3710_ports_ops = { | ||
337 | .set_pio_mode = palm_bk3710_set_pio_mode, | ||
338 | .set_dma_mode = palm_bk3710_set_dma_mode, | ||
339 | .cable_detect = palm_bk3710_cable_detect, | ||
340 | }; | ||
341 | |||
328 | static const struct ide_port_info __devinitdata palm_bk3710_port_info = { | 342 | static const struct ide_port_info __devinitdata palm_bk3710_port_info = { |
329 | .init_hwif = palm_bk3710_init_hwif, | 343 | .init_dma = palm_bk3710_init_dma, |
330 | .host_flags = IDE_HFLAG_NO_DMA, /* hack (no PCI) */ | 344 | .port_ops = &palm_bk3710_ports_ops, |
331 | .pio_mask = ATA_PIO4, | 345 | .pio_mask = ATA_PIO4, |
332 | .udma_mask = ATA_UDMA4, /* (input clk 99MHz) */ | 346 | .udma_mask = ATA_UDMA4, /* (input clk 99MHz) */ |
333 | .mwdma_mask = ATA_MWDMA2, | 347 | .mwdma_mask = ATA_MWDMA2, |
@@ -394,8 +408,6 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev) | |||
394 | hwif->mmio = 1; | 408 | hwif->mmio = 1; |
395 | default_hwif_mmiops(hwif); | 409 | default_hwif_mmiops(hwif); |
396 | 410 | ||
397 | ide_setup_dma(hwif, mem->start); | ||
398 | |||
399 | idx[0] = i; | 411 | idx[0] = i; |
400 | 412 | ||
401 | ide_device_add(idx, &palm_bk3710_port_info); | 413 | ide_device_add(idx, &palm_bk3710_port_info); |
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c index 2c3d0ec91dc3..c0581bd98d0d 100644 --- a/drivers/ide/arm/rapide.c +++ b/drivers/ide/arm/rapide.c | |||
@@ -53,7 +53,6 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
53 | 53 | ||
54 | ide_init_port_hw(hwif, &hw); | 54 | ide_init_port_hw(hwif, &hw); |
55 | 55 | ||
56 | hwif->mmio = 1; | ||
57 | default_hwif_mmiops(hwif); | 56 | default_hwif_mmiops(hwif); |
58 | 57 | ||
59 | idx[0] = hwif->index; | 58 | idx[0] = hwif->index; |
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c index 790a7759d455..a62ca75c7e28 100644 --- a/drivers/ide/cris/ide-cris.c +++ b/drivers/ide/cris/ide-cris.c | |||
@@ -673,11 +673,6 @@ cris_ide_inb(unsigned long reg) | |||
673 | return (unsigned char)cris_ide_inw(reg); | 673 | return (unsigned char)cris_ide_inw(reg); |
674 | } | 674 | } |
675 | 675 | ||
676 | static int cris_dma_end (ide_drive_t *drive); | ||
677 | static int cris_dma_setup (ide_drive_t *drive); | ||
678 | static void cris_dma_exec_cmd (ide_drive_t *drive, u8 command); | ||
679 | static int cris_dma_test_irq(ide_drive_t *drive); | ||
680 | static void cris_dma_start(ide_drive_t *drive); | ||
681 | static void cris_ide_input_data (ide_drive_t *drive, void *, unsigned int); | 676 | static void cris_ide_input_data (ide_drive_t *drive, void *, unsigned int); |
682 | static void cris_ide_output_data (ide_drive_t *drive, void *, unsigned int); | 677 | static void cris_ide_output_data (ide_drive_t *drive, void *, unsigned int); |
683 | static void cris_atapi_input_bytes(ide_drive_t *drive, void *, unsigned int); | 678 | static void cris_atapi_input_bytes(ide_drive_t *drive, void *, unsigned int); |
@@ -782,8 +777,17 @@ static void __init cris_setup_ports(hw_regs_t *hw, unsigned long base) | |||
782 | hw->ack_intr = cris_ide_ack_intr; | 777 | hw->ack_intr = cris_ide_ack_intr; |
783 | } | 778 | } |
784 | 779 | ||
780 | static const struct ide_port_ops cris_port_ops = { | ||
781 | .set_pio_mode = cris_set_pio_mode, | ||
782 | .set_dma_mode = cris_set_dma_mode, | ||
783 | }; | ||
784 | |||
785 | static const struct ide_dma_ops cris_dma_ops; | ||
786 | |||
785 | static const struct ide_port_info cris_port_info __initdata = { | 787 | static const struct ide_port_info cris_port_info __initdata = { |
786 | .chipset = ide_etrax100, | 788 | .chipset = ide_etrax100, |
789 | .port_ops = &cris_port_ops, | ||
790 | .dma_ops = &cris_dma_ops, | ||
787 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | 791 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | |
788 | IDE_HFLAG_NO_DMA, /* no SFF-style DMA */ | 792 | IDE_HFLAG_NO_DMA, /* no SFF-style DMA */ |
789 | .pio_mask = ATA_PIO4, | 793 | .pio_mask = ATA_PIO4, |
@@ -809,19 +813,11 @@ static int __init init_e100_ide(void) | |||
809 | continue; | 813 | continue; |
810 | ide_init_port_data(hwif, hwif->index); | 814 | ide_init_port_data(hwif, hwif->index); |
811 | ide_init_port_hw(hwif, &hw); | 815 | ide_init_port_hw(hwif, &hw); |
812 | hwif->mmio = 1; | 816 | |
813 | hwif->set_pio_mode = &cris_set_pio_mode; | ||
814 | hwif->set_dma_mode = &cris_set_dma_mode; | ||
815 | hwif->ata_input_data = &cris_ide_input_data; | 817 | hwif->ata_input_data = &cris_ide_input_data; |
816 | hwif->ata_output_data = &cris_ide_output_data; | 818 | hwif->ata_output_data = &cris_ide_output_data; |
817 | hwif->atapi_input_bytes = &cris_atapi_input_bytes; | 819 | hwif->atapi_input_bytes = &cris_atapi_input_bytes; |
818 | hwif->atapi_output_bytes = &cris_atapi_output_bytes; | 820 | hwif->atapi_output_bytes = &cris_atapi_output_bytes; |
819 | hwif->dma_host_set = &cris_dma_host_set; | ||
820 | hwif->ide_dma_end = &cris_dma_end; | ||
821 | hwif->dma_setup = &cris_dma_setup; | ||
822 | hwif->dma_exec_cmd = &cris_dma_exec_cmd; | ||
823 | hwif->ide_dma_test_irq = &cris_dma_test_irq; | ||
824 | hwif->dma_start = &cris_dma_start; | ||
825 | hwif->OUTB = &cris_ide_outb; | 821 | hwif->OUTB = &cris_ide_outb; |
826 | hwif->OUTW = &cris_ide_outw; | 822 | hwif->OUTW = &cris_ide_outw; |
827 | hwif->OUTBSYNC = &cris_ide_outbsync; | 823 | hwif->OUTBSYNC = &cris_ide_outbsync; |
@@ -1076,6 +1072,15 @@ static void cris_dma_start(ide_drive_t *drive) | |||
1076 | } | 1072 | } |
1077 | } | 1073 | } |
1078 | 1074 | ||
1075 | static const struct ide_dma_ops cris_dma_ops = { | ||
1076 | .dma_host_set = cris_dma_host_set, | ||
1077 | .dma_setup = cris_dma_setup, | ||
1078 | .dma_exec_cmd = cris_dma_exec_cmd, | ||
1079 | .dma_start = cris_dma_start, | ||
1080 | .dma_end = cris_dma_end, | ||
1081 | .dma_test_irq = cris_dma_test_irq, | ||
1082 | }; | ||
1083 | |||
1079 | module_init(init_e100_ide); | 1084 | module_init(init_e100_ide); |
1080 | 1085 | ||
1081 | MODULE_LICENSE("GPL"); | 1086 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/h8300/ide-h8300.c b/drivers/ide/h8300/ide-h8300.c index 92b02b96d7db..0708b29cdb17 100644 --- a/drivers/ide/h8300/ide-h8300.c +++ b/drivers/ide/h8300/ide-h8300.c | |||
@@ -74,7 +74,6 @@ static inline void hwif_setup(ide_hwif_t *hwif) | |||
74 | { | 74 | { |
75 | default_hwif_iops(hwif); | 75 | default_hwif_iops(hwif); |
76 | 76 | ||
77 | hwif->mmio = 1; | ||
78 | hwif->OUTW = mm_outw; | 77 | hwif->OUTW = mm_outw; |
79 | hwif->OUTSW = mm_outsw; | 78 | hwif->OUTSW = mm_outsw; |
80 | hwif->INW = mm_inw; | 79 | hwif->INW = mm_inw; |
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index 0f6fb6b72dd9..e4ad26e4fce7 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c | |||
@@ -55,7 +55,7 @@ struct ide_acpi_hwif_link { | |||
55 | /* note: adds function name and KERN_DEBUG */ | 55 | /* note: adds function name and KERN_DEBUG */ |
56 | #ifdef DEBUGGING | 56 | #ifdef DEBUGGING |
57 | #define DEBPRINT(fmt, args...) \ | 57 | #define DEBPRINT(fmt, args...) \ |
58 | printk(KERN_DEBUG "%s: " fmt, __FUNCTION__, ## args) | 58 | printk(KERN_DEBUG "%s: " fmt, __func__, ## args) |
59 | #else | 59 | #else |
60 | #define DEBPRINT(fmt, args...) do {} while (0) | 60 | #define DEBPRINT(fmt, args...) do {} while (0) |
61 | #endif /* DEBUGGING */ | 61 | #endif /* DEBUGGING */ |
@@ -309,7 +309,7 @@ static int do_drive_get_GTF(ide_drive_t *drive, | |||
309 | if (ACPI_FAILURE(status)) { | 309 | if (ACPI_FAILURE(status)) { |
310 | printk(KERN_DEBUG | 310 | printk(KERN_DEBUG |
311 | "%s: Run _GTF error: status = 0x%x\n", | 311 | "%s: Run _GTF error: status = 0x%x\n", |
312 | __FUNCTION__, status); | 312 | __func__, status); |
313 | goto out; | 313 | goto out; |
314 | } | 314 | } |
315 | 315 | ||
@@ -335,7 +335,7 @@ static int do_drive_get_GTF(ide_drive_t *drive, | |||
335 | out_obj->buffer.length % REGS_PER_GTF) { | 335 | out_obj->buffer.length % REGS_PER_GTF) { |
336 | printk(KERN_ERR | 336 | printk(KERN_ERR |
337 | "%s: unexpected GTF length (%d) or addr (0x%p)\n", | 337 | "%s: unexpected GTF length (%d) or addr (0x%p)\n", |
338 | __FUNCTION__, out_obj->buffer.length, | 338 | __func__, out_obj->buffer.length, |
339 | out_obj->buffer.pointer); | 339 | out_obj->buffer.pointer); |
340 | err = -ENOENT; | 340 | err = -ENOENT; |
341 | kfree(output.pointer); | 341 | kfree(output.pointer); |
@@ -384,7 +384,7 @@ static int taskfile_load_raw(ide_drive_t *drive, | |||
384 | err = ide_no_data_taskfile(drive, &args); | 384 | err = ide_no_data_taskfile(drive, &args); |
385 | if (err) | 385 | if (err) |
386 | printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n", | 386 | printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n", |
387 | __FUNCTION__, err); | 387 | __func__, err); |
388 | 388 | ||
389 | return err; | 389 | return err; |
390 | } | 390 | } |
@@ -422,7 +422,7 @@ static int do_drive_set_taskfiles(ide_drive_t *drive, | |||
422 | 422 | ||
423 | if (gtf_length % REGS_PER_GTF) { | 423 | if (gtf_length % REGS_PER_GTF) { |
424 | printk(KERN_ERR "%s: unexpected GTF length (%d)\n", | 424 | printk(KERN_ERR "%s: unexpected GTF length (%d)\n", |
425 | __FUNCTION__, gtf_length); | 425 | __func__, gtf_length); |
426 | goto out; | 426 | goto out; |
427 | } | 427 | } |
428 | 428 | ||
@@ -547,7 +547,7 @@ void ide_acpi_get_timing(ide_hwif_t *hwif) | |||
547 | printk(KERN_ERR | 547 | printk(KERN_ERR |
548 | "%s: unexpected _GTM length (0x%x)[should be 0x%zx] or " | 548 | "%s: unexpected _GTM length (0x%x)[should be 0x%zx] or " |
549 | "addr (0x%p)\n", | 549 | "addr (0x%p)\n", |
550 | __FUNCTION__, out_obj->buffer.length, | 550 | __func__, out_obj->buffer.length, |
551 | sizeof(struct GTM_buffer), out_obj->buffer.pointer); | 551 | sizeof(struct GTM_buffer), out_obj->buffer.pointer); |
552 | return; | 552 | return; |
553 | } | 553 | } |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 1afd95ad4653..ad984322da94 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -39,12 +39,13 @@ | |||
39 | #include <linux/mutex.h> | 39 | #include <linux/mutex.h> |
40 | #include <linux/bcd.h> | 40 | #include <linux/bcd.h> |
41 | 41 | ||
42 | #include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */ | 42 | /* For SCSI -> ATAPI command conversion */ |
43 | #include <scsi/scsi.h> | ||
43 | 44 | ||
44 | #include <asm/irq.h> | 45 | #include <linux/irq.h> |
45 | #include <asm/io.h> | 46 | #include <linux/io.h> |
46 | #include <asm/byteorder.h> | 47 | #include <asm/byteorder.h> |
47 | #include <asm/uaccess.h> | 48 | #include <linux/uaccess.h> |
48 | #include <asm/unaligned.h> | 49 | #include <asm/unaligned.h> |
49 | 50 | ||
50 | #include "ide-cd.h" | 51 | #include "ide-cd.h" |
@@ -77,12 +78,11 @@ static void ide_cd_put(struct cdrom_info *cd) | |||
77 | mutex_unlock(&idecd_ref_mutex); | 78 | mutex_unlock(&idecd_ref_mutex); |
78 | } | 79 | } |
79 | 80 | ||
80 | /**************************************************************************** | 81 | /* |
81 | * Generic packet command support and error handling routines. | 82 | * Generic packet command support and error handling routines. |
82 | */ | 83 | */ |
83 | 84 | ||
84 | /* Mark that we've seen a media change, and invalidate our internal | 85 | /* Mark that we've seen a media change and invalidate our internal buffers. */ |
85 | buffers. */ | ||
86 | static void cdrom_saw_media_change(ide_drive_t *drive) | 86 | static void cdrom_saw_media_change(ide_drive_t *drive) |
87 | { | 87 | { |
88 | struct cdrom_info *cd = drive->driver_data; | 88 | struct cdrom_info *cd = drive->driver_data; |
@@ -105,9 +105,8 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, | |||
105 | break; | 105 | break; |
106 | case NOT_READY: | 106 | case NOT_READY: |
107 | /* | 107 | /* |
108 | * don't care about tray state messages for | 108 | * don't care about tray state messages for e.g. capacity |
109 | * e.g. capacity commands or in-progress or | 109 | * commands or in-progress or becoming ready |
110 | * becoming ready | ||
111 | */ | 110 | */ |
112 | if (sense->asc == 0x3a || sense->asc == 0x04) | 111 | if (sense->asc == 0x3a || sense->asc == 0x04) |
113 | break; | 112 | break; |
@@ -115,8 +114,8 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, | |||
115 | break; | 114 | break; |
116 | case ILLEGAL_REQUEST: | 115 | case ILLEGAL_REQUEST: |
117 | /* | 116 | /* |
118 | * don't log START_STOP unit with LoEj set, since | 117 | * don't log START_STOP unit with LoEj set, since we cannot |
119 | * we cannot reliably check if drive can auto-close | 118 | * reliably check if drive can auto-close |
120 | */ | 119 | */ |
121 | if (rq->cmd[0] == GPCMD_START_STOP_UNIT && sense->asc == 0x24) | 120 | if (rq->cmd[0] == GPCMD_START_STOP_UNIT && sense->asc == 0x24) |
122 | break; | 121 | break; |
@@ -124,9 +123,9 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, | |||
124 | break; | 123 | break; |
125 | case UNIT_ATTENTION: | 124 | case UNIT_ATTENTION: |
126 | /* | 125 | /* |
127 | * Make good and sure we've seen this potential media | 126 | * Make good and sure we've seen this potential media change. |
128 | * change. Some drives (i.e. Creative) fail to present | 127 | * Some drives (i.e. Creative) fail to present the correct sense |
129 | * the correct sense key in the error register. | 128 | * key in the error register. |
130 | */ | 129 | */ |
131 | cdrom_saw_media_change(drive); | 130 | cdrom_saw_media_change(drive); |
132 | break; | 131 | break; |
@@ -137,8 +136,7 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, | |||
137 | return log; | 136 | return log; |
138 | } | 137 | } |
139 | 138 | ||
140 | static | 139 | static void cdrom_analyze_sense_data(ide_drive_t *drive, |
141 | void cdrom_analyze_sense_data(ide_drive_t *drive, | ||
142 | struct request *failed_command, | 140 | struct request *failed_command, |
143 | struct request_sense *sense) | 141 | struct request_sense *sense) |
144 | { | 142 | { |
@@ -151,15 +149,16 @@ void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
151 | return; | 149 | return; |
152 | 150 | ||
153 | /* | 151 | /* |
154 | * If a read toc is executed for a CD-R or CD-RW medium where | 152 | * If a read toc is executed for a CD-R or CD-RW medium where the first |
155 | * the first toc has not been recorded yet, it will fail with | 153 | * toc has not been recorded yet, it will fail with 05/24/00 (which is a |
156 | * 05/24/00 (which is a confusing error) | 154 | * confusing error) |
157 | */ | 155 | */ |
158 | if (failed_command && failed_command->cmd[0] == GPCMD_READ_TOC_PMA_ATIP) | 156 | if (failed_command && failed_command->cmd[0] == GPCMD_READ_TOC_PMA_ATIP) |
159 | if (sense->sense_key == 0x05 && sense->asc == 0x24) | 157 | if (sense->sense_key == 0x05 && sense->asc == 0x24) |
160 | return; | 158 | return; |
161 | 159 | ||
162 | if (sense->error_code == 0x70) { /* Current Error */ | 160 | /* current error */ |
161 | if (sense->error_code == 0x70) { | ||
163 | switch (sense->sense_key) { | 162 | switch (sense->sense_key) { |
164 | case MEDIUM_ERROR: | 163 | case MEDIUM_ERROR: |
165 | case VOLUME_OVERFLOW: | 164 | case VOLUME_OVERFLOW: |
@@ -178,25 +177,23 @@ void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
178 | if (bio_sectors < 4) | 177 | if (bio_sectors < 4) |
179 | bio_sectors = 4; | 178 | bio_sectors = 4; |
180 | if (drive->queue->hardsect_size == 2048) | 179 | if (drive->queue->hardsect_size == 2048) |
181 | sector <<= 2; /* Device sector size is 2K */ | 180 | /* device sector size is 2K */ |
181 | sector <<= 2; | ||
182 | sector &= ~(bio_sectors - 1); | 182 | sector &= ~(bio_sectors - 1); |
183 | valid = (sector - failed_command->sector) << 9; | 183 | valid = (sector - failed_command->sector) << 9; |
184 | 184 | ||
185 | if (valid < 0) | 185 | if (valid < 0) |
186 | valid = 0; | 186 | valid = 0; |
187 | if (sector < get_capacity(info->disk) && | 187 | if (sector < get_capacity(info->disk) && |
188 | drive->probed_capacity - sector < 4 * 75) { | 188 | drive->probed_capacity - sector < 4 * 75) |
189 | set_capacity(info->disk, sector); | 189 | set_capacity(info->disk, sector); |
190 | } | ||
191 | } | 190 | } |
192 | } | 191 | } |
193 | 192 | ||
194 | ide_cd_log_error(drive->name, failed_command, sense); | 193 | ide_cd_log_error(drive->name, failed_command, sense); |
195 | } | 194 | } |
196 | 195 | ||
197 | /* | 196 | /* Initialize a ide-cd packet command request */ |
198 | * Initialize a ide-cd packet command request | ||
199 | */ | ||
200 | void ide_cd_init_rq(ide_drive_t *drive, struct request *rq) | 197 | void ide_cd_init_rq(ide_drive_t *drive, struct request *rq) |
201 | { | 198 | { |
202 | struct cdrom_info *cd = drive->driver_data; | 199 | struct cdrom_info *cd = drive->driver_data; |
@@ -220,7 +217,8 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | |||
220 | 217 | ||
221 | rq->data = sense; | 218 | rq->data = sense; |
222 | rq->cmd[0] = GPCMD_REQUEST_SENSE; | 219 | rq->cmd[0] = GPCMD_REQUEST_SENSE; |
223 | rq->cmd[4] = rq->data_len = 18; | 220 | rq->cmd[4] = 18; |
221 | rq->data_len = 18; | ||
224 | 222 | ||
225 | rq->cmd_type = REQ_TYPE_SENSE; | 223 | rq->cmd_type = REQ_TYPE_SENSE; |
226 | 224 | ||
@@ -252,7 +250,7 @@ static void cdrom_end_request(ide_drive_t *drive, int uptodate) | |||
252 | } | 250 | } |
253 | cdrom_analyze_sense_data(drive, failed, sense); | 251 | cdrom_analyze_sense_data(drive, failed, sense); |
254 | /* | 252 | /* |
255 | * now end failed request | 253 | * now end the failed request |
256 | */ | 254 | */ |
257 | if (blk_fs_request(failed)) { | 255 | if (blk_fs_request(failed)) { |
258 | if (ide_end_dequeued_request(drive, failed, 0, | 256 | if (ide_end_dequeued_request(drive, failed, 0, |
@@ -280,21 +278,24 @@ static void cdrom_end_request(ide_drive_t *drive, int uptodate) | |||
280 | ide_end_request(drive, uptodate, nsectors); | 278 | ide_end_request(drive, uptodate, nsectors); |
281 | } | 279 | } |
282 | 280 | ||
283 | static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 stat) | 281 | static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 st) |
284 | { | 282 | { |
285 | if (stat & 0x80) | 283 | if (st & 0x80) |
286 | return; | 284 | return; |
287 | ide_dump_status(drive, msg, stat); | 285 | ide_dump_status(drive, msg, st); |
288 | } | 286 | } |
289 | 287 | ||
290 | /* Returns 0 if the request should be continued. | 288 | /* |
291 | Returns 1 if the request was ended. */ | 289 | * Returns: |
290 | * 0: if the request should be continued. | ||
291 | * 1: if the request was ended. | ||
292 | */ | ||
292 | static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | 293 | static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) |
293 | { | 294 | { |
294 | struct request *rq = HWGROUP(drive)->rq; | 295 | struct request *rq = HWGROUP(drive)->rq; |
295 | int stat, err, sense_key; | 296 | int stat, err, sense_key; |
296 | 297 | ||
297 | /* Check for errors. */ | 298 | /* check for errors */ |
298 | stat = ide_read_status(drive); | 299 | stat = ide_read_status(drive); |
299 | 300 | ||
300 | if (stat_ret) | 301 | if (stat_ret) |
@@ -303,20 +304,22 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
303 | if (OK_STAT(stat, good_stat, BAD_R_STAT)) | 304 | if (OK_STAT(stat, good_stat, BAD_R_STAT)) |
304 | return 0; | 305 | return 0; |
305 | 306 | ||
306 | /* Get the IDE error register. */ | 307 | /* get the IDE error register */ |
307 | err = ide_read_error(drive); | 308 | err = ide_read_error(drive); |
308 | sense_key = err >> 4; | 309 | sense_key = err >> 4; |
309 | 310 | ||
310 | if (rq == NULL) { | 311 | if (rq == NULL) { |
311 | printk("%s: missing rq in cdrom_decode_status\n", drive->name); | 312 | printk(KERN_ERR "%s: missing rq in %s\n", |
313 | drive->name, __func__); | ||
312 | return 1; | 314 | return 1; |
313 | } | 315 | } |
314 | 316 | ||
315 | if (blk_sense_request(rq)) { | 317 | if (blk_sense_request(rq)) { |
316 | /* We got an error trying to get sense info | 318 | /* |
317 | from the drive (probably while trying | 319 | * We got an error trying to get sense info from the drive |
318 | to recover from a former error). Just give up. */ | 320 | * (probably while trying to recover from a former error). |
319 | 321 | * Just give up. | |
322 | */ | ||
320 | rq->cmd_flags |= REQ_FAILED; | 323 | rq->cmd_flags |= REQ_FAILED; |
321 | cdrom_end_request(drive, 0); | 324 | cdrom_end_request(drive, 0); |
322 | ide_error(drive, "request sense failure", stat); | 325 | ide_error(drive, "request sense failure", stat); |
@@ -332,13 +335,12 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
332 | if (blk_pc_request(rq) && !rq->errors) | 335 | if (blk_pc_request(rq) && !rq->errors) |
333 | rq->errors = SAM_STAT_CHECK_CONDITION; | 336 | rq->errors = SAM_STAT_CHECK_CONDITION; |
334 | 337 | ||
335 | /* Check for tray open. */ | 338 | /* check for tray open */ |
336 | if (sense_key == NOT_READY) { | 339 | if (sense_key == NOT_READY) { |
337 | cdrom_saw_media_change(drive); | 340 | cdrom_saw_media_change(drive); |
338 | } else if (sense_key == UNIT_ATTENTION) { | 341 | } else if (sense_key == UNIT_ATTENTION) { |
339 | /* Check for media change. */ | 342 | /* check for media change */ |
340 | cdrom_saw_media_change(drive); | 343 | cdrom_saw_media_change(drive); |
341 | /*printk("%s: media changed\n",drive->name);*/ | ||
342 | return 0; | 344 | return 0; |
343 | } else if (sense_key == ILLEGAL_REQUEST && | 345 | } else if (sense_key == ILLEGAL_REQUEST && |
344 | rq->cmd[0] == GPCMD_START_STOP_UNIT) { | 346 | rq->cmd[0] == GPCMD_START_STOP_UNIT) { |
@@ -350,7 +352,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
350 | * cdrom_log_sense() knows this! | 352 | * cdrom_log_sense() knows this! |
351 | */ | 353 | */ |
352 | } else if (!(rq->cmd_flags & REQ_QUIET)) { | 354 | } else if (!(rq->cmd_flags & REQ_QUIET)) { |
353 | /* Otherwise, print an error. */ | 355 | /* otherwise, print an error */ |
354 | ide_dump_status(drive, "packet command error", stat); | 356 | ide_dump_status(drive, "packet command error", stat); |
355 | } | 357 | } |
356 | 358 | ||
@@ -366,27 +368,30 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
366 | } else if (blk_fs_request(rq)) { | 368 | } else if (blk_fs_request(rq)) { |
367 | int do_end_request = 0; | 369 | int do_end_request = 0; |
368 | 370 | ||
369 | /* Handle errors from READ and WRITE requests. */ | 371 | /* handle errors from READ and WRITE requests */ |
370 | 372 | ||
371 | if (blk_noretry_request(rq)) | 373 | if (blk_noretry_request(rq)) |
372 | do_end_request = 1; | 374 | do_end_request = 1; |
373 | 375 | ||
374 | if (sense_key == NOT_READY) { | 376 | if (sense_key == NOT_READY) { |
375 | /* Tray open. */ | 377 | /* tray open */ |
376 | if (rq_data_dir(rq) == READ) { | 378 | if (rq_data_dir(rq) == READ) { |
377 | cdrom_saw_media_change(drive); | 379 | cdrom_saw_media_change(drive); |
378 | 380 | ||
379 | /* Fail the request. */ | 381 | /* fail the request */ |
380 | printk("%s: tray open\n", drive->name); | 382 | printk(KERN_ERR "%s: tray open\n", drive->name); |
381 | do_end_request = 1; | 383 | do_end_request = 1; |
382 | } else { | 384 | } else { |
383 | struct cdrom_info *info = drive->driver_data; | 385 | struct cdrom_info *info = drive->driver_data; |
384 | 386 | ||
385 | /* allow the drive 5 seconds to recover, some | 387 | /* |
388 | * Allow the drive 5 seconds to recover, some | ||
386 | * devices will return this error while flushing | 389 | * devices will return this error while flushing |
387 | * data from cache */ | 390 | * data from cache. |
391 | */ | ||
388 | if (!rq->errors) | 392 | if (!rq->errors) |
389 | info->write_timeout = jiffies + ATAPI_WAIT_WRITE_BUSY; | 393 | info->write_timeout = jiffies + |
394 | ATAPI_WAIT_WRITE_BUSY; | ||
390 | rq->errors = 1; | 395 | rq->errors = 1; |
391 | if (time_after(jiffies, info->write_timeout)) | 396 | if (time_after(jiffies, info->write_timeout)) |
392 | do_end_request = 1; | 397 | do_end_request = 1; |
@@ -394,65 +399,68 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
394 | unsigned long flags; | 399 | unsigned long flags; |
395 | 400 | ||
396 | /* | 401 | /* |
397 | * take a breather relying on the | 402 | * take a breather relying on the unplug |
398 | * unplug timer to kick us again | 403 | * timer to kick us again |
399 | */ | 404 | */ |
400 | spin_lock_irqsave(&ide_lock, flags); | 405 | spin_lock_irqsave(&ide_lock, flags); |
401 | blk_plug_device(drive->queue); | 406 | blk_plug_device(drive->queue); |
402 | spin_unlock_irqrestore(&ide_lock, flags); | 407 | spin_unlock_irqrestore(&ide_lock, |
408 | flags); | ||
403 | return 1; | 409 | return 1; |
404 | } | 410 | } |
405 | } | 411 | } |
406 | } else if (sense_key == UNIT_ATTENTION) { | 412 | } else if (sense_key == UNIT_ATTENTION) { |
407 | /* Media change. */ | 413 | /* media change */ |
408 | cdrom_saw_media_change (drive); | 414 | cdrom_saw_media_change(drive); |
409 | 415 | ||
410 | /* | 416 | /* |
411 | * Arrange to retry the request. | 417 | * Arrange to retry the request but be sure to give up |
412 | * But be sure to give up if we've retried | 418 | * if we've retried too many times. |
413 | * too many times. | ||
414 | */ | 419 | */ |
415 | if (++rq->errors > ERROR_MAX) | 420 | if (++rq->errors > ERROR_MAX) |
416 | do_end_request = 1; | 421 | do_end_request = 1; |
417 | } else if (sense_key == ILLEGAL_REQUEST || | 422 | } else if (sense_key == ILLEGAL_REQUEST || |
418 | sense_key == DATA_PROTECT) { | 423 | sense_key == DATA_PROTECT) { |
419 | /* | 424 | /* |
420 | * No point in retrying after an illegal | 425 | * No point in retrying after an illegal request or data |
421 | * request or data protect error. | 426 | * protect error. |
422 | */ | 427 | */ |
423 | ide_dump_status_no_sense(drive, "command error", stat); | 428 | ide_dump_status_no_sense(drive, "command error", stat); |
424 | do_end_request = 1; | 429 | do_end_request = 1; |
425 | } else if (sense_key == MEDIUM_ERROR) { | 430 | } else if (sense_key == MEDIUM_ERROR) { |
426 | /* | 431 | /* |
427 | * No point in re-trying a zillion times on a bad | 432 | * No point in re-trying a zillion times on a bad |
428 | * sector... If we got here the error is not correctable | 433 | * sector. If we got here the error is not correctable. |
429 | */ | 434 | */ |
430 | ide_dump_status_no_sense(drive, "media error (bad sector)", stat); | 435 | ide_dump_status_no_sense(drive, |
436 | "media error (bad sector)", | ||
437 | stat); | ||
431 | do_end_request = 1; | 438 | do_end_request = 1; |
432 | } else if (sense_key == BLANK_CHECK) { | 439 | } else if (sense_key == BLANK_CHECK) { |
433 | /* Disk appears blank ?? */ | 440 | /* disk appears blank ?? */ |
434 | ide_dump_status_no_sense(drive, "media error (blank)", stat); | 441 | ide_dump_status_no_sense(drive, "media error (blank)", |
442 | stat); | ||
435 | do_end_request = 1; | 443 | do_end_request = 1; |
436 | } else if ((err & ~ABRT_ERR) != 0) { | 444 | } else if ((err & ~ABRT_ERR) != 0) { |
437 | /* Go to the default handler | 445 | /* go to the default handler for other errors */ |
438 | for other errors. */ | ||
439 | ide_error(drive, "cdrom_decode_status", stat); | 446 | ide_error(drive, "cdrom_decode_status", stat); |
440 | return 1; | 447 | return 1; |
441 | } else if ((++rq->errors > ERROR_MAX)) { | 448 | } else if ((++rq->errors > ERROR_MAX)) { |
442 | /* We've racked up too many retries. Abort. */ | 449 | /* we've racked up too many retries, abort */ |
443 | do_end_request = 1; | 450 | do_end_request = 1; |
444 | } | 451 | } |
445 | 452 | ||
446 | /* End a request through request sense analysis when we have | 453 | /* |
447 | sense data. We need this in order to perform end of media | 454 | * End a request through request sense analysis when we have |
448 | processing */ | 455 | * sense data. We need this in order to perform end of media |
449 | 456 | * processing. | |
457 | */ | ||
450 | if (do_end_request) | 458 | if (do_end_request) |
451 | goto end_request; | 459 | goto end_request; |
452 | 460 | ||
453 | /* | 461 | /* |
454 | * If we got a CHECK_CONDITION status, | 462 | * If we got a CHECK_CONDITION status, queue |
455 | * queue a request sense command. | 463 | * a request sense command. |
456 | */ | 464 | */ |
457 | if (stat & ERR_STAT) | 465 | if (stat & ERR_STAT) |
458 | cdrom_queue_request_sense(drive, NULL, NULL); | 466 | cdrom_queue_request_sense(drive, NULL, NULL); |
@@ -461,7 +469,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
461 | cdrom_end_request(drive, 0); | 469 | cdrom_end_request(drive, 0); |
462 | } | 470 | } |
463 | 471 | ||
464 | /* Retry, or handle the next request. */ | 472 | /* retry, or handle the next request */ |
465 | return 1; | 473 | return 1; |
466 | 474 | ||
467 | end_request: | 475 | end_request: |
@@ -486,10 +494,10 @@ static int cdrom_timer_expiry(ide_drive_t *drive) | |||
486 | unsigned long wait = 0; | 494 | unsigned long wait = 0; |
487 | 495 | ||
488 | /* | 496 | /* |
489 | * Some commands are *slow* and normally take a long time to | 497 | * Some commands are *slow* and normally take a long time to complete. |
490 | * complete. Usually we can use the ATAPI "disconnect" to bypass | 498 | * Usually we can use the ATAPI "disconnect" to bypass this, but not all |
491 | * this, but not all commands/drives support that. Let | 499 | * commands/drives support that. Let ide_timer_expiry keep polling us |
492 | * ide_timer_expiry keep polling us for these. | 500 | * for these. |
493 | */ | 501 | */ |
494 | switch (rq->cmd[0]) { | 502 | switch (rq->cmd[0]) { |
495 | case GPCMD_BLANK: | 503 | case GPCMD_BLANK: |
@@ -501,20 +509,22 @@ static int cdrom_timer_expiry(ide_drive_t *drive) | |||
501 | break; | 509 | break; |
502 | default: | 510 | default: |
503 | if (!(rq->cmd_flags & REQ_QUIET)) | 511 | if (!(rq->cmd_flags & REQ_QUIET)) |
504 | printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", rq->cmd[0]); | 512 | printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", |
513 | rq->cmd[0]); | ||
505 | wait = 0; | 514 | wait = 0; |
506 | break; | 515 | break; |
507 | } | 516 | } |
508 | return wait; | 517 | return wait; |
509 | } | 518 | } |
510 | 519 | ||
511 | /* Set up the device registers for transferring a packet command on DEV, | 520 | /* |
512 | expecting to later transfer XFERLEN bytes. HANDLER is the routine | 521 | * Set up the device registers for transferring a packet command on DEV, |
513 | which actually transfers the command to the drive. If this is a | 522 | * expecting to later transfer XFERLEN bytes. HANDLER is the routine |
514 | drq_interrupt device, this routine will arrange for HANDLER to be | 523 | * which actually transfers the command to the drive. If this is a |
515 | called when the interrupt from the drive arrives. Otherwise, HANDLER | 524 | * drq_interrupt device, this routine will arrange for HANDLER to be |
516 | will be called immediately after the drive is prepared for the transfer. */ | 525 | * called when the interrupt from the drive arrives. Otherwise, HANDLER |
517 | 526 | * will be called immediately after the drive is prepared for the transfer. | |
527 | */ | ||
518 | static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | 528 | static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, |
519 | int xferlen, | 529 | int xferlen, |
520 | ide_handler_t *handler) | 530 | ide_handler_t *handler) |
@@ -523,15 +533,15 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
523 | struct cdrom_info *info = drive->driver_data; | 533 | struct cdrom_info *info = drive->driver_data; |
524 | ide_hwif_t *hwif = drive->hwif; | 534 | ide_hwif_t *hwif = drive->hwif; |
525 | 535 | ||
526 | /* Wait for the controller to be idle. */ | 536 | /* wait for the controller to be idle */ |
527 | if (ide_wait_stat(&startstop, drive, 0, BUSY_STAT, WAIT_READY)) | 537 | if (ide_wait_stat(&startstop, drive, 0, BUSY_STAT, WAIT_READY)) |
528 | return startstop; | 538 | return startstop; |
529 | 539 | ||
530 | /* FIXME: for Virtual DMA we must check harder */ | 540 | /* FIXME: for Virtual DMA we must check harder */ |
531 | if (info->dma) | 541 | if (info->dma) |
532 | info->dma = !hwif->dma_setup(drive); | 542 | info->dma = !hwif->dma_ops->dma_setup(drive); |
533 | 543 | ||
534 | /* Set up the controller registers. */ | 544 | /* set up the controller registers */ |
535 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL | | 545 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL | |
536 | IDE_TFLAG_NO_SELECT_MASK, xferlen, info->dma); | 546 | IDE_TFLAG_NO_SELECT_MASK, xferlen, info->dma); |
537 | 547 | ||
@@ -541,7 +551,8 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
541 | drive->waiting_for_dma = 0; | 551 | drive->waiting_for_dma = 0; |
542 | 552 | ||
543 | /* packet command */ | 553 | /* packet command */ |
544 | ide_execute_command(drive, WIN_PACKETCMD, handler, ATAPI_WAIT_PC, cdrom_timer_expiry); | 554 | ide_execute_command(drive, WIN_PACKETCMD, handler, |
555 | ATAPI_WAIT_PC, cdrom_timer_expiry); | ||
545 | return ide_started; | 556 | return ide_started; |
546 | } else { | 557 | } else { |
547 | unsigned long flags; | 558 | unsigned long flags; |
@@ -557,11 +568,12 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
557 | } | 568 | } |
558 | } | 569 | } |
559 | 570 | ||
560 | /* Send a packet command to DRIVE described by CMD_BUF and CMD_LEN. | 571 | /* |
561 | The device registers must have already been prepared | 572 | * Send a packet command to DRIVE described by CMD_BUF and CMD_LEN. The device |
562 | by cdrom_start_packet_command. | 573 | * registers must have already been prepared by cdrom_start_packet_command. |
563 | HANDLER is the interrupt handler to call when the command completes | 574 | * HANDLER is the interrupt handler to call when the command completes or |
564 | or there's data ready. */ | 575 | * there's data ready. |
576 | */ | ||
565 | #define ATAPI_MIN_CDB_BYTES 12 | 577 | #define ATAPI_MIN_CDB_BYTES 12 |
566 | static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, | 578 | static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, |
567 | struct request *rq, | 579 | struct request *rq, |
@@ -573,24 +585,26 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, | |||
573 | ide_startstop_t startstop; | 585 | ide_startstop_t startstop; |
574 | 586 | ||
575 | if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { | 587 | if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { |
576 | /* Here we should have been called after receiving an interrupt | 588 | /* |
577 | from the device. DRQ should how be set. */ | 589 | * Here we should have been called after receiving an interrupt |
590 | * from the device. DRQ should how be set. | ||
591 | */ | ||
578 | 592 | ||
579 | /* Check for errors. */ | 593 | /* check for errors */ |
580 | if (cdrom_decode_status(drive, DRQ_STAT, NULL)) | 594 | if (cdrom_decode_status(drive, DRQ_STAT, NULL)) |
581 | return ide_stopped; | 595 | return ide_stopped; |
582 | 596 | ||
583 | /* Ok, next interrupt will be DMA interrupt. */ | 597 | /* ok, next interrupt will be DMA interrupt */ |
584 | if (info->dma) | 598 | if (info->dma) |
585 | drive->waiting_for_dma = 1; | 599 | drive->waiting_for_dma = 1; |
586 | } else { | 600 | } else { |
587 | /* Otherwise, we must wait for DRQ to get set. */ | 601 | /* otherwise, we must wait for DRQ to get set */ |
588 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, | 602 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, |
589 | BUSY_STAT, WAIT_READY)) | 603 | BUSY_STAT, WAIT_READY)) |
590 | return startstop; | 604 | return startstop; |
591 | } | 605 | } |
592 | 606 | ||
593 | /* Arm the interrupt handler. */ | 607 | /* arm the interrupt handler */ |
594 | ide_set_handler(drive, handler, rq->timeout, cdrom_timer_expiry); | 608 | ide_set_handler(drive, handler, rq->timeout, cdrom_timer_expiry); |
595 | 609 | ||
596 | /* ATAPI commands get padded out to 12 bytes minimum */ | 610 | /* ATAPI commands get padded out to 12 bytes minimum */ |
@@ -598,20 +612,19 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, | |||
598 | if (cmd_len < ATAPI_MIN_CDB_BYTES) | 612 | if (cmd_len < ATAPI_MIN_CDB_BYTES) |
599 | cmd_len = ATAPI_MIN_CDB_BYTES; | 613 | cmd_len = ATAPI_MIN_CDB_BYTES; |
600 | 614 | ||
601 | /* Send the command to the device. */ | 615 | /* send the command to the device */ |
602 | HWIF(drive)->atapi_output_bytes(drive, rq->cmd, cmd_len); | 616 | HWIF(drive)->atapi_output_bytes(drive, rq->cmd, cmd_len); |
603 | 617 | ||
604 | /* Start the DMA if need be */ | 618 | /* start the DMA if need be */ |
605 | if (info->dma) | 619 | if (info->dma) |
606 | hwif->dma_start(drive); | 620 | hwif->dma_ops->dma_start(drive); |
607 | 621 | ||
608 | return ide_started; | 622 | return ide_started; |
609 | } | 623 | } |
610 | 624 | ||
611 | /**************************************************************************** | 625 | /* |
612 | * Block read functions. | 626 | * Block read functions. |
613 | */ | 627 | */ |
614 | |||
615 | static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len) | 628 | static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len) |
616 | { | 629 | { |
617 | while (len > 0) { | 630 | while (len > 0) { |
@@ -649,20 +662,21 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq, | |||
649 | ide_hwif_t *hwif = drive->hwif; | 662 | ide_hwif_t *hwif = drive->hwif; |
650 | xfer_func_t *xf; | 663 | xfer_func_t *xf; |
651 | 664 | ||
652 | /* Whoops... */ | 665 | /* whoops... */ |
653 | printk(KERN_ERR "%s: %s: wrong transfer direction!\n", | 666 | printk(KERN_ERR "%s: %s: wrong transfer direction!\n", |
654 | drive->name, __func__); | 667 | drive->name, __func__); |
655 | 668 | ||
656 | xf = rw ? hwif->atapi_output_bytes : hwif->atapi_input_bytes; | 669 | xf = rw ? hwif->atapi_output_bytes : hwif->atapi_input_bytes; |
657 | ide_cd_pad_transfer(drive, xf, len); | 670 | ide_cd_pad_transfer(drive, xf, len); |
658 | } else if (rw == 0 && ireason == 1) { | 671 | } else if (rw == 0 && ireason == 1) { |
659 | /* Some drives (ASUS) seem to tell us that status | 672 | /* |
660 | * info is available. just get it and ignore. | 673 | * Some drives (ASUS) seem to tell us that status info is |
674 | * available. Just get it and ignore. | ||
661 | */ | 675 | */ |
662 | (void)ide_read_status(drive); | 676 | (void)ide_read_status(drive); |
663 | return 0; | 677 | return 0; |
664 | } else { | 678 | } else { |
665 | /* Drive wants a command packet, or invalid ireason... */ | 679 | /* drive wants a command packet, or invalid ireason... */ |
666 | printk(KERN_ERR "%s: %s: bad interrupt reason 0x%02x\n", | 680 | printk(KERN_ERR "%s: %s: bad interrupt reason 0x%02x\n", |
667 | drive->name, __func__, ireason); | 681 | drive->name, __func__, ireason); |
668 | } | 682 | } |
@@ -702,10 +716,10 @@ static int ide_cd_check_transfer_size(ide_drive_t *drive, int len) | |||
702 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); | 716 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); |
703 | 717 | ||
704 | /* | 718 | /* |
705 | * Routine to send a read/write packet command to the drive. | 719 | * Routine to send a read/write packet command to the drive. This is usually |
706 | * This is usually called directly from cdrom_start_{read,write}(). | 720 | * called directly from cdrom_start_{read,write}(). However, for drq_interrupt |
707 | * However, for drq_interrupt devices, it is called from an interrupt | 721 | * devices, it is called from an interrupt when the drive is ready to accept |
708 | * when the drive is ready to accept the command. | 722 | * the command. |
709 | */ | 723 | */ |
710 | static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) | 724 | static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) |
711 | { | 725 | { |
@@ -727,7 +741,7 @@ static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) | |||
727 | * is larger than the buffer size. | 741 | * is larger than the buffer size. |
728 | */ | 742 | */ |
729 | if (nskip > 0) { | 743 | if (nskip > 0) { |
730 | /* Sanity check... */ | 744 | /* sanity check... */ |
731 | if (rq->current_nr_sectors != | 745 | if (rq->current_nr_sectors != |
732 | bio_cur_sectors(rq->bio)) { | 746 | bio_cur_sectors(rq->bio)) { |
733 | printk(KERN_ERR "%s: %s: buffer botch (%u)\n", | 747 | printk(KERN_ERR "%s: %s: buffer botch (%u)\n", |
@@ -744,10 +758,10 @@ static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) | |||
744 | /* the immediate bit */ | 758 | /* the immediate bit */ |
745 | rq->cmd[1] = 1 << 3; | 759 | rq->cmd[1] = 1 << 3; |
746 | #endif | 760 | #endif |
747 | /* Set up the command */ | 761 | /* set up the command */ |
748 | rq->timeout = ATAPI_WAIT_PC; | 762 | rq->timeout = ATAPI_WAIT_PC; |
749 | 763 | ||
750 | /* Send the command to the drive and return. */ | 764 | /* send the command to the drive and return */ |
751 | return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); | 765 | return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); |
752 | } | 766 | } |
753 | 767 | ||
@@ -767,14 +781,8 @@ static ide_startstop_t cdrom_seek_intr(ide_drive_t *drive) | |||
767 | info->cd_flags |= IDE_CD_FLAG_SEEKING; | 781 | info->cd_flags |= IDE_CD_FLAG_SEEKING; |
768 | 782 | ||
769 | if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) { | 783 | if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) { |
770 | if (--retry == 0) { | 784 | if (--retry == 0) |
771 | /* | ||
772 | * this condition is far too common, to bother | ||
773 | * users about it | ||
774 | */ | ||
775 | /* printk("%s: disabled DSC seek overlap\n", drive->name);*/ | ||
776 | drive->dsc_overlap = 0; | 785 | drive->dsc_overlap = 0; |
777 | } | ||
778 | } | 786 | } |
779 | return ide_stopped; | 787 | return ide_stopped; |
780 | } | 788 | } |
@@ -800,32 +808,34 @@ static ide_startstop_t cdrom_start_seek(ide_drive_t *drive, unsigned int block) | |||
800 | 808 | ||
801 | info->dma = 0; | 809 | info->dma = 0; |
802 | info->start_seek = jiffies; | 810 | info->start_seek = jiffies; |
803 | return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation); | 811 | return cdrom_start_packet_command(drive, 0, |
812 | cdrom_start_seek_continuation); | ||
804 | } | 813 | } |
805 | 814 | ||
806 | /* | 815 | /* |
807 | * Fix up a possibly partially-processed request so that we can | 816 | * Fix up a possibly partially-processed request so that we can start it over |
808 | * start it over entirely, or even put it back on the request queue. | 817 | * entirely, or even put it back on the request queue. |
809 | */ | 818 | */ |
810 | static void restore_request(struct request *rq) | 819 | static void restore_request(struct request *rq) |
811 | { | 820 | { |
812 | if (rq->buffer != bio_data(rq->bio)) { | 821 | if (rq->buffer != bio_data(rq->bio)) { |
813 | sector_t n = (rq->buffer - (char *) bio_data(rq->bio)) / SECTOR_SIZE; | 822 | sector_t n = |
823 | (rq->buffer - (char *)bio_data(rq->bio)) / SECTOR_SIZE; | ||
814 | 824 | ||
815 | rq->buffer = bio_data(rq->bio); | 825 | rq->buffer = bio_data(rq->bio); |
816 | rq->nr_sectors += n; | 826 | rq->nr_sectors += n; |
817 | rq->sector -= n; | 827 | rq->sector -= n; |
818 | } | 828 | } |
819 | rq->hard_cur_sectors = rq->current_nr_sectors = bio_cur_sectors(rq->bio); | 829 | rq->current_nr_sectors = bio_cur_sectors(rq->bio); |
830 | rq->hard_cur_sectors = rq->current_nr_sectors; | ||
820 | rq->hard_nr_sectors = rq->nr_sectors; | 831 | rq->hard_nr_sectors = rq->nr_sectors; |
821 | rq->hard_sector = rq->sector; | 832 | rq->hard_sector = rq->sector; |
822 | rq->q->prep_rq_fn(rq->q, rq); | 833 | rq->q->prep_rq_fn(rq->q, rq); |
823 | } | 834 | } |
824 | 835 | ||
825 | /**************************************************************************** | 836 | /* |
826 | * Execute all other packet commands. | 837 | * All other packet commands. |
827 | */ | 838 | */ |
828 | |||
829 | static void ide_cd_request_sense_fixup(struct request *rq) | 839 | static void ide_cd_request_sense_fixup(struct request *rq) |
830 | { | 840 | { |
831 | /* | 841 | /* |
@@ -849,7 +859,7 @@ int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq) | |||
849 | if (rq->sense == NULL) | 859 | if (rq->sense == NULL) |
850 | rq->sense = &sense; | 860 | rq->sense = &sense; |
851 | 861 | ||
852 | /* Start of retry loop. */ | 862 | /* start of retry loop */ |
853 | do { | 863 | do { |
854 | int error; | 864 | int error; |
855 | unsigned long time = jiffies; | 865 | unsigned long time = jiffies; |
@@ -858,41 +868,45 @@ int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq) | |||
858 | error = ide_do_drive_cmd(drive, rq, ide_wait); | 868 | error = ide_do_drive_cmd(drive, rq, ide_wait); |
859 | time = jiffies - time; | 869 | time = jiffies - time; |
860 | 870 | ||
861 | /* FIXME: we should probably abort/retry or something | 871 | /* |
862 | * in case of failure */ | 872 | * FIXME: we should probably abort/retry or something in case of |
873 | * failure. | ||
874 | */ | ||
863 | if (rq->cmd_flags & REQ_FAILED) { | 875 | if (rq->cmd_flags & REQ_FAILED) { |
864 | /* The request failed. Retry if it was due to a unit | 876 | /* |
865 | attention status | 877 | * The request failed. Retry if it was due to a unit |
866 | (usually means media was changed). */ | 878 | * attention status (usually means media was changed). |
879 | */ | ||
867 | struct request_sense *reqbuf = rq->sense; | 880 | struct request_sense *reqbuf = rq->sense; |
868 | 881 | ||
869 | if (reqbuf->sense_key == UNIT_ATTENTION) | 882 | if (reqbuf->sense_key == UNIT_ATTENTION) |
870 | cdrom_saw_media_change(drive); | 883 | cdrom_saw_media_change(drive); |
871 | else if (reqbuf->sense_key == NOT_READY && | 884 | else if (reqbuf->sense_key == NOT_READY && |
872 | reqbuf->asc == 4 && reqbuf->ascq != 4) { | 885 | reqbuf->asc == 4 && reqbuf->ascq != 4) { |
873 | /* The drive is in the process of loading | 886 | /* |
874 | a disk. Retry, but wait a little to give | 887 | * The drive is in the process of loading |
875 | the drive time to complete the load. */ | 888 | * a disk. Retry, but wait a little to give |
889 | * the drive time to complete the load. | ||
890 | */ | ||
876 | ssleep(2); | 891 | ssleep(2); |
877 | } else { | 892 | } else { |
878 | /* Otherwise, don't retry. */ | 893 | /* otherwise, don't retry */ |
879 | retries = 0; | 894 | retries = 0; |
880 | } | 895 | } |
881 | --retries; | 896 | --retries; |
882 | } | 897 | } |
883 | 898 | ||
884 | /* End of retry loop. */ | 899 | /* end of retry loop */ |
885 | } while ((rq->cmd_flags & REQ_FAILED) && retries >= 0); | 900 | } while ((rq->cmd_flags & REQ_FAILED) && retries >= 0); |
886 | 901 | ||
887 | /* Return an error if the command failed. */ | 902 | /* return an error if the command failed */ |
888 | return (rq->cmd_flags & REQ_FAILED) ? -EIO : 0; | 903 | return (rq->cmd_flags & REQ_FAILED) ? -EIO : 0; |
889 | } | 904 | } |
890 | 905 | ||
891 | /* | 906 | /* |
892 | * Called from blk_end_request_callback() after the data of the request | 907 | * Called from blk_end_request_callback() after the data of the request is |
893 | * is completed and before the request is completed. | 908 | * completed and before the request itself is completed. By returning value '1', |
894 | * By returning value '1', blk_end_request_callback() returns immediately | 909 | * blk_end_request_callback() returns immediately without completing it. |
895 | * without completing the request. | ||
896 | */ | 910 | */ |
897 | static int cdrom_newpc_intr_dummy_cb(struct request *rq) | 911 | static int cdrom_newpc_intr_dummy_cb(struct request *rq) |
898 | { | 912 | { |
@@ -911,11 +925,11 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
911 | unsigned int timeout; | 925 | unsigned int timeout; |
912 | u8 lowcyl, highcyl; | 926 | u8 lowcyl, highcyl; |
913 | 927 | ||
914 | /* Check for errors. */ | 928 | /* check for errors */ |
915 | dma = info->dma; | 929 | dma = info->dma; |
916 | if (dma) { | 930 | if (dma) { |
917 | info->dma = 0; | 931 | info->dma = 0; |
918 | dma_error = HWIF(drive)->ide_dma_end(drive); | 932 | dma_error = hwif->dma_ops->dma_end(drive); |
919 | if (dma_error) { | 933 | if (dma_error) { |
920 | printk(KERN_ERR "%s: DMA %s error\n", drive->name, | 934 | printk(KERN_ERR "%s: DMA %s error\n", drive->name, |
921 | write ? "write" : "read"); | 935 | write ? "write" : "read"); |
@@ -926,9 +940,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
926 | if (cdrom_decode_status(drive, 0, &stat)) | 940 | if (cdrom_decode_status(drive, 0, &stat)) |
927 | return ide_stopped; | 941 | return ide_stopped; |
928 | 942 | ||
929 | /* | 943 | /* using dma, transfer is complete now */ |
930 | * using dma, transfer is complete now | ||
931 | */ | ||
932 | if (dma) { | 944 | if (dma) { |
933 | if (dma_error) | 945 | if (dma_error) |
934 | return ide_error(drive, "dma error", stat); | 946 | return ide_error(drive, "dma error", stat); |
@@ -939,9 +951,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
939 | goto end_request; | 951 | goto end_request; |
940 | } | 952 | } |
941 | 953 | ||
942 | /* | 954 | /* ok we fall to pio :/ */ |
943 | * ok we fall to pio :/ | ||
944 | */ | ||
945 | ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]) & 0x3; | 955 | ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]) & 0x3; |
946 | lowcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]); | 956 | lowcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]); |
947 | highcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]); | 957 | highcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]); |
@@ -952,9 +962,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
952 | if (thislen > len) | 962 | if (thislen > len) |
953 | thislen = len; | 963 | thislen = len; |
954 | 964 | ||
955 | /* | 965 | /* If DRQ is clear, the command has completed. */ |
956 | * If DRQ is clear, the command has completed. | ||
957 | */ | ||
958 | if ((stat & DRQ_STAT) == 0) { | 966 | if ((stat & DRQ_STAT) == 0) { |
959 | if (blk_fs_request(rq)) { | 967 | if (blk_fs_request(rq)) { |
960 | /* | 968 | /* |
@@ -975,15 +983,13 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
975 | return ide_stopped; | 983 | return ide_stopped; |
976 | } else if (!blk_pc_request(rq)) { | 984 | } else if (!blk_pc_request(rq)) { |
977 | ide_cd_request_sense_fixup(rq); | 985 | ide_cd_request_sense_fixup(rq); |
978 | /* Complain if we still have data left to transfer. */ | 986 | /* complain if we still have data left to transfer */ |
979 | uptodate = rq->data_len ? 0 : 1; | 987 | uptodate = rq->data_len ? 0 : 1; |
980 | } | 988 | } |
981 | goto end_request; | 989 | goto end_request; |
982 | } | 990 | } |
983 | 991 | ||
984 | /* | 992 | /* check which way to transfer data */ |
985 | * check which way to transfer data | ||
986 | */ | ||
987 | if (ide_cd_check_ireason(drive, rq, len, ireason, write)) | 993 | if (ide_cd_check_ireason(drive, rq, len, ireason, write)) |
988 | return ide_stopped; | 994 | return ide_stopped; |
989 | 995 | ||
@@ -1019,16 +1025,12 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1019 | xferfunc = HWIF(drive)->atapi_input_bytes; | 1025 | xferfunc = HWIF(drive)->atapi_input_bytes; |
1020 | } | 1026 | } |
1021 | 1027 | ||
1022 | /* | 1028 | /* transfer data */ |
1023 | * transfer data | ||
1024 | */ | ||
1025 | while (thislen > 0) { | 1029 | while (thislen > 0) { |
1026 | u8 *ptr = blk_fs_request(rq) ? NULL : rq->data; | 1030 | u8 *ptr = blk_fs_request(rq) ? NULL : rq->data; |
1027 | int blen = rq->data_len; | 1031 | int blen = rq->data_len; |
1028 | 1032 | ||
1029 | /* | 1033 | /* bio backed? */ |
1030 | * bio backed? | ||
1031 | */ | ||
1032 | if (rq->bio) { | 1034 | if (rq->bio) { |
1033 | if (blk_fs_request(rq)) { | 1035 | if (blk_fs_request(rq)) { |
1034 | ptr = rq->buffer; | 1036 | ptr = rq->buffer; |
@@ -1043,7 +1045,8 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1043 | if (blk_fs_request(rq) && !write) | 1045 | if (blk_fs_request(rq) && !write) |
1044 | /* | 1046 | /* |
1045 | * If the buffers are full, pipe the rest into | 1047 | * If the buffers are full, pipe the rest into |
1046 | * oblivion. */ | 1048 | * oblivion. |
1049 | */ | ||
1047 | ide_cd_drain_data(drive, thislen >> 9); | 1050 | ide_cd_drain_data(drive, thislen >> 9); |
1048 | else { | 1051 | else { |
1049 | printk(KERN_ERR "%s: confused, missing data\n", | 1052 | printk(KERN_ERR "%s: confused, missing data\n", |
@@ -1090,9 +1093,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1090 | rq->sense_len += blen; | 1093 | rq->sense_len += blen; |
1091 | } | 1094 | } |
1092 | 1095 | ||
1093 | /* | 1096 | /* pad, if necessary */ |
1094 | * pad, if necessary | ||
1095 | */ | ||
1096 | if (!blk_fs_request(rq) && len > 0) | 1097 | if (!blk_fs_request(rq) && len > 0) |
1097 | ide_cd_pad_transfer(drive, xferfunc, len); | 1098 | ide_cd_pad_transfer(drive, xferfunc, len); |
1098 | 1099 | ||
@@ -1136,9 +1137,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
1136 | queue_hardsect_size(drive->queue) >> SECTOR_BITS; | 1137 | queue_hardsect_size(drive->queue) >> SECTOR_BITS; |
1137 | 1138 | ||
1138 | if (write) { | 1139 | if (write) { |
1139 | /* | 1140 | /* disk has become write protected */ |
1140 | * disk has become write protected | ||
1141 | */ | ||
1142 | if (cd->disk->policy) { | 1141 | if (cd->disk->policy) { |
1143 | cdrom_end_request(drive, 0); | 1142 | cdrom_end_request(drive, 0); |
1144 | return ide_stopped; | 1143 | return ide_stopped; |
@@ -1151,9 +1150,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
1151 | restore_request(rq); | 1150 | restore_request(rq); |
1152 | } | 1151 | } |
1153 | 1152 | ||
1154 | /* | 1153 | /* use DMA, if possible / writes *must* be hardware frame aligned */ |
1155 | * use DMA, if possible / writes *must* be hardware frame aligned | ||
1156 | */ | ||
1157 | if ((rq->nr_sectors & (sectors_per_frame - 1)) || | 1154 | if ((rq->nr_sectors & (sectors_per_frame - 1)) || |
1158 | (rq->sector & (sectors_per_frame - 1))) { | 1155 | (rq->sector & (sectors_per_frame - 1))) { |
1159 | if (write) { | 1156 | if (write) { |
@@ -1167,7 +1164,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
1167 | if (write) | 1164 | if (write) |
1168 | cd->devinfo.media_written = 1; | 1165 | cd->devinfo.media_written = 1; |
1169 | 1166 | ||
1170 | /* Start sending the read/write request to the drive. */ | 1167 | /* start sending the read/write request to the drive */ |
1171 | return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont); | 1168 | return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont); |
1172 | } | 1169 | } |
1173 | 1170 | ||
@@ -1192,12 +1189,11 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
1192 | 1189 | ||
1193 | info->dma = 0; | 1190 | info->dma = 0; |
1194 | 1191 | ||
1195 | /* | 1192 | /* sg request */ |
1196 | * sg request | ||
1197 | */ | ||
1198 | if (rq->bio) { | 1193 | if (rq->bio) { |
1199 | int mask = drive->queue->dma_alignment; | 1194 | int mask = drive->queue->dma_alignment; |
1200 | unsigned long addr = (unsigned long) page_address(bio_page(rq->bio)); | 1195 | unsigned long addr = |
1196 | (unsigned long)page_address(bio_page(rq->bio)); | ||
1201 | 1197 | ||
1202 | info->dma = drive->using_dma; | 1198 | info->dma = drive->using_dma; |
1203 | 1199 | ||
@@ -1211,15 +1207,16 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
1211 | info->dma = 0; | 1207 | info->dma = 0; |
1212 | } | 1208 | } |
1213 | 1209 | ||
1214 | /* Start sending the command to the drive. */ | 1210 | /* start sending the command to the drive */ |
1215 | return cdrom_start_packet_command(drive, rq->data_len, cdrom_do_newpc_cont); | 1211 | return cdrom_start_packet_command(drive, rq->data_len, |
1212 | cdrom_do_newpc_cont); | ||
1216 | } | 1213 | } |
1217 | 1214 | ||
1218 | /**************************************************************************** | 1215 | /* |
1219 | * cdrom driver request routine. | 1216 | * cdrom driver request routine. |
1220 | */ | 1217 | */ |
1221 | static ide_startstop_t | 1218 | static ide_startstop_t ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, |
1222 | ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, sector_t block) | 1219 | sector_t block) |
1223 | { | 1220 | { |
1224 | ide_startstop_t action; | 1221 | ide_startstop_t action; |
1225 | struct cdrom_info *info = drive->driver_data; | 1222 | struct cdrom_info *info = drive->driver_data; |
@@ -1231,14 +1228,19 @@ ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, sector_t block) | |||
1231 | 1228 | ||
1232 | if ((stat & SEEK_STAT) != SEEK_STAT) { | 1229 | if ((stat & SEEK_STAT) != SEEK_STAT) { |
1233 | if (elapsed < IDECD_SEEK_TIMEOUT) { | 1230 | if (elapsed < IDECD_SEEK_TIMEOUT) { |
1234 | ide_stall_queue(drive, IDECD_SEEK_TIMER); | 1231 | ide_stall_queue(drive, |
1232 | IDECD_SEEK_TIMER); | ||
1235 | return ide_stopped; | 1233 | return ide_stopped; |
1236 | } | 1234 | } |
1237 | printk(KERN_ERR "%s: DSC timeout\n", drive->name); | 1235 | printk(KERN_ERR "%s: DSC timeout\n", |
1236 | drive->name); | ||
1238 | } | 1237 | } |
1239 | info->cd_flags &= ~IDE_CD_FLAG_SEEKING; | 1238 | info->cd_flags &= ~IDE_CD_FLAG_SEEKING; |
1240 | } | 1239 | } |
1241 | if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) | 1240 | if (rq_data_dir(rq) == READ && |
1241 | IDE_LARGE_SEEK(info->last_block, block, | ||
1242 | IDECD_SEEK_THRESHOLD) && | ||
1243 | drive->dsc_overlap) | ||
1242 | action = cdrom_start_seek(drive, block); | 1244 | action = cdrom_start_seek(drive, block); |
1243 | else | 1245 | else |
1244 | action = cdrom_start_rw(drive, rq); | 1246 | action = cdrom_start_rw(drive, rq); |
@@ -1248,9 +1250,7 @@ ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, sector_t block) | |||
1248 | rq->cmd_type == REQ_TYPE_ATA_PC) { | 1250 | rq->cmd_type == REQ_TYPE_ATA_PC) { |
1249 | return cdrom_do_block_pc(drive, rq); | 1251 | return cdrom_do_block_pc(drive, rq); |
1250 | } else if (blk_special_request(rq)) { | 1252 | } else if (blk_special_request(rq)) { |
1251 | /* | 1253 | /* right now this can only be a reset... */ |
1252 | * right now this can only be a reset... | ||
1253 | */ | ||
1254 | cdrom_end_request(drive, 1); | 1254 | cdrom_end_request(drive, 1); |
1255 | return ide_stopped; | 1255 | return ide_stopped; |
1256 | } | 1256 | } |
@@ -1262,18 +1262,16 @@ ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, sector_t block) | |||
1262 | 1262 | ||
1263 | 1263 | ||
1264 | 1264 | ||
1265 | /**************************************************************************** | 1265 | /* |
1266 | * Ioctl handling. | 1266 | * Ioctl handling. |
1267 | * | 1267 | * |
1268 | * Routines which queue packet commands take as a final argument a pointer | 1268 | * Routines which queue packet commands take as a final argument a pointer to a |
1269 | * to a request_sense struct. If execution of the command results | 1269 | * request_sense struct. If execution of the command results in an error with a |
1270 | * in an error with a CHECK CONDITION status, this structure will be filled | 1270 | * CHECK CONDITION status, this structure will be filled with the results of the |
1271 | * with the results of the subsequent request sense command. The pointer | 1271 | * subsequent request sense command. The pointer can also be NULL, in which case |
1272 | * can also be NULL, in which case no sense information is returned. | 1272 | * no sense information is returned. |
1273 | */ | 1273 | */ |
1274 | 1274 | static void msf_from_bcd(struct atapi_msf *msf) | |
1275 | static | ||
1276 | void msf_from_bcd(struct atapi_msf *msf) | ||
1277 | { | 1275 | { |
1278 | msf->minute = BCD2BIN(msf->minute); | 1276 | msf->minute = BCD2BIN(msf->minute); |
1279 | msf->second = BCD2BIN(msf->second); | 1277 | msf->second = BCD2BIN(msf->second); |
@@ -1293,8 +1291,8 @@ int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) | |||
1293 | req.cmd_flags |= REQ_QUIET; | 1291 | req.cmd_flags |= REQ_QUIET; |
1294 | 1292 | ||
1295 | /* | 1293 | /* |
1296 | * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to | 1294 | * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to switch CDs |
1297 | * switch CDs instead of supporting the LOAD_UNLOAD opcode. | 1295 | * instead of supporting the LOAD_UNLOAD opcode. |
1298 | */ | 1296 | */ |
1299 | req.cmd[7] = cdi->sanyo_slot % 3; | 1297 | req.cmd[7] = cdi->sanyo_slot % 3; |
1300 | 1298 | ||
@@ -1370,36 +1368,39 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1370 | unsigned long sectors_per_frame = SECTORS_PER_FRAME; | 1368 | unsigned long sectors_per_frame = SECTORS_PER_FRAME; |
1371 | 1369 | ||
1372 | if (toc == NULL) { | 1370 | if (toc == NULL) { |
1373 | /* Try to allocate space. */ | 1371 | /* try to allocate space */ |
1374 | toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); | 1372 | toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); |
1375 | if (toc == NULL) { | 1373 | if (toc == NULL) { |
1376 | printk(KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name); | 1374 | printk(KERN_ERR "%s: No cdrom TOC buffer!\n", |
1375 | drive->name); | ||
1377 | return -ENOMEM; | 1376 | return -ENOMEM; |
1378 | } | 1377 | } |
1379 | info->toc = toc; | 1378 | info->toc = toc; |
1380 | } | 1379 | } |
1381 | 1380 | ||
1382 | /* Check to see if the existing data is still valid. | 1381 | /* |
1383 | If it is, just return. */ | 1382 | * Check to see if the existing data is still valid. If it is, |
1383 | * just return. | ||
1384 | */ | ||
1384 | (void) cdrom_check_status(drive, sense); | 1385 | (void) cdrom_check_status(drive, sense); |
1385 | 1386 | ||
1386 | if (info->cd_flags & IDE_CD_FLAG_TOC_VALID) | 1387 | if (info->cd_flags & IDE_CD_FLAG_TOC_VALID) |
1387 | return 0; | 1388 | return 0; |
1388 | 1389 | ||
1389 | /* Try to get the total cdrom capacity and sector size. */ | 1390 | /* try to get the total cdrom capacity and sector size */ |
1390 | stat = cdrom_read_capacity(drive, &toc->capacity, §ors_per_frame, | 1391 | stat = cdrom_read_capacity(drive, &toc->capacity, §ors_per_frame, |
1391 | sense); | 1392 | sense); |
1392 | if (stat) | 1393 | if (stat) |
1393 | toc->capacity = 0x1fffff; | 1394 | toc->capacity = 0x1fffff; |
1394 | 1395 | ||
1395 | set_capacity(info->disk, toc->capacity * sectors_per_frame); | 1396 | set_capacity(info->disk, toc->capacity * sectors_per_frame); |
1396 | /* Save a private copy of te TOC capacity for error handling */ | 1397 | /* save a private copy of the TOC capacity for error handling */ |
1397 | drive->probed_capacity = toc->capacity * sectors_per_frame; | 1398 | drive->probed_capacity = toc->capacity * sectors_per_frame; |
1398 | 1399 | ||
1399 | blk_queue_hardsect_size(drive->queue, | 1400 | blk_queue_hardsect_size(drive->queue, |
1400 | sectors_per_frame << SECTOR_BITS); | 1401 | sectors_per_frame << SECTOR_BITS); |
1401 | 1402 | ||
1402 | /* First read just the header, so we know how long the TOC is. */ | 1403 | /* first read just the header, so we know how long the TOC is */ |
1403 | stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr, | 1404 | stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr, |
1404 | sizeof(struct atapi_toc_header), sense); | 1405 | sizeof(struct atapi_toc_header), sense); |
1405 | if (stat) | 1406 | if (stat) |
@@ -1416,7 +1417,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1416 | if (ntracks > MAX_TRACKS) | 1417 | if (ntracks > MAX_TRACKS) |
1417 | ntracks = MAX_TRACKS; | 1418 | ntracks = MAX_TRACKS; |
1418 | 1419 | ||
1419 | /* Now read the whole schmeer. */ | 1420 | /* now read the whole schmeer */ |
1420 | stat = cdrom_read_tocentry(drive, toc->hdr.first_track, 1, 0, | 1421 | stat = cdrom_read_tocentry(drive, toc->hdr.first_track, 1, 0, |
1421 | (char *)&toc->hdr, | 1422 | (char *)&toc->hdr, |
1422 | sizeof(struct atapi_toc_header) + | 1423 | sizeof(struct atapi_toc_header) + |
@@ -1424,15 +1425,18 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1424 | sizeof(struct atapi_toc_entry), sense); | 1425 | sizeof(struct atapi_toc_entry), sense); |
1425 | 1426 | ||
1426 | if (stat && toc->hdr.first_track > 1) { | 1427 | if (stat && toc->hdr.first_track > 1) { |
1427 | /* Cds with CDI tracks only don't have any TOC entries, | 1428 | /* |
1428 | despite of this the returned values are | 1429 | * Cds with CDI tracks only don't have any TOC entries, despite |
1429 | first_track == last_track = number of CDI tracks + 1, | 1430 | * of this the returned values are |
1430 | so that this case is indistinguishable from the same | 1431 | * first_track == last_track = number of CDI tracks + 1, |
1431 | layout plus an additional audio track. | 1432 | * so that this case is indistinguishable from the same layout |
1432 | If we get an error for the regular case, we assume | 1433 | * plus an additional audio track. If we get an error for the |
1433 | a CDI without additional audio tracks. In this case | 1434 | * regular case, we assume a CDI without additional audio |
1434 | the readable TOC is empty (CDI tracks are not included) | 1435 | * tracks. In this case the readable TOC is empty (CDI tracks |
1435 | and only holds the Leadout entry. Heiko Eißfeldt */ | 1436 | * are not included) and only holds the Leadout entry. |
1437 | * | ||
1438 | * Heiko Eißfeldt. | ||
1439 | */ | ||
1436 | ntracks = 0; | 1440 | ntracks = 0; |
1437 | stat = cdrom_read_tocentry(drive, CDROM_LEADOUT, 1, 0, | 1441 | stat = cdrom_read_tocentry(drive, CDROM_LEADOUT, 1, 0, |
1438 | (char *)&toc->hdr, | 1442 | (char *)&toc->hdr, |
@@ -1473,9 +1477,8 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1473 | toc->ent[i].addr.msf.frame); | 1477 | toc->ent[i].addr.msf.frame); |
1474 | } | 1478 | } |
1475 | 1479 | ||
1476 | /* Read the multisession information. */ | ||
1477 | if (toc->hdr.first_track != CDROM_LEADOUT) { | 1480 | if (toc->hdr.first_track != CDROM_LEADOUT) { |
1478 | /* Read the multisession information. */ | 1481 | /* read the multisession information */ |
1479 | stat = cdrom_read_tocentry(drive, 0, 0, 1, (char *)&ms_tmp, | 1482 | stat = cdrom_read_tocentry(drive, 0, 0, 1, (char *)&ms_tmp, |
1480 | sizeof(ms_tmp), sense); | 1483 | sizeof(ms_tmp), sense); |
1481 | if (stat) | 1484 | if (stat) |
@@ -1483,12 +1486,13 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1483 | 1486 | ||
1484 | toc->last_session_lba = be32_to_cpu(ms_tmp.ent.addr.lba); | 1487 | toc->last_session_lba = be32_to_cpu(ms_tmp.ent.addr.lba); |
1485 | } else { | 1488 | } else { |
1486 | ms_tmp.hdr.first_track = ms_tmp.hdr.last_track = CDROM_LEADOUT; | 1489 | ms_tmp.hdr.last_track = CDROM_LEADOUT; |
1490 | ms_tmp.hdr.first_track = ms_tmp.hdr.last_track; | ||
1487 | toc->last_session_lba = msf_to_lba(0, 2, 0); /* 0m 2s 0f */ | 1491 | toc->last_session_lba = msf_to_lba(0, 2, 0); /* 0m 2s 0f */ |
1488 | } | 1492 | } |
1489 | 1493 | ||
1490 | if (info->cd_flags & IDE_CD_FLAG_TOCADDR_AS_BCD) { | 1494 | if (info->cd_flags & IDE_CD_FLAG_TOCADDR_AS_BCD) { |
1491 | /* Re-read multisession information using MSF format */ | 1495 | /* re-read multisession information using MSF format */ |
1492 | stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp, | 1496 | stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp, |
1493 | sizeof(ms_tmp), sense); | 1497 | sizeof(ms_tmp), sense); |
1494 | if (stat) | 1498 | if (stat) |
@@ -1502,7 +1506,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1502 | 1506 | ||
1503 | toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track); | 1507 | toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track); |
1504 | 1508 | ||
1505 | /* Now try to get the total cdrom capacity. */ | 1509 | /* now try to get the total cdrom capacity */ |
1506 | stat = cdrom_get_last_written(cdi, &last_written); | 1510 | stat = cdrom_get_last_written(cdi, &last_written); |
1507 | if (!stat && (last_written > toc->capacity)) { | 1511 | if (!stat && (last_written > toc->capacity)) { |
1508 | toc->capacity = last_written; | 1512 | toc->capacity = last_written; |
@@ -1527,7 +1531,8 @@ int ide_cdrom_get_capabilities(ide_drive_t *drive, u8 *buf) | |||
1527 | size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE; | 1531 | size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE; |
1528 | 1532 | ||
1529 | init_cdrom_command(&cgc, buf, size, CGC_DATA_UNKNOWN); | 1533 | init_cdrom_command(&cgc, buf, size, CGC_DATA_UNKNOWN); |
1530 | do { /* we seem to get stat=0x01,err=0x00 the first time (??) */ | 1534 | do { |
1535 | /* we seem to get stat=0x01,err=0x00 the first time (??) */ | ||
1531 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0); | 1536 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0); |
1532 | if (!stat) | 1537 | if (!stat) |
1533 | break; | 1538 | break; |
@@ -1596,8 +1601,7 @@ static int ide_cdrom_register(ide_drive_t *drive, int nslots) | |||
1596 | return register_cdrom(devinfo); | 1601 | return register_cdrom(devinfo); |
1597 | } | 1602 | } |
1598 | 1603 | ||
1599 | static | 1604 | static int ide_cdrom_probe_capabilities(ide_drive_t *drive) |
1600 | int ide_cdrom_probe_capabilities(ide_drive_t *drive) | ||
1601 | { | 1605 | { |
1602 | struct cdrom_info *cd = drive->driver_data; | 1606 | struct cdrom_info *cd = drive->driver_data; |
1603 | struct cdrom_device_info *cdi = &cd->devinfo; | 1607 | struct cdrom_device_info *cdi = &cd->devinfo; |
@@ -1611,7 +1615,8 @@ int ide_cdrom_probe_capabilities(ide_drive_t *drive) | |||
1611 | 1615 | ||
1612 | if (drive->media == ide_optical) { | 1616 | if (drive->media == ide_optical) { |
1613 | cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM); | 1617 | cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM); |
1614 | printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", drive->name); | 1618 | printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", |
1619 | drive->name); | ||
1615 | return nslots; | 1620 | return nslots; |
1616 | } | 1621 | } |
1617 | 1622 | ||
@@ -1622,11 +1627,10 @@ int ide_cdrom_probe_capabilities(ide_drive_t *drive) | |||
1622 | } | 1627 | } |
1623 | 1628 | ||
1624 | /* | 1629 | /* |
1625 | * we have to cheat a little here. the packet will eventually | 1630 | * We have to cheat a little here. the packet will eventually be queued |
1626 | * be queued with ide_cdrom_packet(), which extracts the | 1631 | * with ide_cdrom_packet(), which extracts the drive from cdi->handle. |
1627 | * drive from cdi->handle. Since this device hasn't been | 1632 | * Since this device hasn't been registered with the Uniform layer yet, |
1628 | * registered with the Uniform layer yet, it can't do this. | 1633 | * it can't do this. Same goes for cdi->ops. |
1629 | * Same goes for cdi->ops. | ||
1630 | */ | 1634 | */ |
1631 | cdi->handle = drive; | 1635 | cdi->handle = drive; |
1632 | cdi->ops = &ide_cdrom_dops; | 1636 | cdi->ops = &ide_cdrom_dops; |
@@ -1695,18 +1699,7 @@ int ide_cdrom_probe_capabilities(ide_drive_t *drive) | |||
1695 | return nslots; | 1699 | return nslots; |
1696 | } | 1700 | } |
1697 | 1701 | ||
1698 | #ifdef CONFIG_IDE_PROC_FS | 1702 | /* standard prep_rq_fn that builds 10 byte cmds */ |
1699 | static void ide_cdrom_add_settings(ide_drive_t *drive) | ||
1700 | { | ||
1701 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL); | ||
1702 | } | ||
1703 | #else | ||
1704 | static inline void ide_cdrom_add_settings(ide_drive_t *drive) { ; } | ||
1705 | #endif | ||
1706 | |||
1707 | /* | ||
1708 | * standard prep_rq_fn that builds 10 byte cmds | ||
1709 | */ | ||
1710 | static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq) | 1703 | static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq) |
1711 | { | 1704 | { |
1712 | int hard_sect = queue_hardsect_size(q); | 1705 | int hard_sect = queue_hardsect_size(q); |
@@ -1745,9 +1738,7 @@ static int ide_cdrom_prep_pc(struct request *rq) | |||
1745 | { | 1738 | { |
1746 | u8 *c = rq->cmd; | 1739 | u8 *c = rq->cmd; |
1747 | 1740 | ||
1748 | /* | 1741 | /* transform 6-byte read/write commands to the 10-byte version */ |
1749 | * Transform 6-byte read/write commands to the 10-byte version | ||
1750 | */ | ||
1751 | if (c[0] == READ_6 || c[0] == WRITE_6) { | 1742 | if (c[0] == READ_6 || c[0] == WRITE_6) { |
1752 | c[8] = c[4]; | 1743 | c[8] = c[4]; |
1753 | c[5] = c[3]; | 1744 | c[5] = c[3]; |
@@ -1789,6 +1780,41 @@ struct cd_list_entry { | |||
1789 | unsigned int cd_flags; | 1780 | unsigned int cd_flags; |
1790 | }; | 1781 | }; |
1791 | 1782 | ||
1783 | #ifdef CONFIG_IDE_PROC_FS | ||
1784 | static sector_t ide_cdrom_capacity(ide_drive_t *drive) | ||
1785 | { | ||
1786 | unsigned long capacity, sectors_per_frame; | ||
1787 | |||
1788 | if (cdrom_read_capacity(drive, &capacity, §ors_per_frame, NULL)) | ||
1789 | return 0; | ||
1790 | |||
1791 | return capacity * sectors_per_frame; | ||
1792 | } | ||
1793 | |||
1794 | static int proc_idecd_read_capacity(char *page, char **start, off_t off, | ||
1795 | int count, int *eof, void *data) | ||
1796 | { | ||
1797 | ide_drive_t *drive = data; | ||
1798 | int len; | ||
1799 | |||
1800 | len = sprintf(page, "%llu\n", (long long)ide_cdrom_capacity(drive)); | ||
1801 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | ||
1802 | } | ||
1803 | |||
1804 | static ide_proc_entry_t idecd_proc[] = { | ||
1805 | { "capacity", S_IFREG|S_IRUGO, proc_idecd_read_capacity, NULL }, | ||
1806 | { NULL, 0, NULL, NULL } | ||
1807 | }; | ||
1808 | |||
1809 | static void ide_cdrom_add_settings(ide_drive_t *drive) | ||
1810 | { | ||
1811 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, | ||
1812 | &drive->dsc_overlap, NULL); | ||
1813 | } | ||
1814 | #else | ||
1815 | static inline void ide_cdrom_add_settings(ide_drive_t *drive) { ; } | ||
1816 | #endif | ||
1817 | |||
1792 | static const struct cd_list_entry ide_cd_quirks_list[] = { | 1818 | static const struct cd_list_entry ide_cd_quirks_list[] = { |
1793 | /* Limit transfer size per interrupt. */ | 1819 | /* Limit transfer size per interrupt. */ |
1794 | { "SAMSUNG CD-ROM SCR-2430", NULL, IDE_CD_FLAG_LIMIT_NFRAMES }, | 1820 | { "SAMSUNG CD-ROM SCR-2430", NULL, IDE_CD_FLAG_LIMIT_NFRAMES }, |
@@ -1846,8 +1872,7 @@ static unsigned int ide_cd_flags(struct hd_driveid *id) | |||
1846 | return 0; | 1872 | return 0; |
1847 | } | 1873 | } |
1848 | 1874 | ||
1849 | static | 1875 | static int ide_cdrom_setup(ide_drive_t *drive) |
1850 | int ide_cdrom_setup(ide_drive_t *drive) | ||
1851 | { | 1876 | { |
1852 | struct cdrom_info *cd = drive->driver_data; | 1877 | struct cdrom_info *cd = drive->driver_data; |
1853 | struct cdrom_device_info *cdi = &cd->devinfo; | 1878 | struct cdrom_device_info *cdi = &cd->devinfo; |
@@ -1876,13 +1901,12 @@ int ide_cdrom_setup(ide_drive_t *drive) | |||
1876 | id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') | 1901 | id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') |
1877 | cd->cd_flags |= IDE_CD_FLAG_TOCTRACKS_AS_BCD; | 1902 | cd->cd_flags |= IDE_CD_FLAG_TOCTRACKS_AS_BCD; |
1878 | else if (cd->cd_flags & IDE_CD_FLAG_SANYO_3CD) | 1903 | else if (cd->cd_flags & IDE_CD_FLAG_SANYO_3CD) |
1879 | cdi->sanyo_slot = 3; /* 3 => use CD in slot 0 */ | 1904 | /* 3 => use CD in slot 0 */ |
1905 | cdi->sanyo_slot = 3; | ||
1880 | 1906 | ||
1881 | nslots = ide_cdrom_probe_capabilities(drive); | 1907 | nslots = ide_cdrom_probe_capabilities(drive); |
1882 | 1908 | ||
1883 | /* | 1909 | /* set correct block size */ |
1884 | * set correct block size | ||
1885 | */ | ||
1886 | blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE); | 1910 | blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE); |
1887 | 1911 | ||
1888 | if (drive->autotune == IDE_TUNE_DEFAULT || | 1912 | if (drive->autotune == IDE_TUNE_DEFAULT || |
@@ -1890,7 +1914,8 @@ int ide_cdrom_setup(ide_drive_t *drive) | |||
1890 | drive->dsc_overlap = (drive->next != drive); | 1914 | drive->dsc_overlap = (drive->next != drive); |
1891 | 1915 | ||
1892 | if (ide_cdrom_register(drive, nslots)) { | 1916 | if (ide_cdrom_register(drive, nslots)) { |
1893 | printk(KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name); | 1917 | printk(KERN_ERR "%s: %s failed to register device with the" |
1918 | " cdrom driver.\n", drive->name, __func__); | ||
1894 | cd->devinfo.handle = NULL; | 1919 | cd->devinfo.handle = NULL; |
1895 | return 1; | 1920 | return 1; |
1896 | } | 1921 | } |
@@ -1929,33 +1954,6 @@ static void ide_cd_release(struct kref *kref) | |||
1929 | 1954 | ||
1930 | static int ide_cd_probe(ide_drive_t *); | 1955 | static int ide_cd_probe(ide_drive_t *); |
1931 | 1956 | ||
1932 | #ifdef CONFIG_IDE_PROC_FS | ||
1933 | static sector_t ide_cdrom_capacity(ide_drive_t *drive) | ||
1934 | { | ||
1935 | unsigned long capacity, sectors_per_frame; | ||
1936 | |||
1937 | if (cdrom_read_capacity(drive, &capacity, §ors_per_frame, NULL)) | ||
1938 | return 0; | ||
1939 | |||
1940 | return capacity * sectors_per_frame; | ||
1941 | } | ||
1942 | |||
1943 | static int proc_idecd_read_capacity | ||
1944 | (char *page, char **start, off_t off, int count, int *eof, void *data) | ||
1945 | { | ||
1946 | ide_drive_t *drive = data; | ||
1947 | int len; | ||
1948 | |||
1949 | len = sprintf(page, "%llu\n", (long long)ide_cdrom_capacity(drive)); | ||
1950 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | ||
1951 | } | ||
1952 | |||
1953 | static ide_proc_entry_t idecd_proc[] = { | ||
1954 | { "capacity", S_IFREG|S_IRUGO, proc_idecd_read_capacity, NULL }, | ||
1955 | { NULL, 0, NULL, NULL } | ||
1956 | }; | ||
1957 | #endif | ||
1958 | |||
1959 | static ide_driver_t ide_cdrom_driver = { | 1957 | static ide_driver_t ide_cdrom_driver = { |
1960 | .gen_driver = { | 1958 | .gen_driver = { |
1961 | .owner = THIS_MODULE, | 1959 | .owner = THIS_MODULE, |
@@ -2093,7 +2091,7 @@ static struct block_device_operations idecd_ops = { | |||
2093 | .revalidate_disk = idecd_revalidate_disk | 2091 | .revalidate_disk = idecd_revalidate_disk |
2094 | }; | 2092 | }; |
2095 | 2093 | ||
2096 | /* options */ | 2094 | /* module options */ |
2097 | static char *ignore; | 2095 | static char *ignore; |
2098 | 2096 | ||
2099 | module_param(ignore, charp, 0400); | 2097 | module_param(ignore, charp, 0400); |
@@ -2114,17 +2112,20 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
2114 | /* skip drives that we were told to ignore */ | 2112 | /* skip drives that we were told to ignore */ |
2115 | if (ignore != NULL) { | 2113 | if (ignore != NULL) { |
2116 | if (strstr(ignore, drive->name)) { | 2114 | if (strstr(ignore, drive->name)) { |
2117 | printk(KERN_INFO "ide-cd: ignoring drive %s\n", drive->name); | 2115 | printk(KERN_INFO "ide-cd: ignoring drive %s\n", |
2116 | drive->name); | ||
2118 | goto failed; | 2117 | goto failed; |
2119 | } | 2118 | } |
2120 | } | 2119 | } |
2121 | if (drive->scsi) { | 2120 | if (drive->scsi) { |
2122 | printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name); | 2121 | printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi " |
2122 | "emulation.\n", drive->name); | ||
2123 | goto failed; | 2123 | goto failed; |
2124 | } | 2124 | } |
2125 | info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); | 2125 | info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); |
2126 | if (info == NULL) { | 2126 | if (info == NULL) { |
2127 | printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name); | 2127 | printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", |
2128 | drive->name); | ||
2128 | goto failed; | 2129 | goto failed; |
2129 | } | 2130 | } |
2130 | 2131 | ||
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 8757e5ef6c95..c352cf27b6e7 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -102,7 +102,7 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive) | |||
102 | { | 102 | { |
103 | u8 stat = 0, dma_stat = 0; | 103 | u8 stat = 0, dma_stat = 0; |
104 | 104 | ||
105 | dma_stat = HWIF(drive)->ide_dma_end(drive); | 105 | dma_stat = drive->hwif->dma_ops->dma_end(drive); |
106 | stat = ide_read_status(drive); | 106 | stat = ide_read_status(drive); |
107 | 107 | ||
108 | if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) { | 108 | if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) { |
@@ -394,7 +394,7 @@ void ide_dma_off_quietly(ide_drive_t *drive) | |||
394 | drive->using_dma = 0; | 394 | drive->using_dma = 0; |
395 | ide_toggle_bounce(drive, 0); | 395 | ide_toggle_bounce(drive, 0); |
396 | 396 | ||
397 | drive->hwif->dma_host_set(drive, 0); | 397 | drive->hwif->dma_ops->dma_host_set(drive, 0); |
398 | } | 398 | } |
399 | 399 | ||
400 | EXPORT_SYMBOL(ide_dma_off_quietly); | 400 | EXPORT_SYMBOL(ide_dma_off_quietly); |
@@ -427,7 +427,7 @@ void ide_dma_on(ide_drive_t *drive) | |||
427 | drive->using_dma = 1; | 427 | drive->using_dma = 1; |
428 | ide_toggle_bounce(drive, 1); | 428 | ide_toggle_bounce(drive, 1); |
429 | 429 | ||
430 | drive->hwif->dma_host_set(drive, 1); | 430 | drive->hwif->dma_ops->dma_host_set(drive, 1); |
431 | } | 431 | } |
432 | 432 | ||
433 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF | 433 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF |
@@ -482,11 +482,12 @@ int ide_dma_setup(ide_drive_t *drive) | |||
482 | 482 | ||
483 | EXPORT_SYMBOL_GPL(ide_dma_setup); | 483 | EXPORT_SYMBOL_GPL(ide_dma_setup); |
484 | 484 | ||
485 | static void ide_dma_exec_cmd(ide_drive_t *drive, u8 command) | 485 | void ide_dma_exec_cmd(ide_drive_t *drive, u8 command) |
486 | { | 486 | { |
487 | /* issue cmd to drive */ | 487 | /* issue cmd to drive */ |
488 | ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, dma_timer_expiry); | 488 | ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, dma_timer_expiry); |
489 | } | 489 | } |
490 | EXPORT_SYMBOL_GPL(ide_dma_exec_cmd); | ||
490 | 491 | ||
491 | void ide_dma_start(ide_drive_t *drive) | 492 | void ide_dma_start(ide_drive_t *drive) |
492 | { | 493 | { |
@@ -532,7 +533,7 @@ int __ide_dma_end (ide_drive_t *drive) | |||
532 | EXPORT_SYMBOL(__ide_dma_end); | 533 | EXPORT_SYMBOL(__ide_dma_end); |
533 | 534 | ||
534 | /* returns 1 if dma irq issued, 0 otherwise */ | 535 | /* returns 1 if dma irq issued, 0 otherwise */ |
535 | static int __ide_dma_test_irq(ide_drive_t *drive) | 536 | int ide_dma_test_irq(ide_drive_t *drive) |
536 | { | 537 | { |
537 | ide_hwif_t *hwif = HWIF(drive); | 538 | ide_hwif_t *hwif = HWIF(drive); |
538 | u8 dma_stat = hwif->INB(hwif->dma_status); | 539 | u8 dma_stat = hwif->INB(hwif->dma_status); |
@@ -542,9 +543,10 @@ static int __ide_dma_test_irq(ide_drive_t *drive) | |||
542 | return 1; | 543 | return 1; |
543 | if (!drive->waiting_for_dma) | 544 | if (!drive->waiting_for_dma) |
544 | printk(KERN_WARNING "%s: (%s) called while not waiting\n", | 545 | printk(KERN_WARNING "%s: (%s) called while not waiting\n", |
545 | drive->name, __FUNCTION__); | 546 | drive->name, __func__); |
546 | return 0; | 547 | return 0; |
547 | } | 548 | } |
549 | EXPORT_SYMBOL_GPL(ide_dma_test_irq); | ||
548 | #else | 550 | #else |
549 | static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } | 551 | static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } |
550 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ | 552 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ |
@@ -574,6 +576,7 @@ static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode) | |||
574 | { | 576 | { |
575 | struct hd_driveid *id = drive->id; | 577 | struct hd_driveid *id = drive->id; |
576 | ide_hwif_t *hwif = drive->hwif; | 578 | ide_hwif_t *hwif = drive->hwif; |
579 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
577 | unsigned int mask = 0; | 580 | unsigned int mask = 0; |
578 | 581 | ||
579 | switch(base) { | 582 | switch(base) { |
@@ -581,8 +584,8 @@ static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode) | |||
581 | if ((id->field_valid & 4) == 0) | 584 | if ((id->field_valid & 4) == 0) |
582 | break; | 585 | break; |
583 | 586 | ||
584 | if (hwif->udma_filter) | 587 | if (port_ops && port_ops->udma_filter) |
585 | mask = hwif->udma_filter(drive); | 588 | mask = port_ops->udma_filter(drive); |
586 | else | 589 | else |
587 | mask = hwif->ultra_mask; | 590 | mask = hwif->ultra_mask; |
588 | mask &= id->dma_ultra; | 591 | mask &= id->dma_ultra; |
@@ -598,8 +601,8 @@ static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode) | |||
598 | case XFER_MW_DMA_0: | 601 | case XFER_MW_DMA_0: |
599 | if ((id->field_valid & 2) == 0) | 602 | if ((id->field_valid & 2) == 0) |
600 | break; | 603 | break; |
601 | if (hwif->mdma_filter) | 604 | if (port_ops && port_ops->mdma_filter) |
602 | mask = hwif->mdma_filter(drive); | 605 | mask = port_ops->mdma_filter(drive); |
603 | else | 606 | else |
604 | mask = hwif->mwdma_mask; | 607 | mask = hwif->mwdma_mask; |
605 | mask &= id->dma_mword; | 608 | mask &= id->dma_mword; |
@@ -801,15 +804,15 @@ void ide_dma_timeout (ide_drive_t *drive) | |||
801 | 804 | ||
802 | printk(KERN_ERR "%s: timeout waiting for DMA\n", drive->name); | 805 | printk(KERN_ERR "%s: timeout waiting for DMA\n", drive->name); |
803 | 806 | ||
804 | if (hwif->ide_dma_test_irq(drive)) | 807 | if (hwif->dma_ops->dma_test_irq(drive)) |
805 | return; | 808 | return; |
806 | 809 | ||
807 | hwif->ide_dma_end(drive); | 810 | hwif->dma_ops->dma_end(drive); |
808 | } | 811 | } |
809 | 812 | ||
810 | EXPORT_SYMBOL(ide_dma_timeout); | 813 | EXPORT_SYMBOL(ide_dma_timeout); |
811 | 814 | ||
812 | static void ide_release_dma_engine(ide_hwif_t *hwif) | 815 | void ide_release_dma_engine(ide_hwif_t *hwif) |
813 | { | 816 | { |
814 | if (hwif->dmatable_cpu) { | 817 | if (hwif->dmatable_cpu) { |
815 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 818 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
@@ -820,28 +823,7 @@ static void ide_release_dma_engine(ide_hwif_t *hwif) | |||
820 | } | 823 | } |
821 | } | 824 | } |
822 | 825 | ||
823 | static int ide_release_iomio_dma(ide_hwif_t *hwif) | 826 | int ide_allocate_dma_engine(ide_hwif_t *hwif) |
824 | { | ||
825 | release_region(hwif->dma_base, 8); | ||
826 | if (hwif->extra_ports) | ||
827 | release_region(hwif->extra_base, hwif->extra_ports); | ||
828 | return 1; | ||
829 | } | ||
830 | |||
831 | /* | ||
832 | * Needed for allowing full modular support of ide-driver | ||
833 | */ | ||
834 | int ide_release_dma(ide_hwif_t *hwif) | ||
835 | { | ||
836 | ide_release_dma_engine(hwif); | ||
837 | |||
838 | if (hwif->mmio) | ||
839 | return 1; | ||
840 | else | ||
841 | return ide_release_iomio_dma(hwif); | ||
842 | } | ||
843 | |||
844 | static int ide_allocate_dma_engine(ide_hwif_t *hwif) | ||
845 | { | 827 | { |
846 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 828 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
847 | 829 | ||
@@ -853,65 +835,25 @@ static int ide_allocate_dma_engine(ide_hwif_t *hwif) | |||
853 | return 0; | 835 | return 0; |
854 | 836 | ||
855 | printk(KERN_ERR "%s: -- Error, unable to allocate DMA table.\n", | 837 | printk(KERN_ERR "%s: -- Error, unable to allocate DMA table.\n", |
856 | hwif->cds->name); | 838 | hwif->name); |
857 | 839 | ||
858 | return 1; | 840 | return 1; |
859 | } | 841 | } |
860 | 842 | EXPORT_SYMBOL_GPL(ide_allocate_dma_engine); | |
861 | static int ide_mapped_mmio_dma(ide_hwif_t *hwif, unsigned long base) | 843 | |
862 | { | 844 | static const struct ide_dma_ops sff_dma_ops = { |
863 | printk(KERN_INFO " %s: MMIO-DMA ", hwif->name); | 845 | .dma_host_set = ide_dma_host_set, |
864 | 846 | .dma_setup = ide_dma_setup, | |
865 | return 0; | 847 | .dma_exec_cmd = ide_dma_exec_cmd, |
866 | } | 848 | .dma_start = ide_dma_start, |
867 | 849 | .dma_end = __ide_dma_end, | |
868 | static int ide_iomio_dma(ide_hwif_t *hwif, unsigned long base) | 850 | .dma_test_irq = ide_dma_test_irq, |
869 | { | 851 | .dma_timeout = ide_dma_timeout, |
870 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx", | 852 | .dma_lost_irq = ide_dma_lost_irq, |
871 | hwif->name, base, base + 7); | 853 | }; |
872 | |||
873 | if (!request_region(base, 8, hwif->name)) { | ||
874 | printk(" -- Error, ports in use.\n"); | ||
875 | return 1; | ||
876 | } | ||
877 | |||
878 | if (hwif->cds->extra) { | ||
879 | hwif->extra_base = base + (hwif->channel ? 8 : 16); | ||
880 | |||
881 | if (!hwif->mate || !hwif->mate->extra_ports) { | ||
882 | if (!request_region(hwif->extra_base, | ||
883 | hwif->cds->extra, hwif->cds->name)) { | ||
884 | printk(" -- Error, extra ports in use.\n"); | ||
885 | release_region(base, 8); | ||
886 | return 1; | ||
887 | } | ||
888 | hwif->extra_ports = hwif->cds->extra; | ||
889 | } | ||
890 | } | ||
891 | |||
892 | return 0; | ||
893 | } | ||
894 | |||
895 | static int ide_dma_iobase(ide_hwif_t *hwif, unsigned long base) | ||
896 | { | ||
897 | if (hwif->mmio) | ||
898 | return ide_mapped_mmio_dma(hwif, base); | ||
899 | |||
900 | return ide_iomio_dma(hwif, base); | ||
901 | } | ||
902 | 854 | ||
903 | void ide_setup_dma(ide_hwif_t *hwif, unsigned long base) | 855 | void ide_setup_dma(ide_hwif_t *hwif, unsigned long base) |
904 | { | 856 | { |
905 | u8 dma_stat; | ||
906 | |||
907 | if (ide_dma_iobase(hwif, base)) | ||
908 | return; | ||
909 | |||
910 | if (ide_allocate_dma_engine(hwif)) { | ||
911 | ide_release_dma(hwif); | ||
912 | return; | ||
913 | } | ||
914 | |||
915 | hwif->dma_base = base; | 857 | hwif->dma_base = base; |
916 | 858 | ||
917 | if (!hwif->dma_command) | 859 | if (!hwif->dma_command) |
@@ -925,27 +867,7 @@ void ide_setup_dma(ide_hwif_t *hwif, unsigned long base) | |||
925 | if (!hwif->dma_prdtable) | 867 | if (!hwif->dma_prdtable) |
926 | hwif->dma_prdtable = hwif->dma_base + 4; | 868 | hwif->dma_prdtable = hwif->dma_base + 4; |
927 | 869 | ||
928 | if (!hwif->dma_host_set) | 870 | hwif->dma_ops = &sff_dma_ops; |
929 | hwif->dma_host_set = &ide_dma_host_set; | ||
930 | if (!hwif->dma_setup) | ||
931 | hwif->dma_setup = &ide_dma_setup; | ||
932 | if (!hwif->dma_exec_cmd) | ||
933 | hwif->dma_exec_cmd = &ide_dma_exec_cmd; | ||
934 | if (!hwif->dma_start) | ||
935 | hwif->dma_start = &ide_dma_start; | ||
936 | if (!hwif->ide_dma_end) | ||
937 | hwif->ide_dma_end = &__ide_dma_end; | ||
938 | if (!hwif->ide_dma_test_irq) | ||
939 | hwif->ide_dma_test_irq = &__ide_dma_test_irq; | ||
940 | if (!hwif->dma_timeout) | ||
941 | hwif->dma_timeout = &ide_dma_timeout; | ||
942 | if (!hwif->dma_lost_irq) | ||
943 | hwif->dma_lost_irq = &ide_dma_lost_irq; | ||
944 | |||
945 | dma_stat = hwif->INB(hwif->dma_status); | ||
946 | printk(KERN_CONT ", BIOS settings: %s:%s, %s:%s\n", | ||
947 | hwif->drives[0].name, (dma_stat & 0x20) ? "DMA" : "PIO", | ||
948 | hwif->drives[1].name, (dma_stat & 0x40) ? "DMA" : "PIO"); | ||
949 | } | 871 | } |
950 | 872 | ||
951 | EXPORT_SYMBOL_GPL(ide_setup_dma); | 873 | EXPORT_SYMBOL_GPL(ide_setup_dma); |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index ed19a8bbd2d2..6e891bccd052 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -411,7 +411,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) | |||
411 | debug_log("Reached %s interrupt handler\n", __func__); | 411 | debug_log("Reached %s interrupt handler\n", __func__); |
412 | 412 | ||
413 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | 413 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { |
414 | dma_error = hwif->ide_dma_end(drive); | 414 | dma_error = hwif->dma_ops->dma_end(drive); |
415 | if (dma_error) { | 415 | if (dma_error) { |
416 | printk(KERN_ERR "%s: DMA %s error\n", drive->name, | 416 | printk(KERN_ERR "%s: DMA %s error\n", drive->name, |
417 | rq_data_dir(rq) ? "write" : "read"); | 417 | rq_data_dir(rq) ? "write" : "read"); |
@@ -663,7 +663,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
663 | dma = 0; | 663 | dma = 0; |
664 | 664 | ||
665 | if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) | 665 | if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) |
666 | dma = !hwif->dma_setup(drive); | 666 | dma = !hwif->dma_ops->dma_setup(drive); |
667 | 667 | ||
668 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | | 668 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | |
669 | IDE_TFLAG_OUT_DEVICE, bcount, dma); | 669 | IDE_TFLAG_OUT_DEVICE, bcount, dma); |
@@ -671,7 +671,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
671 | if (dma) { | 671 | if (dma) { |
672 | /* Begin DMA, if necessary */ | 672 | /* Begin DMA, if necessary */ |
673 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; | 673 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; |
674 | hwif->dma_start(drive); | 674 | hwif->dma_ops->dma_start(drive); |
675 | } | 675 | } |
676 | 676 | ||
677 | /* Can we transfer the packet when we get the interrupt or wait? */ | 677 | /* Can we transfer the packet when we get the interrupt or wait? */ |
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c index 19f63e393d18..a6073e248f45 100644 --- a/drivers/ide/ide-generic.c +++ b/drivers/ide/ide-generic.c | |||
@@ -94,7 +94,24 @@ static int __init ide_generic_init(void) | |||
94 | unsigned long io_addr = ide_default_io_base(i); | 94 | unsigned long io_addr = ide_default_io_base(i); |
95 | hw_regs_t hw; | 95 | hw_regs_t hw; |
96 | 96 | ||
97 | idx[i] = 0xff; | ||
98 | |||
97 | if (io_addr) { | 99 | if (io_addr) { |
100 | if (!request_region(io_addr, 8, DRV_NAME)) { | ||
101 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX " | ||
102 | "not free.\n", | ||
103 | DRV_NAME, io_addr, io_addr + 7); | ||
104 | continue; | ||
105 | } | ||
106 | |||
107 | if (!request_region(io_addr + 0x206, 1, DRV_NAME)) { | ||
108 | printk(KERN_ERR "%s: I/O resource 0x%lX " | ||
109 | "not free.\n", | ||
110 | DRV_NAME, io_addr + 0x206); | ||
111 | release_region(io_addr, 8); | ||
112 | continue; | ||
113 | } | ||
114 | |||
98 | /* | 115 | /* |
99 | * Skip probing if the corresponding | 116 | * Skip probing if the corresponding |
100 | * slot is already occupied. | 117 | * slot is already occupied. |
@@ -111,8 +128,7 @@ static int __init ide_generic_init(void) | |||
111 | ide_init_port_hw(hwif, &hw); | 128 | ide_init_port_hw(hwif, &hw); |
112 | 129 | ||
113 | idx[i] = i; | 130 | idx[i] = i; |
114 | } else | 131 | } |
115 | idx[i] = 0xff; | ||
116 | } | 132 | } |
117 | 133 | ||
118 | ide_device_add_all(idx, NULL); | 134 | ide_device_add_all(idx, NULL); |
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 51d181ee9cf7..0fe89a599275 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -218,7 +218,7 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * | |||
218 | * we could be smarter and check for current xfer_speed | 218 | * we could be smarter and check for current xfer_speed |
219 | * in struct drive etc... | 219 | * in struct drive etc... |
220 | */ | 220 | */ |
221 | if (drive->hwif->dma_host_set == NULL) | 221 | if (drive->hwif->dma_ops == NULL) |
222 | break; | 222 | break; |
223 | /* | 223 | /* |
224 | * TODO: respect ->using_dma setting | 224 | * TODO: respect ->using_dma setting |
@@ -721,6 +721,7 @@ static ide_startstop_t do_special (ide_drive_t *drive) | |||
721 | #endif | 721 | #endif |
722 | if (s->b.set_tune) { | 722 | if (s->b.set_tune) { |
723 | ide_hwif_t *hwif = drive->hwif; | 723 | ide_hwif_t *hwif = drive->hwif; |
724 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
724 | u8 req_pio = drive->tune_req; | 725 | u8 req_pio = drive->tune_req; |
725 | 726 | ||
726 | s->b.set_tune = 0; | 727 | s->b.set_tune = 0; |
@@ -733,10 +734,10 @@ static ide_startstop_t do_special (ide_drive_t *drive) | |||
733 | unsigned long flags; | 734 | unsigned long flags; |
734 | 735 | ||
735 | spin_lock_irqsave(&ide_lock, flags); | 736 | spin_lock_irqsave(&ide_lock, flags); |
736 | hwif->set_pio_mode(drive, req_pio); | 737 | port_ops->set_pio_mode(drive, req_pio); |
737 | spin_unlock_irqrestore(&ide_lock, flags); | 738 | spin_unlock_irqrestore(&ide_lock, flags); |
738 | } else | 739 | } else |
739 | hwif->set_pio_mode(drive, req_pio); | 740 | port_ops->set_pio_mode(drive, req_pio); |
740 | } else { | 741 | } else { |
741 | int keep_dma = drive->using_dma; | 742 | int keep_dma = drive->using_dma; |
742 | 743 | ||
@@ -1237,12 +1238,12 @@ static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) | |||
1237 | 1238 | ||
1238 | if (error < 0) { | 1239 | if (error < 0) { |
1239 | printk(KERN_WARNING "%s: DMA timeout error\n", drive->name); | 1240 | printk(KERN_WARNING "%s: DMA timeout error\n", drive->name); |
1240 | (void)HWIF(drive)->ide_dma_end(drive); | 1241 | (void)hwif->dma_ops->dma_end(drive); |
1241 | ret = ide_error(drive, "dma timeout error", | 1242 | ret = ide_error(drive, "dma timeout error", |
1242 | ide_read_status(drive)); | 1243 | ide_read_status(drive)); |
1243 | } else { | 1244 | } else { |
1244 | printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name); | 1245 | printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name); |
1245 | hwif->dma_timeout(drive); | 1246 | hwif->dma_ops->dma_timeout(drive); |
1246 | } | 1247 | } |
1247 | 1248 | ||
1248 | /* | 1249 | /* |
@@ -1354,7 +1355,7 @@ void ide_timer_expiry (unsigned long data) | |||
1354 | startstop = handler(drive); | 1355 | startstop = handler(drive); |
1355 | } else if (drive_is_ready(drive)) { | 1356 | } else if (drive_is_ready(drive)) { |
1356 | if (drive->waiting_for_dma) | 1357 | if (drive->waiting_for_dma) |
1357 | hwgroup->hwif->dma_lost_irq(drive); | 1358 | hwif->dma_ops->dma_lost_irq(drive); |
1358 | (void)ide_ack_intr(hwif); | 1359 | (void)ide_ack_intr(hwif); |
1359 | printk(KERN_WARNING "%s: lost interrupt\n", drive->name); | 1360 | printk(KERN_WARNING "%s: lost interrupt\n", drive->name); |
1360 | startstop = handler(drive); | 1361 | startstop = handler(drive); |
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 45944219eea0..9c646bd63549 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -159,17 +159,20 @@ EXPORT_SYMBOL(default_hwif_mmiops); | |||
159 | void SELECT_DRIVE (ide_drive_t *drive) | 159 | void SELECT_DRIVE (ide_drive_t *drive) |
160 | { | 160 | { |
161 | ide_hwif_t *hwif = drive->hwif; | 161 | ide_hwif_t *hwif = drive->hwif; |
162 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
162 | 163 | ||
163 | if (hwif->selectproc) | 164 | if (port_ops && port_ops->selectproc) |
164 | hwif->selectproc(drive); | 165 | port_ops->selectproc(drive); |
165 | 166 | ||
166 | hwif->OUTB(drive->select.all, hwif->io_ports[IDE_SELECT_OFFSET]); | 167 | hwif->OUTB(drive->select.all, hwif->io_ports[IDE_SELECT_OFFSET]); |
167 | } | 168 | } |
168 | 169 | ||
169 | void SELECT_MASK (ide_drive_t *drive, int mask) | 170 | void SELECT_MASK (ide_drive_t *drive, int mask) |
170 | { | 171 | { |
171 | if (HWIF(drive)->maskproc) | 172 | const struct ide_port_ops *port_ops = drive->hwif->port_ops; |
172 | HWIF(drive)->maskproc(drive, mask); | 173 | |
174 | if (port_ops && port_ops->maskproc) | ||
175 | port_ops->maskproc(drive, mask); | ||
173 | } | 176 | } |
174 | 177 | ||
175 | /* | 178 | /* |
@@ -429,7 +432,7 @@ int drive_is_ready (ide_drive_t *drive) | |||
429 | u8 stat = 0; | 432 | u8 stat = 0; |
430 | 433 | ||
431 | if (drive->waiting_for_dma) | 434 | if (drive->waiting_for_dma) |
432 | return hwif->ide_dma_test_irq(drive); | 435 | return hwif->dma_ops->dma_test_irq(drive); |
433 | 436 | ||
434 | #if 0 | 437 | #if 0 |
435 | /* need to guarantee 400ns since last command was issued */ | 438 | /* need to guarantee 400ns since last command was issued */ |
@@ -700,8 +703,8 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
700 | // msleep(50); | 703 | // msleep(50); |
701 | 704 | ||
702 | #ifdef CONFIG_BLK_DEV_IDEDMA | 705 | #ifdef CONFIG_BLK_DEV_IDEDMA |
703 | if (hwif->dma_host_set) /* check if host supports DMA */ | 706 | if (hwif->dma_ops) /* check if host supports DMA */ |
704 | hwif->dma_host_set(drive, 0); | 707 | hwif->dma_ops->dma_host_set(drive, 0); |
705 | #endif | 708 | #endif |
706 | 709 | ||
707 | /* Skip setting PIO flow-control modes on pre-EIDE drives */ | 710 | /* Skip setting PIO flow-control modes on pre-EIDE drives */ |
@@ -759,8 +762,8 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
759 | #ifdef CONFIG_BLK_DEV_IDEDMA | 762 | #ifdef CONFIG_BLK_DEV_IDEDMA |
760 | if ((speed >= XFER_SW_DMA_0 || (hwif->host_flags & IDE_HFLAG_VDMA)) && | 763 | if ((speed >= XFER_SW_DMA_0 || (hwif->host_flags & IDE_HFLAG_VDMA)) && |
761 | drive->using_dma) | 764 | drive->using_dma) |
762 | hwif->dma_host_set(drive, 1); | 765 | hwif->dma_ops->dma_host_set(drive, 1); |
763 | else if (hwif->dma_host_set) /* check if host supports DMA */ | 766 | else if (hwif->dma_ops) /* check if host supports DMA */ |
764 | ide_dma_off_quietly(drive); | 767 | ide_dma_off_quietly(drive); |
765 | #endif | 768 | #endif |
766 | 769 | ||
@@ -905,10 +908,11 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive) | |||
905 | { | 908 | { |
906 | ide_hwgroup_t *hwgroup = HWGROUP(drive); | 909 | ide_hwgroup_t *hwgroup = HWGROUP(drive); |
907 | ide_hwif_t *hwif = HWIF(drive); | 910 | ide_hwif_t *hwif = HWIF(drive); |
911 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
908 | u8 tmp; | 912 | u8 tmp; |
909 | 913 | ||
910 | if (hwif->reset_poll != NULL) { | 914 | if (port_ops && port_ops->reset_poll) { |
911 | if (hwif->reset_poll(drive)) { | 915 | if (port_ops->reset_poll(drive)) { |
912 | printk(KERN_ERR "%s: host reset_poll failure for %s.\n", | 916 | printk(KERN_ERR "%s: host reset_poll failure for %s.\n", |
913 | hwif->name, drive->name); | 917 | hwif->name, drive->name); |
914 | return ide_stopped; | 918 | return ide_stopped; |
@@ -974,6 +978,8 @@ static void ide_disk_pre_reset(ide_drive_t *drive) | |||
974 | 978 | ||
975 | static void pre_reset(ide_drive_t *drive) | 979 | static void pre_reset(ide_drive_t *drive) |
976 | { | 980 | { |
981 | const struct ide_port_ops *port_ops = drive->hwif->port_ops; | ||
982 | |||
977 | if (drive->media == ide_disk) | 983 | if (drive->media == ide_disk) |
978 | ide_disk_pre_reset(drive); | 984 | ide_disk_pre_reset(drive); |
979 | else | 985 | else |
@@ -994,8 +1000,8 @@ static void pre_reset(ide_drive_t *drive) | |||
994 | return; | 1000 | return; |
995 | } | 1001 | } |
996 | 1002 | ||
997 | if (HWIF(drive)->pre_reset != NULL) | 1003 | if (port_ops && port_ops->pre_reset) |
998 | HWIF(drive)->pre_reset(drive); | 1004 | port_ops->pre_reset(drive); |
999 | 1005 | ||
1000 | if (drive->current_speed != 0xff) | 1006 | if (drive->current_speed != 0xff) |
1001 | drive->desired_speed = drive->current_speed; | 1007 | drive->desired_speed = drive->current_speed; |
@@ -1023,6 +1029,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1023 | unsigned long flags; | 1029 | unsigned long flags; |
1024 | ide_hwif_t *hwif; | 1030 | ide_hwif_t *hwif; |
1025 | ide_hwgroup_t *hwgroup; | 1031 | ide_hwgroup_t *hwgroup; |
1032 | const struct ide_port_ops *port_ops; | ||
1026 | u8 ctl; | 1033 | u8 ctl; |
1027 | 1034 | ||
1028 | spin_lock_irqsave(&ide_lock, flags); | 1035 | spin_lock_irqsave(&ide_lock, flags); |
@@ -1089,8 +1096,9 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1089 | * state when the disks are reset this way. At least, the Winbond | 1096 | * state when the disks are reset this way. At least, the Winbond |
1090 | * 553 documentation says that | 1097 | * 553 documentation says that |
1091 | */ | 1098 | */ |
1092 | if (hwif->resetproc) | 1099 | port_ops = hwif->port_ops; |
1093 | hwif->resetproc(drive); | 1100 | if (port_ops && port_ops->resetproc) |
1101 | port_ops->resetproc(drive); | ||
1094 | 1102 | ||
1095 | spin_unlock_irqrestore(&ide_lock, flags); | 1103 | spin_unlock_irqrestore(&ide_lock, flags); |
1096 | return ide_started; | 1104 | return ide_started; |
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index c859de77aa8f..6f04ea3e93a8 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c | |||
@@ -85,7 +85,7 @@ static u8 ide_rate_filter(ide_drive_t *drive, u8 speed) | |||
85 | mode = XFER_PIO_4; | 85 | mode = XFER_PIO_4; |
86 | } | 86 | } |
87 | 87 | ||
88 | // printk("%s: mode 0x%02x, speed 0x%02x\n", __FUNCTION__, mode, speed); | 88 | /* printk("%s: mode 0x%02x, speed 0x%02x\n", __func__, mode, speed); */ |
89 | 89 | ||
90 | return min(speed, mode); | 90 | return min(speed, mode); |
91 | } | 91 | } |
@@ -288,9 +288,10 @@ EXPORT_SYMBOL_GPL(ide_get_best_pio_mode); | |||
288 | void ide_set_pio(ide_drive_t *drive, u8 req_pio) | 288 | void ide_set_pio(ide_drive_t *drive, u8 req_pio) |
289 | { | 289 | { |
290 | ide_hwif_t *hwif = drive->hwif; | 290 | ide_hwif_t *hwif = drive->hwif; |
291 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
291 | u8 host_pio, pio; | 292 | u8 host_pio, pio; |
292 | 293 | ||
293 | if (hwif->set_pio_mode == NULL || | 294 | if (port_ops == NULL || port_ops->set_pio_mode == NULL || |
294 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) | 295 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) |
295 | return; | 296 | return; |
296 | 297 | ||
@@ -343,29 +344,30 @@ void ide_toggle_bounce(ide_drive_t *drive, int on) | |||
343 | int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) | 344 | int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) |
344 | { | 345 | { |
345 | ide_hwif_t *hwif = drive->hwif; | 346 | ide_hwif_t *hwif = drive->hwif; |
347 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
346 | 348 | ||
347 | if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) | 349 | if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) |
348 | return 0; | 350 | return 0; |
349 | 351 | ||
350 | if (hwif->set_pio_mode == NULL) | 352 | if (port_ops == NULL || port_ops->set_pio_mode == NULL) |
351 | return -1; | 353 | return -1; |
352 | 354 | ||
353 | /* | 355 | /* |
354 | * TODO: temporary hack for some legacy host drivers that didn't | 356 | * TODO: temporary hack for some legacy host drivers that didn't |
355 | * set transfer mode on the device in ->set_pio_mode method... | 357 | * set transfer mode on the device in ->set_pio_mode method... |
356 | */ | 358 | */ |
357 | if (hwif->set_dma_mode == NULL) { | 359 | if (port_ops->set_dma_mode == NULL) { |
358 | hwif->set_pio_mode(drive, mode - XFER_PIO_0); | 360 | port_ops->set_pio_mode(drive, mode - XFER_PIO_0); |
359 | return 0; | 361 | return 0; |
360 | } | 362 | } |
361 | 363 | ||
362 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { | 364 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { |
363 | if (ide_config_drive_speed(drive, mode)) | 365 | if (ide_config_drive_speed(drive, mode)) |
364 | return -1; | 366 | return -1; |
365 | hwif->set_pio_mode(drive, mode - XFER_PIO_0); | 367 | port_ops->set_pio_mode(drive, mode - XFER_PIO_0); |
366 | return 0; | 368 | return 0; |
367 | } else { | 369 | } else { |
368 | hwif->set_pio_mode(drive, mode - XFER_PIO_0); | 370 | port_ops->set_pio_mode(drive, mode - XFER_PIO_0); |
369 | return ide_config_drive_speed(drive, mode); | 371 | return ide_config_drive_speed(drive, mode); |
370 | } | 372 | } |
371 | } | 373 | } |
@@ -373,20 +375,21 @@ int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) | |||
373 | int ide_set_dma_mode(ide_drive_t *drive, const u8 mode) | 375 | int ide_set_dma_mode(ide_drive_t *drive, const u8 mode) |
374 | { | 376 | { |
375 | ide_hwif_t *hwif = drive->hwif; | 377 | ide_hwif_t *hwif = drive->hwif; |
378 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
376 | 379 | ||
377 | if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) | 380 | if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) |
378 | return 0; | 381 | return 0; |
379 | 382 | ||
380 | if (hwif->set_dma_mode == NULL) | 383 | if (port_ops == NULL || port_ops->set_dma_mode == NULL) |
381 | return -1; | 384 | return -1; |
382 | 385 | ||
383 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { | 386 | if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { |
384 | if (ide_config_drive_speed(drive, mode)) | 387 | if (ide_config_drive_speed(drive, mode)) |
385 | return -1; | 388 | return -1; |
386 | hwif->set_dma_mode(drive, mode); | 389 | port_ops->set_dma_mode(drive, mode); |
387 | return 0; | 390 | return 0; |
388 | } else { | 391 | } else { |
389 | hwif->set_dma_mode(drive, mode); | 392 | port_ops->set_dma_mode(drive, mode); |
390 | return ide_config_drive_speed(drive, mode); | 393 | return ide_config_drive_speed(drive, mode); |
391 | } | 394 | } |
392 | } | 395 | } |
@@ -406,8 +409,9 @@ EXPORT_SYMBOL_GPL(ide_set_dma_mode); | |||
406 | int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) | 409 | int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) |
407 | { | 410 | { |
408 | ide_hwif_t *hwif = drive->hwif; | 411 | ide_hwif_t *hwif = drive->hwif; |
412 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
409 | 413 | ||
410 | if (hwif->set_dma_mode == NULL || | 414 | if (port_ops == NULL || port_ops->set_dma_mode == NULL || |
411 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) | 415 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) |
412 | return -1; | 416 | return -1; |
413 | 417 | ||
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c index 8a178a55a027..10c20e9a5785 100644 --- a/drivers/ide/ide-pnp.c +++ b/drivers/ide/ide-pnp.c | |||
@@ -18,6 +18,8 @@ | |||
18 | #include <linux/pnp.h> | 18 | #include <linux/pnp.h> |
19 | #include <linux/ide.h> | 19 | #include <linux/ide.h> |
20 | 20 | ||
21 | #define DRV_NAME "ide-pnp" | ||
22 | |||
21 | /* Add your devices here :)) */ | 23 | /* Add your devices here :)) */ |
22 | static struct pnp_device_id idepnp_devices[] = { | 24 | static struct pnp_device_id idepnp_devices[] = { |
23 | /* Generic ESDI/IDE/ATA compatible hard disk controller */ | 25 | /* Generic ESDI/IDE/ATA compatible hard disk controller */ |
@@ -29,13 +31,29 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) | |||
29 | { | 31 | { |
30 | hw_regs_t hw; | 32 | hw_regs_t hw; |
31 | ide_hwif_t *hwif; | 33 | ide_hwif_t *hwif; |
34 | unsigned long base, ctl; | ||
32 | 35 | ||
33 | if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0))) | 36 | if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0))) |
34 | return -1; | 37 | return -1; |
35 | 38 | ||
39 | base = pnp_port_start(dev, 0); | ||
40 | ctl = pnp_port_start(dev, 1); | ||
41 | |||
42 | if (!request_region(base, 8, DRV_NAME)) { | ||
43 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | ||
44 | DRV_NAME, base, base + 7); | ||
45 | return -EBUSY; | ||
46 | } | ||
47 | |||
48 | if (!request_region(ctl, 1, DRV_NAME)) { | ||
49 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", | ||
50 | DRV_NAME, ctl); | ||
51 | release_region(base, 8); | ||
52 | return -EBUSY; | ||
53 | } | ||
54 | |||
36 | memset(&hw, 0, sizeof(hw)); | 55 | memset(&hw, 0, sizeof(hw)); |
37 | ide_std_init_ports(&hw, pnp_port_start(dev, 0), | 56 | ide_std_init_ports(&hw, base, ctl); |
38 | pnp_port_start(dev, 1)); | ||
39 | hw.irq = pnp_irq(dev, 0); | 57 | hw.irq = pnp_irq(dev, 0); |
40 | 58 | ||
41 | hwif = ide_find_port(); | 59 | hwif = ide_find_port(); |
@@ -54,6 +72,9 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) | |||
54 | return 0; | 72 | return 0; |
55 | } | 73 | } |
56 | 74 | ||
75 | release_region(ctl, 1); | ||
76 | release_region(base, 8); | ||
77 | |||
57 | return -1; | 78 | return -1; |
58 | } | 79 | } |
59 | 80 | ||
@@ -65,6 +86,9 @@ static void idepnp_remove(struct pnp_dev *dev) | |||
65 | ide_unregister(hwif->index); | 86 | ide_unregister(hwif->index); |
66 | else | 87 | else |
67 | printk(KERN_ERR "idepnp: Unable to remove device, please report.\n"); | 88 | printk(KERN_ERR "idepnp: Unable to remove device, please report.\n"); |
89 | |||
90 | release_region(pnp_port_start(dev, 1), 1); | ||
91 | release_region(pnp_port_start(dev, 0), 8); | ||
68 | } | 92 | } |
69 | 93 | ||
70 | static struct pnp_driver idepnp_driver = { | 94 | static struct pnp_driver idepnp_driver = { |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 875429728021..a4b65b321f51 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -644,7 +644,7 @@ static int ide_register_port(ide_hwif_t *hwif) | |||
644 | ret = device_register(&hwif->gendev); | 644 | ret = device_register(&hwif->gendev); |
645 | if (ret < 0) { | 645 | if (ret < 0) { |
646 | printk(KERN_WARNING "IDE: %s: device_register error: %d\n", | 646 | printk(KERN_WARNING "IDE: %s: device_register error: %d\n", |
647 | __FUNCTION__, ret); | 647 | __func__, ret); |
648 | goto out; | 648 | goto out; |
649 | } | 649 | } |
650 | 650 | ||
@@ -773,8 +773,7 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
773 | 773 | ||
774 | BUG_ON(hwif->present); | 774 | BUG_ON(hwif->present); |
775 | 775 | ||
776 | if (hwif->noprobe || | 776 | if (hwif->drives[0].noprobe && hwif->drives[1].noprobe) |
777 | (hwif->drives[0].noprobe && hwif->drives[1].noprobe)) | ||
778 | return -EACCES; | 777 | return -EACCES; |
779 | 778 | ||
780 | /* | 779 | /* |
@@ -821,13 +820,14 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
821 | 820 | ||
822 | static void ide_port_tune_devices(ide_hwif_t *hwif) | 821 | static void ide_port_tune_devices(ide_hwif_t *hwif) |
823 | { | 822 | { |
823 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
824 | int unit; | 824 | int unit; |
825 | 825 | ||
826 | for (unit = 0; unit < MAX_DRIVES; unit++) { | 826 | for (unit = 0; unit < MAX_DRIVES; unit++) { |
827 | ide_drive_t *drive = &hwif->drives[unit]; | 827 | ide_drive_t *drive = &hwif->drives[unit]; |
828 | 828 | ||
829 | if (drive->present && hwif->quirkproc) | 829 | if (drive->present && port_ops && port_ops->quirkproc) |
830 | hwif->quirkproc(drive); | 830 | port_ops->quirkproc(drive); |
831 | } | 831 | } |
832 | 832 | ||
833 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | 833 | for (unit = 0; unit < MAX_DRIVES; ++unit) { |
@@ -843,7 +843,7 @@ static void ide_port_tune_devices(ide_hwif_t *hwif) | |||
843 | 843 | ||
844 | drive->nice1 = 1; | 844 | drive->nice1 = 1; |
845 | 845 | ||
846 | if (hwif->dma_host_set) | 846 | if (hwif->dma_ops) |
847 | ide_set_dma(drive); | 847 | ide_set_dma(drive); |
848 | } | 848 | } |
849 | } | 849 | } |
@@ -1324,6 +1324,7 @@ static void hwif_register_devices(ide_hwif_t *hwif) | |||
1324 | 1324 | ||
1325 | static void ide_port_init_devices(ide_hwif_t *hwif) | 1325 | static void ide_port_init_devices(ide_hwif_t *hwif) |
1326 | { | 1326 | { |
1327 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
1327 | int i; | 1328 | int i; |
1328 | 1329 | ||
1329 | for (i = 0; i < MAX_DRIVES; i++) { | 1330 | for (i = 0; i < MAX_DRIVES; i++) { |
@@ -1339,8 +1340,8 @@ static void ide_port_init_devices(ide_hwif_t *hwif) | |||
1339 | drive->autotune = 1; | 1340 | drive->autotune = 1; |
1340 | } | 1341 | } |
1341 | 1342 | ||
1342 | if (hwif->port_init_devs) | 1343 | if (port_ops && port_ops->port_init_devs) |
1343 | hwif->port_init_devs(hwif); | 1344 | port_ops->port_init_devs(hwif); |
1344 | } | 1345 | } |
1345 | 1346 | ||
1346 | static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | 1347 | static void ide_init_port(ide_hwif_t *hwif, unsigned int port, |
@@ -1355,9 +1356,6 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | |||
1355 | if (d->init_iops) | 1356 | if (d->init_iops) |
1356 | d->init_iops(hwif); | 1357 | d->init_iops(hwif); |
1357 | 1358 | ||
1358 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) | ||
1359 | ide_hwif_setup_dma(hwif, d); | ||
1360 | |||
1361 | if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) || | 1359 | if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) || |
1362 | (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) | 1360 | (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) |
1363 | hwif->irq = port ? 15 : 14; | 1361 | hwif->irq = port ? 15 : 14; |
@@ -1365,16 +1363,36 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | |||
1365 | hwif->host_flags = d->host_flags; | 1363 | hwif->host_flags = d->host_flags; |
1366 | hwif->pio_mask = d->pio_mask; | 1364 | hwif->pio_mask = d->pio_mask; |
1367 | 1365 | ||
1368 | if ((d->host_flags & IDE_HFLAG_SERIALIZE) && hwif->mate) | 1366 | /* ->set_pio_mode for DTC2278 is currently limited to port 0 */ |
1369 | hwif->mate->serialized = hwif->serialized = 1; | 1367 | if (hwif->chipset != ide_dtc2278 || hwif->channel == 0) |
1368 | hwif->port_ops = d->port_ops; | ||
1369 | |||
1370 | if ((d->host_flags & IDE_HFLAG_SERIALIZE) || | ||
1371 | ((d->host_flags & IDE_HFLAG_SERIALIZE_DMA) && hwif->dma_base)) { | ||
1372 | if (hwif->mate) | ||
1373 | hwif->mate->serialized = hwif->serialized = 1; | ||
1374 | } | ||
1370 | 1375 | ||
1371 | hwif->swdma_mask = d->swdma_mask; | 1376 | hwif->swdma_mask = d->swdma_mask; |
1372 | hwif->mwdma_mask = d->mwdma_mask; | 1377 | hwif->mwdma_mask = d->mwdma_mask; |
1373 | hwif->ultra_mask = d->udma_mask; | 1378 | hwif->ultra_mask = d->udma_mask; |
1374 | 1379 | ||
1375 | /* reset DMA masks only for SFF-style DMA controllers */ | 1380 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) { |
1376 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0 && hwif->dma_base == 0) | 1381 | int rc; |
1377 | hwif->swdma_mask = hwif->mwdma_mask = hwif->ultra_mask = 0; | 1382 | |
1383 | if (d->init_dma) | ||
1384 | rc = d->init_dma(hwif, d); | ||
1385 | else | ||
1386 | rc = ide_hwif_setup_dma(hwif, d); | ||
1387 | |||
1388 | if (rc < 0) { | ||
1389 | printk(KERN_INFO "%s: DMA disabled\n", hwif->name); | ||
1390 | hwif->swdma_mask = 0; | ||
1391 | hwif->mwdma_mask = 0; | ||
1392 | hwif->ultra_mask = 0; | ||
1393 | } else if (d->dma_ops) | ||
1394 | hwif->dma_ops = d->dma_ops; | ||
1395 | } | ||
1378 | 1396 | ||
1379 | if (d->host_flags & IDE_HFLAG_RQSIZE_256) | 1397 | if (d->host_flags & IDE_HFLAG_RQSIZE_256) |
1380 | hwif->rqsize = 256; | 1398 | hwif->rqsize = 256; |
@@ -1386,9 +1404,11 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | |||
1386 | 1404 | ||
1387 | static void ide_port_cable_detect(ide_hwif_t *hwif) | 1405 | static void ide_port_cable_detect(ide_hwif_t *hwif) |
1388 | { | 1406 | { |
1389 | if (hwif->cable_detect && (hwif->ultra_mask & 0x78)) { | 1407 | const struct ide_port_ops *port_ops = hwif->port_ops; |
1408 | |||
1409 | if (port_ops && port_ops->cable_detect && (hwif->ultra_mask & 0x78)) { | ||
1390 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | 1410 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) |
1391 | hwif->cbl = hwif->cable_detect(hwif); | 1411 | hwif->cbl = port_ops->cable_detect(hwif); |
1392 | } | 1412 | } |
1393 | } | 1413 | } |
1394 | 1414 | ||
@@ -1523,25 +1543,15 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1523 | 1543 | ||
1524 | hwif = &ide_hwifs[idx[i]]; | 1544 | hwif = &ide_hwifs[idx[i]]; |
1525 | 1545 | ||
1526 | if ((hwif->chipset != ide_4drives || !hwif->mate || | 1546 | if (ide_probe_port(hwif) == 0) |
1527 | !hwif->mate->present) && ide_hwif_request_regions(hwif)) { | 1547 | hwif->present = 1; |
1528 | printk(KERN_ERR "%s: ports already in use, " | ||
1529 | "skipping probe\n", hwif->name); | ||
1530 | continue; | ||
1531 | } | ||
1532 | |||
1533 | if (ide_probe_port(hwif) < 0) { | ||
1534 | ide_hwif_release_regions(hwif); | ||
1535 | continue; | ||
1536 | } | ||
1537 | |||
1538 | hwif->present = 1; | ||
1539 | 1548 | ||
1540 | if (hwif->chipset != ide_4drives || !hwif->mate || | 1549 | if (hwif->chipset != ide_4drives || !hwif->mate || |
1541 | !hwif->mate->present) | 1550 | !hwif->mate->present) |
1542 | ide_register_port(hwif); | 1551 | ide_register_port(hwif); |
1543 | 1552 | ||
1544 | ide_port_tune_devices(hwif); | 1553 | if (hwif->present) |
1554 | ide_port_tune_devices(hwif); | ||
1545 | } | 1555 | } |
1546 | 1556 | ||
1547 | for (i = 0; i < MAX_HWIFS; i++) { | 1557 | for (i = 0; i < MAX_HWIFS; i++) { |
@@ -1550,9 +1560,6 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1550 | 1560 | ||
1551 | hwif = &ide_hwifs[idx[i]]; | 1561 | hwif = &ide_hwifs[idx[i]]; |
1552 | 1562 | ||
1553 | if (!hwif->present) | ||
1554 | continue; | ||
1555 | |||
1556 | if (hwif_init(hwif) == 0) { | 1563 | if (hwif_init(hwif) == 0) { |
1557 | printk(KERN_INFO "%s: failed to initialize IDE " | 1564 | printk(KERN_INFO "%s: failed to initialize IDE " |
1558 | "interface\n", hwif->name); | 1565 | "interface\n", hwif->name); |
@@ -1561,10 +1568,13 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1561 | continue; | 1568 | continue; |
1562 | } | 1569 | } |
1563 | 1570 | ||
1564 | ide_port_setup_devices(hwif); | 1571 | if (hwif->present) |
1572 | ide_port_setup_devices(hwif); | ||
1565 | 1573 | ||
1566 | ide_acpi_init(hwif); | 1574 | ide_acpi_init(hwif); |
1567 | ide_acpi_port_init_devices(hwif); | 1575 | |
1576 | if (hwif->present) | ||
1577 | ide_acpi_port_init_devices(hwif); | ||
1568 | } | 1578 | } |
1569 | 1579 | ||
1570 | for (i = 0; i < MAX_HWIFS; i++) { | 1580 | for (i = 0; i < MAX_HWIFS; i++) { |
@@ -1573,11 +1583,11 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1573 | 1583 | ||
1574 | hwif = &ide_hwifs[idx[i]]; | 1584 | hwif = &ide_hwifs[idx[i]]; |
1575 | 1585 | ||
1576 | if (hwif->present) { | 1586 | if (hwif->chipset == ide_unknown) |
1577 | if (hwif->chipset == ide_unknown) | 1587 | hwif->chipset = ide_generic; |
1578 | hwif->chipset = ide_generic; | 1588 | |
1589 | if (hwif->present) | ||
1579 | hwif_register_devices(hwif); | 1590 | hwif_register_devices(hwif); |
1580 | } | ||
1581 | } | 1591 | } |
1582 | 1592 | ||
1583 | for (i = 0; i < MAX_HWIFS; i++) { | 1593 | for (i = 0; i < MAX_HWIFS; i++) { |
@@ -1586,11 +1596,11 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1586 | 1596 | ||
1587 | hwif = &ide_hwifs[idx[i]]; | 1597 | hwif = &ide_hwifs[idx[i]]; |
1588 | 1598 | ||
1589 | if (hwif->present) { | 1599 | ide_sysfs_register_port(hwif); |
1590 | ide_sysfs_register_port(hwif); | 1600 | ide_proc_register_port(hwif); |
1591 | ide_proc_register_port(hwif); | 1601 | |
1602 | if (hwif->present) | ||
1592 | ide_proc_port_register_devices(hwif); | 1603 | ide_proc_port_register_devices(hwif); |
1593 | } | ||
1594 | } | 1604 | } |
1595 | 1605 | ||
1596 | return rc; | 1606 | return rc; |
@@ -1626,3 +1636,67 @@ void ide_port_scan(ide_hwif_t *hwif) | |||
1626 | ide_proc_port_register_devices(hwif); | 1636 | ide_proc_port_register_devices(hwif); |
1627 | } | 1637 | } |
1628 | EXPORT_SYMBOL_GPL(ide_port_scan); | 1638 | EXPORT_SYMBOL_GPL(ide_port_scan); |
1639 | |||
1640 | static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no, | ||
1641 | const struct ide_port_info *d, | ||
1642 | unsigned long config) | ||
1643 | { | ||
1644 | ide_hwif_t *hwif; | ||
1645 | unsigned long base, ctl; | ||
1646 | int irq; | ||
1647 | |||
1648 | if (port_no == 0) { | ||
1649 | base = 0x1f0; | ||
1650 | ctl = 0x3f6; | ||
1651 | irq = 14; | ||
1652 | } else { | ||
1653 | base = 0x170; | ||
1654 | ctl = 0x376; | ||
1655 | irq = 15; | ||
1656 | } | ||
1657 | |||
1658 | if (!request_region(base, 8, d->name)) { | ||
1659 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | ||
1660 | d->name, base, base + 7); | ||
1661 | return; | ||
1662 | } | ||
1663 | |||
1664 | if (!request_region(ctl, 1, d->name)) { | ||
1665 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", | ||
1666 | d->name, ctl); | ||
1667 | release_region(base, 8); | ||
1668 | return; | ||
1669 | } | ||
1670 | |||
1671 | ide_std_init_ports(hw, base, ctl); | ||
1672 | hw->irq = irq; | ||
1673 | |||
1674 | hwif = ide_find_port_slot(d); | ||
1675 | if (hwif) { | ||
1676 | ide_init_port_hw(hwif, hw); | ||
1677 | if (config) | ||
1678 | hwif->config_data = config; | ||
1679 | idx[port_no] = hwif->index; | ||
1680 | } | ||
1681 | } | ||
1682 | |||
1683 | int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config) | ||
1684 | { | ||
1685 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
1686 | hw_regs_t hw[2]; | ||
1687 | |||
1688 | memset(&hw, 0, sizeof(hw)); | ||
1689 | |||
1690 | if ((d->host_flags & IDE_HFLAG_QD_2ND_PORT) == 0) | ||
1691 | ide_legacy_init_one(idx, &hw[0], 0, d, config); | ||
1692 | ide_legacy_init_one(idx, &hw[1], 1, d, config); | ||
1693 | |||
1694 | if (idx[0] == 0xff && idx[1] == 0xff && | ||
1695 | (d->host_flags & IDE_HFLAG_SINGLE)) | ||
1696 | return -ENOENT; | ||
1697 | |||
1698 | ide_device_add(idx, d); | ||
1699 | |||
1700 | return 0; | ||
1701 | } | ||
1702 | EXPORT_SYMBOL_GPL(ide_legacy_device_add); | ||
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index 5d3562b45039..d9d98ac85b29 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
@@ -599,14 +599,14 @@ static int ide_replace_subdriver(ide_drive_t *drive, const char *driver) | |||
599 | err = device_attach(dev); | 599 | err = device_attach(dev); |
600 | if (err < 0) | 600 | if (err < 0) |
601 | printk(KERN_WARNING "IDE: %s: device_attach error: %d\n", | 601 | printk(KERN_WARNING "IDE: %s: device_attach error: %d\n", |
602 | __FUNCTION__, err); | 602 | __func__, err); |
603 | drive->driver_req[0] = 0; | 603 | drive->driver_req[0] = 0; |
604 | if (dev->driver == NULL) { | 604 | if (dev->driver == NULL) { |
605 | err = device_attach(dev); | 605 | err = device_attach(dev); |
606 | if (err < 0) | 606 | if (err < 0) |
607 | printk(KERN_WARNING | 607 | printk(KERN_WARNING |
608 | "IDE: %s: device_attach(2) error: %d\n", | 608 | "IDE: %s: device_attach(2) error: %d\n", |
609 | __FUNCTION__, err); | 609 | __func__, err); |
610 | } | 610 | } |
611 | if (dev->driver && !strcmp(dev->driver->name, driver)) | 611 | if (dev->driver && !strcmp(dev->driver->name, driver)) |
612 | ret = 0; | 612 | ret = 0; |
@@ -820,7 +820,7 @@ static int ide_drivers_show(struct seq_file *s, void *p) | |||
820 | err = bus_for_each_drv(&ide_bus_type, NULL, s, proc_print_driver); | 820 | err = bus_for_each_drv(&ide_bus_type, NULL, s, proc_print_driver); |
821 | if (err < 0) | 821 | if (err < 0) |
822 | printk(KERN_WARNING "IDE: %s: bus_for_each_drv error: %d\n", | 822 | printk(KERN_WARNING "IDE: %s: bus_for_each_drv error: %d\n", |
823 | __FUNCTION__, err); | 823 | __func__, err); |
824 | return 0; | 824 | return 0; |
825 | } | 825 | } |
826 | 826 | ||
diff --git a/drivers/ide/ide-scan-pci.c b/drivers/ide/ide-scan-pci.c index 98888da1b600..0e79efff1deb 100644 --- a/drivers/ide/ide-scan-pci.c +++ b/drivers/ide/ide-scan-pci.c | |||
@@ -102,7 +102,7 @@ static int __init ide_scan_pcibus(void) | |||
102 | if (__pci_register_driver(d, d->driver.owner, | 102 | if (__pci_register_driver(d, d->driver.owner, |
103 | d->driver.mod_name)) | 103 | d->driver.mod_name)) |
104 | printk(KERN_ERR "%s: failed to register %s driver\n", | 104 | printk(KERN_ERR "%s: failed to register %s driver\n", |
105 | __FUNCTION__, d->driver.mod_name); | 105 | __func__, d->driver.mod_name); |
106 | } | 106 | } |
107 | 107 | ||
108 | return 0; | 108 | return 0; |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index f43fd070f1b6..d3d8b8d5157c 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -993,7 +993,7 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
993 | stat = ide_read_status(drive); | 993 | stat = ide_read_status(drive); |
994 | 994 | ||
995 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | 995 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { |
996 | if (hwif->ide_dma_end(drive) || (stat & ERR_STAT)) { | 996 | if (hwif->dma_ops->dma_end(drive) || (stat & ERR_STAT)) { |
997 | /* | 997 | /* |
998 | * A DMA error is sometimes expected. For example, | 998 | * A DMA error is sometimes expected. For example, |
999 | * if the tape is crossing a filemark during a | 999 | * if the tape is crossing a filemark during a |
@@ -1213,7 +1213,7 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) | |||
1213 | #ifdef CONFIG_BLK_DEV_IDEDMA | 1213 | #ifdef CONFIG_BLK_DEV_IDEDMA |
1214 | /* Begin DMA, if necessary */ | 1214 | /* Begin DMA, if necessary */ |
1215 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) | 1215 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) |
1216 | hwif->dma_start(drive); | 1216 | hwif->dma_ops->dma_start(drive); |
1217 | #endif | 1217 | #endif |
1218 | /* Send the actual packet */ | 1218 | /* Send the actual packet */ |
1219 | HWIF(drive)->atapi_output_bytes(drive, pc->c, 12); | 1219 | HWIF(drive)->atapi_output_bytes(drive, pc->c, 12); |
@@ -1279,7 +1279,7 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, | |||
1279 | ide_dma_off(drive); | 1279 | ide_dma_off(drive); |
1280 | } | 1280 | } |
1281 | if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) | 1281 | if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) |
1282 | dma_ok = !hwif->dma_setup(drive); | 1282 | dma_ok = !hwif->dma_ops->dma_setup(drive); |
1283 | 1283 | ||
1284 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | | 1284 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | |
1285 | IDE_TFLAG_OUT_DEVICE, bcount, dma_ok); | 1285 | IDE_TFLAG_OUT_DEVICE, bcount, dma_ok); |
@@ -1605,14 +1605,6 @@ out: | |||
1605 | } | 1605 | } |
1606 | 1606 | ||
1607 | /* Pipeline related functions */ | 1607 | /* Pipeline related functions */ |
1608 | static inline int idetape_pipeline_active(idetape_tape_t *tape) | ||
1609 | { | ||
1610 | int rc1, rc2; | ||
1611 | |||
1612 | rc1 = test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags); | ||
1613 | rc2 = (tape->active_data_rq != NULL); | ||
1614 | return rc1; | ||
1615 | } | ||
1616 | 1608 | ||
1617 | /* | 1609 | /* |
1618 | * The function below uses __get_free_page to allocate a pipeline stage, along | 1610 | * The function below uses __get_free_page to allocate a pipeline stage, along |
@@ -2058,7 +2050,7 @@ static int __idetape_discard_read_pipeline(ide_drive_t *drive) | |||
2058 | 2050 | ||
2059 | spin_lock_irqsave(&tape->lock, flags); | 2051 | spin_lock_irqsave(&tape->lock, flags); |
2060 | tape->next_stage = NULL; | 2052 | tape->next_stage = NULL; |
2061 | if (idetape_pipeline_active(tape)) | 2053 | if (test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) |
2062 | idetape_wait_for_request(drive, tape->active_data_rq); | 2054 | idetape_wait_for_request(drive, tape->active_data_rq); |
2063 | spin_unlock_irqrestore(&tape->lock, flags); | 2055 | spin_unlock_irqrestore(&tape->lock, flags); |
2064 | 2056 | ||
@@ -2131,7 +2123,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, | |||
2131 | 2123 | ||
2132 | debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); | 2124 | debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); |
2133 | 2125 | ||
2134 | if (idetape_pipeline_active(tape)) { | 2126 | if (test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) { |
2135 | printk(KERN_ERR "ide-tape: bug: the pipeline is active in %s\n", | 2127 | printk(KERN_ERR "ide-tape: bug: the pipeline is active in %s\n", |
2136 | __func__); | 2128 | __func__); |
2137 | return (0); | 2129 | return (0); |
@@ -2162,8 +2154,7 @@ static void idetape_plug_pipeline(ide_drive_t *drive) | |||
2162 | 2154 | ||
2163 | if (tape->next_stage == NULL) | 2155 | if (tape->next_stage == NULL) |
2164 | return; | 2156 | return; |
2165 | if (!idetape_pipeline_active(tape)) { | 2157 | if (!test_and_set_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) { |
2166 | set_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags); | ||
2167 | idetape_activate_next_stage(drive); | 2158 | idetape_activate_next_stage(drive); |
2168 | (void) ide_do_drive_cmd(drive, tape->active_data_rq, ide_end); | 2159 | (void) ide_do_drive_cmd(drive, tape->active_data_rq, ide_end); |
2169 | } | 2160 | } |
@@ -2242,13 +2233,14 @@ static int idetape_add_chrdev_write_request(ide_drive_t *drive, int blocks) | |||
2242 | /* Attempt to allocate a new stage. Beware possible race conditions. */ | 2233 | /* Attempt to allocate a new stage. Beware possible race conditions. */ |
2243 | while ((new_stage = idetape_kmalloc_stage(tape)) == NULL) { | 2234 | while ((new_stage = idetape_kmalloc_stage(tape)) == NULL) { |
2244 | spin_lock_irqsave(&tape->lock, flags); | 2235 | spin_lock_irqsave(&tape->lock, flags); |
2245 | if (idetape_pipeline_active(tape)) { | 2236 | if (test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) { |
2246 | idetape_wait_for_request(drive, tape->active_data_rq); | 2237 | idetape_wait_for_request(drive, tape->active_data_rq); |
2247 | spin_unlock_irqrestore(&tape->lock, flags); | 2238 | spin_unlock_irqrestore(&tape->lock, flags); |
2248 | } else { | 2239 | } else { |
2249 | spin_unlock_irqrestore(&tape->lock, flags); | 2240 | spin_unlock_irqrestore(&tape->lock, flags); |
2250 | idetape_plug_pipeline(drive); | 2241 | idetape_plug_pipeline(drive); |
2251 | if (idetape_pipeline_active(tape)) | 2242 | if (test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, |
2243 | &tape->flags)) | ||
2252 | continue; | 2244 | continue; |
2253 | /* | 2245 | /* |
2254 | * The machine is short on memory. Fallback to non- | 2246 | * The machine is short on memory. Fallback to non- |
@@ -2277,7 +2269,7 @@ static int idetape_add_chrdev_write_request(ide_drive_t *drive, int blocks) | |||
2277 | * starting to service requests, so that we will be able to keep up with | 2269 | * starting to service requests, so that we will be able to keep up with |
2278 | * the higher speeds of the tape. | 2270 | * the higher speeds of the tape. |
2279 | */ | 2271 | */ |
2280 | if (!idetape_pipeline_active(tape)) { | 2272 | if (!test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) { |
2281 | if (tape->nr_stages >= tape->max_stages * 9 / 10 || | 2273 | if (tape->nr_stages >= tape->max_stages * 9 / 10 || |
2282 | tape->nr_stages >= tape->max_stages - | 2274 | tape->nr_stages >= tape->max_stages - |
2283 | tape->uncontrolled_pipeline_head_speed * 3 * 1024 / | 2275 | tape->uncontrolled_pipeline_head_speed * 3 * 1024 / |
@@ -2304,10 +2296,11 @@ static void idetape_wait_for_pipeline(ide_drive_t *drive) | |||
2304 | idetape_tape_t *tape = drive->driver_data; | 2296 | idetape_tape_t *tape = drive->driver_data; |
2305 | unsigned long flags; | 2297 | unsigned long flags; |
2306 | 2298 | ||
2307 | while (tape->next_stage || idetape_pipeline_active(tape)) { | 2299 | while (tape->next_stage || test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, |
2300 | &tape->flags)) { | ||
2308 | idetape_plug_pipeline(drive); | 2301 | idetape_plug_pipeline(drive); |
2309 | spin_lock_irqsave(&tape->lock, flags); | 2302 | spin_lock_irqsave(&tape->lock, flags); |
2310 | if (idetape_pipeline_active(tape)) | 2303 | if (test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) |
2311 | idetape_wait_for_request(drive, tape->active_data_rq); | 2304 | idetape_wait_for_request(drive, tape->active_data_rq); |
2312 | spin_unlock_irqrestore(&tape->lock, flags); | 2305 | spin_unlock_irqrestore(&tape->lock, flags); |
2313 | } | 2306 | } |
@@ -2464,7 +2457,7 @@ static int idetape_init_read(ide_drive_t *drive, int max_stages) | |||
2464 | new_stage = idetape_kmalloc_stage(tape); | 2457 | new_stage = idetape_kmalloc_stage(tape); |
2465 | } | 2458 | } |
2466 | } | 2459 | } |
2467 | if (!idetape_pipeline_active(tape)) { | 2460 | if (!test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) { |
2468 | if (tape->nr_pending_stages >= 3 * max_stages / 4) { | 2461 | if (tape->nr_pending_stages >= 3 * max_stages / 4) { |
2469 | tape->measure_insert_time = 1; | 2462 | tape->measure_insert_time = 1; |
2470 | tape->insert_time = jiffies; | 2463 | tape->insert_time = jiffies; |
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 155cc904f4eb..a317ca9c46e5 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c | |||
@@ -135,6 +135,7 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) | |||
135 | ide_hwif_t *hwif = HWIF(drive); | 135 | ide_hwif_t *hwif = HWIF(drive); |
136 | struct ide_taskfile *tf = &task->tf; | 136 | struct ide_taskfile *tf = &task->tf; |
137 | ide_handler_t *handler = NULL; | 137 | ide_handler_t *handler = NULL; |
138 | const struct ide_dma_ops *dma_ops = hwif->dma_ops; | ||
138 | 139 | ||
139 | if (task->data_phase == TASKFILE_MULTI_IN || | 140 | if (task->data_phase == TASKFILE_MULTI_IN || |
140 | task->data_phase == TASKFILE_MULTI_OUT) { | 141 | task->data_phase == TASKFILE_MULTI_OUT) { |
@@ -178,10 +179,10 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) | |||
178 | return ide_started; | 179 | return ide_started; |
179 | default: | 180 | default: |
180 | if (task_dma_ok(task) == 0 || drive->using_dma == 0 || | 181 | if (task_dma_ok(task) == 0 || drive->using_dma == 0 || |
181 | hwif->dma_setup(drive)) | 182 | dma_ops->dma_setup(drive)) |
182 | return ide_stopped; | 183 | return ide_stopped; |
183 | hwif->dma_exec_cmd(drive, tf->command); | 184 | dma_ops->dma_exec_cmd(drive, tf->command); |
184 | hwif->dma_start(drive); | 185 | dma_ops->dma_start(drive); |
185 | return ide_started; | 186 | return ide_started; |
186 | } | 187 | } |
187 | } | 188 | } |
@@ -455,7 +456,7 @@ static ide_startstop_t task_in_intr(ide_drive_t *drive) | |||
455 | 456 | ||
456 | /* Error? */ | 457 | /* Error? */ |
457 | if (stat & ERR_STAT) | 458 | if (stat & ERR_STAT) |
458 | return task_error(drive, rq, __FUNCTION__, stat); | 459 | return task_error(drive, rq, __func__, stat); |
459 | 460 | ||
460 | /* Didn't want any data? Odd. */ | 461 | /* Didn't want any data? Odd. */ |
461 | if (!(stat & DRQ_STAT)) | 462 | if (!(stat & DRQ_STAT)) |
@@ -467,7 +468,7 @@ static ide_startstop_t task_in_intr(ide_drive_t *drive) | |||
467 | if (!hwif->nleft) { | 468 | if (!hwif->nleft) { |
468 | stat = wait_drive_not_busy(drive); | 469 | stat = wait_drive_not_busy(drive); |
469 | if (!OK_STAT(stat, 0, BAD_STAT)) | 470 | if (!OK_STAT(stat, 0, BAD_STAT)) |
470 | return task_error(drive, rq, __FUNCTION__, stat); | 471 | return task_error(drive, rq, __func__, stat); |
471 | task_end_request(drive, rq, stat); | 472 | task_end_request(drive, rq, stat); |
472 | return ide_stopped; | 473 | return ide_stopped; |
473 | } | 474 | } |
@@ -488,11 +489,11 @@ static ide_startstop_t task_out_intr (ide_drive_t *drive) | |||
488 | u8 stat = ide_read_status(drive); | 489 | u8 stat = ide_read_status(drive); |
489 | 490 | ||
490 | if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) | 491 | if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) |
491 | return task_error(drive, rq, __FUNCTION__, stat); | 492 | return task_error(drive, rq, __func__, stat); |
492 | 493 | ||
493 | /* Deal with unexpected ATA data phase. */ | 494 | /* Deal with unexpected ATA data phase. */ |
494 | if (((stat & DRQ_STAT) == 0) ^ !hwif->nleft) | 495 | if (((stat & DRQ_STAT) == 0) ^ !hwif->nleft) |
495 | return task_error(drive, rq, __FUNCTION__, stat); | 496 | return task_error(drive, rq, __func__, stat); |
496 | 497 | ||
497 | if (!hwif->nleft) { | 498 | if (!hwif->nleft) { |
498 | task_end_request(drive, rq, stat); | 499 | task_end_request(drive, rq, stat); |
@@ -675,7 +676,7 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) | |||
675 | /* (hs): give up if multcount is not set */ | 676 | /* (hs): give up if multcount is not set */ |
676 | printk(KERN_ERR "%s: %s Multimode Write " \ | 677 | printk(KERN_ERR "%s: %s Multimode Write " \ |
677 | "multcount is not set\n", | 678 | "multcount is not set\n", |
678 | drive->name, __FUNCTION__); | 679 | drive->name, __func__); |
679 | err = -EPERM; | 680 | err = -EPERM; |
680 | goto abort; | 681 | goto abort; |
681 | } | 682 | } |
@@ -692,7 +693,7 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) | |||
692 | /* (hs): give up if multcount is not set */ | 693 | /* (hs): give up if multcount is not set */ |
693 | printk(KERN_ERR "%s: %s Multimode Read failure " \ | 694 | printk(KERN_ERR "%s: %s Multimode Read failure " \ |
694 | "multcount is not set\n", | 695 | "multcount is not set\n", |
695 | drive->name, __FUNCTION__); | 696 | drive->name, __func__); |
696 | err = -EPERM; | 697 | err = -EPERM; |
697 | goto abort; | 698 | goto abort; |
698 | } | 699 | } |
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index d868ca44d033..bced02f9f2c3 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -227,79 +227,6 @@ static int ide_system_bus_speed(void) | |||
227 | return pci_dev_present(pci_default) ? 33 : 50; | 227 | return pci_dev_present(pci_default) ? 33 : 50; |
228 | } | 228 | } |
229 | 229 | ||
230 | static struct resource* hwif_request_region(ide_hwif_t *hwif, | ||
231 | unsigned long addr, int num) | ||
232 | { | ||
233 | struct resource *res = request_region(addr, num, hwif->name); | ||
234 | |||
235 | if (!res) | ||
236 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | ||
237 | hwif->name, addr, addr+num-1); | ||
238 | return res; | ||
239 | } | ||
240 | |||
241 | /** | ||
242 | * ide_hwif_request_regions - request resources for IDE | ||
243 | * @hwif: interface to use | ||
244 | * | ||
245 | * Requests all the needed resources for an interface. | ||
246 | * Right now core IDE code does this work which is deeply wrong. | ||
247 | * MMIO leaves it to the controller driver, | ||
248 | * PIO will migrate this way over time. | ||
249 | */ | ||
250 | |||
251 | int ide_hwif_request_regions(ide_hwif_t *hwif) | ||
252 | { | ||
253 | unsigned long addr; | ||
254 | |||
255 | if (hwif->mmio) | ||
256 | return 0; | ||
257 | |||
258 | addr = hwif->io_ports[IDE_CONTROL_OFFSET]; | ||
259 | |||
260 | if (addr && !hwif_request_region(hwif, addr, 1)) | ||
261 | goto control_region_busy; | ||
262 | |||
263 | addr = hwif->io_ports[IDE_DATA_OFFSET]; | ||
264 | BUG_ON((addr | 7) != hwif->io_ports[IDE_STATUS_OFFSET]); | ||
265 | |||
266 | if (!hwif_request_region(hwif, addr, 8)) | ||
267 | goto data_region_busy; | ||
268 | |||
269 | return 0; | ||
270 | |||
271 | data_region_busy: | ||
272 | addr = hwif->io_ports[IDE_CONTROL_OFFSET]; | ||
273 | if (addr) | ||
274 | release_region(addr, 1); | ||
275 | control_region_busy: | ||
276 | /* If any errors are return, we drop the hwif interface. */ | ||
277 | return -EBUSY; | ||
278 | } | ||
279 | |||
280 | /** | ||
281 | * ide_hwif_release_regions - free IDE resources | ||
282 | * | ||
283 | * Note that we only release the standard ports, | ||
284 | * and do not even try to handle any extra ports | ||
285 | * allocated for weird IDE interface chipsets. | ||
286 | * | ||
287 | * Note also that we don't yet handle mmio resources here. More | ||
288 | * importantly our caller should be doing this so we need to | ||
289 | * restructure this as a helper function for drivers. | ||
290 | */ | ||
291 | |||
292 | void ide_hwif_release_regions(ide_hwif_t *hwif) | ||
293 | { | ||
294 | if (hwif->mmio) | ||
295 | return; | ||
296 | |||
297 | if (hwif->io_ports[IDE_CONTROL_OFFSET]) | ||
298 | release_region(hwif->io_ports[IDE_CONTROL_OFFSET], 1); | ||
299 | |||
300 | release_region(hwif->io_ports[IDE_DATA_OFFSET], 8); | ||
301 | } | ||
302 | |||
303 | void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) | 230 | void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) |
304 | { | 231 | { |
305 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | 232 | ide_hwgroup_t *hwgroup = hwif->hwgroup; |
@@ -436,9 +363,7 @@ void ide_unregister(unsigned int index) | |||
436 | spin_lock_irq(&ide_lock); | 363 | spin_lock_irq(&ide_lock); |
437 | 364 | ||
438 | if (hwif->dma_base) | 365 | if (hwif->dma_base) |
439 | (void)ide_release_dma(hwif); | 366 | ide_release_dma_engine(hwif); |
440 | |||
441 | ide_hwif_release_regions(hwif); | ||
442 | 367 | ||
443 | /* restore hwif data to pristine status */ | 368 | /* restore hwif data to pristine status */ |
444 | ide_init_port_data(hwif, index); | 369 | ide_init_port_data(hwif, index); |
@@ -454,7 +379,6 @@ void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) | |||
454 | { | 379 | { |
455 | memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports)); | 380 | memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports)); |
456 | hwif->irq = hw->irq; | 381 | hwif->irq = hw->irq; |
457 | hwif->noprobe = 0; | ||
458 | hwif->chipset = hw->chipset; | 382 | hwif->chipset = hw->chipset; |
459 | hwif->gendev.parent = hw->dev; | 383 | hwif->gendev.parent = hw->dev; |
460 | hwif->ack_intr = hw->ack_intr; | 384 | hwif->ack_intr = hw->ack_intr; |
@@ -545,7 +469,7 @@ int set_using_dma(ide_drive_t *drive, int arg) | |||
545 | if (!drive->id || !(drive->id->capability & 1)) | 469 | if (!drive->id || !(drive->id->capability & 1)) |
546 | goto out; | 470 | goto out; |
547 | 471 | ||
548 | if (hwif->dma_host_set == NULL) | 472 | if (hwif->dma_ops == NULL) |
549 | goto out; | 473 | goto out; |
550 | 474 | ||
551 | err = -EBUSY; | 475 | err = -EBUSY; |
@@ -585,11 +509,12 @@ int set_pio_mode(ide_drive_t *drive, int arg) | |||
585 | { | 509 | { |
586 | struct request rq; | 510 | struct request rq; |
587 | ide_hwif_t *hwif = drive->hwif; | 511 | ide_hwif_t *hwif = drive->hwif; |
512 | const struct ide_port_ops *port_ops = hwif->port_ops; | ||
588 | 513 | ||
589 | if (arg < 0 || arg > 255) | 514 | if (arg < 0 || arg > 255) |
590 | return -EINVAL; | 515 | return -EINVAL; |
591 | 516 | ||
592 | if (hwif->set_pio_mode == NULL || | 517 | if (port_ops == NULL || port_ops->set_pio_mode == NULL || |
593 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) | 518 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) |
594 | return -ENOSYS; | 519 | return -ENOSYS; |
595 | 520 | ||
@@ -1005,14 +930,12 @@ static int __init ide_setup(char *s) | |||
1005 | goto done; | 930 | goto done; |
1006 | case -3: /* "nowerr" */ | 931 | case -3: /* "nowerr" */ |
1007 | drive->bad_wstat = BAD_R_STAT; | 932 | drive->bad_wstat = BAD_R_STAT; |
1008 | hwif->noprobe = 0; | ||
1009 | goto done; | 933 | goto done; |
1010 | case -4: /* "cdrom" */ | 934 | case -4: /* "cdrom" */ |
1011 | drive->present = 1; | 935 | drive->present = 1; |
1012 | drive->media = ide_cdrom; | 936 | drive->media = ide_cdrom; |
1013 | /* an ATAPI device ignores DRDY */ | 937 | /* an ATAPI device ignores DRDY */ |
1014 | drive->ready_stat = 0; | 938 | drive->ready_stat = 0; |
1015 | hwif->noprobe = 0; | ||
1016 | goto done; | 939 | goto done; |
1017 | case -5: /* nodma */ | 940 | case -5: /* nodma */ |
1018 | drive->nodma = 1; | 941 | drive->nodma = 1; |
@@ -1043,7 +966,6 @@ static int __init ide_setup(char *s) | |||
1043 | drive->sect = drive->bios_sect = vals[2]; | 966 | drive->sect = drive->bios_sect = vals[2]; |
1044 | drive->present = 1; | 967 | drive->present = 1; |
1045 | drive->forced_geom = 1; | 968 | drive->forced_geom = 1; |
1046 | hwif->noprobe = 0; | ||
1047 | goto done; | 969 | goto done; |
1048 | default: | 970 | default: |
1049 | goto bad_option; | 971 | goto bad_option; |
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c index 33bb7b87be5d..6efbf947c6db 100644 --- a/drivers/ide/legacy/ali14xx.c +++ b/drivers/ide/legacy/ali14xx.c | |||
@@ -49,6 +49,8 @@ | |||
49 | 49 | ||
50 | #include <asm/io.h> | 50 | #include <asm/io.h> |
51 | 51 | ||
52 | #define DRV_NAME "ali14xx" | ||
53 | |||
52 | /* port addresses for auto-detection */ | 54 | /* port addresses for auto-detection */ |
53 | #define ALI_NUM_PORTS 4 | 55 | #define ALI_NUM_PORTS 4 |
54 | static const int ports[ALI_NUM_PORTS] __initdata = | 56 | static const int ports[ALI_NUM_PORTS] __initdata = |
@@ -192,18 +194,20 @@ static int __init initRegisters(void) | |||
192 | return t; | 194 | return t; |
193 | } | 195 | } |
194 | 196 | ||
197 | static const struct ide_port_ops ali14xx_port_ops = { | ||
198 | .set_pio_mode = ali14xx_set_pio_mode, | ||
199 | }; | ||
200 | |||
195 | static const struct ide_port_info ali14xx_port_info = { | 201 | static const struct ide_port_info ali14xx_port_info = { |
202 | .name = DRV_NAME, | ||
196 | .chipset = ide_ali14xx, | 203 | .chipset = ide_ali14xx, |
204 | .port_ops = &ali14xx_port_ops, | ||
197 | .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE, | 205 | .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE, |
198 | .pio_mask = ATA_PIO4, | 206 | .pio_mask = ATA_PIO4, |
199 | }; | 207 | }; |
200 | 208 | ||
201 | static int __init ali14xx_probe(void) | 209 | static int __init ali14xx_probe(void) |
202 | { | 210 | { |
203 | ide_hwif_t *hwif, *mate; | ||
204 | static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
205 | hw_regs_t hw[2]; | ||
206 | |||
207 | printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n", | 211 | printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n", |
208 | basePort, regOn); | 212 | basePort, regOn); |
209 | 213 | ||
@@ -213,31 +217,7 @@ static int __init ali14xx_probe(void) | |||
213 | return 1; | 217 | return 1; |
214 | } | 218 | } |
215 | 219 | ||
216 | memset(&hw, 0, sizeof(hw)); | 220 | return ide_legacy_device_add(&ali14xx_port_info, 0); |
217 | |||
218 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | ||
219 | hw[0].irq = 14; | ||
220 | |||
221 | ide_std_init_ports(&hw[1], 0x170, 0x376); | ||
222 | hw[1].irq = 15; | ||
223 | |||
224 | hwif = ide_find_port(); | ||
225 | if (hwif) { | ||
226 | ide_init_port_hw(hwif, &hw[0]); | ||
227 | hwif->set_pio_mode = &ali14xx_set_pio_mode; | ||
228 | idx[0] = hwif->index; | ||
229 | } | ||
230 | |||
231 | mate = ide_find_port(); | ||
232 | if (mate) { | ||
233 | ide_init_port_hw(mate, &hw[1]); | ||
234 | mate->set_pio_mode = &ali14xx_set_pio_mode; | ||
235 | idx[1] = mate->index; | ||
236 | } | ||
237 | |||
238 | ide_device_add(idx, &ali14xx_port_info); | ||
239 | |||
240 | return 0; | ||
241 | } | 221 | } |
242 | 222 | ||
243 | int probe_ali14xx; | 223 | int probe_ali14xx; |
diff --git a/drivers/ide/legacy/buddha.c b/drivers/ide/legacy/buddha.c index 6956eb8f2d5f..f51433bce8e4 100644 --- a/drivers/ide/legacy/buddha.c +++ b/drivers/ide/legacy/buddha.c | |||
@@ -228,8 +228,6 @@ fail_base2: | |||
228 | ide_init_port_data(hwif, index); | 228 | ide_init_port_data(hwif, index); |
229 | ide_init_port_hw(hwif, &hw); | 229 | ide_init_port_hw(hwif, &hw); |
230 | 230 | ||
231 | hwif->mmio = 1; | ||
232 | |||
233 | idx[i] = index; | 231 | idx[i] = index; |
234 | } | 232 | } |
235 | } | 233 | } |
diff --git a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c index 9c6b3249a004..f7c4ad1c57c0 100644 --- a/drivers/ide/legacy/dtc2278.c +++ b/drivers/ide/legacy/dtc2278.c | |||
@@ -16,6 +16,8 @@ | |||
16 | 16 | ||
17 | #include <asm/io.h> | 17 | #include <asm/io.h> |
18 | 18 | ||
19 | #define DRV_NAME "dtc2278" | ||
20 | |||
19 | /* | 21 | /* |
20 | * Changing this #undef to #define may solve start up problems in some systems. | 22 | * Changing this #undef to #define may solve start up problems in some systems. |
21 | */ | 23 | */ |
@@ -86,8 +88,14 @@ static void dtc2278_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
86 | } | 88 | } |
87 | } | 89 | } |
88 | 90 | ||
91 | static const struct ide_port_ops dtc2278_port_ops = { | ||
92 | .set_pio_mode = dtc2278_set_pio_mode, | ||
93 | }; | ||
94 | |||
89 | static const struct ide_port_info dtc2278_port_info __initdata = { | 95 | static const struct ide_port_info dtc2278_port_info __initdata = { |
96 | .name = DRV_NAME, | ||
90 | .chipset = ide_dtc2278, | 97 | .chipset = ide_dtc2278, |
98 | .port_ops = &dtc2278_port_ops, | ||
91 | .host_flags = IDE_HFLAG_SERIALIZE | | 99 | .host_flags = IDE_HFLAG_SERIALIZE | |
92 | IDE_HFLAG_NO_UNMASK_IRQS | | 100 | IDE_HFLAG_NO_UNMASK_IRQS | |
93 | IDE_HFLAG_IO_32BIT | | 101 | IDE_HFLAG_IO_32BIT | |
@@ -101,9 +109,6 @@ static const struct ide_port_info dtc2278_port_info __initdata = { | |||
101 | static int __init dtc2278_probe(void) | 109 | static int __init dtc2278_probe(void) |
102 | { | 110 | { |
103 | unsigned long flags; | 111 | unsigned long flags; |
104 | ide_hwif_t *hwif, *mate; | ||
105 | static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
106 | hw_regs_t hw[2]; | ||
107 | 112 | ||
108 | local_irq_save(flags); | 113 | local_irq_save(flags); |
109 | /* | 114 | /* |
@@ -123,30 +128,7 @@ static int __init dtc2278_probe(void) | |||
123 | #endif | 128 | #endif |
124 | local_irq_restore(flags); | 129 | local_irq_restore(flags); |
125 | 130 | ||
126 | memset(&hw, 0, sizeof(hw)); | 131 | return ide_legacy_device_add(&dtc2278_port_info, 0); |
127 | |||
128 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | ||
129 | hw[0].irq = 14; | ||
130 | |||
131 | ide_std_init_ports(&hw[1], 0x170, 0x376); | ||
132 | hw[1].irq = 15; | ||
133 | |||
134 | hwif = ide_find_port(); | ||
135 | if (hwif) { | ||
136 | ide_init_port_hw(hwif, &hw[0]); | ||
137 | hwif->set_pio_mode = dtc2278_set_pio_mode; | ||
138 | idx[0] = hwif->index; | ||
139 | } | ||
140 | |||
141 | mate = ide_find_port(); | ||
142 | if (mate) { | ||
143 | ide_init_port_hw(mate, &hw[1]); | ||
144 | idx[1] = mate->index; | ||
145 | } | ||
146 | |||
147 | ide_device_add(idx, &dtc2278_port_info); | ||
148 | |||
149 | return 0; | ||
150 | } | 132 | } |
151 | 133 | ||
152 | int probe_dtc2278 = 0; | 134 | int probe_dtc2278 = 0; |
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c index 8c9c9f7f54ca..5c19c422c5cc 100644 --- a/drivers/ide/legacy/falconide.c +++ b/drivers/ide/legacy/falconide.c | |||
@@ -89,7 +89,6 @@ static int __init falconide_init(void) | |||
89 | 89 | ||
90 | ide_init_port_data(hwif, index); | 90 | ide_init_port_data(hwif, index); |
91 | ide_init_port_hw(hwif, &hw); | 91 | ide_init_port_hw(hwif, &hw); |
92 | hwif->mmio = 1; | ||
93 | 92 | ||
94 | ide_get_lock(NULL, NULL); | 93 | ide_get_lock(NULL, NULL); |
95 | ide_device_add(idx, NULL); | 94 | ide_device_add(idx, NULL); |
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c index fcc8d52bf2a1..a0c9601bdaf0 100644 --- a/drivers/ide/legacy/gayle.c +++ b/drivers/ide/legacy/gayle.c | |||
@@ -182,8 +182,6 @@ found: | |||
182 | ide_init_port_data(hwif, index); | 182 | ide_init_port_data(hwif, index); |
183 | ide_init_port_hw(hwif, &hw); | 183 | ide_init_port_hw(hwif, &hw); |
184 | 184 | ||
185 | hwif->mmio = 1; | ||
186 | |||
187 | idx[i] = index; | 185 | idx[i] = index; |
188 | } else | 186 | } else |
189 | release_mem_region(res_start, res_n); | 187 | release_mem_region(res_start, res_n); |
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c index 60f52f5158c9..702d8deb5780 100644 --- a/drivers/ide/legacy/ht6560b.c +++ b/drivers/ide/legacy/ht6560b.c | |||
@@ -328,8 +328,16 @@ int probe_ht6560b = 0; | |||
328 | module_param_named(probe, probe_ht6560b, bool, 0); | 328 | module_param_named(probe, probe_ht6560b, bool, 0); |
329 | MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); | 329 | MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); |
330 | 330 | ||
331 | static const struct ide_port_ops ht6560b_port_ops = { | ||
332 | .port_init_devs = ht6560b_port_init_devs, | ||
333 | .set_pio_mode = ht6560b_set_pio_mode, | ||
334 | .selectproc = ht6560b_selectproc, | ||
335 | }; | ||
336 | |||
331 | static const struct ide_port_info ht6560b_port_info __initdata = { | 337 | static const struct ide_port_info ht6560b_port_info __initdata = { |
338 | .name = DRV_NAME, | ||
332 | .chipset = ide_ht6560b, | 339 | .chipset = ide_ht6560b, |
340 | .port_ops = &ht6560b_port_ops, | ||
333 | .host_flags = IDE_HFLAG_SERIALIZE | /* is this needed? */ | 341 | .host_flags = IDE_HFLAG_SERIALIZE | /* is this needed? */ |
334 | IDE_HFLAG_NO_DMA | | 342 | IDE_HFLAG_NO_DMA | |
335 | IDE_HFLAG_NO_AUTOTUNE | | 343 | IDE_HFLAG_NO_AUTOTUNE | |
@@ -339,53 +347,21 @@ static const struct ide_port_info ht6560b_port_info __initdata = { | |||
339 | 347 | ||
340 | static int __init ht6560b_init(void) | 348 | static int __init ht6560b_init(void) |
341 | { | 349 | { |
342 | ide_hwif_t *hwif, *mate; | ||
343 | static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
344 | hw_regs_t hw[2]; | ||
345 | |||
346 | if (probe_ht6560b == 0) | 350 | if (probe_ht6560b == 0) |
347 | return -ENODEV; | 351 | return -ENODEV; |
348 | 352 | ||
349 | if (!request_region(HT_CONFIG_PORT, 1, DRV_NAME)) { | 353 | if (!request_region(HT_CONFIG_PORT, 1, DRV_NAME)) { |
350 | printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n", | 354 | printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n", |
351 | __FUNCTION__); | 355 | __func__); |
352 | return -ENODEV; | 356 | return -ENODEV; |
353 | } | 357 | } |
354 | 358 | ||
355 | if (!try_to_init_ht6560b()) { | 359 | if (!try_to_init_ht6560b()) { |
356 | printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__); | 360 | printk(KERN_NOTICE "%s: HBA not found\n", __func__); |
357 | goto release_region; | 361 | goto release_region; |
358 | } | 362 | } |
359 | 363 | ||
360 | memset(&hw, 0, sizeof(hw)); | 364 | return ide_legacy_device_add(&ht6560b_port_info, 0); |
361 | |||
362 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | ||
363 | hw[0].irq = 14; | ||
364 | |||
365 | ide_std_init_ports(&hw[1], 0x170, 0x376); | ||
366 | hw[1].irq = 15; | ||
367 | |||
368 | hwif = ide_find_port(); | ||
369 | if (hwif) { | ||
370 | ide_init_port_hw(hwif, &hw[0]); | ||
371 | hwif->selectproc = ht6560b_selectproc; | ||
372 | hwif->set_pio_mode = ht6560b_set_pio_mode; | ||
373 | hwif->port_init_devs = ht6560b_port_init_devs; | ||
374 | idx[0] = hwif->index; | ||
375 | } | ||
376 | |||
377 | mate = ide_find_port(); | ||
378 | if (mate) { | ||
379 | ide_init_port_hw(mate, &hw[1]); | ||
380 | mate->selectproc = ht6560b_selectproc; | ||
381 | mate->set_pio_mode = ht6560b_set_pio_mode; | ||
382 | mate->port_init_devs = ht6560b_port_init_devs; | ||
383 | idx[1] = mate->index; | ||
384 | } | ||
385 | |||
386 | ide_device_add(idx, &ht6560b_port_info); | ||
387 | |||
388 | return 0; | ||
389 | 365 | ||
390 | release_region: | 366 | release_region: |
391 | release_region(HT_CONFIG_PORT, 1); | 367 | release_region(HT_CONFIG_PORT, 1); |
diff --git a/drivers/ide/legacy/ide-4drives.c b/drivers/ide/legacy/ide-4drives.c index c352f12348af..17f94d0cb539 100644 --- a/drivers/ide/legacy/ide-4drives.c +++ b/drivers/ide/legacy/ide-4drives.c | |||
@@ -4,6 +4,8 @@ | |||
4 | #include <linux/module.h> | 4 | #include <linux/module.h> |
5 | #include <linux/ide.h> | 5 | #include <linux/ide.h> |
6 | 6 | ||
7 | #define DRV_NAME "ide-4drives" | ||
8 | |||
7 | int probe_4drives; | 9 | int probe_4drives; |
8 | 10 | ||
9 | module_param_named(probe, probe_4drives, bool, 0); | 11 | module_param_named(probe, probe_4drives, bool, 0); |
@@ -12,15 +14,29 @@ MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port"); | |||
12 | static int __init ide_4drives_init(void) | 14 | static int __init ide_4drives_init(void) |
13 | { | 15 | { |
14 | ide_hwif_t *hwif, *mate; | 16 | ide_hwif_t *hwif, *mate; |
17 | unsigned long base = 0x1f0, ctl = 0x3f6; | ||
15 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 18 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
16 | hw_regs_t hw; | 19 | hw_regs_t hw; |
17 | 20 | ||
18 | if (probe_4drives == 0) | 21 | if (probe_4drives == 0) |
19 | return -ENODEV; | 22 | return -ENODEV; |
20 | 23 | ||
24 | if (!request_region(base, 8, DRV_NAME)) { | ||
25 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | ||
26 | DRV_NAME, base, base + 7); | ||
27 | return -EBUSY; | ||
28 | } | ||
29 | |||
30 | if (!request_region(ctl, 1, DRV_NAME)) { | ||
31 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", | ||
32 | DRV_NAME, ctl); | ||
33 | release_region(base, 8); | ||
34 | return -EBUSY; | ||
35 | } | ||
36 | |||
21 | memset(&hw, 0, sizeof(hw)); | 37 | memset(&hw, 0, sizeof(hw)); |
22 | 38 | ||
23 | ide_std_init_ports(&hw, 0x1f0, 0x3f6); | 39 | ide_std_init_ports(&hw, base, ctl); |
24 | hw.irq = 14; | 40 | hw.irq = 14; |
25 | hw.chipset = ide_4drives; | 41 | hw.chipset = ide_4drives; |
26 | 42 | ||
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index b97b8d51b3eb..855e157b18d3 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c | |||
@@ -51,6 +51,8 @@ | |||
51 | #include <pcmcia/cisreg.h> | 51 | #include <pcmcia/cisreg.h> |
52 | #include <pcmcia/ciscode.h> | 52 | #include <pcmcia/ciscode.h> |
53 | 53 | ||
54 | #define DRV_NAME "ide-cs" | ||
55 | |||
54 | /*====================================================================*/ | 56 | /*====================================================================*/ |
55 | 57 | ||
56 | /* Module parameters */ | 58 | /* Module parameters */ |
@@ -72,16 +74,11 @@ static char *version = | |||
72 | 74 | ||
73 | /*====================================================================*/ | 75 | /*====================================================================*/ |
74 | 76 | ||
75 | static const char ide_major[] = { | ||
76 | IDE0_MAJOR, IDE1_MAJOR, IDE2_MAJOR, IDE3_MAJOR, | ||
77 | IDE4_MAJOR, IDE5_MAJOR | ||
78 | }; | ||
79 | |||
80 | typedef struct ide_info_t { | 77 | typedef struct ide_info_t { |
81 | struct pcmcia_device *p_dev; | 78 | struct pcmcia_device *p_dev; |
79 | ide_hwif_t *hwif; | ||
82 | int ndev; | 80 | int ndev; |
83 | dev_node_t node; | 81 | dev_node_t node; |
84 | int hd; | ||
85 | } ide_info_t; | 82 | } ide_info_t; |
86 | 83 | ||
87 | static void ide_release(struct pcmcia_device *); | 84 | static void ide_release(struct pcmcia_device *); |
@@ -136,20 +133,44 @@ static int ide_probe(struct pcmcia_device *link) | |||
136 | 133 | ||
137 | static void ide_detach(struct pcmcia_device *link) | 134 | static void ide_detach(struct pcmcia_device *link) |
138 | { | 135 | { |
136 | ide_info_t *info = link->priv; | ||
137 | ide_hwif_t *hwif = info->hwif; | ||
138 | |||
139 | DEBUG(0, "ide_detach(0x%p)\n", link); | 139 | DEBUG(0, "ide_detach(0x%p)\n", link); |
140 | 140 | ||
141 | ide_release(link); | 141 | ide_release(link); |
142 | 142 | ||
143 | kfree(link->priv); | 143 | release_region(hwif->io_ports[IDE_CONTROL_OFFSET], 1); |
144 | release_region(hwif->io_ports[IDE_DATA_OFFSET], 8); | ||
145 | |||
146 | kfree(info); | ||
144 | } /* ide_detach */ | 147 | } /* ide_detach */ |
145 | 148 | ||
146 | static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle) | 149 | static const struct ide_port_ops idecs_port_ops = { |
150 | .quirkproc = ide_undecoded_slave, | ||
151 | }; | ||
152 | |||
153 | static ide_hwif_t *idecs_register(unsigned long io, unsigned long ctl, | ||
154 | unsigned long irq, struct pcmcia_device *handle) | ||
147 | { | 155 | { |
148 | ide_hwif_t *hwif; | 156 | ide_hwif_t *hwif; |
149 | hw_regs_t hw; | 157 | hw_regs_t hw; |
150 | int i; | 158 | int i; |
151 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 159 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
152 | 160 | ||
161 | if (!request_region(io, 8, DRV_NAME)) { | ||
162 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | ||
163 | DRV_NAME, io, io + 7); | ||
164 | return NULL; | ||
165 | } | ||
166 | |||
167 | if (!request_region(ctl, 1, DRV_NAME)) { | ||
168 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", | ||
169 | DRV_NAME, ctl); | ||
170 | release_region(io, 8); | ||
171 | return NULL; | ||
172 | } | ||
173 | |||
153 | memset(&hw, 0, sizeof(hw)); | 174 | memset(&hw, 0, sizeof(hw)); |
154 | ide_std_init_ports(&hw, io, ctl); | 175 | ide_std_init_ports(&hw, io, ctl); |
155 | hw.irq = irq; | 176 | hw.irq = irq; |
@@ -158,7 +179,7 @@ static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq | |||
158 | 179 | ||
159 | hwif = ide_find_port(); | 180 | hwif = ide_find_port(); |
160 | if (hwif == NULL) | 181 | if (hwif == NULL) |
161 | return -1; | 182 | goto out_release; |
162 | 183 | ||
163 | i = hwif->index; | 184 | i = hwif->index; |
164 | 185 | ||
@@ -168,13 +189,19 @@ static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq | |||
168 | ide_init_port_data(hwif, i); | 189 | ide_init_port_data(hwif, i); |
169 | 190 | ||
170 | ide_init_port_hw(hwif, &hw); | 191 | ide_init_port_hw(hwif, &hw); |
171 | hwif->quirkproc = &ide_undecoded_slave; | 192 | hwif->port_ops = &idecs_port_ops; |
172 | 193 | ||
173 | idx[0] = i; | 194 | idx[0] = i; |
174 | 195 | ||
175 | ide_device_add(idx, NULL); | 196 | ide_device_add(idx, NULL); |
176 | 197 | ||
177 | return hwif->present ? i : -1; | 198 | if (hwif->present) |
199 | return hwif; | ||
200 | |||
201 | out_release: | ||
202 | release_region(ctl, 1); | ||
203 | release_region(io, 8); | ||
204 | return NULL; | ||
178 | } | 205 | } |
179 | 206 | ||
180 | /*====================================================================== | 207 | /*====================================================================== |
@@ -199,8 +226,9 @@ static int ide_config(struct pcmcia_device *link) | |||
199 | cistpl_cftable_entry_t dflt; | 226 | cistpl_cftable_entry_t dflt; |
200 | } *stk = NULL; | 227 | } *stk = NULL; |
201 | cistpl_cftable_entry_t *cfg; | 228 | cistpl_cftable_entry_t *cfg; |
202 | int i, pass, last_ret = 0, last_fn = 0, hd, is_kme = 0; | 229 | int i, pass, last_ret = 0, last_fn = 0, is_kme = 0; |
203 | unsigned long io_base, ctl_base; | 230 | unsigned long io_base, ctl_base; |
231 | ide_hwif_t *hwif; | ||
204 | 232 | ||
205 | DEBUG(0, "ide_config(0x%p)\n", link); | 233 | DEBUG(0, "ide_config(0x%p)\n", link); |
206 | 234 | ||
@@ -296,14 +324,15 @@ static int ide_config(struct pcmcia_device *link) | |||
296 | outb(0x81, ctl_base+1); | 324 | outb(0x81, ctl_base+1); |
297 | 325 | ||
298 | /* retry registration in case device is still spinning up */ | 326 | /* retry registration in case device is still spinning up */ |
299 | for (hd = -1, i = 0; i < 10; i++) { | 327 | for (i = 0; i < 10; i++) { |
300 | hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link); | 328 | hwif = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link); |
301 | if (hd >= 0) break; | 329 | if (hwif) |
330 | break; | ||
302 | if (link->io.NumPorts1 == 0x20) { | 331 | if (link->io.NumPorts1 == 0x20) { |
303 | outb(0x02, ctl_base + 0x10); | 332 | outb(0x02, ctl_base + 0x10); |
304 | hd = idecs_register(io_base + 0x10, ctl_base + 0x10, | 333 | hwif = idecs_register(io_base + 0x10, ctl_base + 0x10, |
305 | link->irq.AssignedIRQ, link); | 334 | link->irq.AssignedIRQ, link); |
306 | if (hd >= 0) { | 335 | if (hwif) { |
307 | io_base += 0x10; | 336 | io_base += 0x10; |
308 | ctl_base += 0x10; | 337 | ctl_base += 0x10; |
309 | break; | 338 | break; |
@@ -312,7 +341,7 @@ static int ide_config(struct pcmcia_device *link) | |||
312 | msleep(100); | 341 | msleep(100); |
313 | } | 342 | } |
314 | 343 | ||
315 | if (hd < 0) { | 344 | if (hwif == NULL) { |
316 | printk(KERN_NOTICE "ide-cs: ide_register() at 0x%3lx & 0x%3lx" | 345 | printk(KERN_NOTICE "ide-cs: ide_register() at 0x%3lx & 0x%3lx" |
317 | ", irq %u failed\n", io_base, ctl_base, | 346 | ", irq %u failed\n", io_base, ctl_base, |
318 | link->irq.AssignedIRQ); | 347 | link->irq.AssignedIRQ); |
@@ -320,10 +349,10 @@ static int ide_config(struct pcmcia_device *link) | |||
320 | } | 349 | } |
321 | 350 | ||
322 | info->ndev = 1; | 351 | info->ndev = 1; |
323 | sprintf(info->node.dev_name, "hd%c", 'a' + (hd * 2)); | 352 | sprintf(info->node.dev_name, "hd%c", 'a' + hwif->index * 2); |
324 | info->node.major = ide_major[hd]; | 353 | info->node.major = hwif->major; |
325 | info->node.minor = 0; | 354 | info->node.minor = 0; |
326 | info->hd = hd; | 355 | info->hwif = hwif; |
327 | link->dev_node = &info->node; | 356 | link->dev_node = &info->node; |
328 | printk(KERN_INFO "ide-cs: %s: Vpp = %d.%d\n", | 357 | printk(KERN_INFO "ide-cs: %s: Vpp = %d.%d\n", |
329 | info->node.dev_name, link->conf.Vpp / 10, link->conf.Vpp % 10); | 358 | info->node.dev_name, link->conf.Vpp / 10, link->conf.Vpp % 10); |
@@ -354,13 +383,14 @@ failed: | |||
354 | void ide_release(struct pcmcia_device *link) | 383 | void ide_release(struct pcmcia_device *link) |
355 | { | 384 | { |
356 | ide_info_t *info = link->priv; | 385 | ide_info_t *info = link->priv; |
386 | ide_hwif_t *hwif = info->hwif; | ||
357 | 387 | ||
358 | DEBUG(0, "ide_release(0x%p)\n", link); | 388 | DEBUG(0, "ide_release(0x%p)\n", link); |
359 | 389 | ||
360 | if (info->ndev) { | 390 | if (info->ndev) { |
361 | /* FIXME: if this fails we need to queue the cleanup somehow | 391 | /* FIXME: if this fails we need to queue the cleanup somehow |
362 | -- need to investigate the required PCMCIA magic */ | 392 | -- need to investigate the required PCMCIA magic */ |
363 | ide_unregister(info->hd); | 393 | ide_unregister(hwif->index); |
364 | } | 394 | } |
365 | info->ndev = 0; | 395 | info->ndev = 0; |
366 | 396 | ||
diff --git a/drivers/ide/legacy/ide_platform.c b/drivers/ide/legacy/ide_platform.c index bf240775531e..822f48b05c70 100644 --- a/drivers/ide/legacy/ide_platform.c +++ b/drivers/ide/legacy/ide_platform.c | |||
@@ -100,7 +100,6 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) | |||
100 | hw.dev = &pdev->dev; | 100 | hw.dev = &pdev->dev; |
101 | 101 | ||
102 | ide_init_port_hw(hwif, &hw); | 102 | ide_init_port_hw(hwif, &hw); |
103 | hwif->mmio = 1; | ||
104 | 103 | ||
105 | if (mmio) | 104 | if (mmio) |
106 | default_hwif_mmiops(hwif); | 105 | default_hwif_mmiops(hwif); |
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c index 7429b80cb089..26546d0afc7f 100644 --- a/drivers/ide/legacy/macide.c +++ b/drivers/ide/legacy/macide.c | |||
@@ -128,8 +128,6 @@ static int __init macide_init(void) | |||
128 | ide_init_port_data(hwif, index); | 128 | ide_init_port_data(hwif, index); |
129 | ide_init_port_hw(hwif, &hw); | 129 | ide_init_port_hw(hwif, &hw); |
130 | 130 | ||
131 | hwif->mmio = 1; | ||
132 | |||
133 | ide_device_add(idx, NULL); | 131 | ide_device_add(idx, NULL); |
134 | } | 132 | } |
135 | 133 | ||
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c index fcbff0eced1b..f23999dd3d46 100644 --- a/drivers/ide/legacy/q40ide.c +++ b/drivers/ide/legacy/q40ide.c | |||
@@ -141,7 +141,6 @@ static int __init q40ide_init(void) | |||
141 | if (hwif) { | 141 | if (hwif) { |
142 | ide_init_port_data(hwif, hwif->index); | 142 | ide_init_port_data(hwif, hwif->index); |
143 | ide_init_port_hw(hwif, &hw); | 143 | ide_init_port_hw(hwif, &hw); |
144 | hwif->mmio = 1; | ||
145 | 144 | ||
146 | idx[i] = hwif->index; | 145 | idx[i] = hwif->index; |
147 | } | 146 | } |
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c index 6e820c7c5c6b..15a99aae0cf9 100644 --- a/drivers/ide/legacy/qd65xx.c +++ b/drivers/ide/legacy/qd65xx.c | |||
@@ -37,6 +37,8 @@ | |||
37 | #include <asm/system.h> | 37 | #include <asm/system.h> |
38 | #include <asm/io.h> | 38 | #include <asm/io.h> |
39 | 39 | ||
40 | #define DRV_NAME "qd65xx" | ||
41 | |||
40 | #include "qd65xx.h" | 42 | #include "qd65xx.h" |
41 | 43 | ||
42 | /* | 44 | /* |
@@ -304,7 +306,20 @@ static void __init qd6580_port_init_devs(ide_hwif_t *hwif) | |||
304 | hwif->drives[1].drive_data = t2; | 306 | hwif->drives[1].drive_data = t2; |
305 | } | 307 | } |
306 | 308 | ||
309 | static const struct ide_port_ops qd6500_port_ops = { | ||
310 | .port_init_devs = qd6500_port_init_devs, | ||
311 | .set_pio_mode = qd6500_set_pio_mode, | ||
312 | .selectproc = qd65xx_select, | ||
313 | }; | ||
314 | |||
315 | static const struct ide_port_ops qd6580_port_ops = { | ||
316 | .port_init_devs = qd6580_port_init_devs, | ||
317 | .set_pio_mode = qd6580_set_pio_mode, | ||
318 | .selectproc = qd65xx_select, | ||
319 | }; | ||
320 | |||
307 | static const struct ide_port_info qd65xx_port_info __initdata = { | 321 | static const struct ide_port_info qd65xx_port_info __initdata = { |
322 | .name = DRV_NAME, | ||
308 | .chipset = ide_qd65xx, | 323 | .chipset = ide_qd65xx, |
309 | .host_flags = IDE_HFLAG_IO_32BIT | | 324 | .host_flags = IDE_HFLAG_IO_32BIT | |
310 | IDE_HFLAG_NO_DMA | | 325 | IDE_HFLAG_NO_DMA | |
@@ -321,10 +336,8 @@ static const struct ide_port_info qd65xx_port_info __initdata = { | |||
321 | 336 | ||
322 | static int __init qd_probe(int base) | 337 | static int __init qd_probe(int base) |
323 | { | 338 | { |
324 | ide_hwif_t *hwif; | 339 | int rc; |
325 | u8 config, unit; | 340 | u8 config, unit, control; |
326 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
327 | hw_regs_t hw[2]; | ||
328 | struct ide_port_info d = qd65xx_port_info; | 341 | struct ide_port_info d = qd65xx_port_info; |
329 | 342 | ||
330 | config = inb(QD_CONFIG_PORT); | 343 | config = inb(QD_CONFIG_PORT); |
@@ -337,21 +350,11 @@ static int __init qd_probe(int base) | |||
337 | if (unit) | 350 | if (unit) |
338 | d.host_flags |= IDE_HFLAG_QD_2ND_PORT; | 351 | d.host_flags |= IDE_HFLAG_QD_2ND_PORT; |
339 | 352 | ||
340 | memset(&hw, 0, sizeof(hw)); | 353 | switch (config & 0xf0) { |
341 | 354 | case QD_CONFIG_QD6500: | |
342 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | ||
343 | hw[0].irq = 14; | ||
344 | |||
345 | ide_std_init_ports(&hw[1], 0x170, 0x376); | ||
346 | hw[1].irq = 15; | ||
347 | |||
348 | if ((config & 0xf0) == QD_CONFIG_QD6500) { | ||
349 | |||
350 | if (qd_testreg(base)) | 355 | if (qd_testreg(base)) |
351 | return -ENODEV; /* bad register */ | 356 | return -ENODEV; /* bad register */ |
352 | 357 | ||
353 | /* qd6500 found */ | ||
354 | |||
355 | if (config & QD_CONFIG_DISABLED) { | 358 | if (config & QD_CONFIG_DISABLED) { |
356 | printk(KERN_WARNING "qd6500 is disabled !\n"); | 359 | printk(KERN_WARNING "qd6500 is disabled !\n"); |
357 | return -ENODEV; | 360 | return -ENODEV; |
@@ -361,37 +364,14 @@ static int __init qd_probe(int base) | |||
361 | printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n", | 364 | printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n", |
362 | config, QD_ID3); | 365 | config, QD_ID3); |
363 | 366 | ||
367 | d.port_ops = &qd6500_port_ops; | ||
364 | d.host_flags |= IDE_HFLAG_SINGLE; | 368 | d.host_flags |= IDE_HFLAG_SINGLE; |
365 | 369 | break; | |
366 | hwif = ide_find_port_slot(&d); | 370 | case QD_CONFIG_QD6580_A: |
367 | if (hwif == NULL) | 371 | case QD_CONFIG_QD6580_B: |
368 | return -ENOENT; | ||
369 | |||
370 | ide_init_port_hw(hwif, &hw[unit]); | ||
371 | |||
372 | hwif->config_data = (base << 8) | config; | ||
373 | |||
374 | hwif->port_init_devs = qd6500_port_init_devs; | ||
375 | hwif->set_pio_mode = qd6500_set_pio_mode; | ||
376 | hwif->selectproc = qd65xx_select; | ||
377 | |||
378 | idx[unit] = hwif->index; | ||
379 | |||
380 | ide_device_add(idx, &d); | ||
381 | |||
382 | return 1; | ||
383 | } | ||
384 | |||
385 | if (((config & 0xf0) == QD_CONFIG_QD6580_A) || | ||
386 | ((config & 0xf0) == QD_CONFIG_QD6580_B)) { | ||
387 | |||
388 | u8 control; | ||
389 | |||
390 | if (qd_testreg(base) || qd_testreg(base + 0x02)) | 372 | if (qd_testreg(base) || qd_testreg(base + 0x02)) |
391 | return -ENODEV; /* bad registers */ | 373 | return -ENODEV; /* bad registers */ |
392 | 374 | ||
393 | /* qd6580 found */ | ||
394 | |||
395 | control = inb(QD_CONTROL_PORT); | 375 | control = inb(QD_CONTROL_PORT); |
396 | 376 | ||
397 | printk(KERN_NOTICE "qd6580 at %#x\n", base); | 377 | printk(KERN_NOTICE "qd6580 at %#x\n", base); |
@@ -400,63 +380,23 @@ static int __init qd_probe(int base) | |||
400 | 380 | ||
401 | outb(QD_DEF_CONTR, QD_CONTROL_PORT); | 381 | outb(QD_DEF_CONTR, QD_CONTROL_PORT); |
402 | 382 | ||
403 | if (control & QD_CONTR_SEC_DISABLED) { | 383 | d.port_ops = &qd6580_port_ops; |
404 | /* secondary disabled */ | 384 | if (control & QD_CONTR_SEC_DISABLED) |
405 | |||
406 | printk(KERN_INFO "qd6580: single IDE board\n"); | ||
407 | |||
408 | d.host_flags |= IDE_HFLAG_SINGLE; | 385 | d.host_flags |= IDE_HFLAG_SINGLE; |
409 | 386 | ||
410 | hwif = ide_find_port_slot(&d); | 387 | printk(KERN_INFO "qd6580: %s IDE board\n", |
411 | if (hwif == NULL) | 388 | (control & QD_CONTR_SEC_DISABLED) ? "single" : "dual"); |
412 | return -ENOENT; | 389 | break; |
413 | 390 | default: | |
414 | ide_init_port_hw(hwif, &hw[unit]); | 391 | return -ENODEV; |
415 | 392 | } | |
416 | hwif->config_data = (base << 8) | config; | ||
417 | |||
418 | hwif->port_init_devs = qd6580_port_init_devs; | ||
419 | hwif->set_pio_mode = qd6580_set_pio_mode; | ||
420 | hwif->selectproc = qd65xx_select; | ||
421 | 393 | ||
422 | idx[unit] = hwif->index; | 394 | rc = ide_legacy_device_add(&d, (base << 8) | config); |
423 | 395 | ||
424 | ide_device_add(idx, &d); | 396 | if (d.host_flags & IDE_HFLAG_SINGLE) |
397 | return (rc == 0) ? 1 : rc; | ||
425 | 398 | ||
426 | return 1; | 399 | return rc; |
427 | } else { | ||
428 | ide_hwif_t *mate; | ||
429 | |||
430 | /* secondary enabled */ | ||
431 | printk(KERN_INFO "qd6580: dual IDE board\n"); | ||
432 | |||
433 | hwif = ide_find_port(); | ||
434 | if (hwif) { | ||
435 | ide_init_port_hw(hwif, &hw[0]); | ||
436 | hwif->config_data = (base << 8) | config; | ||
437 | hwif->port_init_devs = qd6580_port_init_devs; | ||
438 | hwif->set_pio_mode = qd6580_set_pio_mode; | ||
439 | hwif->selectproc = qd65xx_select; | ||
440 | idx[0] = hwif->index; | ||
441 | } | ||
442 | |||
443 | mate = ide_find_port(); | ||
444 | if (mate) { | ||
445 | ide_init_port_hw(mate, &hw[1]); | ||
446 | mate->config_data = (base << 8) | config; | ||
447 | mate->port_init_devs = qd6580_port_init_devs; | ||
448 | mate->set_pio_mode = qd6580_set_pio_mode; | ||
449 | mate->selectproc = qd65xx_select; | ||
450 | idx[1] = mate->index; | ||
451 | } | ||
452 | |||
453 | ide_device_add(idx, &qd65xx_port_info); | ||
454 | |||
455 | return 0; /* no other qd65xx possible */ | ||
456 | } | ||
457 | } | ||
458 | /* no qd65xx found */ | ||
459 | return -ENODEV; | ||
460 | } | 400 | } |
461 | 401 | ||
462 | int probe_qd65xx = 0; | 402 | int probe_qd65xx = 0; |
diff --git a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c index 4d90badd2bda..17d515329fe0 100644 --- a/drivers/ide/legacy/umc8672.c +++ b/drivers/ide/legacy/umc8672.c | |||
@@ -51,6 +51,8 @@ | |||
51 | 51 | ||
52 | #include <asm/io.h> | 52 | #include <asm/io.h> |
53 | 53 | ||
54 | #define DRV_NAME "umc8672" | ||
55 | |||
54 | /* | 56 | /* |
55 | * Default speeds. These can be changed with "auto-tune" and/or hdparm. | 57 | * Default speeds. These can be changed with "auto-tune" and/or hdparm. |
56 | */ | 58 | */ |
@@ -120,18 +122,21 @@ static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
120 | spin_unlock_irqrestore(&ide_lock, flags); | 122 | spin_unlock_irqrestore(&ide_lock, flags); |
121 | } | 123 | } |
122 | 124 | ||
125 | static const struct ide_port_ops umc8672_port_ops = { | ||
126 | .set_pio_mode = umc_set_pio_mode, | ||
127 | }; | ||
128 | |||
123 | static const struct ide_port_info umc8672_port_info __initdata = { | 129 | static const struct ide_port_info umc8672_port_info __initdata = { |
130 | .name = DRV_NAME, | ||
124 | .chipset = ide_umc8672, | 131 | .chipset = ide_umc8672, |
132 | .port_ops = &umc8672_port_ops, | ||
125 | .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE, | 133 | .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE, |
126 | .pio_mask = ATA_PIO4, | 134 | .pio_mask = ATA_PIO4, |
127 | }; | 135 | }; |
128 | 136 | ||
129 | static int __init umc8672_probe(void) | 137 | static int __init umc8672_probe(void) |
130 | { | 138 | { |
131 | ide_hwif_t *hwif, *mate; | ||
132 | unsigned long flags; | 139 | unsigned long flags; |
133 | static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
134 | hw_regs_t hw[2]; | ||
135 | 140 | ||
136 | if (!request_region(0x108, 2, "umc8672")) { | 141 | if (!request_region(0x108, 2, "umc8672")) { |
137 | printk(KERN_ERR "umc8672: ports 0x108-0x109 already in use.\n"); | 142 | printk(KERN_ERR "umc8672: ports 0x108-0x109 already in use.\n"); |
@@ -150,31 +155,7 @@ static int __init umc8672_probe(void) | |||
150 | umc_set_speeds(current_speeds); | 155 | umc_set_speeds(current_speeds); |
151 | local_irq_restore(flags); | 156 | local_irq_restore(flags); |
152 | 157 | ||
153 | memset(&hw, 0, sizeof(hw)); | 158 | return ide_legacy_device_add(&umc8672_port_info, 0); |
154 | |||
155 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | ||
156 | hw[0].irq = 14; | ||
157 | |||
158 | ide_std_init_ports(&hw[1], 0x170, 0x376); | ||
159 | hw[1].irq = 15; | ||
160 | |||
161 | hwif = ide_find_port(); | ||
162 | if (hwif) { | ||
163 | ide_init_port_hw(hwif, &hw[0]); | ||
164 | hwif->set_pio_mode = umc_set_pio_mode; | ||
165 | idx[0] = hwif->index; | ||
166 | } | ||
167 | |||
168 | mate = ide_find_port(); | ||
169 | if (mate) { | ||
170 | ide_init_port_hw(mate, &hw[1]); | ||
171 | mate->set_pio_mode = umc_set_pio_mode; | ||
172 | idx[1] = mate->index; | ||
173 | } | ||
174 | |||
175 | ide_device_add(idx, &umc8672_port_info); | ||
176 | |||
177 | return 0; | ||
178 | } | 159 | } |
179 | 160 | ||
180 | int probe_umc8672; | 161 | int probe_umc8672; |
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c index a8cd0035936d..3485a310c95b 100644 --- a/drivers/ide/mips/au1xxx-ide.c +++ b/drivers/ide/mips/au1xxx-ide.c | |||
@@ -47,7 +47,6 @@ | |||
47 | #define IDE_AU1XXX_BURSTMODE 1 | 47 | #define IDE_AU1XXX_BURSTMODE 1 |
48 | 48 | ||
49 | static _auide_hwif auide_hwif; | 49 | static _auide_hwif auide_hwif; |
50 | static int dbdma_init_done; | ||
51 | 50 | ||
52 | static int auide_ddma_init(_auide_hwif *auide); | 51 | static int auide_ddma_init(_auide_hwif *auide); |
53 | 52 | ||
@@ -61,7 +60,7 @@ void auide_insw(unsigned long port, void *addr, u32 count) | |||
61 | 60 | ||
62 | if(!put_dest_flags(ahwif->rx_chan, (void*)addr, count << 1, | 61 | if(!put_dest_flags(ahwif->rx_chan, (void*)addr, count << 1, |
63 | DDMA_FLAGS_NOIE)) { | 62 | DDMA_FLAGS_NOIE)) { |
64 | printk(KERN_ERR "%s failed %d\n", __FUNCTION__, __LINE__); | 63 | printk(KERN_ERR "%s failed %d\n", __func__, __LINE__); |
65 | return; | 64 | return; |
66 | } | 65 | } |
67 | ctp = *((chan_tab_t **)ahwif->rx_chan); | 66 | ctp = *((chan_tab_t **)ahwif->rx_chan); |
@@ -79,7 +78,7 @@ void auide_outsw(unsigned long port, void *addr, u32 count) | |||
79 | 78 | ||
80 | if(!put_source_flags(ahwif->tx_chan, (void*)addr, | 79 | if(!put_source_flags(ahwif->tx_chan, (void*)addr, |
81 | count << 1, DDMA_FLAGS_NOIE)) { | 80 | count << 1, DDMA_FLAGS_NOIE)) { |
82 | printk(KERN_ERR "%s failed %d\n", __FUNCTION__, __LINE__); | 81 | printk(KERN_ERR "%s failed %d\n", __func__, __LINE__); |
83 | return; | 82 | return; |
84 | } | 83 | } |
85 | ctp = *((chan_tab_t **)ahwif->tx_chan); | 84 | ctp = *((chan_tab_t **)ahwif->tx_chan); |
@@ -250,7 +249,7 @@ static int auide_build_dmatable(ide_drive_t *drive) | |||
250 | (void*) sg_virt(sg), | 249 | (void*) sg_virt(sg), |
251 | tc, flags)) { | 250 | tc, flags)) { |
252 | printk(KERN_ERR "%s failed %d\n", | 251 | printk(KERN_ERR "%s failed %d\n", |
253 | __FUNCTION__, __LINE__); | 252 | __func__, __LINE__); |
254 | } | 253 | } |
255 | } else | 254 | } else |
256 | { | 255 | { |
@@ -258,7 +257,7 @@ static int auide_build_dmatable(ide_drive_t *drive) | |||
258 | (void*) sg_virt(sg), | 257 | (void*) sg_virt(sg), |
259 | tc, flags)) { | 258 | tc, flags)) { |
260 | printk(KERN_ERR "%s failed %d\n", | 259 | printk(KERN_ERR "%s failed %d\n", |
261 | __FUNCTION__, __LINE__); | 260 | __func__, __LINE__); |
262 | } | 261 | } |
263 | } | 262 | } |
264 | 263 | ||
@@ -315,35 +314,6 @@ static int auide_dma_setup(ide_drive_t *drive) | |||
315 | return 0; | 314 | return 0; |
316 | } | 315 | } |
317 | 316 | ||
318 | static u8 auide_mdma_filter(ide_drive_t *drive) | ||
319 | { | ||
320 | /* | ||
321 | * FIXME: ->white_list and ->black_list are based on completely bogus | ||
322 | * ->ide_dma_check implementation which didn't set neither the host | ||
323 | * controller timings nor the device for the desired transfer mode. | ||
324 | * | ||
325 | * They should be either removed or 0x00 MWDMA mask should be | ||
326 | * returned for devices on the ->black_list. | ||
327 | */ | ||
328 | |||
329 | if (dbdma_init_done == 0) { | ||
330 | auide_hwif.white_list = ide_in_drive_list(drive->id, | ||
331 | dma_white_list); | ||
332 | auide_hwif.black_list = ide_in_drive_list(drive->id, | ||
333 | dma_black_list); | ||
334 | auide_hwif.drive = drive; | ||
335 | auide_ddma_init(&auide_hwif); | ||
336 | dbdma_init_done = 1; | ||
337 | } | ||
338 | |||
339 | /* Is the drive in our DMA black list? */ | ||
340 | if (auide_hwif.black_list) | ||
341 | printk(KERN_WARNING "%s: Disabling DMA for %s (blacklisted)\n", | ||
342 | drive->name, drive->id->model); | ||
343 | |||
344 | return drive->hwif->mwdma_mask; | ||
345 | } | ||
346 | |||
347 | static int auide_dma_test_irq(ide_drive_t *drive) | 317 | static int auide_dma_test_irq(ide_drive_t *drive) |
348 | { | 318 | { |
349 | if (drive->waiting_for_dma == 0) | 319 | if (drive->waiting_for_dma == 0) |
@@ -396,41 +366,41 @@ static void auide_init_dbdma_dev(dbdev_tab_t *dev, u32 dev_id, u32 tsize, u32 de | |||
396 | dev->dev_devwidth = devwidth; | 366 | dev->dev_devwidth = devwidth; |
397 | dev->dev_flags = flags; | 367 | dev->dev_flags = flags; |
398 | } | 368 | } |
399 | |||
400 | #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) | ||
401 | 369 | ||
370 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | ||
402 | static void auide_dma_timeout(ide_drive_t *drive) | 371 | static void auide_dma_timeout(ide_drive_t *drive) |
403 | { | 372 | { |
404 | ide_hwif_t *hwif = HWIF(drive); | 373 | ide_hwif_t *hwif = HWIF(drive); |
405 | 374 | ||
406 | printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name); | 375 | printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name); |
407 | 376 | ||
408 | if (hwif->ide_dma_test_irq(drive)) | 377 | if (auide_dma_test_irq(drive)) |
409 | return; | 378 | return; |
410 | 379 | ||
411 | hwif->ide_dma_end(drive); | 380 | auide_dma_end(drive); |
412 | } | 381 | } |
413 | |||
414 | 382 | ||
415 | static int auide_ddma_init(_auide_hwif *auide) { | 383 | static const struct ide_dma_ops au1xxx_dma_ops = { |
416 | 384 | .dma_host_set = auide_dma_host_set, | |
385 | .dma_setup = auide_dma_setup, | ||
386 | .dma_exec_cmd = auide_dma_exec_cmd, | ||
387 | .dma_start = auide_dma_start, | ||
388 | .dma_end = auide_dma_end, | ||
389 | .dma_test_irq = auide_dma_test_irq, | ||
390 | .dma_lost_irq = auide_dma_lost_irq, | ||
391 | .dma_timeout = auide_dma_timeout, | ||
392 | }; | ||
393 | |||
394 | static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d) | ||
395 | { | ||
396 | _auide_hwif *auide = (_auide_hwif *)hwif->hwif_data; | ||
417 | dbdev_tab_t source_dev_tab, target_dev_tab; | 397 | dbdev_tab_t source_dev_tab, target_dev_tab; |
418 | u32 dev_id, tsize, devwidth, flags; | 398 | u32 dev_id, tsize, devwidth, flags; |
419 | ide_hwif_t *hwif = auide->hwif; | ||
420 | 399 | ||
421 | dev_id = AU1XXX_ATA_DDMA_REQ; | 400 | dev_id = AU1XXX_ATA_DDMA_REQ; |
422 | 401 | ||
423 | if (auide->white_list || auide->black_list) { | 402 | tsize = 8; /* 1 */ |
424 | tsize = 8; | 403 | devwidth = 32; /* 16 */ |
425 | devwidth = 32; | ||
426 | } | ||
427 | else { | ||
428 | tsize = 1; | ||
429 | devwidth = 16; | ||
430 | |||
431 | printk(KERN_ERR "au1xxx-ide: %s is not on ide driver whitelist.\n",auide_hwif.drive->id->model); | ||
432 | printk(KERN_ERR " please read 'Documentation/mips/AU1xxx_IDE.README'"); | ||
433 | } | ||
434 | 404 | ||
435 | #ifdef IDE_AU1XXX_BURSTMODE | 405 | #ifdef IDE_AU1XXX_BURSTMODE |
436 | flags = DEV_FLAGS_SYNC | DEV_FLAGS_BURSTABLE; | 406 | flags = DEV_FLAGS_SYNC | DEV_FLAGS_BURSTABLE; |
@@ -482,9 +452,9 @@ static int auide_ddma_init(_auide_hwif *auide) { | |||
482 | return 0; | 452 | return 0; |
483 | } | 453 | } |
484 | #else | 454 | #else |
485 | 455 | static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d) | |
486 | static int auide_ddma_init( _auide_hwif *auide ) | ||
487 | { | 456 | { |
457 | _auide_hwif *auide = (_auide_hwif *)hwif->hwif_data; | ||
488 | dbdev_tab_t source_dev_tab; | 458 | dbdev_tab_t source_dev_tab; |
489 | int flags; | 459 | int flags; |
490 | 460 | ||
@@ -543,9 +513,18 @@ static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif) | |||
543 | *ata_regs = ahwif->regbase + (14 << AU1XXX_ATA_REG_OFFSET); | 513 | *ata_regs = ahwif->regbase + (14 << AU1XXX_ATA_REG_OFFSET); |
544 | } | 514 | } |
545 | 515 | ||
516 | static const struct ide_port_ops au1xxx_port_ops = { | ||
517 | .set_pio_mode = au1xxx_set_pio_mode, | ||
518 | .set_dma_mode = auide_set_dma_mode, | ||
519 | }; | ||
520 | |||
546 | static const struct ide_port_info au1xxx_port_info = { | 521 | static const struct ide_port_info au1xxx_port_info = { |
522 | .init_dma = auide_ddma_init, | ||
523 | .port_ops = &au1xxx_port_ops, | ||
524 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | ||
525 | .dma_ops = &au1xxx_dma_ops, | ||
526 | #endif | ||
547 | .host_flags = IDE_HFLAG_POST_SET_MODE | | 527 | .host_flags = IDE_HFLAG_POST_SET_MODE | |
548 | IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ | ||
549 | IDE_HFLAG_NO_IO_32BIT | | 528 | IDE_HFLAG_NO_IO_32BIT | |
550 | IDE_HFLAG_UNMASK_IRQS, | 529 | IDE_HFLAG_UNMASK_IRQS, |
551 | .pio_mask = ATA_PIO4, | 530 | .pio_mask = ATA_PIO4, |
@@ -615,8 +594,6 @@ static int au_ide_probe(struct device *dev) | |||
615 | 594 | ||
616 | hwif->dev = dev; | 595 | hwif->dev = dev; |
617 | 596 | ||
618 | hwif->mmio = 1; | ||
619 | |||
620 | /* If the user has selected DDMA assisted copies, | 597 | /* If the user has selected DDMA assisted copies, |
621 | then set up a few local I/O function entry points | 598 | then set up a few local I/O function entry points |
622 | */ | 599 | */ |
@@ -625,34 +602,12 @@ static int au_ide_probe(struct device *dev) | |||
625 | hwif->INSW = auide_insw; | 602 | hwif->INSW = auide_insw; |
626 | hwif->OUTSW = auide_outsw; | 603 | hwif->OUTSW = auide_outsw; |
627 | #endif | 604 | #endif |
628 | |||
629 | hwif->set_pio_mode = &au1xxx_set_pio_mode; | ||
630 | hwif->set_dma_mode = &auide_set_dma_mode; | ||
631 | |||
632 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | ||
633 | hwif->dma_timeout = &auide_dma_timeout; | ||
634 | |||
635 | hwif->mdma_filter = &auide_mdma_filter; | ||
636 | |||
637 | hwif->dma_host_set = &auide_dma_host_set; | ||
638 | hwif->dma_exec_cmd = &auide_dma_exec_cmd; | ||
639 | hwif->dma_start = &auide_dma_start; | ||
640 | hwif->ide_dma_end = &auide_dma_end; | ||
641 | hwif->dma_setup = &auide_dma_setup; | ||
642 | hwif->ide_dma_test_irq = &auide_dma_test_irq; | ||
643 | hwif->dma_lost_irq = &auide_dma_lost_irq; | ||
644 | #endif | ||
645 | hwif->select_data = 0; /* no chipset-specific code */ | 605 | hwif->select_data = 0; /* no chipset-specific code */ |
646 | hwif->config_data = 0; /* no chipset-specific code */ | 606 | hwif->config_data = 0; /* no chipset-specific code */ |
647 | 607 | ||
648 | auide_hwif.hwif = hwif; | 608 | auide_hwif.hwif = hwif; |
649 | hwif->hwif_data = &auide_hwif; | 609 | hwif->hwif_data = &auide_hwif; |
650 | 610 | ||
651 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA | ||
652 | auide_ddma_init(&auide_hwif); | ||
653 | dbdma_init_done = 1; | ||
654 | #endif | ||
655 | |||
656 | idx[0] = hwif->index; | 611 | idx[0] = hwif->index; |
657 | 612 | ||
658 | ide_device_add(idx, &au1xxx_port_info); | 613 | ide_device_add(idx, &au1xxx_port_info); |
diff --git a/drivers/ide/mips/swarm.c b/drivers/ide/mips/swarm.c index bbe8d5853348..112fe566bb93 100644 --- a/drivers/ide/mips/swarm.c +++ b/drivers/ide/mips/swarm.c | |||
@@ -110,10 +110,8 @@ static int __devinit swarm_ide_probe(struct device *dev) | |||
110 | 110 | ||
111 | /* Setup MMIO ops. */ | 111 | /* Setup MMIO ops. */ |
112 | default_hwif_mmiops(hwif); | 112 | default_hwif_mmiops(hwif); |
113 | /* Prevent resource map manipulation. */ | 113 | |
114 | hwif->mmio = 1; | ||
115 | hwif->chipset = ide_generic; | 114 | hwif->chipset = ide_generic; |
116 | hwif->noprobe = 0; | ||
117 | 115 | ||
118 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) | 116 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) |
119 | hwif->io_ports[i] = | 117 | hwif->io_ports[i] = |
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c index c9ba15afe97d..ca16f37f9486 100644 --- a/drivers/ide/pci/aec62xx.c +++ b/drivers/ide/pci/aec62xx.c | |||
@@ -135,7 +135,7 @@ static void aec6260_set_mode(ide_drive_t *drive, const u8 speed) | |||
135 | 135 | ||
136 | static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio) | 136 | static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio) |
137 | { | 137 | { |
138 | drive->hwif->set_dma_mode(drive, pio + XFER_PIO_0); | 138 | drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0); |
139 | } | 139 | } |
140 | 140 | ||
141 | static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name) | 141 | static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name) |
@@ -175,27 +175,23 @@ static u8 __devinit atp86x_cable_detect(ide_hwif_t *hwif) | |||
175 | return (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | 175 | return (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; |
176 | } | 176 | } |
177 | 177 | ||
178 | static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) | 178 | static const struct ide_port_ops atp850_port_ops = { |
179 | { | 179 | .set_pio_mode = aec_set_pio_mode, |
180 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 180 | .set_dma_mode = aec6210_set_mode, |
181 | 181 | }; | |
182 | hwif->set_pio_mode = &aec_set_pio_mode; | ||
183 | |||
184 | if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) | ||
185 | hwif->set_dma_mode = &aec6210_set_mode; | ||
186 | else { | ||
187 | hwif->set_dma_mode = &aec6260_set_mode; | ||
188 | 182 | ||
189 | hwif->cable_detect = atp86x_cable_detect; | 183 | static const struct ide_port_ops atp86x_port_ops = { |
190 | } | 184 | .set_pio_mode = aec_set_pio_mode, |
191 | } | 185 | .set_dma_mode = aec6260_set_mode, |
186 | .cable_detect = atp86x_cable_detect, | ||
187 | }; | ||
192 | 188 | ||
193 | static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | 189 | static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { |
194 | { /* 0 */ | 190 | { /* 0 */ |
195 | .name = "AEC6210", | 191 | .name = "AEC6210", |
196 | .init_chipset = init_chipset_aec62xx, | 192 | .init_chipset = init_chipset_aec62xx, |
197 | .init_hwif = init_hwif_aec62xx, | ||
198 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, | 193 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, |
194 | .port_ops = &atp850_port_ops, | ||
199 | .host_flags = IDE_HFLAG_SERIALIZE | | 195 | .host_flags = IDE_HFLAG_SERIALIZE | |
200 | IDE_HFLAG_NO_ATAPI_DMA | | 196 | IDE_HFLAG_NO_ATAPI_DMA | |
201 | IDE_HFLAG_NO_DSC | | 197 | IDE_HFLAG_NO_DSC | |
@@ -207,7 +203,7 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
207 | },{ /* 1 */ | 203 | },{ /* 1 */ |
208 | .name = "AEC6260", | 204 | .name = "AEC6260", |
209 | .init_chipset = init_chipset_aec62xx, | 205 | .init_chipset = init_chipset_aec62xx, |
210 | .init_hwif = init_hwif_aec62xx, | 206 | .port_ops = &atp86x_port_ops, |
211 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA | | 207 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA | |
212 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | 208 | IDE_HFLAG_ABUSE_SET_DMA_MODE | |
213 | IDE_HFLAG_OFF_BOARD, | 209 | IDE_HFLAG_OFF_BOARD, |
@@ -217,8 +213,8 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
217 | },{ /* 2 */ | 213 | },{ /* 2 */ |
218 | .name = "AEC6260R", | 214 | .name = "AEC6260R", |
219 | .init_chipset = init_chipset_aec62xx, | 215 | .init_chipset = init_chipset_aec62xx, |
220 | .init_hwif = init_hwif_aec62xx, | ||
221 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, | 216 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, |
217 | .port_ops = &atp86x_port_ops, | ||
222 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | 218 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | |
223 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | 219 | IDE_HFLAG_ABUSE_SET_DMA_MODE | |
224 | IDE_HFLAG_NON_BOOTABLE, | 220 | IDE_HFLAG_NON_BOOTABLE, |
@@ -228,7 +224,7 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
228 | },{ /* 3 */ | 224 | },{ /* 3 */ |
229 | .name = "AEC6280", | 225 | .name = "AEC6280", |
230 | .init_chipset = init_chipset_aec62xx, | 226 | .init_chipset = init_chipset_aec62xx, |
231 | .init_hwif = init_hwif_aec62xx, | 227 | .port_ops = &atp86x_port_ops, |
232 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | 228 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | |
233 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | 229 | IDE_HFLAG_ABUSE_SET_DMA_MODE | |
234 | IDE_HFLAG_OFF_BOARD, | 230 | IDE_HFLAG_OFF_BOARD, |
@@ -238,8 +234,8 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { | |||
238 | },{ /* 4 */ | 234 | },{ /* 4 */ |
239 | .name = "AEC6280R", | 235 | .name = "AEC6280R", |
240 | .init_chipset = init_chipset_aec62xx, | 236 | .init_chipset = init_chipset_aec62xx, |
241 | .init_hwif = init_hwif_aec62xx, | ||
242 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, | 237 | .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, |
238 | .port_ops = &atp86x_port_ops, | ||
243 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | 239 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | |
244 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | 240 | IDE_HFLAG_ABUSE_SET_DMA_MODE | |
245 | IDE_HFLAG_OFF_BOARD, | 241 | IDE_HFLAG_OFF_BOARD, |
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index 3fa2d9f7b1b2..b5a3bc33e167 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c | |||
@@ -610,7 +610,7 @@ static int ali_cable_override(struct pci_dev *pdev) | |||
610 | } | 610 | } |
611 | 611 | ||
612 | /** | 612 | /** |
613 | * ata66_ali15x3 - check for UDMA 66 support | 613 | * ali_cable_detect - cable detection |
614 | * @hwif: IDE interface | 614 | * @hwif: IDE interface |
615 | * | 615 | * |
616 | * This checks if the controller and the cable are capable | 616 | * This checks if the controller and the cable are capable |
@@ -620,7 +620,7 @@ static int ali_cable_override(struct pci_dev *pdev) | |||
620 | * FIXME: frobs bits that are not defined on newer ALi devicea | 620 | * FIXME: frobs bits that are not defined on newer ALi devicea |
621 | */ | 621 | */ |
622 | 622 | ||
623 | static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif) | 623 | static u8 __devinit ali_cable_detect(ide_hwif_t *hwif) |
624 | { | 624 | { |
625 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 625 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
626 | unsigned long flags; | 626 | unsigned long flags; |
@@ -652,27 +652,7 @@ static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif) | |||
652 | return cbl; | 652 | return cbl; |
653 | } | 653 | } |
654 | 654 | ||
655 | /** | 655 | #ifndef CONFIG_SPARC64 |
656 | * init_hwif_common_ali15x3 - Set up ALI IDE hardware | ||
657 | * @hwif: IDE interface | ||
658 | * | ||
659 | * Initialize the IDE structure side of the ALi 15x3 driver. | ||
660 | */ | ||
661 | |||
662 | static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif) | ||
663 | { | ||
664 | hwif->set_pio_mode = &ali_set_pio_mode; | ||
665 | hwif->set_dma_mode = &ali_set_dma_mode; | ||
666 | hwif->udma_filter = &ali_udma_filter; | ||
667 | |||
668 | hwif->cable_detect = ata66_ali15x3; | ||
669 | |||
670 | if (hwif->dma_base == 0) | ||
671 | return; | ||
672 | |||
673 | hwif->dma_setup = &ali15x3_dma_setup; | ||
674 | } | ||
675 | |||
676 | /** | 656 | /** |
677 | * init_hwif_ali15x3 - Initialize the ALI IDE x86 stuff | 657 | * init_hwif_ali15x3 - Initialize the ALI IDE x86 stuff |
678 | * @hwif: interface to configure | 658 | * @hwif: interface to configure |
@@ -722,34 +702,66 @@ static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif) | |||
722 | if(irq >= 0) | 702 | if(irq >= 0) |
723 | hwif->irq = irq; | 703 | hwif->irq = irq; |
724 | } | 704 | } |
725 | |||
726 | init_hwif_common_ali15x3(hwif); | ||
727 | } | 705 | } |
706 | #endif | ||
728 | 707 | ||
729 | /** | 708 | /** |
730 | * init_dma_ali15x3 - set up DMA on ALi15x3 | 709 | * init_dma_ali15x3 - set up DMA on ALi15x3 |
731 | * @hwif: IDE interface | 710 | * @hwif: IDE interface |
732 | * @dmabase: DMA interface base PCI address | 711 | * @d: IDE port info |
733 | * | 712 | * |
734 | * Set up the DMA functionality on the ALi 15x3. For the ALi | 713 | * Set up the DMA functionality on the ALi 15x3. |
735 | * controllers this is generic so we can let the generic code do | ||
736 | * the actual work. | ||
737 | */ | 714 | */ |
738 | 715 | ||
739 | static void __devinit init_dma_ali15x3 (ide_hwif_t *hwif, unsigned long dmabase) | 716 | static int __devinit init_dma_ali15x3(ide_hwif_t *hwif, |
717 | const struct ide_port_info *d) | ||
740 | { | 718 | { |
741 | if (m5229_revision < 0x20) | 719 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
742 | return; | 720 | unsigned long base = ide_pci_dma_base(hwif, d); |
721 | |||
722 | if (base == 0 || ide_pci_set_master(dev, d->name) < 0) | ||
723 | return -1; | ||
724 | |||
743 | if (!hwif->channel) | 725 | if (!hwif->channel) |
744 | outb(inb(dmabase + 2) & 0x60, dmabase + 2); | 726 | outb(inb(base + 2) & 0x60, base + 2); |
745 | ide_setup_dma(hwif, dmabase); | 727 | |
728 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", | ||
729 | hwif->name, base, base + 7); | ||
730 | |||
731 | if (ide_allocate_dma_engine(hwif)) | ||
732 | return -1; | ||
733 | |||
734 | ide_setup_dma(hwif, base); | ||
735 | |||
736 | return 0; | ||
746 | } | 737 | } |
747 | 738 | ||
739 | static const struct ide_port_ops ali_port_ops = { | ||
740 | .set_pio_mode = ali_set_pio_mode, | ||
741 | .set_dma_mode = ali_set_dma_mode, | ||
742 | .udma_filter = ali_udma_filter, | ||
743 | .cable_detect = ali_cable_detect, | ||
744 | }; | ||
745 | |||
746 | static const struct ide_dma_ops ali_dma_ops = { | ||
747 | .dma_host_set = ide_dma_host_set, | ||
748 | .dma_setup = ali15x3_dma_setup, | ||
749 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
750 | .dma_start = ide_dma_start, | ||
751 | .dma_end = __ide_dma_end, | ||
752 | .dma_test_irq = ide_dma_test_irq, | ||
753 | .dma_lost_irq = ide_dma_lost_irq, | ||
754 | .dma_timeout = ide_dma_timeout, | ||
755 | }; | ||
756 | |||
748 | static const struct ide_port_info ali15x3_chipset __devinitdata = { | 757 | static const struct ide_port_info ali15x3_chipset __devinitdata = { |
749 | .name = "ALI15X3", | 758 | .name = "ALI15X3", |
750 | .init_chipset = init_chipset_ali15x3, | 759 | .init_chipset = init_chipset_ali15x3, |
760 | #ifndef CONFIG_SPARC64 | ||
751 | .init_hwif = init_hwif_ali15x3, | 761 | .init_hwif = init_hwif_ali15x3, |
762 | #endif | ||
752 | .init_dma = init_dma_ali15x3, | 763 | .init_dma = init_dma_ali15x3, |
764 | .port_ops = &ali_port_ops, | ||
753 | .pio_mask = ATA_PIO5, | 765 | .pio_mask = ATA_PIO5, |
754 | .swdma_mask = ATA_SWDMA2, | 766 | .swdma_mask = ATA_SWDMA2, |
755 | .mwdma_mask = ATA_MWDMA2, | 767 | .mwdma_mask = ATA_MWDMA2, |
@@ -792,14 +804,17 @@ static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_dev | |||
792 | d.udma_mask = ATA_UDMA5; | 804 | d.udma_mask = ATA_UDMA5; |
793 | else | 805 | else |
794 | d.udma_mask = ATA_UDMA6; | 806 | d.udma_mask = ATA_UDMA6; |
807 | |||
808 | d.dma_ops = &ali_dma_ops; | ||
809 | } else { | ||
810 | d.host_flags |= IDE_HFLAG_NO_DMA; | ||
811 | |||
812 | d.mwdma_mask = d.swdma_mask = 0; | ||
795 | } | 813 | } |
796 | 814 | ||
797 | if (idx == 0) | 815 | if (idx == 0) |
798 | d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; | 816 | d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; |
799 | 817 | ||
800 | #if defined(CONFIG_SPARC64) | ||
801 | d.init_hwif = init_hwif_common_ali15x3; | ||
802 | #endif /* CONFIG_SPARC64 */ | ||
803 | return ide_setup_pci_device(dev, &d); | 818 | return ide_setup_pci_device(dev, &d); |
804 | } | 819 | } |
805 | 820 | ||
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index ff684d312378..f7c883808b02 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c | |||
@@ -210,13 +210,14 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | |||
210 | 210 | ||
211 | if (hwif->irq == 0) /* 0 is bogus but will do for now */ | 211 | if (hwif->irq == 0) /* 0 is bogus but will do for now */ |
212 | hwif->irq = pci_get_legacy_ide_irq(dev, hwif->channel); | 212 | hwif->irq = pci_get_legacy_ide_irq(dev, hwif->channel); |
213 | |||
214 | hwif->set_pio_mode = &amd_set_pio_mode; | ||
215 | hwif->set_dma_mode = &amd_set_drive; | ||
216 | |||
217 | hwif->cable_detect = amd_cable_detect; | ||
218 | } | 213 | } |
219 | 214 | ||
215 | static const struct ide_port_ops amd_port_ops = { | ||
216 | .set_pio_mode = amd_set_pio_mode, | ||
217 | .set_dma_mode = amd_set_drive, | ||
218 | .cable_detect = amd_cable_detect, | ||
219 | }; | ||
220 | |||
220 | #define IDE_HFLAGS_AMD \ | 221 | #define IDE_HFLAGS_AMD \ |
221 | (IDE_HFLAG_PIO_NO_BLACKLIST | \ | 222 | (IDE_HFLAG_PIO_NO_BLACKLIST | \ |
222 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ | 223 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ |
@@ -230,6 +231,7 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | |||
230 | .init_chipset = init_chipset_amd74xx, \ | 231 | .init_chipset = init_chipset_amd74xx, \ |
231 | .init_hwif = init_hwif_amd74xx, \ | 232 | .init_hwif = init_hwif_amd74xx, \ |
232 | .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ | 233 | .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ |
234 | .port_ops = &amd_port_ops, \ | ||
233 | .host_flags = IDE_HFLAGS_AMD, \ | 235 | .host_flags = IDE_HFLAGS_AMD, \ |
234 | .pio_mask = ATA_PIO5, \ | 236 | .pio_mask = ATA_PIO5, \ |
235 | .swdma_mask = swdma, \ | 237 | .swdma_mask = swdma, \ |
@@ -243,6 +245,7 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | |||
243 | .init_chipset = init_chipset_amd74xx, \ | 245 | .init_chipset = init_chipset_amd74xx, \ |
244 | .init_hwif = init_hwif_amd74xx, \ | 246 | .init_hwif = init_hwif_amd74xx, \ |
245 | .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ | 247 | .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ |
248 | .port_ops = &amd_port_ops, \ | ||
246 | .host_flags = IDE_HFLAGS_AMD, \ | 249 | .host_flags = IDE_HFLAGS_AMD, \ |
247 | .pio_mask = ATA_PIO5, \ | 250 | .pio_mask = ATA_PIO5, \ |
248 | .swdma_mask = ATA_SWDMA2, \ | 251 | .swdma_mask = ATA_SWDMA2, \ |
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c index 91722f88b7bd..8b637181681a 100644 --- a/drivers/ide/pci/atiixp.c +++ b/drivers/ide/pci/atiixp.c | |||
@@ -130,35 +130,25 @@ static u8 __devinit atiixp_cable_detect(ide_hwif_t *hwif) | |||
130 | return ATA_CBL_PATA40; | 130 | return ATA_CBL_PATA40; |
131 | } | 131 | } |
132 | 132 | ||
133 | /** | 133 | static const struct ide_port_ops atiixp_port_ops = { |
134 | * init_hwif_atiixp - fill in the hwif for the ATIIXP | 134 | .set_pio_mode = atiixp_set_pio_mode, |
135 | * @hwif: IDE interface | 135 | .set_dma_mode = atiixp_set_dma_mode, |
136 | * | 136 | .cable_detect = atiixp_cable_detect, |
137 | * Set up the ide_hwif_t for the ATIIXP interface according to the | 137 | }; |
138 | * capabilities of the hardware. | ||
139 | */ | ||
140 | |||
141 | static void __devinit init_hwif_atiixp(ide_hwif_t *hwif) | ||
142 | { | ||
143 | hwif->set_pio_mode = &atiixp_set_pio_mode; | ||
144 | hwif->set_dma_mode = &atiixp_set_dma_mode; | ||
145 | |||
146 | hwif->cable_detect = atiixp_cable_detect; | ||
147 | } | ||
148 | 138 | ||
149 | static const struct ide_port_info atiixp_pci_info[] __devinitdata = { | 139 | static const struct ide_port_info atiixp_pci_info[] __devinitdata = { |
150 | { /* 0 */ | 140 | { /* 0 */ |
151 | .name = "ATIIXP", | 141 | .name = "ATIIXP", |
152 | .init_hwif = init_hwif_atiixp, | ||
153 | .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}}, | 142 | .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}}, |
143 | .port_ops = &atiixp_port_ops, | ||
154 | .host_flags = IDE_HFLAG_LEGACY_IRQS, | 144 | .host_flags = IDE_HFLAG_LEGACY_IRQS, |
155 | .pio_mask = ATA_PIO4, | 145 | .pio_mask = ATA_PIO4, |
156 | .mwdma_mask = ATA_MWDMA2, | 146 | .mwdma_mask = ATA_MWDMA2, |
157 | .udma_mask = ATA_UDMA5, | 147 | .udma_mask = ATA_UDMA5, |
158 | },{ /* 1 */ | 148 | },{ /* 1 */ |
159 | .name = "SB600_PATA", | 149 | .name = "SB600_PATA", |
160 | .init_hwif = init_hwif_atiixp, | ||
161 | .enablebits = {{0x48,0x01,0x00}, {0x00,0x00,0x00}}, | 150 | .enablebits = {{0x48,0x01,0x00}, {0x00,0x00,0x00}}, |
151 | .port_ops = &atiixp_port_ops, | ||
162 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_LEGACY_IRQS, | 152 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_LEGACY_IRQS, |
163 | .pio_mask = ATA_PIO4, | 153 | .pio_mask = ATA_PIO4, |
164 | .mwdma_mask = ATA_MWDMA2, | 154 | .mwdma_mask = ATA_MWDMA2, |
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c index b076dbfc43a7..25c2f1bd175f 100644 --- a/drivers/ide/pci/cmd640.c +++ b/drivers/ide/pci/cmd640.c | |||
@@ -109,6 +109,8 @@ | |||
109 | 109 | ||
110 | #include <asm/io.h> | 110 | #include <asm/io.h> |
111 | 111 | ||
112 | #define DRV_NAME "cmd640" | ||
113 | |||
112 | /* | 114 | /* |
113 | * This flag is set in ide.c by the parameter: ide0=cmd640_vlb | 115 | * This flag is set in ide.c by the parameter: ide0=cmd640_vlb |
114 | */ | 116 | */ |
@@ -633,6 +635,9 @@ static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
633 | display_clocks(index); | 635 | display_clocks(index); |
634 | } | 636 | } |
635 | 637 | ||
638 | static const struct ide_port_ops cmd640_port_ops = { | ||
639 | .set_pio_mode = cmd640_set_pio_mode, | ||
640 | }; | ||
636 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | 641 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ |
637 | 642 | ||
638 | static int pci_conf1(void) | 643 | static int pci_conf1(void) |
@@ -678,10 +683,29 @@ static const struct ide_port_info cmd640_port_info __initdata = { | |||
678 | IDE_HFLAG_ABUSE_PREFETCH | | 683 | IDE_HFLAG_ABUSE_PREFETCH | |
679 | IDE_HFLAG_ABUSE_FAST_DEVSEL, | 684 | IDE_HFLAG_ABUSE_FAST_DEVSEL, |
680 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | 685 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED |
686 | .port_ops = &cmd640_port_ops, | ||
681 | .pio_mask = ATA_PIO5, | 687 | .pio_mask = ATA_PIO5, |
682 | #endif | 688 | #endif |
683 | }; | 689 | }; |
684 | 690 | ||
691 | static int cmd640x_init_one(unsigned long base, unsigned long ctl) | ||
692 | { | ||
693 | if (!request_region(base, 8, DRV_NAME)) { | ||
694 | printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", | ||
695 | DRV_NAME, base, base + 7); | ||
696 | return -EBUSY; | ||
697 | } | ||
698 | |||
699 | if (!request_region(ctl, 1, DRV_NAME)) { | ||
700 | printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", | ||
701 | DRV_NAME, ctl); | ||
702 | release_region(base, 8); | ||
703 | return -EBUSY; | ||
704 | } | ||
705 | |||
706 | return 0; | ||
707 | } | ||
708 | |||
685 | /* | 709 | /* |
686 | * Probe for a cmd640 chipset, and initialize it if found. | 710 | * Probe for a cmd640 chipset, and initialize it if found. |
687 | */ | 711 | */ |
@@ -690,7 +714,7 @@ static int __init cmd640x_init(void) | |||
690 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | 714 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED |
691 | int second_port_toggled = 0; | 715 | int second_port_toggled = 0; |
692 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | 716 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ |
693 | int second_port_cmd640 = 0; | 717 | int second_port_cmd640 = 0, rc; |
694 | const char *bus_type, *port2; | 718 | const char *bus_type, *port2; |
695 | unsigned int index; | 719 | unsigned int index; |
696 | u8 b, cfr; | 720 | u8 b, cfr; |
@@ -734,6 +758,17 @@ static int __init cmd640x_init(void) | |||
734 | return 0; | 758 | return 0; |
735 | } | 759 | } |
736 | 760 | ||
761 | rc = cmd640x_init_one(0x1f0, 0x3f6); | ||
762 | if (rc) | ||
763 | return rc; | ||
764 | |||
765 | rc = cmd640x_init_one(0x170, 0x376); | ||
766 | if (rc) { | ||
767 | release_region(0x3f6, 1); | ||
768 | release_region(0x1f0, 8); | ||
769 | return rc; | ||
770 | } | ||
771 | |||
737 | memset(&hw, 0, sizeof(hw)); | 772 | memset(&hw, 0, sizeof(hw)); |
738 | 773 | ||
739 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | 774 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); |
@@ -752,10 +787,6 @@ static int __init cmd640x_init(void) | |||
752 | */ | 787 | */ |
753 | if (cmd_hwif0) { | 788 | if (cmd_hwif0) { |
754 | ide_init_port_hw(cmd_hwif0, &hw[0]); | 789 | ide_init_port_hw(cmd_hwif0, &hw[0]); |
755 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | ||
756 | cmd_hwif0->set_pio_mode = &cmd640_set_pio_mode; | ||
757 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | ||
758 | |||
759 | idx[0] = cmd_hwif0->index; | 790 | idx[0] = cmd_hwif0->index; |
760 | } | 791 | } |
761 | 792 | ||
@@ -808,10 +839,6 @@ static int __init cmd640x_init(void) | |||
808 | */ | 839 | */ |
809 | if (second_port_cmd640 && cmd_hwif1) { | 840 | if (second_port_cmd640 && cmd_hwif1) { |
810 | ide_init_port_hw(cmd_hwif1, &hw[1]); | 841 | ide_init_port_hw(cmd_hwif1, &hw[1]); |
811 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | ||
812 | cmd_hwif1->set_pio_mode = &cmd640_set_pio_mode; | ||
813 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | ||
814 | |||
815 | idx[1] = cmd_hwif1->index; | 842 | idx[1] = cmd_hwif1->index; |
816 | } | 843 | } |
817 | printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n", | 844 | printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n", |
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index 8baccfef237f..006fb62656bc 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c | |||
@@ -223,7 +223,7 @@ static void cmd64x_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
223 | (void) pci_write_config_byte(dev, pciU, regU); | 223 | (void) pci_write_config_byte(dev, pciU, regU); |
224 | } | 224 | } |
225 | 225 | ||
226 | static int cmd648_ide_dma_end (ide_drive_t *drive) | 226 | static int cmd648_dma_end(ide_drive_t *drive) |
227 | { | 227 | { |
228 | ide_hwif_t *hwif = HWIF(drive); | 228 | ide_hwif_t *hwif = HWIF(drive); |
229 | unsigned long base = hwif->dma_base - (hwif->channel * 8); | 229 | unsigned long base = hwif->dma_base - (hwif->channel * 8); |
@@ -239,7 +239,7 @@ static int cmd648_ide_dma_end (ide_drive_t *drive) | |||
239 | return err; | 239 | return err; |
240 | } | 240 | } |
241 | 241 | ||
242 | static int cmd64x_ide_dma_end (ide_drive_t *drive) | 242 | static int cmd64x_dma_end(ide_drive_t *drive) |
243 | { | 243 | { |
244 | ide_hwif_t *hwif = HWIF(drive); | 244 | ide_hwif_t *hwif = HWIF(drive); |
245 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 245 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -256,7 +256,7 @@ static int cmd64x_ide_dma_end (ide_drive_t *drive) | |||
256 | return err; | 256 | return err; |
257 | } | 257 | } |
258 | 258 | ||
259 | static int cmd648_ide_dma_test_irq (ide_drive_t *drive) | 259 | static int cmd648_dma_test_irq(ide_drive_t *drive) |
260 | { | 260 | { |
261 | ide_hwif_t *hwif = HWIF(drive); | 261 | ide_hwif_t *hwif = HWIF(drive); |
262 | unsigned long base = hwif->dma_base - (hwif->channel * 8); | 262 | unsigned long base = hwif->dma_base - (hwif->channel * 8); |
@@ -279,7 +279,7 @@ static int cmd648_ide_dma_test_irq (ide_drive_t *drive) | |||
279 | return 0; | 279 | return 0; |
280 | } | 280 | } |
281 | 281 | ||
282 | static int cmd64x_ide_dma_test_irq (ide_drive_t *drive) | 282 | static int cmd64x_dma_test_irq(ide_drive_t *drive) |
283 | { | 283 | { |
284 | ide_hwif_t *hwif = HWIF(drive); | 284 | ide_hwif_t *hwif = HWIF(drive); |
285 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 285 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -310,7 +310,7 @@ static int cmd64x_ide_dma_test_irq (ide_drive_t *drive) | |||
310 | * event order for DMA transfers. | 310 | * event order for DMA transfers. |
311 | */ | 311 | */ |
312 | 312 | ||
313 | static int cmd646_1_ide_dma_end (ide_drive_t *drive) | 313 | static int cmd646_1_dma_end(ide_drive_t *drive) |
314 | { | 314 | { |
315 | ide_hwif_t *hwif = HWIF(drive); | 315 | ide_hwif_t *hwif = HWIF(drive); |
316 | u8 dma_stat = 0, dma_cmd = 0; | 316 | u8 dma_stat = 0, dma_cmd = 0; |
@@ -370,7 +370,7 @@ static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const cha | |||
370 | return 0; | 370 | return 0; |
371 | } | 371 | } |
372 | 372 | ||
373 | static u8 __devinit ata66_cmd64x(ide_hwif_t *hwif) | 373 | static u8 __devinit cmd64x_cable_detect(ide_hwif_t *hwif) |
374 | { | 374 | { |
375 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 375 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
376 | u8 bmidecsr = 0, mask = hwif->channel ? 0x02 : 0x01; | 376 | u8 bmidecsr = 0, mask = hwif->channel ? 0x02 : 0x01; |
@@ -385,60 +385,52 @@ static u8 __devinit ata66_cmd64x(ide_hwif_t *hwif) | |||
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
388 | static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif) | 388 | static const struct ide_port_ops cmd64x_port_ops = { |
389 | { | 389 | .set_pio_mode = cmd64x_set_pio_mode, |
390 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 390 | .set_dma_mode = cmd64x_set_dma_mode, |
391 | 391 | .cable_detect = cmd64x_cable_detect, | |
392 | hwif->set_pio_mode = &cmd64x_set_pio_mode; | 392 | }; |
393 | hwif->set_dma_mode = &cmd64x_set_dma_mode; | ||
394 | |||
395 | hwif->cable_detect = ata66_cmd64x; | ||
396 | 393 | ||
397 | if (!hwif->dma_base) | 394 | static const struct ide_dma_ops cmd64x_dma_ops = { |
398 | return; | 395 | .dma_host_set = ide_dma_host_set, |
396 | .dma_setup = ide_dma_setup, | ||
397 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
398 | .dma_start = ide_dma_start, | ||
399 | .dma_end = cmd64x_dma_end, | ||
400 | .dma_test_irq = cmd64x_dma_test_irq, | ||
401 | .dma_lost_irq = ide_dma_lost_irq, | ||
402 | .dma_timeout = ide_dma_timeout, | ||
403 | }; | ||
399 | 404 | ||
400 | /* | 405 | static const struct ide_dma_ops cmd646_rev1_dma_ops = { |
401 | * UltraDMA only supported on PCI646U and PCI646U2, which | 406 | .dma_host_set = ide_dma_host_set, |
402 | * correspond to revisions 0x03, 0x05 and 0x07 respectively. | 407 | .dma_setup = ide_dma_setup, |
403 | * Actually, although the CMD tech support people won't | 408 | .dma_exec_cmd = ide_dma_exec_cmd, |
404 | * tell me the details, the 0x03 revision cannot support | 409 | .dma_start = ide_dma_start, |
405 | * UDMA correctly without hardware modifications, and even | 410 | .dma_end = cmd646_1_dma_end, |
406 | * then it only works with Quantum disks due to some | 411 | .dma_test_irq = ide_dma_test_irq, |
407 | * hold time assumptions in the 646U part which are fixed | 412 | .dma_lost_irq = ide_dma_lost_irq, |
408 | * in the 646U2. | 413 | .dma_timeout = ide_dma_timeout, |
409 | * | 414 | }; |
410 | * So we only do UltraDMA on revision 0x05 and 0x07 chipsets. | ||
411 | */ | ||
412 | if (dev->device == PCI_DEVICE_ID_CMD_646 && dev->revision < 5) | ||
413 | hwif->ultra_mask = 0x00; | ||
414 | 415 | ||
415 | switch (dev->device) { | 416 | static const struct ide_dma_ops cmd648_dma_ops = { |
416 | case PCI_DEVICE_ID_CMD_648: | 417 | .dma_host_set = ide_dma_host_set, |
417 | case PCI_DEVICE_ID_CMD_649: | 418 | .dma_setup = ide_dma_setup, |
418 | alt_irq_bits: | 419 | .dma_exec_cmd = ide_dma_exec_cmd, |
419 | hwif->ide_dma_end = &cmd648_ide_dma_end; | 420 | .dma_start = ide_dma_start, |
420 | hwif->ide_dma_test_irq = &cmd648_ide_dma_test_irq; | 421 | .dma_end = cmd648_dma_end, |
421 | break; | 422 | .dma_test_irq = cmd648_dma_test_irq, |
422 | case PCI_DEVICE_ID_CMD_646: | 423 | .dma_lost_irq = ide_dma_lost_irq, |
423 | if (dev->revision == 0x01) { | 424 | .dma_timeout = ide_dma_timeout, |
424 | hwif->ide_dma_end = &cmd646_1_ide_dma_end; | 425 | }; |
425 | break; | ||
426 | } else if (dev->revision >= 0x03) | ||
427 | goto alt_irq_bits; | ||
428 | /* fall thru */ | ||
429 | default: | ||
430 | hwif->ide_dma_end = &cmd64x_ide_dma_end; | ||
431 | hwif->ide_dma_test_irq = &cmd64x_ide_dma_test_irq; | ||
432 | break; | ||
433 | } | ||
434 | } | ||
435 | 426 | ||
436 | static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { | 427 | static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { |
437 | { /* 0 */ | 428 | { /* 0 */ |
438 | .name = "CMD643", | 429 | .name = "CMD643", |
439 | .init_chipset = init_chipset_cmd64x, | 430 | .init_chipset = init_chipset_cmd64x, |
440 | .init_hwif = init_hwif_cmd64x, | ||
441 | .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, | 431 | .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, |
432 | .port_ops = &cmd64x_port_ops, | ||
433 | .dma_ops = &cmd64x_dma_ops, | ||
442 | .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | | 434 | .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | |
443 | IDE_HFLAG_ABUSE_PREFETCH, | 435 | IDE_HFLAG_ABUSE_PREFETCH, |
444 | .pio_mask = ATA_PIO5, | 436 | .pio_mask = ATA_PIO5, |
@@ -447,9 +439,10 @@ static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { | |||
447 | },{ /* 1 */ | 439 | },{ /* 1 */ |
448 | .name = "CMD646", | 440 | .name = "CMD646", |
449 | .init_chipset = init_chipset_cmd64x, | 441 | .init_chipset = init_chipset_cmd64x, |
450 | .init_hwif = init_hwif_cmd64x, | ||
451 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 442 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
452 | .chipset = ide_cmd646, | 443 | .chipset = ide_cmd646, |
444 | .port_ops = &cmd64x_port_ops, | ||
445 | .dma_ops = &cmd648_dma_ops, | ||
453 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH, | 446 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH, |
454 | .pio_mask = ATA_PIO5, | 447 | .pio_mask = ATA_PIO5, |
455 | .mwdma_mask = ATA_MWDMA2, | 448 | .mwdma_mask = ATA_MWDMA2, |
@@ -457,8 +450,9 @@ static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { | |||
457 | },{ /* 2 */ | 450 | },{ /* 2 */ |
458 | .name = "CMD648", | 451 | .name = "CMD648", |
459 | .init_chipset = init_chipset_cmd64x, | 452 | .init_chipset = init_chipset_cmd64x, |
460 | .init_hwif = init_hwif_cmd64x, | ||
461 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 453 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
454 | .port_ops = &cmd64x_port_ops, | ||
455 | .dma_ops = &cmd648_dma_ops, | ||
462 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH, | 456 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH, |
463 | .pio_mask = ATA_PIO5, | 457 | .pio_mask = ATA_PIO5, |
464 | .mwdma_mask = ATA_MWDMA2, | 458 | .mwdma_mask = ATA_MWDMA2, |
@@ -466,8 +460,9 @@ static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { | |||
466 | },{ /* 3 */ | 460 | },{ /* 3 */ |
467 | .name = "CMD649", | 461 | .name = "CMD649", |
468 | .init_chipset = init_chipset_cmd64x, | 462 | .init_chipset = init_chipset_cmd64x, |
469 | .init_hwif = init_hwif_cmd64x, | ||
470 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 463 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
464 | .port_ops = &cmd64x_port_ops, | ||
465 | .dma_ops = &cmd648_dma_ops, | ||
471 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH, | 466 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH, |
472 | .pio_mask = ATA_PIO5, | 467 | .pio_mask = ATA_PIO5, |
473 | .mwdma_mask = ATA_MWDMA2, | 468 | .mwdma_mask = ATA_MWDMA2, |
@@ -482,12 +477,35 @@ static int __devinit cmd64x_init_one(struct pci_dev *dev, const struct pci_devic | |||
482 | 477 | ||
483 | d = cmd64x_chipsets[idx]; | 478 | d = cmd64x_chipsets[idx]; |
484 | 479 | ||
485 | /* | 480 | if (idx == 1) { |
486 | * The original PCI0646 didn't have the primary channel enable bit, | 481 | /* |
487 | * it appeared starting with PCI0646U (i.e. revision ID 3). | 482 | * UltraDMA only supported on PCI646U and PCI646U2, which |
488 | */ | 483 | * correspond to revisions 0x03, 0x05 and 0x07 respectively. |
489 | if (idx == 1 && dev->revision < 3) | 484 | * Actually, although the CMD tech support people won't |
490 | d.enablebits[0].reg = 0; | 485 | * tell me the details, the 0x03 revision cannot support |
486 | * UDMA correctly without hardware modifications, and even | ||
487 | * then it only works with Quantum disks due to some | ||
488 | * hold time assumptions in the 646U part which are fixed | ||
489 | * in the 646U2. | ||
490 | * | ||
491 | * So we only do UltraDMA on revision 0x05 and 0x07 chipsets. | ||
492 | */ | ||
493 | if (dev->revision < 5) { | ||
494 | d.udma_mask = 0x00; | ||
495 | /* | ||
496 | * The original PCI0646 didn't have the primary | ||
497 | * channel enable bit, it appeared starting with | ||
498 | * PCI0646U (i.e. revision ID 3). | ||
499 | */ | ||
500 | if (dev->revision < 3) { | ||
501 | d.enablebits[0].reg = 0; | ||
502 | if (dev->revision == 1) | ||
503 | d.dma_ops = &cmd646_rev1_dma_ops; | ||
504 | else | ||
505 | d.dma_ops = &cmd64x_dma_ops; | ||
506 | } | ||
507 | } | ||
508 | } | ||
491 | 509 | ||
492 | return ide_setup_pci_device(dev, &d); | 510 | return ide_setup_pci_device(dev, &d); |
493 | } | 511 | } |
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c index 01b37ecb5a5a..17669a434438 100644 --- a/drivers/ide/pci/cs5520.c +++ b/drivers/ide/pci/cs5520.c | |||
@@ -103,21 +103,27 @@ static void cs5520_dma_host_set(ide_drive_t *drive, int on) | |||
103 | ide_dma_host_set(drive, on); | 103 | ide_dma_host_set(drive, on); |
104 | } | 104 | } |
105 | 105 | ||
106 | static void __devinit init_hwif_cs5520(ide_hwif_t *hwif) | 106 | static const struct ide_port_ops cs5520_port_ops = { |
107 | { | 107 | .set_pio_mode = cs5520_set_pio_mode, |
108 | hwif->set_pio_mode = &cs5520_set_pio_mode; | 108 | .set_dma_mode = cs5520_set_dma_mode, |
109 | hwif->set_dma_mode = &cs5520_set_dma_mode; | 109 | }; |
110 | |||
111 | if (hwif->dma_base == 0) | ||
112 | return; | ||
113 | 110 | ||
114 | hwif->dma_host_set = &cs5520_dma_host_set; | 111 | static const struct ide_dma_ops cs5520_dma_ops = { |
115 | } | 112 | .dma_host_set = cs5520_dma_host_set, |
113 | .dma_setup = ide_dma_setup, | ||
114 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
115 | .dma_start = ide_dma_start, | ||
116 | .dma_end = __ide_dma_end, | ||
117 | .dma_test_irq = ide_dma_test_irq, | ||
118 | .dma_lost_irq = ide_dma_lost_irq, | ||
119 | .dma_timeout = ide_dma_timeout, | ||
120 | }; | ||
116 | 121 | ||
117 | #define DECLARE_CS_DEV(name_str) \ | 122 | #define DECLARE_CS_DEV(name_str) \ |
118 | { \ | 123 | { \ |
119 | .name = name_str, \ | 124 | .name = name_str, \ |
120 | .init_hwif = init_hwif_cs5520, \ | 125 | .port_ops = &cs5520_port_ops, \ |
126 | .dma_ops = &cs5520_dma_ops, \ | ||
121 | .host_flags = IDE_HFLAG_ISA_PORTS | \ | 127 | .host_flags = IDE_HFLAG_ISA_PORTS | \ |
122 | IDE_HFLAG_CS5520 | \ | 128 | IDE_HFLAG_CS5520 | \ |
123 | IDE_HFLAG_VDMA | \ | 129 | IDE_HFLAG_VDMA | \ |
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c index 56a369c2a78a..f5534c1ff349 100644 --- a/drivers/ide/pci/cs5530.c +++ b/drivers/ide/pci/cs5530.c | |||
@@ -228,26 +228,25 @@ static void __devinit init_hwif_cs5530 (ide_hwif_t *hwif) | |||
228 | unsigned long basereg; | 228 | unsigned long basereg; |
229 | u32 d0_timings; | 229 | u32 d0_timings; |
230 | 230 | ||
231 | hwif->set_pio_mode = &cs5530_set_pio_mode; | ||
232 | hwif->set_dma_mode = &cs5530_set_dma_mode; | ||
233 | |||
234 | basereg = CS5530_BASEREG(hwif); | 231 | basereg = CS5530_BASEREG(hwif); |
235 | d0_timings = inl(basereg + 0); | 232 | d0_timings = inl(basereg + 0); |
236 | if (CS5530_BAD_PIO(d0_timings)) | 233 | if (CS5530_BAD_PIO(d0_timings)) |
237 | outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 0); | 234 | outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 0); |
238 | if (CS5530_BAD_PIO(inl(basereg + 8))) | 235 | if (CS5530_BAD_PIO(inl(basereg + 8))) |
239 | outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 8); | 236 | outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 8); |
240 | |||
241 | if (hwif->dma_base == 0) | ||
242 | return; | ||
243 | |||
244 | hwif->udma_filter = cs5530_udma_filter; | ||
245 | } | 237 | } |
246 | 238 | ||
239 | static const struct ide_port_ops cs5530_port_ops = { | ||
240 | .set_pio_mode = cs5530_set_pio_mode, | ||
241 | .set_dma_mode = cs5530_set_dma_mode, | ||
242 | .udma_filter = cs5530_udma_filter, | ||
243 | }; | ||
244 | |||
247 | static const struct ide_port_info cs5530_chipset __devinitdata = { | 245 | static const struct ide_port_info cs5530_chipset __devinitdata = { |
248 | .name = "CS5530", | 246 | .name = "CS5530", |
249 | .init_chipset = init_chipset_cs5530, | 247 | .init_chipset = init_chipset_cs5530, |
250 | .init_hwif = init_hwif_cs5530, | 248 | .init_hwif = init_hwif_cs5530, |
249 | .port_ops = &cs5530_port_ops, | ||
251 | .host_flags = IDE_HFLAG_SERIALIZE | | 250 | .host_flags = IDE_HFLAG_SERIALIZE | |
252 | IDE_HFLAG_POST_SET_MODE, | 251 | IDE_HFLAG_POST_SET_MODE, |
253 | .pio_mask = ATA_PIO4, | 252 | .pio_mask = ATA_PIO4, |
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c index c9685f239c65..99fe91a191b8 100644 --- a/drivers/ide/pci/cs5535.c +++ b/drivers/ide/pci/cs5535.c | |||
@@ -166,25 +166,15 @@ static u8 __devinit cs5535_cable_detect(ide_hwif_t *hwif) | |||
166 | return (bit & 1) ? ATA_CBL_PATA80 : ATA_CBL_PATA40; | 166 | return (bit & 1) ? ATA_CBL_PATA80 : ATA_CBL_PATA40; |
167 | } | 167 | } |
168 | 168 | ||
169 | /**** | 169 | static const struct ide_port_ops cs5535_port_ops = { |
170 | * init_hwif_cs5535 - Initialize one ide cannel | 170 | .set_pio_mode = cs5535_set_pio_mode, |
171 | * @hwif: Channel descriptor | 171 | .set_dma_mode = cs5535_set_dma_mode, |
172 | * | 172 | .cable_detect = cs5535_cable_detect, |
173 | * This gets invoked by the IDE driver once for each channel. It | 173 | }; |
174 | * performs channel-specific pre-initialization before drive probing. | ||
175 | * | ||
176 | */ | ||
177 | static void __devinit init_hwif_cs5535(ide_hwif_t *hwif) | ||
178 | { | ||
179 | hwif->set_pio_mode = &cs5535_set_pio_mode; | ||
180 | hwif->set_dma_mode = &cs5535_set_dma_mode; | ||
181 | |||
182 | hwif->cable_detect = cs5535_cable_detect; | ||
183 | } | ||
184 | 174 | ||
185 | static const struct ide_port_info cs5535_chipset __devinitdata = { | 175 | static const struct ide_port_info cs5535_chipset __devinitdata = { |
186 | .name = "CS5535", | 176 | .name = "CS5535", |
187 | .init_hwif = init_hwif_cs5535, | 177 | .port_ops = &cs5535_port_ops, |
188 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE | | 178 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE | |
189 | IDE_HFLAG_ABUSE_SET_DMA_MODE, | 179 | IDE_HFLAG_ABUSE_SET_DMA_MODE, |
190 | .pio_mask = ATA_PIO4, | 180 | .pio_mask = ATA_PIO4, |
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c index 08eab7e7f051..e30eae5a01b6 100644 --- a/drivers/ide/pci/cy82c693.c +++ b/drivers/ide/pci/cy82c693.c | |||
@@ -382,15 +382,6 @@ static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev, const c | |||
382 | return 0; | 382 | return 0; |
383 | } | 383 | } |
384 | 384 | ||
385 | /* | ||
386 | * the init function - called for each ide channel once | ||
387 | */ | ||
388 | static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif) | ||
389 | { | ||
390 | hwif->set_pio_mode = &cy82c693_set_pio_mode; | ||
391 | hwif->set_dma_mode = &cy82c693_set_dma_mode; | ||
392 | } | ||
393 | |||
394 | static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) | 385 | static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) |
395 | { | 386 | { |
396 | static ide_hwif_t *primary; | 387 | static ide_hwif_t *primary; |
@@ -404,11 +395,16 @@ static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) | |||
404 | } | 395 | } |
405 | } | 396 | } |
406 | 397 | ||
398 | static const struct ide_port_ops cy82c693_port_ops = { | ||
399 | .set_pio_mode = cy82c693_set_pio_mode, | ||
400 | .set_dma_mode = cy82c693_set_dma_mode, | ||
401 | }; | ||
402 | |||
407 | static const struct ide_port_info cy82c693_chipset __devinitdata = { | 403 | static const struct ide_port_info cy82c693_chipset __devinitdata = { |
408 | .name = "CY82C693", | 404 | .name = "CY82C693", |
409 | .init_chipset = init_chipset_cy82c693, | 405 | .init_chipset = init_chipset_cy82c693, |
410 | .init_iops = init_iops_cy82c693, | 406 | .init_iops = init_iops_cy82c693, |
411 | .init_hwif = init_hwif_cy82c693, | 407 | .port_ops = &cy82c693_port_ops, |
412 | .chipset = ide_cy82c693, | 408 | .chipset = ide_cy82c693, |
413 | .host_flags = IDE_HFLAG_SINGLE, | 409 | .host_flags = IDE_HFLAG_SINGLE, |
414 | .pio_mask = ATA_PIO4, | 410 | .pio_mask = ATA_PIO4, |
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c index 753b86fc6637..c7b7e0483287 100644 --- a/drivers/ide/pci/delkin_cb.c +++ b/drivers/ide/pci/delkin_cb.c | |||
@@ -43,6 +43,10 @@ static const u8 setup[] = { | |||
43 | 0x00, 0x00, 0x00, 0x00, 0xa4, 0x83, 0x02, 0x13, | 43 | 0x00, 0x00, 0x00, 0x00, 0xa4, 0x83, 0x02, 0x13, |
44 | }; | 44 | }; |
45 | 45 | ||
46 | static const struct ide_port_ops delkin_cb_port_ops = { | ||
47 | .quirkproc = ide_undecoded_slave, | ||
48 | }; | ||
49 | |||
46 | static int __devinit | 50 | static int __devinit |
47 | delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) | 51 | delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) |
48 | { | 52 | { |
@@ -89,8 +93,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) | |||
89 | ide_init_port_data(hwif, i); | 93 | ide_init_port_data(hwif, i); |
90 | 94 | ||
91 | ide_init_port_hw(hwif, &hw); | 95 | ide_init_port_hw(hwif, &hw); |
92 | hwif->mmio = 1; | 96 | hwif->port_ops = &delkin_cb_port_ops; |
93 | hwif->quirkproc = &ide_undecoded_slave; | ||
94 | 97 | ||
95 | idx[0] = i; | 98 | idx[0] = i; |
96 | 99 | ||
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c index 9f2fc3094000..84c36c117194 100644 --- a/drivers/ide/pci/hpt34x.c +++ b/drivers/ide/pci/hpt34x.c | |||
@@ -115,11 +115,10 @@ static unsigned int __devinit init_chipset_hpt34x(struct pci_dev *dev, const cha | |||
115 | return dev->irq; | 115 | return dev->irq; |
116 | } | 116 | } |
117 | 117 | ||
118 | static void __devinit init_hwif_hpt34x(ide_hwif_t *hwif) | 118 | static const struct ide_port_ops hpt34x_port_ops = { |
119 | { | 119 | .set_pio_mode = hpt34x_set_pio_mode, |
120 | hwif->set_pio_mode = &hpt34x_set_pio_mode; | 120 | .set_dma_mode = hpt34x_set_mode, |
121 | hwif->set_dma_mode = &hpt34x_set_mode; | 121 | }; |
122 | } | ||
123 | 122 | ||
124 | #define IDE_HFLAGS_HPT34X \ | 123 | #define IDE_HFLAGS_HPT34X \ |
125 | (IDE_HFLAG_NO_ATAPI_DMA | \ | 124 | (IDE_HFLAG_NO_ATAPI_DMA | \ |
@@ -131,16 +130,14 @@ static const struct ide_port_info hpt34x_chipsets[] __devinitdata = { | |||
131 | { /* 0 */ | 130 | { /* 0 */ |
132 | .name = "HPT343", | 131 | .name = "HPT343", |
133 | .init_chipset = init_chipset_hpt34x, | 132 | .init_chipset = init_chipset_hpt34x, |
134 | .init_hwif = init_hwif_hpt34x, | 133 | .port_ops = &hpt34x_port_ops, |
135 | .extra = 16, | ||
136 | .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_NON_BOOTABLE, | 134 | .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_NON_BOOTABLE, |
137 | .pio_mask = ATA_PIO5, | 135 | .pio_mask = ATA_PIO5, |
138 | }, | 136 | }, |
139 | { /* 1 */ | 137 | { /* 1 */ |
140 | .name = "HPT345", | 138 | .name = "HPT345", |
141 | .init_chipset = init_chipset_hpt34x, | 139 | .init_chipset = init_chipset_hpt34x, |
142 | .init_hwif = init_hwif_hpt34x, | 140 | .port_ops = &hpt34x_port_ops, |
143 | .extra = 16, | ||
144 | .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_OFF_BOARD, | 141 | .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_OFF_BOARD, |
145 | .pio_mask = ATA_PIO5, | 142 | .pio_mask = ATA_PIO5, |
146 | #ifdef CONFIG_HPT34X_AUTODMA | 143 | #ifdef CONFIG_HPT34X_AUTODMA |
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index a49090672145..8c02961d0188 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
@@ -776,7 +776,7 @@ static void hpt366_dma_lost_irq(ide_drive_t *drive) | |||
776 | pci_read_config_byte(dev, 0x52, &mcr3); | 776 | pci_read_config_byte(dev, 0x52, &mcr3); |
777 | pci_read_config_byte(dev, 0x5a, &scr1); | 777 | pci_read_config_byte(dev, 0x5a, &scr1); |
778 | printk("%s: (%s) mcr1=0x%02x, mcr3=0x%02x, scr1=0x%02x\n", | 778 | printk("%s: (%s) mcr1=0x%02x, mcr3=0x%02x, scr1=0x%02x\n", |
779 | drive->name, __FUNCTION__, mcr1, mcr3, scr1); | 779 | drive->name, __func__, mcr1, mcr3, scr1); |
780 | if (scr1 & 0x10) | 780 | if (scr1 & 0x10) |
781 | pci_write_config_byte(dev, 0x5a, scr1 & ~0x10); | 781 | pci_write_config_byte(dev, 0x5a, scr1 & ~0x10); |
782 | ide_dma_lost_irq(drive); | 782 | ide_dma_lost_irq(drive); |
@@ -808,7 +808,7 @@ static void hpt370_irq_timeout(ide_drive_t *drive) | |||
808 | hpt370_clear_engine(drive); | 808 | hpt370_clear_engine(drive); |
809 | } | 809 | } |
810 | 810 | ||
811 | static void hpt370_ide_dma_start(ide_drive_t *drive) | 811 | static void hpt370_dma_start(ide_drive_t *drive) |
812 | { | 812 | { |
813 | #ifdef HPT_RESET_STATE_ENGINE | 813 | #ifdef HPT_RESET_STATE_ENGINE |
814 | hpt370_clear_engine(drive); | 814 | hpt370_clear_engine(drive); |
@@ -816,7 +816,7 @@ static void hpt370_ide_dma_start(ide_drive_t *drive) | |||
816 | ide_dma_start(drive); | 816 | ide_dma_start(drive); |
817 | } | 817 | } |
818 | 818 | ||
819 | static int hpt370_ide_dma_end(ide_drive_t *drive) | 819 | static int hpt370_dma_end(ide_drive_t *drive) |
820 | { | 820 | { |
821 | ide_hwif_t *hwif = HWIF(drive); | 821 | ide_hwif_t *hwif = HWIF(drive); |
822 | u8 dma_stat = inb(hwif->dma_status); | 822 | u8 dma_stat = inb(hwif->dma_status); |
@@ -838,7 +838,7 @@ static void hpt370_dma_timeout(ide_drive_t *drive) | |||
838 | } | 838 | } |
839 | 839 | ||
840 | /* returns 1 if DMA IRQ issued, 0 otherwise */ | 840 | /* returns 1 if DMA IRQ issued, 0 otherwise */ |
841 | static int hpt374_ide_dma_test_irq(ide_drive_t *drive) | 841 | static int hpt374_dma_test_irq(ide_drive_t *drive) |
842 | { | 842 | { |
843 | ide_hwif_t *hwif = HWIF(drive); | 843 | ide_hwif_t *hwif = HWIF(drive); |
844 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 844 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -858,11 +858,11 @@ static int hpt374_ide_dma_test_irq(ide_drive_t *drive) | |||
858 | 858 | ||
859 | if (!drive->waiting_for_dma) | 859 | if (!drive->waiting_for_dma) |
860 | printk(KERN_WARNING "%s: (%s) called while not waiting\n", | 860 | printk(KERN_WARNING "%s: (%s) called while not waiting\n", |
861 | drive->name, __FUNCTION__); | 861 | drive->name, __func__); |
862 | return 0; | 862 | return 0; |
863 | } | 863 | } |
864 | 864 | ||
865 | static int hpt374_ide_dma_end(ide_drive_t *drive) | 865 | static int hpt374_dma_end(ide_drive_t *drive) |
866 | { | 866 | { |
867 | ide_hwif_t *hwif = HWIF(drive); | 867 | ide_hwif_t *hwif = HWIF(drive); |
868 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 868 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -1271,17 +1271,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | |||
1271 | /* Cache the channel's MISC. control registers' offset */ | 1271 | /* Cache the channel's MISC. control registers' offset */ |
1272 | hwif->select_data = hwif->channel ? 0x54 : 0x50; | 1272 | hwif->select_data = hwif->channel ? 0x54 : 0x50; |
1273 | 1273 | ||
1274 | hwif->set_pio_mode = &hpt3xx_set_pio_mode; | ||
1275 | hwif->set_dma_mode = &hpt3xx_set_mode; | ||
1276 | |||
1277 | hwif->quirkproc = &hpt3xx_quirkproc; | ||
1278 | hwif->maskproc = &hpt3xx_maskproc; | ||
1279 | |||
1280 | hwif->udma_filter = &hpt3xx_udma_filter; | ||
1281 | hwif->mdma_filter = &hpt3xx_mdma_filter; | ||
1282 | |||
1283 | hwif->cable_detect = hpt3xx_cable_detect; | ||
1284 | |||
1285 | /* | 1274 | /* |
1286 | * HPT3xxN chips have some complications: | 1275 | * HPT3xxN chips have some complications: |
1287 | * | 1276 | * |
@@ -1323,29 +1312,19 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | |||
1323 | 1312 | ||
1324 | if (new_mcr != old_mcr) | 1313 | if (new_mcr != old_mcr) |
1325 | pci_write_config_byte(dev, hwif->select_data + 1, new_mcr); | 1314 | pci_write_config_byte(dev, hwif->select_data + 1, new_mcr); |
1326 | |||
1327 | if (hwif->dma_base == 0) | ||
1328 | return; | ||
1329 | |||
1330 | if (chip_type >= HPT374) { | ||
1331 | hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq; | ||
1332 | hwif->ide_dma_end = &hpt374_ide_dma_end; | ||
1333 | } else if (chip_type >= HPT370) { | ||
1334 | hwif->dma_start = &hpt370_ide_dma_start; | ||
1335 | hwif->ide_dma_end = &hpt370_ide_dma_end; | ||
1336 | hwif->dma_timeout = &hpt370_dma_timeout; | ||
1337 | } else | ||
1338 | hwif->dma_lost_irq = &hpt366_dma_lost_irq; | ||
1339 | } | 1315 | } |
1340 | 1316 | ||
1341 | static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) | 1317 | static int __devinit init_dma_hpt366(ide_hwif_t *hwif, |
1318 | const struct ide_port_info *d) | ||
1342 | { | 1319 | { |
1343 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 1320 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
1344 | u8 masterdma = 0, slavedma = 0; | 1321 | unsigned long flags, base = ide_pci_dma_base(hwif, d); |
1345 | u8 dma_new = 0, dma_old = 0; | 1322 | u8 dma_old, dma_new, masterdma = 0, slavedma = 0; |
1346 | unsigned long flags; | ||
1347 | 1323 | ||
1348 | dma_old = inb(dmabase + 2); | 1324 | if (base == 0 || ide_pci_set_master(dev, d->name) < 0) |
1325 | return -1; | ||
1326 | |||
1327 | dma_old = inb(base + 2); | ||
1349 | 1328 | ||
1350 | local_irq_save(flags); | 1329 | local_irq_save(flags); |
1351 | 1330 | ||
@@ -1356,11 +1335,21 @@ static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) | |||
1356 | if (masterdma & 0x30) dma_new |= 0x20; | 1335 | if (masterdma & 0x30) dma_new |= 0x20; |
1357 | if ( slavedma & 0x30) dma_new |= 0x40; | 1336 | if ( slavedma & 0x30) dma_new |= 0x40; |
1358 | if (dma_new != dma_old) | 1337 | if (dma_new != dma_old) |
1359 | outb(dma_new, dmabase + 2); | 1338 | outb(dma_new, base + 2); |
1360 | 1339 | ||
1361 | local_irq_restore(flags); | 1340 | local_irq_restore(flags); |
1362 | 1341 | ||
1363 | ide_setup_dma(hwif, dmabase); | 1342 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", |
1343 | hwif->name, base, base + 7); | ||
1344 | |||
1345 | hwif->extra_base = base + (hwif->channel ? 8 : 16); | ||
1346 | |||
1347 | if (ide_allocate_dma_engine(hwif)) | ||
1348 | return -1; | ||
1349 | |||
1350 | ide_setup_dma(hwif, base); | ||
1351 | |||
1352 | return 0; | ||
1364 | } | 1353 | } |
1365 | 1354 | ||
1366 | static void __devinit hpt374_init(struct pci_dev *dev, struct pci_dev *dev2) | 1355 | static void __devinit hpt374_init(struct pci_dev *dev, struct pci_dev *dev2) |
@@ -1416,6 +1405,49 @@ static int __devinit hpt36x_init(struct pci_dev *dev, struct pci_dev *dev2) | |||
1416 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ | 1405 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ |
1417 | IDE_HFLAG_OFF_BOARD) | 1406 | IDE_HFLAG_OFF_BOARD) |
1418 | 1407 | ||
1408 | static const struct ide_port_ops hpt3xx_port_ops = { | ||
1409 | .set_pio_mode = hpt3xx_set_pio_mode, | ||
1410 | .set_dma_mode = hpt3xx_set_mode, | ||
1411 | .quirkproc = hpt3xx_quirkproc, | ||
1412 | .maskproc = hpt3xx_maskproc, | ||
1413 | .mdma_filter = hpt3xx_mdma_filter, | ||
1414 | .udma_filter = hpt3xx_udma_filter, | ||
1415 | .cable_detect = hpt3xx_cable_detect, | ||
1416 | }; | ||
1417 | |||
1418 | static const struct ide_dma_ops hpt37x_dma_ops = { | ||
1419 | .dma_host_set = ide_dma_host_set, | ||
1420 | .dma_setup = ide_dma_setup, | ||
1421 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
1422 | .dma_start = ide_dma_start, | ||
1423 | .dma_end = hpt374_dma_end, | ||
1424 | .dma_test_irq = hpt374_dma_test_irq, | ||
1425 | .dma_lost_irq = ide_dma_lost_irq, | ||
1426 | .dma_timeout = ide_dma_timeout, | ||
1427 | }; | ||
1428 | |||
1429 | static const struct ide_dma_ops hpt370_dma_ops = { | ||
1430 | .dma_host_set = ide_dma_host_set, | ||
1431 | .dma_setup = ide_dma_setup, | ||
1432 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
1433 | .dma_start = hpt370_dma_start, | ||
1434 | .dma_end = hpt370_dma_end, | ||
1435 | .dma_test_irq = ide_dma_test_irq, | ||
1436 | .dma_lost_irq = ide_dma_lost_irq, | ||
1437 | .dma_timeout = hpt370_dma_timeout, | ||
1438 | }; | ||
1439 | |||
1440 | static const struct ide_dma_ops hpt36x_dma_ops = { | ||
1441 | .dma_host_set = ide_dma_host_set, | ||
1442 | .dma_setup = ide_dma_setup, | ||
1443 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
1444 | .dma_start = ide_dma_start, | ||
1445 | .dma_end = __ide_dma_end, | ||
1446 | .dma_test_irq = ide_dma_test_irq, | ||
1447 | .dma_lost_irq = hpt366_dma_lost_irq, | ||
1448 | .dma_timeout = ide_dma_timeout, | ||
1449 | }; | ||
1450 | |||
1419 | static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | 1451 | static const struct ide_port_info hpt366_chipsets[] __devinitdata = { |
1420 | { /* 0 */ | 1452 | { /* 0 */ |
1421 | .name = "HPT36x", | 1453 | .name = "HPT36x", |
@@ -1429,7 +1461,8 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1429 | * Bit 4 is for the primary channel, bit 5 for the secondary. | 1461 | * Bit 4 is for the primary channel, bit 5 for the secondary. |
1430 | */ | 1462 | */ |
1431 | .enablebits = {{0x50,0x10,0x10}, {0x54,0x04,0x04}}, | 1463 | .enablebits = {{0x50,0x10,0x10}, {0x54,0x04,0x04}}, |
1432 | .extra = 240, | 1464 | .port_ops = &hpt3xx_port_ops, |
1465 | .dma_ops = &hpt36x_dma_ops, | ||
1433 | .host_flags = IDE_HFLAGS_HPT3XX | IDE_HFLAG_SINGLE, | 1466 | .host_flags = IDE_HFLAGS_HPT3XX | IDE_HFLAG_SINGLE, |
1434 | .pio_mask = ATA_PIO4, | 1467 | .pio_mask = ATA_PIO4, |
1435 | .mwdma_mask = ATA_MWDMA2, | 1468 | .mwdma_mask = ATA_MWDMA2, |
@@ -1439,7 +1472,8 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1439 | .init_hwif = init_hwif_hpt366, | 1472 | .init_hwif = init_hwif_hpt366, |
1440 | .init_dma = init_dma_hpt366, | 1473 | .init_dma = init_dma_hpt366, |
1441 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1474 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1442 | .extra = 240, | 1475 | .port_ops = &hpt3xx_port_ops, |
1476 | .dma_ops = &hpt37x_dma_ops, | ||
1443 | .host_flags = IDE_HFLAGS_HPT3XX, | 1477 | .host_flags = IDE_HFLAGS_HPT3XX, |
1444 | .pio_mask = ATA_PIO4, | 1478 | .pio_mask = ATA_PIO4, |
1445 | .mwdma_mask = ATA_MWDMA2, | 1479 | .mwdma_mask = ATA_MWDMA2, |
@@ -1449,7 +1483,8 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1449 | .init_hwif = init_hwif_hpt366, | 1483 | .init_hwif = init_hwif_hpt366, |
1450 | .init_dma = init_dma_hpt366, | 1484 | .init_dma = init_dma_hpt366, |
1451 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1485 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1452 | .extra = 240, | 1486 | .port_ops = &hpt3xx_port_ops, |
1487 | .dma_ops = &hpt37x_dma_ops, | ||
1453 | .host_flags = IDE_HFLAGS_HPT3XX, | 1488 | .host_flags = IDE_HFLAGS_HPT3XX, |
1454 | .pio_mask = ATA_PIO4, | 1489 | .pio_mask = ATA_PIO4, |
1455 | .mwdma_mask = ATA_MWDMA2, | 1490 | .mwdma_mask = ATA_MWDMA2, |
@@ -1459,7 +1494,8 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1459 | .init_hwif = init_hwif_hpt366, | 1494 | .init_hwif = init_hwif_hpt366, |
1460 | .init_dma = init_dma_hpt366, | 1495 | .init_dma = init_dma_hpt366, |
1461 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1496 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1462 | .extra = 240, | 1497 | .port_ops = &hpt3xx_port_ops, |
1498 | .dma_ops = &hpt37x_dma_ops, | ||
1463 | .host_flags = IDE_HFLAGS_HPT3XX, | 1499 | .host_flags = IDE_HFLAGS_HPT3XX, |
1464 | .pio_mask = ATA_PIO4, | 1500 | .pio_mask = ATA_PIO4, |
1465 | .mwdma_mask = ATA_MWDMA2, | 1501 | .mwdma_mask = ATA_MWDMA2, |
@@ -1470,7 +1506,8 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1470 | .init_dma = init_dma_hpt366, | 1506 | .init_dma = init_dma_hpt366, |
1471 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1507 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1472 | .udma_mask = ATA_UDMA5, | 1508 | .udma_mask = ATA_UDMA5, |
1473 | .extra = 240, | 1509 | .port_ops = &hpt3xx_port_ops, |
1510 | .dma_ops = &hpt37x_dma_ops, | ||
1474 | .host_flags = IDE_HFLAGS_HPT3XX, | 1511 | .host_flags = IDE_HFLAGS_HPT3XX, |
1475 | .pio_mask = ATA_PIO4, | 1512 | .pio_mask = ATA_PIO4, |
1476 | .mwdma_mask = ATA_MWDMA2, | 1513 | .mwdma_mask = ATA_MWDMA2, |
@@ -1480,7 +1517,8 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | |||
1480 | .init_hwif = init_hwif_hpt366, | 1517 | .init_hwif = init_hwif_hpt366, |
1481 | .init_dma = init_dma_hpt366, | 1518 | .init_dma = init_dma_hpt366, |
1482 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, | 1519 | .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, |
1483 | .extra = 240, | 1520 | .port_ops = &hpt3xx_port_ops, |
1521 | .dma_ops = &hpt37x_dma_ops, | ||
1484 | .host_flags = IDE_HFLAGS_HPT3XX, | 1522 | .host_flags = IDE_HFLAGS_HPT3XX, |
1485 | .pio_mask = ATA_PIO4, | 1523 | .pio_mask = ATA_PIO4, |
1486 | .mwdma_mask = ATA_MWDMA2, | 1524 | .mwdma_mask = ATA_MWDMA2, |
@@ -1543,6 +1581,10 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic | |||
1543 | d.name = info->chip_name; | 1581 | d.name = info->chip_name; |
1544 | d.udma_mask = info->udma_mask; | 1582 | d.udma_mask = info->udma_mask; |
1545 | 1583 | ||
1584 | /* fixup ->dma_ops for HPT370/HPT370A */ | ||
1585 | if (info == &hpt370 || info == &hpt370a) | ||
1586 | d.dma_ops = &hpt370_dma_ops; | ||
1587 | |||
1546 | pci_set_drvdata(dev, (void *)info); | 1588 | pci_set_drvdata(dev, (void *)info); |
1547 | 1589 | ||
1548 | if (info == &hpt36x || info == &hpt374) | 1590 | if (info == &hpt36x || info == &hpt374) |
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c index 5b5b0cc4b76a..9053c8771e6e 100644 --- a/drivers/ide/pci/it8213.c +++ b/drivers/ide/pci/it8213.c | |||
@@ -149,27 +149,17 @@ static u8 __devinit it8213_cable_detect(ide_hwif_t *hwif) | |||
149 | return (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | 149 | return (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; |
150 | } | 150 | } |
151 | 151 | ||
152 | /** | 152 | static const struct ide_port_ops it8213_port_ops = { |
153 | * init_hwif_it8213 - set up hwif structs | 153 | .set_pio_mode = it8213_set_pio_mode, |
154 | * @hwif: interface to set up | 154 | .set_dma_mode = it8213_set_dma_mode, |
155 | * | 155 | .cable_detect = it8213_cable_detect, |
156 | * We do the basic set up of the interface structure. | 156 | }; |
157 | */ | ||
158 | |||
159 | static void __devinit init_hwif_it8213(ide_hwif_t *hwif) | ||
160 | { | ||
161 | hwif->set_dma_mode = &it8213_set_dma_mode; | ||
162 | hwif->set_pio_mode = &it8213_set_pio_mode; | ||
163 | |||
164 | hwif->cable_detect = it8213_cable_detect; | ||
165 | } | ||
166 | |||
167 | 157 | ||
168 | #define DECLARE_ITE_DEV(name_str) \ | 158 | #define DECLARE_ITE_DEV(name_str) \ |
169 | { \ | 159 | { \ |
170 | .name = name_str, \ | 160 | .name = name_str, \ |
171 | .init_hwif = init_hwif_it8213, \ | ||
172 | .enablebits = { {0x41, 0x80, 0x80} }, \ | 161 | .enablebits = { {0x41, 0x80, 0x80} }, \ |
162 | .port_ops = &it8213_port_ops, \ | ||
173 | .host_flags = IDE_HFLAG_SINGLE, \ | 163 | .host_flags = IDE_HFLAG_SINGLE, \ |
174 | .pio_mask = ATA_PIO4, \ | 164 | .pio_mask = ATA_PIO4, \ |
175 | .swdma_mask = ATA_SWDMA2_ONLY, \ | 165 | .swdma_mask = ATA_SWDMA2_ONLY, \ |
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c index a38ec47423a0..6ab04115286b 100644 --- a/drivers/ide/pci/it821x.c +++ b/drivers/ide/pci/it821x.c | |||
@@ -418,7 +418,7 @@ static void it821x_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
418 | } | 418 | } |
419 | 419 | ||
420 | /** | 420 | /** |
421 | * ata66_it821x - check for 80 pin cable | 421 | * it821x_cable_detect - cable detection |
422 | * @hwif: interface to check | 422 | * @hwif: interface to check |
423 | * | 423 | * |
424 | * Check for the presence of an ATA66 capable cable on the | 424 | * Check for the presence of an ATA66 capable cable on the |
@@ -426,7 +426,7 @@ static void it821x_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
426 | * the needed logic onboard. | 426 | * the needed logic onboard. |
427 | */ | 427 | */ |
428 | 428 | ||
429 | static u8 __devinit ata66_it821x(ide_hwif_t *hwif) | 429 | static u8 __devinit it821x_cable_detect(ide_hwif_t *hwif) |
430 | { | 430 | { |
431 | /* The reference driver also only does disk side */ | 431 | /* The reference driver also only does disk side */ |
432 | return ATA_CBL_PATA80; | 432 | return ATA_CBL_PATA80; |
@@ -511,6 +511,11 @@ static void __devinit it821x_quirkproc(ide_drive_t *drive) | |||
511 | 511 | ||
512 | } | 512 | } |
513 | 513 | ||
514 | static struct ide_dma_ops it821x_pass_through_dma_ops = { | ||
515 | .dma_start = it821x_dma_start, | ||
516 | .dma_end = it821x_dma_end, | ||
517 | }; | ||
518 | |||
514 | /** | 519 | /** |
515 | * init_hwif_it821x - set up hwif structs | 520 | * init_hwif_it821x - set up hwif structs |
516 | * @hwif: interface to set up | 521 | * @hwif: interface to set up |
@@ -527,8 +532,6 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | |||
527 | struct it821x_dev *idev = itdevs[hwif->channel]; | 532 | struct it821x_dev *idev = itdevs[hwif->channel]; |
528 | u8 conf; | 533 | u8 conf; |
529 | 534 | ||
530 | hwif->quirkproc = &it821x_quirkproc; | ||
531 | |||
532 | ide_set_hwifdata(hwif, idev); | 535 | ide_set_hwifdata(hwif, idev); |
533 | 536 | ||
534 | pci_read_config_byte(dev, 0x50, &conf); | 537 | pci_read_config_byte(dev, 0x50, &conf); |
@@ -563,17 +566,11 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | |||
563 | } | 566 | } |
564 | 567 | ||
565 | if (idev->smart == 0) { | 568 | if (idev->smart == 0) { |
566 | hwif->set_pio_mode = &it821x_set_pio_mode; | ||
567 | hwif->set_dma_mode = &it821x_set_dma_mode; | ||
568 | |||
569 | /* MWDMA/PIO clock switching for pass through mode */ | 569 | /* MWDMA/PIO clock switching for pass through mode */ |
570 | hwif->dma_start = &it821x_dma_start; | 570 | hwif->dma_ops = &it821x_pass_through_dma_ops; |
571 | hwif->ide_dma_end = &it821x_dma_end; | ||
572 | } else | 571 | } else |
573 | hwif->host_flags |= IDE_HFLAG_NO_SET_MODE; | 572 | hwif->host_flags |= IDE_HFLAG_NO_SET_MODE; |
574 | 573 | ||
575 | hwif->cable_detect = ata66_it821x; | ||
576 | |||
577 | if (hwif->dma_base == 0) | 574 | if (hwif->dma_base == 0) |
578 | return; | 575 | return; |
579 | 576 | ||
@@ -613,12 +610,20 @@ static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const cha | |||
613 | return 0; | 610 | return 0; |
614 | } | 611 | } |
615 | 612 | ||
613 | static const struct ide_port_ops it821x_port_ops = { | ||
614 | /* it821x_set_{pio,dma}_mode() are only used in pass-through mode */ | ||
615 | .set_pio_mode = it821x_set_pio_mode, | ||
616 | .set_dma_mode = it821x_set_dma_mode, | ||
617 | .quirkproc = it821x_quirkproc, | ||
618 | .cable_detect = it821x_cable_detect, | ||
619 | }; | ||
616 | 620 | ||
617 | #define DECLARE_ITE_DEV(name_str) \ | 621 | #define DECLARE_ITE_DEV(name_str) \ |
618 | { \ | 622 | { \ |
619 | .name = name_str, \ | 623 | .name = name_str, \ |
620 | .init_chipset = init_chipset_it821x, \ | 624 | .init_chipset = init_chipset_it821x, \ |
621 | .init_hwif = init_hwif_it821x, \ | 625 | .init_hwif = init_hwif_it821x, \ |
626 | .port_ops = &it821x_port_ops, \ | ||
622 | .pio_mask = ATA_PIO4, \ | 627 | .pio_mask = ATA_PIO4, \ |
623 | } | 628 | } |
624 | 629 | ||
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c index 673f7dc8ba65..96ef7394f283 100644 --- a/drivers/ide/pci/jmicron.c +++ b/drivers/ide/pci/jmicron.c | |||
@@ -19,13 +19,13 @@ typedef enum { | |||
19 | } port_type; | 19 | } port_type; |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * ata66_jmicron - Cable check | 22 | * jmicron_cable_detect - cable detection |
23 | * @hwif: IDE port | 23 | * @hwif: IDE port |
24 | * | 24 | * |
25 | * Returns the cable type. | 25 | * Returns the cable type. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | static u8 __devinit ata66_jmicron(ide_hwif_t *hwif) | 28 | static u8 __devinit jmicron_cable_detect(ide_hwif_t *hwif) |
29 | { | 29 | { |
30 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 30 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
31 | 31 | ||
@@ -95,25 +95,16 @@ static void jmicron_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
95 | { | 95 | { |
96 | } | 96 | } |
97 | 97 | ||
98 | /** | 98 | static const struct ide_port_ops jmicron_port_ops = { |
99 | * init_hwif_jmicron - set up hwif structs | 99 | .set_pio_mode = jmicron_set_pio_mode, |
100 | * @hwif: interface to set up | 100 | .set_dma_mode = jmicron_set_dma_mode, |
101 | * | 101 | .cable_detect = jmicron_cable_detect, |
102 | * Minimal set up is required for the Jmicron hardware. | 102 | }; |
103 | */ | ||
104 | |||
105 | static void __devinit init_hwif_jmicron(ide_hwif_t *hwif) | ||
106 | { | ||
107 | hwif->set_pio_mode = &jmicron_set_pio_mode; | ||
108 | hwif->set_dma_mode = &jmicron_set_dma_mode; | ||
109 | |||
110 | hwif->cable_detect = ata66_jmicron; | ||
111 | } | ||
112 | 103 | ||
113 | static const struct ide_port_info jmicron_chipset __devinitdata = { | 104 | static const struct ide_port_info jmicron_chipset __devinitdata = { |
114 | .name = "JMB", | 105 | .name = "JMB", |
115 | .init_hwif = init_hwif_jmicron, | ||
116 | .enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } }, | 106 | .enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } }, |
107 | .port_ops = &jmicron_port_ops, | ||
117 | .pio_mask = ATA_PIO5, | 108 | .pio_mask = ATA_PIO5, |
118 | .mwdma_mask = ATA_MWDMA2, | 109 | .mwdma_mask = ATA_MWDMA2, |
119 | .udma_mask = ATA_UDMA6, | 110 | .udma_mask = ATA_UDMA6, |
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c index 3015d6916d4c..e1b0c9a9ab9c 100644 --- a/drivers/ide/pci/ns87415.c +++ b/drivers/ide/pci/ns87415.c | |||
@@ -150,7 +150,7 @@ static void ns87415_selectproc (ide_drive_t *drive) | |||
150 | ns87415_prepare_drive (drive, drive->using_dma); | 150 | ns87415_prepare_drive (drive, drive->using_dma); |
151 | } | 151 | } |
152 | 152 | ||
153 | static int ns87415_ide_dma_end (ide_drive_t *drive) | 153 | static int ns87415_dma_end(ide_drive_t *drive) |
154 | { | 154 | { |
155 | ide_hwif_t *hwif = HWIF(drive); | 155 | ide_hwif_t *hwif = HWIF(drive); |
156 | u8 dma_stat = 0, dma_cmd = 0; | 156 | u8 dma_stat = 0, dma_cmd = 0; |
@@ -170,7 +170,7 @@ static int ns87415_ide_dma_end (ide_drive_t *drive) | |||
170 | return (dma_stat & 7) != 4; | 170 | return (dma_stat & 7) != 4; |
171 | } | 171 | } |
172 | 172 | ||
173 | static int ns87415_ide_dma_setup(ide_drive_t *drive) | 173 | static int ns87415_dma_setup(ide_drive_t *drive) |
174 | { | 174 | { |
175 | /* select DMA xfer */ | 175 | /* select DMA xfer */ |
176 | ns87415_prepare_drive(drive, 1); | 176 | ns87415_prepare_drive(drive, 1); |
@@ -195,8 +195,6 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | |||
195 | u8 stat; | 195 | u8 stat; |
196 | #endif | 196 | #endif |
197 | 197 | ||
198 | hwif->selectproc = &ns87415_selectproc; | ||
199 | |||
200 | /* | 198 | /* |
201 | * We cannot probe for IRQ: both ports share common IRQ on INTA. | 199 | * We cannot probe for IRQ: both ports share common IRQ on INTA. |
202 | * Also, leave IRQ masked during drive probing, to prevent infinite | 200 | * Also, leave IRQ masked during drive probing, to prevent infinite |
@@ -254,16 +252,31 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | |||
254 | return; | 252 | return; |
255 | 253 | ||
256 | outb(0x60, hwif->dma_status); | 254 | outb(0x60, hwif->dma_status); |
257 | hwif->dma_setup = &ns87415_ide_dma_setup; | ||
258 | hwif->ide_dma_end = &ns87415_ide_dma_end; | ||
259 | } | 255 | } |
260 | 256 | ||
257 | static const struct ide_port_ops ns87415_port_ops = { | ||
258 | .selectproc = ns87415_selectproc, | ||
259 | }; | ||
260 | |||
261 | static const struct ide_dma_ops ns87415_dma_ops = { | ||
262 | .dma_host_set = ide_dma_host_set, | ||
263 | .dma_setup = ns87415_dma_setup, | ||
264 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
265 | .dma_start = ide_dma_start, | ||
266 | .dma_end = ns87415_dma_end, | ||
267 | .dma_test_irq = ide_dma_test_irq, | ||
268 | .dma_lost_irq = ide_dma_lost_irq, | ||
269 | .dma_timeout = ide_dma_timeout, | ||
270 | }; | ||
271 | |||
261 | static const struct ide_port_info ns87415_chipset __devinitdata = { | 272 | static const struct ide_port_info ns87415_chipset __devinitdata = { |
262 | .name = "NS87415", | 273 | .name = "NS87415", |
263 | #ifdef CONFIG_SUPERIO | 274 | #ifdef CONFIG_SUPERIO |
264 | .init_iops = init_iops_ns87415, | 275 | .init_iops = init_iops_ns87415, |
265 | #endif | 276 | #endif |
266 | .init_hwif = init_hwif_ns87415, | 277 | .init_hwif = init_hwif_ns87415, |
278 | .port_ops = &ns87415_port_ops, | ||
279 | .dma_ops = &ns87415_dma_ops, | ||
267 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 280 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | |
268 | IDE_HFLAG_NO_ATAPI_DMA, | 281 | IDE_HFLAG_NO_ATAPI_DMA, |
269 | }; | 282 | }; |
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c index 88a4dd94eeea..9edacba20ffb 100644 --- a/drivers/ide/pci/opti621.c +++ b/drivers/ide/pci/opti621.c | |||
@@ -326,28 +326,24 @@ static void __devinit opti621_port_init_devs(ide_hwif_t *hwif) | |||
326 | hwif->drives[1].drive_data = PIO_DONT_KNOW; | 326 | hwif->drives[1].drive_data = PIO_DONT_KNOW; |
327 | } | 327 | } |
328 | 328 | ||
329 | /* | 329 | static const struct ide_port_ops opti621_port_ops = { |
330 | * init_hwif_opti621() is called once for each hwif found at boot. | 330 | .port_init_devs = opti621_port_init_devs, |
331 | */ | 331 | .set_pio_mode = opti621_set_pio_mode, |
332 | static void __devinit init_hwif_opti621(ide_hwif_t *hwif) | 332 | }; |
333 | { | ||
334 | hwif->port_init_devs = opti621_port_init_devs; | ||
335 | hwif->set_pio_mode = &opti621_set_pio_mode; | ||
336 | } | ||
337 | 333 | ||
338 | static const struct ide_port_info opti621_chipsets[] __devinitdata = { | 334 | static const struct ide_port_info opti621_chipsets[] __devinitdata = { |
339 | { /* 0 */ | 335 | { /* 0 */ |
340 | .name = "OPTI621", | 336 | .name = "OPTI621", |
341 | .init_hwif = init_hwif_opti621, | ||
342 | .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} }, | 337 | .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} }, |
338 | .port_ops = &opti621_port_ops, | ||
343 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA, | 339 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA, |
344 | .pio_mask = ATA_PIO3, | 340 | .pio_mask = ATA_PIO3, |
345 | .swdma_mask = ATA_SWDMA2, | 341 | .swdma_mask = ATA_SWDMA2, |
346 | .mwdma_mask = ATA_MWDMA2, | 342 | .mwdma_mask = ATA_MWDMA2, |
347 | }, { /* 1 */ | 343 | }, { /* 1 */ |
348 | .name = "OPTI621X", | 344 | .name = "OPTI621X", |
349 | .init_hwif = init_hwif_opti621, | ||
350 | .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} }, | 345 | .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} }, |
346 | .port_ops = &opti621_port_ops, | ||
351 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA, | 347 | .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA, |
352 | .pio_mask = ATA_PIO3, | 348 | .pio_mask = ATA_PIO3, |
353 | .swdma_mask = ATA_SWDMA2, | 349 | .swdma_mask = ATA_SWDMA2, |
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c index 1c8cb7797a4a..ec9bd7b352fc 100644 --- a/drivers/ide/pci/pdc202xx_new.c +++ b/drivers/ide/pci/pdc202xx_new.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #undef DEBUG | 34 | #undef DEBUG |
35 | 35 | ||
36 | #ifdef DEBUG | 36 | #ifdef DEBUG |
37 | #define DBG(fmt, args...) printk("%s: " fmt, __FUNCTION__, ## args) | 37 | #define DBG(fmt, args...) printk("%s: " fmt, __func__, ## args) |
38 | #else | 38 | #else |
39 | #define DBG(fmt, args...) | 39 | #define DBG(fmt, args...) |
40 | #endif | 40 | #endif |
@@ -442,17 +442,6 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha | |||
442 | return dev->irq; | 442 | return dev->irq; |
443 | } | 443 | } |
444 | 444 | ||
445 | static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif) | ||
446 | { | ||
447 | hwif->set_pio_mode = &pdcnew_set_pio_mode; | ||
448 | hwif->set_dma_mode = &pdcnew_set_dma_mode; | ||
449 | |||
450 | hwif->quirkproc = &pdcnew_quirkproc; | ||
451 | hwif->resetproc = &pdcnew_reset; | ||
452 | |||
453 | hwif->cable_detect = pdcnew_cable_detect; | ||
454 | } | ||
455 | |||
456 | static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) | 445 | static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) |
457 | { | 446 | { |
458 | struct pci_dev *dev2; | 447 | struct pci_dev *dev2; |
@@ -476,11 +465,19 @@ static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) | |||
476 | return NULL; | 465 | return NULL; |
477 | } | 466 | } |
478 | 467 | ||
468 | static const struct ide_port_ops pdcnew_port_ops = { | ||
469 | .set_pio_mode = pdcnew_set_pio_mode, | ||
470 | .set_dma_mode = pdcnew_set_dma_mode, | ||
471 | .quirkproc = pdcnew_quirkproc, | ||
472 | .resetproc = pdcnew_reset, | ||
473 | .cable_detect = pdcnew_cable_detect, | ||
474 | }; | ||
475 | |||
479 | #define DECLARE_PDCNEW_DEV(name_str, udma) \ | 476 | #define DECLARE_PDCNEW_DEV(name_str, udma) \ |
480 | { \ | 477 | { \ |
481 | .name = name_str, \ | 478 | .name = name_str, \ |
482 | .init_chipset = init_chipset_pdcnew, \ | 479 | .init_chipset = init_chipset_pdcnew, \ |
483 | .init_hwif = init_hwif_pdc202new, \ | 480 | .port_ops = &pdcnew_port_ops, \ |
484 | .host_flags = IDE_HFLAG_POST_SET_MODE | \ | 481 | .host_flags = IDE_HFLAG_POST_SET_MODE | \ |
485 | IDE_HFLAG_ERROR_STOPS_FIFO | \ | 482 | IDE_HFLAG_ERROR_STOPS_FIFO | \ |
486 | IDE_HFLAG_OFF_BOARD, \ | 483 | IDE_HFLAG_OFF_BOARD, \ |
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c index 150422ec3cfa..fca89eda5c02 100644 --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c | |||
@@ -115,7 +115,7 @@ static void pdc202xx_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
115 | pdc202xx_set_mode(drive, XFER_PIO_0 + pio); | 115 | pdc202xx_set_mode(drive, XFER_PIO_0 + pio); |
116 | } | 116 | } |
117 | 117 | ||
118 | static u8 __devinit pdc2026x_old_cable_detect(ide_hwif_t *hwif) | 118 | static u8 __devinit pdc2026x_cable_detect(ide_hwif_t *hwif) |
119 | { | 119 | { |
120 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 120 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
121 | u16 CIS, mask = hwif->channel ? (1 << 11) : (1 << 10); | 121 | u16 CIS, mask = hwif->channel ? (1 << 11) : (1 << 10); |
@@ -163,7 +163,7 @@ static void pdc202xx_quirkproc(ide_drive_t *drive) | |||
163 | drive->quirk_list = 0; | 163 | drive->quirk_list = 0; |
164 | } | 164 | } |
165 | 165 | ||
166 | static void pdc202xx_old_ide_dma_start(ide_drive_t *drive) | 166 | static void pdc202xx_dma_start(ide_drive_t *drive) |
167 | { | 167 | { |
168 | if (drive->current_speed > XFER_UDMA_2) | 168 | if (drive->current_speed > XFER_UDMA_2) |
169 | pdc_old_enable_66MHz_clock(drive->hwif); | 169 | pdc_old_enable_66MHz_clock(drive->hwif); |
@@ -185,7 +185,7 @@ static void pdc202xx_old_ide_dma_start(ide_drive_t *drive) | |||
185 | ide_dma_start(drive); | 185 | ide_dma_start(drive); |
186 | } | 186 | } |
187 | 187 | ||
188 | static int pdc202xx_old_ide_dma_end(ide_drive_t *drive) | 188 | static int pdc202xx_dma_end(ide_drive_t *drive) |
189 | { | 189 | { |
190 | if (drive->media != ide_disk || drive->addressing == 1) { | 190 | if (drive->media != ide_disk || drive->addressing == 1) { |
191 | ide_hwif_t *hwif = HWIF(drive); | 191 | ide_hwif_t *hwif = HWIF(drive); |
@@ -202,7 +202,7 @@ static int pdc202xx_old_ide_dma_end(ide_drive_t *drive) | |||
202 | return __ide_dma_end(drive); | 202 | return __ide_dma_end(drive); |
203 | } | 203 | } |
204 | 204 | ||
205 | static int pdc202xx_old_ide_dma_test_irq(ide_drive_t *drive) | 205 | static int pdc202xx_dma_test_irq(ide_drive_t *drive) |
206 | { | 206 | { |
207 | ide_hwif_t *hwif = HWIF(drive); | 207 | ide_hwif_t *hwif = HWIF(drive); |
208 | unsigned long high_16 = hwif->extra_base - 16; | 208 | unsigned long high_16 = hwif->extra_base - 16; |
@@ -226,26 +226,6 @@ somebody_else: | |||
226 | return (dma_stat & 4) == 4; /* return 1 if INTR asserted */ | 226 | return (dma_stat & 4) == 4; /* return 1 if INTR asserted */ |
227 | } | 227 | } |
228 | 228 | ||
229 | static void pdc202xx_dma_lost_irq(ide_drive_t *drive) | ||
230 | { | ||
231 | ide_hwif_t *hwif = HWIF(drive); | ||
232 | |||
233 | if (hwif->resetproc != NULL) | ||
234 | hwif->resetproc(drive); | ||
235 | |||
236 | ide_dma_lost_irq(drive); | ||
237 | } | ||
238 | |||
239 | static void pdc202xx_dma_timeout(ide_drive_t *drive) | ||
240 | { | ||
241 | ide_hwif_t *hwif = HWIF(drive); | ||
242 | |||
243 | if (hwif->resetproc != NULL) | ||
244 | hwif->resetproc(drive); | ||
245 | |||
246 | ide_dma_timeout(drive); | ||
247 | } | ||
248 | |||
249 | static void pdc202xx_reset_host (ide_hwif_t *hwif) | 229 | static void pdc202xx_reset_host (ide_hwif_t *hwif) |
250 | { | 230 | { |
251 | unsigned long high_16 = hwif->extra_base - 16; | 231 | unsigned long high_16 = hwif->extra_base - 16; |
@@ -271,68 +251,46 @@ static void pdc202xx_reset (ide_drive_t *drive) | |||
271 | ide_set_max_pio(drive); | 251 | ide_set_max_pio(drive); |
272 | } | 252 | } |
273 | 253 | ||
274 | static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev, | 254 | static void pdc202xx_dma_lost_irq(ide_drive_t *drive) |
275 | const char *name) | ||
276 | { | 255 | { |
277 | return dev->irq; | 256 | pdc202xx_reset(drive); |
257 | ide_dma_lost_irq(drive); | ||
278 | } | 258 | } |
279 | 259 | ||
280 | static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif) | 260 | static void pdc202xx_dma_timeout(ide_drive_t *drive) |
281 | { | 261 | { |
282 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 262 | pdc202xx_reset(drive); |
283 | 263 | ide_dma_timeout(drive); | |
284 | hwif->set_pio_mode = &pdc202xx_set_pio_mode; | ||
285 | hwif->set_dma_mode = &pdc202xx_set_mode; | ||
286 | |||
287 | hwif->quirkproc = &pdc202xx_quirkproc; | ||
288 | |||
289 | if (dev->device != PCI_DEVICE_ID_PROMISE_20246) { | ||
290 | hwif->resetproc = &pdc202xx_reset; | ||
291 | |||
292 | hwif->cable_detect = pdc2026x_old_cable_detect; | ||
293 | } | ||
294 | |||
295 | if (hwif->dma_base == 0) | ||
296 | return; | ||
297 | |||
298 | hwif->dma_lost_irq = &pdc202xx_dma_lost_irq; | ||
299 | hwif->dma_timeout = &pdc202xx_dma_timeout; | ||
300 | |||
301 | if (dev->device != PCI_DEVICE_ID_PROMISE_20246) { | ||
302 | hwif->dma_start = &pdc202xx_old_ide_dma_start; | ||
303 | hwif->ide_dma_end = &pdc202xx_old_ide_dma_end; | ||
304 | } | ||
305 | hwif->ide_dma_test_irq = &pdc202xx_old_ide_dma_test_irq; | ||
306 | } | 264 | } |
307 | 265 | ||
308 | static void __devinit init_dma_pdc202xx(ide_hwif_t *hwif, unsigned long dmabase) | 266 | static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev, |
267 | const char *name) | ||
309 | { | 268 | { |
269 | unsigned long dmabase = pci_resource_start(dev, 4); | ||
310 | u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; | 270 | u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; |
311 | 271 | ||
312 | if (hwif->channel) { | 272 | if (dmabase == 0) |
313 | ide_setup_dma(hwif, dmabase); | 273 | goto out; |
314 | return; | ||
315 | } | ||
316 | 274 | ||
317 | udma_speed_flag = inb(dmabase | 0x1f); | 275 | udma_speed_flag = inb(dmabase | 0x1f); |
318 | primary_mode = inb(dmabase | 0x1a); | 276 | primary_mode = inb(dmabase | 0x1a); |
319 | secondary_mode = inb(dmabase | 0x1b); | 277 | secondary_mode = inb(dmabase | 0x1b); |
320 | printk(KERN_INFO "%s: (U)DMA Burst Bit %sABLED " \ | 278 | printk(KERN_INFO "%s: (U)DMA Burst Bit %sABLED " \ |
321 | "Primary %s Mode " \ | 279 | "Primary %s Mode " \ |
322 | "Secondary %s Mode.\n", hwif->cds->name, | 280 | "Secondary %s Mode.\n", pci_name(dev), |
323 | (udma_speed_flag & 1) ? "EN" : "DIS", | 281 | (udma_speed_flag & 1) ? "EN" : "DIS", |
324 | (primary_mode & 1) ? "MASTER" : "PCI", | 282 | (primary_mode & 1) ? "MASTER" : "PCI", |
325 | (secondary_mode & 1) ? "MASTER" : "PCI" ); | 283 | (secondary_mode & 1) ? "MASTER" : "PCI" ); |
326 | 284 | ||
327 | if (!(udma_speed_flag & 1)) { | 285 | if (!(udma_speed_flag & 1)) { |
328 | printk(KERN_INFO "%s: FORCING BURST BIT 0x%02x->0x%02x ", | 286 | printk(KERN_INFO "%s: FORCING BURST BIT 0x%02x->0x%02x ", |
329 | hwif->cds->name, udma_speed_flag, | 287 | pci_name(dev), udma_speed_flag, |
330 | (udma_speed_flag|1)); | 288 | (udma_speed_flag|1)); |
331 | outb(udma_speed_flag | 1, dmabase | 0x1f); | 289 | outb(udma_speed_flag | 1, dmabase | 0x1f); |
332 | printk("%sACTIVE\n", (inb(dmabase | 0x1f) & 1) ? "" : "IN"); | 290 | printk("%sACTIVE\n", (inb(dmabase | 0x1f) & 1) ? "" : "IN"); |
333 | } | 291 | } |
334 | 292 | out: | |
335 | ide_setup_dma(hwif, dmabase); | 293 | return dev->irq; |
336 | } | 294 | } |
337 | 295 | ||
338 | static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, | 296 | static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, |
@@ -357,13 +315,48 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, | |||
357 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ | 315 | IDE_HFLAG_ABUSE_SET_DMA_MODE | \ |
358 | IDE_HFLAG_OFF_BOARD) | 316 | IDE_HFLAG_OFF_BOARD) |
359 | 317 | ||
318 | static const struct ide_port_ops pdc20246_port_ops = { | ||
319 | .set_pio_mode = pdc202xx_set_pio_mode, | ||
320 | .set_dma_mode = pdc202xx_set_mode, | ||
321 | .quirkproc = pdc202xx_quirkproc, | ||
322 | }; | ||
323 | |||
324 | static const struct ide_port_ops pdc2026x_port_ops = { | ||
325 | .set_pio_mode = pdc202xx_set_pio_mode, | ||
326 | .set_dma_mode = pdc202xx_set_mode, | ||
327 | .quirkproc = pdc202xx_quirkproc, | ||
328 | .resetproc = pdc202xx_reset, | ||
329 | .cable_detect = pdc2026x_cable_detect, | ||
330 | }; | ||
331 | |||
332 | static const struct ide_dma_ops pdc20246_dma_ops = { | ||
333 | .dma_host_set = ide_dma_host_set, | ||
334 | .dma_setup = ide_dma_setup, | ||
335 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
336 | .dma_start = ide_dma_start, | ||
337 | .dma_end = __ide_dma_end, | ||
338 | .dma_test_irq = pdc202xx_dma_test_irq, | ||
339 | .dma_lost_irq = pdc202xx_dma_lost_irq, | ||
340 | .dma_timeout = pdc202xx_dma_timeout, | ||
341 | }; | ||
342 | |||
343 | static const struct ide_dma_ops pdc2026x_dma_ops = { | ||
344 | .dma_host_set = ide_dma_host_set, | ||
345 | .dma_setup = ide_dma_setup, | ||
346 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
347 | .dma_start = pdc202xx_dma_start, | ||
348 | .dma_end = pdc202xx_dma_end, | ||
349 | .dma_test_irq = pdc202xx_dma_test_irq, | ||
350 | .dma_lost_irq = pdc202xx_dma_lost_irq, | ||
351 | .dma_timeout = pdc202xx_dma_timeout, | ||
352 | }; | ||
353 | |||
360 | #define DECLARE_PDC2026X_DEV(name_str, udma, extra_flags) \ | 354 | #define DECLARE_PDC2026X_DEV(name_str, udma, extra_flags) \ |
361 | { \ | 355 | { \ |
362 | .name = name_str, \ | 356 | .name = name_str, \ |
363 | .init_chipset = init_chipset_pdc202xx, \ | 357 | .init_chipset = init_chipset_pdc202xx, \ |
364 | .init_hwif = init_hwif_pdc202xx, \ | 358 | .port_ops = &pdc2026x_port_ops, \ |
365 | .init_dma = init_dma_pdc202xx, \ | 359 | .dma_ops = &pdc2026x_dma_ops, \ |
366 | .extra = 48, \ | ||
367 | .host_flags = IDE_HFLAGS_PDC202XX | extra_flags, \ | 360 | .host_flags = IDE_HFLAGS_PDC202XX | extra_flags, \ |
368 | .pio_mask = ATA_PIO4, \ | 361 | .pio_mask = ATA_PIO4, \ |
369 | .mwdma_mask = ATA_MWDMA2, \ | 362 | .mwdma_mask = ATA_MWDMA2, \ |
@@ -374,9 +367,8 @@ static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = { | |||
374 | { /* 0 */ | 367 | { /* 0 */ |
375 | .name = "PDC20246", | 368 | .name = "PDC20246", |
376 | .init_chipset = init_chipset_pdc202xx, | 369 | .init_chipset = init_chipset_pdc202xx, |
377 | .init_hwif = init_hwif_pdc202xx, | 370 | .port_ops = &pdc20246_port_ops, |
378 | .init_dma = init_dma_pdc202xx, | 371 | .dma_ops = &pdc20246_dma_ops, |
379 | .extra = 16, | ||
380 | .host_flags = IDE_HFLAGS_PDC202XX, | 372 | .host_flags = IDE_HFLAGS_PDC202XX, |
381 | .pio_mask = ATA_PIO4, | 373 | .pio_mask = ATA_PIO4, |
382 | .mwdma_mask = ATA_MWDMA2, | 374 | .mwdma_mask = ATA_MWDMA2, |
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c index 89d74ffdb207..21c5dd23f928 100644 --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c | |||
@@ -285,11 +285,6 @@ static u8 __devinit piix_cable_detect(ide_hwif_t *hwif) | |||
285 | 285 | ||
286 | static void __devinit init_hwif_piix(ide_hwif_t *hwif) | 286 | static void __devinit init_hwif_piix(ide_hwif_t *hwif) |
287 | { | 287 | { |
288 | hwif->set_pio_mode = &piix_set_pio_mode; | ||
289 | hwif->set_dma_mode = &piix_set_dma_mode; | ||
290 | |||
291 | hwif->cable_detect = piix_cable_detect; | ||
292 | |||
293 | if (!hwif->dma_base) | 288 | if (!hwif->dma_base) |
294 | return; | 289 | return; |
295 | 290 | ||
@@ -306,6 +301,12 @@ static void __devinit init_hwif_ich(ide_hwif_t *hwif) | |||
306 | hwif->ide_dma_clear_irq = &piix_dma_clear_irq; | 301 | hwif->ide_dma_clear_irq = &piix_dma_clear_irq; |
307 | } | 302 | } |
308 | 303 | ||
304 | static const struct ide_port_ops piix_port_ops = { | ||
305 | .set_pio_mode = piix_set_pio_mode, | ||
306 | .set_dma_mode = piix_set_dma_mode, | ||
307 | .cable_detect = piix_cable_detect, | ||
308 | }; | ||
309 | |||
309 | #ifndef CONFIG_IA64 | 310 | #ifndef CONFIG_IA64 |
310 | #define IDE_HFLAGS_PIIX IDE_HFLAG_LEGACY_IRQS | 311 | #define IDE_HFLAGS_PIIX IDE_HFLAG_LEGACY_IRQS |
311 | #else | 312 | #else |
@@ -317,6 +318,7 @@ static void __devinit init_hwif_ich(ide_hwif_t *hwif) | |||
317 | .name = name_str, \ | 318 | .name = name_str, \ |
318 | .init_hwif = init_hwif_piix, \ | 319 | .init_hwif = init_hwif_piix, \ |
319 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ | 320 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ |
321 | .port_ops = &piix_port_ops, \ | ||
320 | .host_flags = IDE_HFLAGS_PIIX, \ | 322 | .host_flags = IDE_HFLAGS_PIIX, \ |
321 | .pio_mask = ATA_PIO4, \ | 323 | .pio_mask = ATA_PIO4, \ |
322 | .swdma_mask = ATA_SWDMA2_ONLY, \ | 324 | .swdma_mask = ATA_SWDMA2_ONLY, \ |
@@ -330,6 +332,7 @@ static void __devinit init_hwif_ich(ide_hwif_t *hwif) | |||
330 | .init_chipset = init_chipset_ich, \ | 332 | .init_chipset = init_chipset_ich, \ |
331 | .init_hwif = init_hwif_ich, \ | 333 | .init_hwif = init_hwif_ich, \ |
332 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ | 334 | .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ |
335 | .port_ops = &piix_port_ops, \ | ||
333 | .host_flags = IDE_HFLAGS_PIIX, \ | 336 | .host_flags = IDE_HFLAGS_PIIX, \ |
334 | .pio_mask = ATA_PIO4, \ | 337 | .pio_mask = ATA_PIO4, \ |
335 | .swdma_mask = ATA_SWDMA2_ONLY, \ | 338 | .swdma_mask = ATA_SWDMA2_ONLY, \ |
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c index 44985c8f36e7..14c787b5d95f 100644 --- a/drivers/ide/pci/sc1200.c +++ b/drivers/ide/pci/sc1200.c | |||
@@ -165,7 +165,7 @@ static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
165 | * | 165 | * |
166 | * returns 1 on error, 0 otherwise | 166 | * returns 1 on error, 0 otherwise |
167 | */ | 167 | */ |
168 | static int sc1200_ide_dma_end (ide_drive_t *drive) | 168 | static int sc1200_dma_end(ide_drive_t *drive) |
169 | { | 169 | { |
170 | ide_hwif_t *hwif = HWIF(drive); | 170 | ide_hwif_t *hwif = HWIF(drive); |
171 | unsigned long dma_base = hwif->dma_base; | 171 | unsigned long dma_base = hwif->dma_base; |
@@ -214,7 +214,7 @@ static void sc1200_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
214 | printk("SC1200: %s: changing (U)DMA mode\n", drive->name); | 214 | printk("SC1200: %s: changing (U)DMA mode\n", drive->name); |
215 | ide_dma_off_quietly(drive); | 215 | ide_dma_off_quietly(drive); |
216 | if (ide_set_dma_mode(drive, mode) == 0 && drive->using_dma) | 216 | if (ide_set_dma_mode(drive, mode) == 0 && drive->using_dma) |
217 | hwif->dma_host_set(drive, 1); | 217 | hwif->dma_ops->dma_host_set(drive, 1); |
218 | return; | 218 | return; |
219 | } | 219 | } |
220 | 220 | ||
@@ -286,25 +286,27 @@ static int sc1200_resume (struct pci_dev *dev) | |||
286 | } | 286 | } |
287 | #endif | 287 | #endif |
288 | 288 | ||
289 | /* | 289 | static const struct ide_port_ops sc1200_port_ops = { |
290 | * This gets invoked by the IDE driver once for each channel, | 290 | .set_pio_mode = sc1200_set_pio_mode, |
291 | * and performs channel-specific pre-initialization before drive probing. | 291 | .set_dma_mode = sc1200_set_dma_mode, |
292 | */ | 292 | .udma_filter = sc1200_udma_filter, |
293 | static void __devinit init_hwif_sc1200 (ide_hwif_t *hwif) | 293 | }; |
294 | { | ||
295 | hwif->set_pio_mode = &sc1200_set_pio_mode; | ||
296 | hwif->set_dma_mode = &sc1200_set_dma_mode; | ||
297 | |||
298 | if (hwif->dma_base == 0) | ||
299 | return; | ||
300 | 294 | ||
301 | hwif->udma_filter = sc1200_udma_filter; | 295 | static const struct ide_dma_ops sc1200_dma_ops = { |
302 | hwif->ide_dma_end = &sc1200_ide_dma_end; | 296 | .dma_host_set = ide_dma_host_set, |
303 | } | 297 | .dma_setup = ide_dma_setup, |
298 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
299 | .dma_start = ide_dma_start, | ||
300 | .dma_end = sc1200_dma_end, | ||
301 | .dma_test_irq = ide_dma_test_irq, | ||
302 | .dma_lost_irq = ide_dma_lost_irq, | ||
303 | .dma_timeout = ide_dma_timeout, | ||
304 | }; | ||
304 | 305 | ||
305 | static const struct ide_port_info sc1200_chipset __devinitdata = { | 306 | static const struct ide_port_info sc1200_chipset __devinitdata = { |
306 | .name = "SC1200", | 307 | .name = "SC1200", |
307 | .init_hwif = init_hwif_sc1200, | 308 | .port_ops = &sc1200_port_ops, |
309 | .dma_ops = &sc1200_dma_ops, | ||
308 | .host_flags = IDE_HFLAG_SERIALIZE | | 310 | .host_flags = IDE_HFLAG_SERIALIZE | |
309 | IDE_HFLAG_POST_SET_MODE | | 311 | IDE_HFLAG_POST_SET_MODE | |
310 | IDE_HFLAG_ABUSE_DMA_MODES, | 312 | IDE_HFLAG_ABUSE_DMA_MODES, |
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c index 52145796f12f..17cf86490d59 100644 --- a/drivers/ide/pci/scc_pata.c +++ b/drivers/ide/pci/scc_pata.c | |||
@@ -317,14 +317,14 @@ static int scc_dma_setup(ide_drive_t *drive) | |||
317 | 317 | ||
318 | 318 | ||
319 | /** | 319 | /** |
320 | * scc_ide_dma_end - Stop DMA | 320 | * scc_dma_end - Stop DMA |
321 | * @drive: IDE drive | 321 | * @drive: IDE drive |
322 | * | 322 | * |
323 | * Check and clear INT Status register. | 323 | * Check and clear INT Status register. |
324 | * Then call __ide_dma_end(). | 324 | * Then call __ide_dma_end(). |
325 | */ | 325 | */ |
326 | 326 | ||
327 | static int scc_ide_dma_end(ide_drive_t * drive) | 327 | static int scc_dma_end(ide_drive_t *drive) |
328 | { | 328 | { |
329 | ide_hwif_t *hwif = HWIF(drive); | 329 | ide_hwif_t *hwif = HWIF(drive); |
330 | unsigned long intsts_port = hwif->dma_base + 0x014; | 330 | unsigned long intsts_port = hwif->dma_base + 0x014; |
@@ -449,7 +449,7 @@ static int scc_dma_test_irq(ide_drive_t *drive) | |||
449 | 449 | ||
450 | if (!drive->waiting_for_dma) | 450 | if (!drive->waiting_for_dma) |
451 | printk(KERN_WARNING "%s: (%s) called while not waiting\n", | 451 | printk(KERN_WARNING "%s: (%s) called while not waiting\n", |
452 | drive->name, __FUNCTION__); | 452 | drive->name, __func__); |
453 | return 0; | 453 | return 0; |
454 | } | 454 | } |
455 | 455 | ||
@@ -483,7 +483,7 @@ static int setup_mmio_scc (struct pci_dev *dev, const char *name) | |||
483 | unsigned long dma_size = pci_resource_len(dev, 1); | 483 | unsigned long dma_size = pci_resource_len(dev, 1); |
484 | void __iomem *ctl_addr; | 484 | void __iomem *ctl_addr; |
485 | void __iomem *dma_addr; | 485 | void __iomem *dma_addr; |
486 | int i; | 486 | int i, ret; |
487 | 487 | ||
488 | for (i = 0; i < MAX_HWIFS; i++) { | 488 | for (i = 0; i < MAX_HWIFS; i++) { |
489 | if (scc_ports[i].ctl == 0) | 489 | if (scc_ports[i].ctl == 0) |
@@ -492,21 +492,17 @@ static int setup_mmio_scc (struct pci_dev *dev, const char *name) | |||
492 | if (i >= MAX_HWIFS) | 492 | if (i >= MAX_HWIFS) |
493 | return -ENOMEM; | 493 | return -ENOMEM; |
494 | 494 | ||
495 | if (!request_mem_region(ctl_base, ctl_size, name)) { | 495 | ret = pci_request_selected_regions(dev, (1 << 2) - 1, name); |
496 | printk(KERN_WARNING "%s: IDE controller MMIO ports not available.\n", SCC_PATA_NAME); | 496 | if (ret < 0) { |
497 | goto fail_0; | 497 | printk(KERN_ERR "%s: can't reserve resources\n", name); |
498 | } | 498 | return ret; |
499 | |||
500 | if (!request_mem_region(dma_base, dma_size, name)) { | ||
501 | printk(KERN_WARNING "%s: IDE controller MMIO ports not available.\n", SCC_PATA_NAME); | ||
502 | goto fail_1; | ||
503 | } | 499 | } |
504 | 500 | ||
505 | if ((ctl_addr = ioremap(ctl_base, ctl_size)) == NULL) | 501 | if ((ctl_addr = ioremap(ctl_base, ctl_size)) == NULL) |
506 | goto fail_2; | 502 | goto fail_0; |
507 | 503 | ||
508 | if ((dma_addr = ioremap(dma_base, dma_size)) == NULL) | 504 | if ((dma_addr = ioremap(dma_base, dma_size)) == NULL) |
509 | goto fail_3; | 505 | goto fail_1; |
510 | 506 | ||
511 | pci_set_master(dev); | 507 | pci_set_master(dev); |
512 | scc_ports[i].ctl = (unsigned long)ctl_addr; | 508 | scc_ports[i].ctl = (unsigned long)ctl_addr; |
@@ -515,12 +511,8 @@ static int setup_mmio_scc (struct pci_dev *dev, const char *name) | |||
515 | 511 | ||
516 | return 1; | 512 | return 1; |
517 | 513 | ||
518 | fail_3: | ||
519 | iounmap(ctl_addr); | ||
520 | fail_2: | ||
521 | release_mem_region(dma_base, dma_size); | ||
522 | fail_1: | 514 | fail_1: |
523 | release_mem_region(ctl_base, ctl_size); | 515 | iounmap(ctl_addr); |
524 | fail_0: | 516 | fail_0: |
525 | return -ENOMEM; | 517 | return -ENOMEM; |
526 | } | 518 | } |
@@ -549,7 +541,6 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev, | |||
549 | hw.chipset = ide_pci; | 541 | hw.chipset = ide_pci; |
550 | ide_init_port_hw(hwif, &hw); | 542 | ide_init_port_hw(hwif, &hw); |
551 | hwif->dev = &dev->dev; | 543 | hwif->dev = &dev->dev; |
552 | hwif->cds = d; | ||
553 | 544 | ||
554 | idx[0] = hwif->index; | 545 | idx[0] = hwif->index; |
555 | 546 | ||
@@ -701,26 +692,37 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif) | |||
701 | /* PTERADD */ | 692 | /* PTERADD */ |
702 | out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma); | 693 | out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma); |
703 | 694 | ||
704 | hwif->dma_setup = scc_dma_setup; | ||
705 | hwif->ide_dma_end = scc_ide_dma_end; | ||
706 | hwif->set_pio_mode = scc_set_pio_mode; | ||
707 | hwif->set_dma_mode = scc_set_dma_mode; | ||
708 | hwif->ide_dma_test_irq = scc_dma_test_irq; | ||
709 | hwif->udma_filter = scc_udma_filter; | ||
710 | |||
711 | if (in_be32((void __iomem *)(hwif->config_data + 0xff0)) & CCKCTRL_ATACLKOEN) | 695 | if (in_be32((void __iomem *)(hwif->config_data + 0xff0)) & CCKCTRL_ATACLKOEN) |
712 | hwif->ultra_mask = ATA_UDMA6; /* 133MHz */ | 696 | hwif->ultra_mask = ATA_UDMA6; /* 133MHz */ |
713 | else | 697 | else |
714 | hwif->ultra_mask = ATA_UDMA5; /* 100MHz */ | 698 | hwif->ultra_mask = ATA_UDMA5; /* 100MHz */ |
715 | |||
716 | hwif->cable_detect = scc_cable_detect; | ||
717 | } | 699 | } |
718 | 700 | ||
701 | static const struct ide_port_ops scc_port_ops = { | ||
702 | .set_pio_mode = scc_set_pio_mode, | ||
703 | .set_dma_mode = scc_set_dma_mode, | ||
704 | .udma_filter = scc_udma_filter, | ||
705 | .cable_detect = scc_cable_detect, | ||
706 | }; | ||
707 | |||
708 | static const struct ide_dma_ops scc_dma_ops = { | ||
709 | .dma_host_set = ide_dma_host_set, | ||
710 | .dma_setup = scc_dma_setup, | ||
711 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
712 | .dma_start = ide_dma_start, | ||
713 | .dma_end = scc_dma_end, | ||
714 | .dma_test_irq = scc_dma_test_irq, | ||
715 | .dma_lost_irq = ide_dma_lost_irq, | ||
716 | .dma_timeout = ide_dma_timeout, | ||
717 | }; | ||
718 | |||
719 | #define DECLARE_SCC_DEV(name_str) \ | 719 | #define DECLARE_SCC_DEV(name_str) \ |
720 | { \ | 720 | { \ |
721 | .name = name_str, \ | 721 | .name = name_str, \ |
722 | .init_iops = init_iops_scc, \ | 722 | .init_iops = init_iops_scc, \ |
723 | .init_hwif = init_hwif_scc, \ | 723 | .init_hwif = init_hwif_scc, \ |
724 | .port_ops = &scc_port_ops, \ | ||
725 | .dma_ops = &scc_dma_ops, \ | ||
724 | .host_flags = IDE_HFLAG_SINGLE, \ | 726 | .host_flags = IDE_HFLAG_SINGLE, \ |
725 | .pio_mask = ATA_PIO4, \ | 727 | .pio_mask = ATA_PIO4, \ |
726 | } | 728 | } |
@@ -754,10 +756,6 @@ static void __devexit scc_remove(struct pci_dev *dev) | |||
754 | { | 756 | { |
755 | struct scc_ports *ports = pci_get_drvdata(dev); | 757 | struct scc_ports *ports = pci_get_drvdata(dev); |
756 | ide_hwif_t *hwif = ports->hwif; | 758 | ide_hwif_t *hwif = ports->hwif; |
757 | unsigned long ctl_base = pci_resource_start(dev, 0); | ||
758 | unsigned long dma_base = pci_resource_start(dev, 1); | ||
759 | unsigned long ctl_size = pci_resource_len(dev, 0); | ||
760 | unsigned long dma_size = pci_resource_len(dev, 1); | ||
761 | 759 | ||
762 | if (hwif->dmatable_cpu) { | 760 | if (hwif->dmatable_cpu) { |
763 | pci_free_consistent(dev, PRD_ENTRIES * PRD_BYTES, | 761 | pci_free_consistent(dev, PRD_ENTRIES * PRD_BYTES, |
@@ -770,8 +768,7 @@ static void __devexit scc_remove(struct pci_dev *dev) | |||
770 | hwif->chipset = ide_unknown; | 768 | hwif->chipset = ide_unknown; |
771 | iounmap((void*)ports->dma); | 769 | iounmap((void*)ports->dma); |
772 | iounmap((void*)ports->ctl); | 770 | iounmap((void*)ports->ctl); |
773 | release_mem_region(dma_base, dma_size); | 771 | pci_release_selected_regions(dev, (1 << 2) - 1); |
774 | release_mem_region(ctl_base, ctl_size); | ||
775 | memset(ports, 0, sizeof(*ports)); | 772 | memset(ports, 0, sizeof(*ports)); |
776 | } | 773 | } |
777 | 774 | ||
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c index cfe927469793..a1fb20826a5b 100644 --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c | |||
@@ -312,7 +312,7 @@ static u8 __devinit ata66_svwks_cobalt(ide_hwif_t *hwif) | |||
312 | return ATA_CBL_PATA40; | 312 | return ATA_CBL_PATA40; |
313 | } | 313 | } |
314 | 314 | ||
315 | static u8 __devinit ata66_svwks(ide_hwif_t *hwif) | 315 | static u8 __devinit svwks_cable_detect(ide_hwif_t *hwif) |
316 | { | 316 | { |
317 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 317 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
318 | 318 | ||
@@ -336,17 +336,18 @@ static u8 __devinit ata66_svwks(ide_hwif_t *hwif) | |||
336 | return ATA_CBL_PATA40; | 336 | return ATA_CBL_PATA40; |
337 | } | 337 | } |
338 | 338 | ||
339 | static void __devinit init_hwif_svwks (ide_hwif_t *hwif) | 339 | static const struct ide_port_ops osb4_port_ops = { |
340 | { | 340 | .set_pio_mode = svwks_set_pio_mode, |
341 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 341 | .set_dma_mode = svwks_set_dma_mode, |
342 | 342 | .udma_filter = svwks_udma_filter, | |
343 | hwif->set_pio_mode = &svwks_set_pio_mode; | 343 | }; |
344 | hwif->set_dma_mode = &svwks_set_dma_mode; | ||
345 | hwif->udma_filter = &svwks_udma_filter; | ||
346 | 344 | ||
347 | if (dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) | 345 | static const struct ide_port_ops svwks_port_ops = { |
348 | hwif->cable_detect = ata66_svwks; | 346 | .set_pio_mode = svwks_set_pio_mode, |
349 | } | 347 | .set_dma_mode = svwks_set_dma_mode, |
348 | .udma_filter = svwks_udma_filter, | ||
349 | .cable_detect = svwks_cable_detect, | ||
350 | }; | ||
350 | 351 | ||
351 | #define IDE_HFLAGS_SVWKS \ | 352 | #define IDE_HFLAGS_SVWKS \ |
352 | (IDE_HFLAG_LEGACY_IRQS | \ | 353 | (IDE_HFLAG_LEGACY_IRQS | \ |
@@ -356,7 +357,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | |||
356 | { /* 0 */ | 357 | { /* 0 */ |
357 | .name = "SvrWks OSB4", | 358 | .name = "SvrWks OSB4", |
358 | .init_chipset = init_chipset_svwks, | 359 | .init_chipset = init_chipset_svwks, |
359 | .init_hwif = init_hwif_svwks, | 360 | .port_ops = &osb4_port_ops, |
360 | .host_flags = IDE_HFLAGS_SVWKS, | 361 | .host_flags = IDE_HFLAGS_SVWKS, |
361 | .pio_mask = ATA_PIO4, | 362 | .pio_mask = ATA_PIO4, |
362 | .mwdma_mask = ATA_MWDMA2, | 363 | .mwdma_mask = ATA_MWDMA2, |
@@ -364,7 +365,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | |||
364 | },{ /* 1 */ | 365 | },{ /* 1 */ |
365 | .name = "SvrWks CSB5", | 366 | .name = "SvrWks CSB5", |
366 | .init_chipset = init_chipset_svwks, | 367 | .init_chipset = init_chipset_svwks, |
367 | .init_hwif = init_hwif_svwks, | 368 | .port_ops = &svwks_port_ops, |
368 | .host_flags = IDE_HFLAGS_SVWKS, | 369 | .host_flags = IDE_HFLAGS_SVWKS, |
369 | .pio_mask = ATA_PIO4, | 370 | .pio_mask = ATA_PIO4, |
370 | .mwdma_mask = ATA_MWDMA2, | 371 | .mwdma_mask = ATA_MWDMA2, |
@@ -372,7 +373,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | |||
372 | },{ /* 2 */ | 373 | },{ /* 2 */ |
373 | .name = "SvrWks CSB6", | 374 | .name = "SvrWks CSB6", |
374 | .init_chipset = init_chipset_svwks, | 375 | .init_chipset = init_chipset_svwks, |
375 | .init_hwif = init_hwif_svwks, | 376 | .port_ops = &svwks_port_ops, |
376 | .host_flags = IDE_HFLAGS_SVWKS, | 377 | .host_flags = IDE_HFLAGS_SVWKS, |
377 | .pio_mask = ATA_PIO4, | 378 | .pio_mask = ATA_PIO4, |
378 | .mwdma_mask = ATA_MWDMA2, | 379 | .mwdma_mask = ATA_MWDMA2, |
@@ -380,7 +381,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | |||
380 | },{ /* 3 */ | 381 | },{ /* 3 */ |
381 | .name = "SvrWks CSB6", | 382 | .name = "SvrWks CSB6", |
382 | .init_chipset = init_chipset_svwks, | 383 | .init_chipset = init_chipset_svwks, |
383 | .init_hwif = init_hwif_svwks, | 384 | .port_ops = &svwks_port_ops, |
384 | .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, | 385 | .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, |
385 | .pio_mask = ATA_PIO4, | 386 | .pio_mask = ATA_PIO4, |
386 | .mwdma_mask = ATA_MWDMA2, | 387 | .mwdma_mask = ATA_MWDMA2, |
@@ -388,7 +389,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = { | |||
388 | },{ /* 4 */ | 389 | },{ /* 4 */ |
389 | .name = "SvrWks HT1000", | 390 | .name = "SvrWks HT1000", |
390 | .init_chipset = init_chipset_svwks, | 391 | .init_chipset = init_chipset_svwks, |
391 | .init_hwif = init_hwif_svwks, | 392 | .port_ops = &svwks_port_ops, |
392 | .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, | 393 | .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, |
393 | .pio_mask = ATA_PIO4, | 394 | .pio_mask = ATA_PIO4, |
394 | .mwdma_mask = ATA_MWDMA2, | 395 | .mwdma_mask = ATA_MWDMA2, |
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c index 6bd9523cf642..321a4e28ac19 100644 --- a/drivers/ide/pci/sgiioc4.c +++ b/drivers/ide/pci/sgiioc4.c | |||
@@ -170,10 +170,10 @@ sgiioc4_clearirq(ide_drive_t * drive) | |||
170 | printk(KERN_ERR | 170 | printk(KERN_ERR |
171 | "%s(%s) : PCI Bus Error when doing DMA:" | 171 | "%s(%s) : PCI Bus Error when doing DMA:" |
172 | " status-cmd reg is 0x%x\n", | 172 | " status-cmd reg is 0x%x\n", |
173 | __FUNCTION__, drive->name, pci_stat_cmd_reg); | 173 | __func__, drive->name, pci_stat_cmd_reg); |
174 | printk(KERN_ERR | 174 | printk(KERN_ERR |
175 | "%s(%s) : PCI Error Address is 0x%x%x\n", | 175 | "%s(%s) : PCI Error Address is 0x%x%x\n", |
176 | __FUNCTION__, drive->name, | 176 | __func__, drive->name, |
177 | pci_err_addr_high, pci_err_addr_low); | 177 | pci_err_addr_high, pci_err_addr_low); |
178 | /* Clear the PCI Error indicator */ | 178 | /* Clear the PCI Error indicator */ |
179 | pci_write_config_dword(dev, PCI_COMMAND, 0x00000146); | 179 | pci_write_config_dword(dev, PCI_COMMAND, 0x00000146); |
@@ -188,7 +188,7 @@ sgiioc4_clearirq(ide_drive_t * drive) | |||
188 | return intr_reg & 3; | 188 | return intr_reg & 3; |
189 | } | 189 | } |
190 | 190 | ||
191 | static void sgiioc4_ide_dma_start(ide_drive_t * drive) | 191 | static void sgiioc4_dma_start(ide_drive_t *drive) |
192 | { | 192 | { |
193 | ide_hwif_t *hwif = HWIF(drive); | 193 | ide_hwif_t *hwif = HWIF(drive); |
194 | unsigned long ioc4_dma_addr = hwif->dma_base + IOC4_DMA_CTRL * 4; | 194 | unsigned long ioc4_dma_addr = hwif->dma_base + IOC4_DMA_CTRL * 4; |
@@ -215,8 +215,7 @@ sgiioc4_ide_dma_stop(ide_hwif_t *hwif, u64 dma_base) | |||
215 | } | 215 | } |
216 | 216 | ||
217 | /* Stops the IOC4 DMA Engine */ | 217 | /* Stops the IOC4 DMA Engine */ |
218 | static int | 218 | static int sgiioc4_dma_end(ide_drive_t *drive) |
219 | sgiioc4_ide_dma_end(ide_drive_t * drive) | ||
220 | { | 219 | { |
221 | u32 ioc4_dma, bc_dev, bc_mem, num, valid = 0, cnt = 0; | 220 | u32 ioc4_dma, bc_dev, bc_mem, num, valid = 0, cnt = 0; |
222 | ide_hwif_t *hwif = HWIF(drive); | 221 | ide_hwif_t *hwif = HWIF(drive); |
@@ -232,7 +231,7 @@ sgiioc4_ide_dma_end(ide_drive_t * drive) | |||
232 | printk(KERN_ERR | 231 | printk(KERN_ERR |
233 | "%s(%s): IOC4 DMA STOP bit is still 1 :" | 232 | "%s(%s): IOC4 DMA STOP bit is still 1 :" |
234 | "ioc4_dma_reg 0x%x\n", | 233 | "ioc4_dma_reg 0x%x\n", |
235 | __FUNCTION__, drive->name, ioc4_dma); | 234 | __func__, drive->name, ioc4_dma); |
236 | dma_stat = 1; | 235 | dma_stat = 1; |
237 | } | 236 | } |
238 | 237 | ||
@@ -251,7 +250,7 @@ sgiioc4_ide_dma_end(ide_drive_t * drive) | |||
251 | udelay(1); | 250 | udelay(1); |
252 | } | 251 | } |
253 | if (!valid) { | 252 | if (!valid) { |
254 | printk(KERN_ERR "%s(%s) : DMA incomplete\n", __FUNCTION__, | 253 | printk(KERN_ERR "%s(%s) : DMA incomplete\n", __func__, |
255 | drive->name); | 254 | drive->name); |
256 | dma_stat = 1; | 255 | dma_stat = 1; |
257 | } | 256 | } |
@@ -264,7 +263,7 @@ sgiioc4_ide_dma_end(ide_drive_t * drive) | |||
264 | printk(KERN_ERR | 263 | printk(KERN_ERR |
265 | "%s(%s): WARNING!! byte_count_dev %d " | 264 | "%s(%s): WARNING!! byte_count_dev %d " |
266 | "!= byte_count_mem %d\n", | 265 | "!= byte_count_mem %d\n", |
267 | __FUNCTION__, drive->name, bc_dev, bc_mem); | 266 | __func__, drive->name, bc_dev, bc_mem); |
268 | } | 267 | } |
269 | } | 268 | } |
270 | 269 | ||
@@ -279,8 +278,7 @@ static void sgiioc4_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
279 | } | 278 | } |
280 | 279 | ||
281 | /* returns 1 if dma irq issued, 0 otherwise */ | 280 | /* returns 1 if dma irq issued, 0 otherwise */ |
282 | static int | 281 | static int sgiioc4_dma_test_irq(ide_drive_t *drive) |
283 | sgiioc4_ide_dma_test_irq(ide_drive_t * drive) | ||
284 | { | 282 | { |
285 | return sgiioc4_checkirq(HWIF(drive)); | 283 | return sgiioc4_checkirq(HWIF(drive)); |
286 | } | 284 | } |
@@ -294,7 +292,7 @@ static void sgiioc4_dma_host_set(ide_drive_t *drive, int on) | |||
294 | static void | 292 | static void |
295 | sgiioc4_resetproc(ide_drive_t * drive) | 293 | sgiioc4_resetproc(ide_drive_t * drive) |
296 | { | 294 | { |
297 | sgiioc4_ide_dma_end(drive); | 295 | sgiioc4_dma_end(drive); |
298 | sgiioc4_clearirq(drive); | 296 | sgiioc4_clearirq(drive); |
299 | } | 297 | } |
300 | 298 | ||
@@ -329,13 +327,17 @@ sgiioc4_INB(unsigned long port) | |||
329 | 327 | ||
330 | /* Creates a dma map for the scatter-gather list entries */ | 328 | /* Creates a dma map for the scatter-gather list entries */ |
331 | static int __devinit | 329 | static int __devinit |
332 | ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) | 330 | ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d) |
333 | { | 331 | { |
334 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 332 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
333 | unsigned long dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET; | ||
335 | void __iomem *virt_dma_base; | 334 | void __iomem *virt_dma_base; |
336 | int num_ports = sizeof (ioc4_dma_regs_t); | 335 | int num_ports = sizeof (ioc4_dma_regs_t); |
337 | void *pad; | 336 | void *pad; |
338 | 337 | ||
338 | if (dma_base == 0) | ||
339 | return -1; | ||
340 | |||
339 | printk(KERN_INFO "%s: BM-DMA at 0x%04lx-0x%04lx\n", hwif->name, | 341 | printk(KERN_INFO "%s: BM-DMA at 0x%04lx-0x%04lx\n", hwif->name, |
340 | dma_base, dma_base + num_ports - 1); | 342 | dma_base, dma_base + num_ports - 1); |
341 | 343 | ||
@@ -343,7 +345,7 @@ ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) | |||
343 | printk(KERN_ERR | 345 | printk(KERN_ERR |
344 | "%s(%s) -- ERROR, Addresses 0x%p to 0x%p " | 346 | "%s(%s) -- ERROR, Addresses 0x%p to 0x%p " |
345 | "ALREADY in use\n", | 347 | "ALREADY in use\n", |
346 | __FUNCTION__, hwif->name, (void *) dma_base, | 348 | __func__, hwif->name, (void *) dma_base, |
347 | (void *) dma_base + num_ports - 1); | 349 | (void *) dma_base + num_ports - 1); |
348 | return -1; | 350 | return -1; |
349 | } | 351 | } |
@@ -352,7 +354,7 @@ ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) | |||
352 | if (virt_dma_base == NULL) { | 354 | if (virt_dma_base == NULL) { |
353 | printk(KERN_ERR | 355 | printk(KERN_ERR |
354 | "%s(%s) -- ERROR, Unable to map addresses 0x%lx to 0x%lx\n", | 356 | "%s(%s) -- ERROR, Unable to map addresses 0x%lx to 0x%lx\n", |
355 | __FUNCTION__, hwif->name, dma_base, dma_base + num_ports - 1); | 357 | __func__, hwif->name, dma_base, dma_base + num_ports - 1); |
356 | goto dma_remap_failure; | 358 | goto dma_remap_failure; |
357 | } | 359 | } |
358 | hwif->dma_base = (unsigned long) virt_dma_base; | 360 | hwif->dma_base = (unsigned long) virt_dma_base; |
@@ -378,7 +380,7 @@ ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) | |||
378 | hwif->dmatable_cpu, hwif->dmatable_dma); | 380 | hwif->dmatable_cpu, hwif->dmatable_dma); |
379 | printk(KERN_INFO | 381 | printk(KERN_INFO |
380 | "%s() -- Error! Unable to allocate DMA Maps for drive %s\n", | 382 | "%s() -- Error! Unable to allocate DMA Maps for drive %s\n", |
381 | __FUNCTION__, hwif->name); | 383 | __func__, hwif->name); |
382 | printk(KERN_INFO | 384 | printk(KERN_INFO |
383 | "Changing from DMA to PIO mode for Drive %s\n", hwif->name); | 385 | "Changing from DMA to PIO mode for Drive %s\n", hwif->name); |
384 | 386 | ||
@@ -406,14 +408,14 @@ sgiioc4_configure_for_dma(int dma_direction, ide_drive_t * drive) | |||
406 | if (ioc4_dma & IOC4_S_DMA_ACTIVE) { | 408 | if (ioc4_dma & IOC4_S_DMA_ACTIVE) { |
407 | printk(KERN_WARNING | 409 | printk(KERN_WARNING |
408 | "%s(%s):Warning!! DMA from previous transfer was still active\n", | 410 | "%s(%s):Warning!! DMA from previous transfer was still active\n", |
409 | __FUNCTION__, drive->name); | 411 | __func__, drive->name); |
410 | writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr); | 412 | writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr); |
411 | ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base); | 413 | ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base); |
412 | 414 | ||
413 | if (ioc4_dma & IOC4_S_DMA_STOP) | 415 | if (ioc4_dma & IOC4_S_DMA_STOP) |
414 | printk(KERN_ERR | 416 | printk(KERN_ERR |
415 | "%s(%s) : IOC4 Dma STOP bit is still 1\n", | 417 | "%s(%s) : IOC4 Dma STOP bit is still 1\n", |
416 | __FUNCTION__, drive->name); | 418 | __func__, drive->name); |
417 | } | 419 | } |
418 | 420 | ||
419 | ioc4_dma = readl((void __iomem *)ioc4_dma_addr); | 421 | ioc4_dma = readl((void __iomem *)ioc4_dma_addr); |
@@ -421,14 +423,14 @@ sgiioc4_configure_for_dma(int dma_direction, ide_drive_t * drive) | |||
421 | printk(KERN_WARNING | 423 | printk(KERN_WARNING |
422 | "%s(%s) : Warning!! - DMA Error during Previous" | 424 | "%s(%s) : Warning!! - DMA Error during Previous" |
423 | " transfer | status 0x%x\n", | 425 | " transfer | status 0x%x\n", |
424 | __FUNCTION__, drive->name, ioc4_dma); | 426 | __func__, drive->name, ioc4_dma); |
425 | writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr); | 427 | writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr); |
426 | ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base); | 428 | ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base); |
427 | 429 | ||
428 | if (ioc4_dma & IOC4_S_DMA_STOP) | 430 | if (ioc4_dma & IOC4_S_DMA_STOP) |
429 | printk(KERN_ERR | 431 | printk(KERN_ERR |
430 | "%s(%s) : IOC4 DMA STOP bit is still 1\n", | 432 | "%s(%s) : IOC4 DMA STOP bit is still 1\n", |
431 | __FUNCTION__, drive->name); | 433 | __func__, drive->name); |
432 | } | 434 | } |
433 | 435 | ||
434 | /* Address of the Scatter Gather List */ | 436 | /* Address of the Scatter Gather List */ |
@@ -519,7 +521,7 @@ use_pio_instead: | |||
519 | return 0; /* revert to PIO for this request */ | 521 | return 0; /* revert to PIO for this request */ |
520 | } | 522 | } |
521 | 523 | ||
522 | static int sgiioc4_ide_dma_setup(ide_drive_t *drive) | 524 | static int sgiioc4_dma_setup(ide_drive_t *drive) |
523 | { | 525 | { |
524 | struct request *rq = HWGROUP(drive)->rq; | 526 | struct request *rq = HWGROUP(drive)->rq; |
525 | unsigned int count = 0; | 527 | unsigned int count = 0; |
@@ -548,45 +550,37 @@ static int sgiioc4_ide_dma_setup(ide_drive_t *drive) | |||
548 | return 0; | 550 | return 0; |
549 | } | 551 | } |
550 | 552 | ||
551 | static void __devinit | 553 | static const struct ide_port_ops sgiioc4_port_ops = { |
552 | ide_init_sgiioc4(ide_hwif_t * hwif) | 554 | .set_dma_mode = sgiioc4_set_dma_mode, |
553 | { | 555 | /* reset DMA engine, clear IRQs */ |
554 | hwif->mmio = 1; | 556 | .resetproc = sgiioc4_resetproc, |
555 | hwif->set_pio_mode = NULL; /* Sets timing for PIO mode */ | 557 | /* mask on/off NIEN register */ |
556 | hwif->set_dma_mode = &sgiioc4_set_dma_mode; | 558 | .maskproc = sgiioc4_maskproc, |
557 | hwif->selectproc = NULL;/* Use the default routine to select drive */ | 559 | }; |
558 | hwif->reset_poll = NULL;/* No HBA specific reset_poll needed */ | ||
559 | hwif->pre_reset = NULL; /* No HBA specific pre_set needed */ | ||
560 | hwif->resetproc = &sgiioc4_resetproc;/* Reset DMA engine, | ||
561 | clear interrupts */ | ||
562 | hwif->maskproc = &sgiioc4_maskproc; /* Mask on/off NIEN register */ | ||
563 | hwif->quirkproc = NULL; | ||
564 | |||
565 | hwif->INB = &sgiioc4_INB; | ||
566 | |||
567 | if (hwif->dma_base == 0) | ||
568 | return; | ||
569 | 560 | ||
570 | hwif->dma_host_set = &sgiioc4_dma_host_set; | 561 | static const struct ide_dma_ops sgiioc4_dma_ops = { |
571 | hwif->dma_setup = &sgiioc4_ide_dma_setup; | 562 | .dma_host_set = sgiioc4_dma_host_set, |
572 | hwif->dma_start = &sgiioc4_ide_dma_start; | 563 | .dma_setup = sgiioc4_dma_setup, |
573 | hwif->ide_dma_end = &sgiioc4_ide_dma_end; | 564 | .dma_start = sgiioc4_dma_start, |
574 | hwif->ide_dma_test_irq = &sgiioc4_ide_dma_test_irq; | 565 | .dma_end = sgiioc4_dma_end, |
575 | hwif->dma_lost_irq = &sgiioc4_dma_lost_irq; | 566 | .dma_test_irq = sgiioc4_dma_test_irq, |
576 | hwif->dma_timeout = &ide_dma_timeout; | 567 | .dma_lost_irq = sgiioc4_dma_lost_irq, |
577 | } | 568 | .dma_timeout = ide_dma_timeout, |
569 | }; | ||
578 | 570 | ||
579 | static const struct ide_port_info sgiioc4_port_info __devinitdata = { | 571 | static const struct ide_port_info sgiioc4_port_info __devinitdata = { |
580 | .chipset = ide_pci, | 572 | .chipset = ide_pci, |
581 | .host_flags = IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ | 573 | .init_dma = ide_dma_sgiioc4, |
582 | IDE_HFLAG_NO_AUTOTUNE, | 574 | .port_ops = &sgiioc4_port_ops, |
575 | .dma_ops = &sgiioc4_dma_ops, | ||
576 | .host_flags = IDE_HFLAG_NO_AUTOTUNE, | ||
583 | .mwdma_mask = ATA_MWDMA2_ONLY, | 577 | .mwdma_mask = ATA_MWDMA2_ONLY, |
584 | }; | 578 | }; |
585 | 579 | ||
586 | static int __devinit | 580 | static int __devinit |
587 | sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | 581 | sgiioc4_ide_setup_pci_device(struct pci_dev *dev) |
588 | { | 582 | { |
589 | unsigned long cmd_base, dma_base, irqport; | 583 | unsigned long cmd_base, irqport; |
590 | unsigned long bar0, cmd_phys_base, ctl; | 584 | unsigned long bar0, cmd_phys_base, ctl; |
591 | void __iomem *virt_base; | 585 | void __iomem *virt_base; |
592 | ide_hwif_t *hwif; | 586 | ide_hwif_t *hwif; |
@@ -612,7 +606,6 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
612 | cmd_base = (unsigned long) virt_base + IOC4_CMD_OFFSET; | 606 | cmd_base = (unsigned long) virt_base + IOC4_CMD_OFFSET; |
613 | ctl = (unsigned long) virt_base + IOC4_CTRL_OFFSET; | 607 | ctl = (unsigned long) virt_base + IOC4_CTRL_OFFSET; |
614 | irqport = (unsigned long) virt_base + IOC4_INTR_OFFSET; | 608 | irqport = (unsigned long) virt_base + IOC4_INTR_OFFSET; |
615 | dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET; | ||
616 | 609 | ||
617 | cmd_phys_base = bar0 + IOC4_CMD_OFFSET; | 610 | cmd_phys_base = bar0 + IOC4_CMD_OFFSET; |
618 | if (!request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE, | 611 | if (!request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE, |
@@ -620,7 +613,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
620 | printk(KERN_ERR | 613 | printk(KERN_ERR |
621 | "%s : %s -- ERROR, Addresses " | 614 | "%s : %s -- ERROR, Addresses " |
622 | "0x%p to 0x%p ALREADY in use\n", | 615 | "0x%p to 0x%p ALREADY in use\n", |
623 | __FUNCTION__, hwif->name, (void *) cmd_phys_base, | 616 | __func__, hwif->name, (void *) cmd_phys_base, |
624 | (void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE); | 617 | (void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE); |
625 | return -ENOMEM; | 618 | return -ENOMEM; |
626 | } | 619 | } |
@@ -641,13 +634,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
641 | /* Initializing chipset IRQ Registers */ | 634 | /* Initializing chipset IRQ Registers */ |
642 | writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); | 635 | writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); |
643 | 636 | ||
644 | if (dma_base == 0 || ide_dma_sgiioc4(hwif, dma_base)) { | 637 | hwif->INB = &sgiioc4_INB; |
645 | printk(KERN_INFO "%s: %s Bus-Master DMA disabled\n", | ||
646 | hwif->name, DRV_NAME); | ||
647 | d.mwdma_mask = 0; | ||
648 | } | ||
649 | |||
650 | ide_init_sgiioc4(hwif); | ||
651 | 638 | ||
652 | idx[0] = hwif->index; | 639 | idx[0] = hwif->index; |
653 | 640 | ||
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c index c9ecab8aeb61..1fffea3211bd 100644 --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c | |||
@@ -301,7 +301,7 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
301 | } | 301 | } |
302 | 302 | ||
303 | /* returns 1 if dma irq issued, 0 otherwise */ | 303 | /* returns 1 if dma irq issued, 0 otherwise */ |
304 | static int siimage_io_ide_dma_test_irq (ide_drive_t *drive) | 304 | static int siimage_io_dma_test_irq(ide_drive_t *drive) |
305 | { | 305 | { |
306 | ide_hwif_t *hwif = HWIF(drive); | 306 | ide_hwif_t *hwif = HWIF(drive); |
307 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 307 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -320,14 +320,14 @@ static int siimage_io_ide_dma_test_irq (ide_drive_t *drive) | |||
320 | } | 320 | } |
321 | 321 | ||
322 | /** | 322 | /** |
323 | * siimage_mmio_ide_dma_test_irq - check we caused an IRQ | 323 | * siimage_mmio_dma_test_irq - check we caused an IRQ |
324 | * @drive: drive we are testing | 324 | * @drive: drive we are testing |
325 | * | 325 | * |
326 | * Check if we caused an IDE DMA interrupt. We may also have caused | 326 | * Check if we caused an IDE DMA interrupt. We may also have caused |
327 | * SATA status interrupts, if so we clean them up and continue. | 327 | * SATA status interrupts, if so we clean them up and continue. |
328 | */ | 328 | */ |
329 | 329 | ||
330 | static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive) | 330 | static int siimage_mmio_dma_test_irq(ide_drive_t *drive) |
331 | { | 331 | { |
332 | ide_hwif_t *hwif = HWIF(drive); | 332 | ide_hwif_t *hwif = HWIF(drive); |
333 | unsigned long addr = siimage_selreg(hwif, 0x1); | 333 | unsigned long addr = siimage_selreg(hwif, 0x1); |
@@ -347,7 +347,7 @@ static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive) | |||
347 | printk(KERN_WARNING "%s: sata_error = 0x%08x, " | 347 | printk(KERN_WARNING "%s: sata_error = 0x%08x, " |
348 | "watchdog = %d, %s\n", | 348 | "watchdog = %d, %s\n", |
349 | drive->name, sata_error, watchdog, | 349 | drive->name, sata_error, watchdog, |
350 | __FUNCTION__); | 350 | __func__); |
351 | 351 | ||
352 | } else { | 352 | } else { |
353 | watchdog = (ext_stat & 0x8000) ? 1 : 0; | 353 | watchdog = (ext_stat & 0x8000) ? 1 : 0; |
@@ -369,6 +369,14 @@ static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive) | |||
369 | return 0; | 369 | return 0; |
370 | } | 370 | } |
371 | 371 | ||
372 | static int siimage_dma_test_irq(ide_drive_t *drive) | ||
373 | { | ||
374 | if (drive->hwif->mmio) | ||
375 | return siimage_mmio_dma_test_irq(drive); | ||
376 | else | ||
377 | return siimage_io_dma_test_irq(drive); | ||
378 | } | ||
379 | |||
372 | /** | 380 | /** |
373 | * sil_sata_reset_poll - wait for SATA reset | 381 | * sil_sata_reset_poll - wait for SATA reset |
374 | * @drive: drive we are resetting | 382 | * @drive: drive we are resetting |
@@ -735,14 +743,14 @@ static void __devinit init_iops_siimage(ide_hwif_t *hwif) | |||
735 | } | 743 | } |
736 | 744 | ||
737 | /** | 745 | /** |
738 | * ata66_siimage - check for 80 pin cable | 746 | * sil_cable_detect - cable detection |
739 | * @hwif: interface to check | 747 | * @hwif: interface to check |
740 | * | 748 | * |
741 | * Check for the presence of an ATA66 capable cable on the | 749 | * Check for the presence of an ATA66 capable cable on the |
742 | * interface. | 750 | * interface. |
743 | */ | 751 | */ |
744 | 752 | ||
745 | static u8 __devinit ata66_siimage(ide_hwif_t *hwif) | 753 | static u8 __devinit sil_cable_detect(ide_hwif_t *hwif) |
746 | { | 754 | { |
747 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 755 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
748 | unsigned long addr = siimage_selreg(hwif, 0); | 756 | unsigned long addr = siimage_selreg(hwif, 0); |
@@ -756,67 +764,44 @@ static u8 __devinit ata66_siimage(ide_hwif_t *hwif) | |||
756 | return (ata66 & 0x01) ? ATA_CBL_PATA80 : ATA_CBL_PATA40; | 764 | return (ata66 & 0x01) ? ATA_CBL_PATA80 : ATA_CBL_PATA40; |
757 | } | 765 | } |
758 | 766 | ||
759 | /** | 767 | static const struct ide_port_ops sil_pata_port_ops = { |
760 | * init_hwif_siimage - set up hwif structs | 768 | .set_pio_mode = sil_set_pio_mode, |
761 | * @hwif: interface to set up | 769 | .set_dma_mode = sil_set_dma_mode, |
762 | * | 770 | .quirkproc = sil_quirkproc, |
763 | * We do the basic set up of the interface structure. The SIIMAGE | 771 | .udma_filter = sil_pata_udma_filter, |
764 | * requires several custom handlers so we override the default | 772 | .cable_detect = sil_cable_detect, |
765 | * ide DMA handlers appropriately | 773 | }; |
766 | */ | ||
767 | |||
768 | static void __devinit init_hwif_siimage(ide_hwif_t *hwif) | ||
769 | { | ||
770 | u8 sata = is_sata(hwif); | ||
771 | |||
772 | hwif->set_pio_mode = &sil_set_pio_mode; | ||
773 | hwif->set_dma_mode = &sil_set_dma_mode; | ||
774 | hwif->quirkproc = &sil_quirkproc; | ||
775 | |||
776 | if (sata) { | ||
777 | static int first = 1; | ||
778 | |||
779 | hwif->reset_poll = &sil_sata_reset_poll; | ||
780 | hwif->pre_reset = &sil_sata_pre_reset; | ||
781 | hwif->udma_filter = &sil_sata_udma_filter; | ||
782 | |||
783 | if (first) { | ||
784 | printk(KERN_INFO "siimage: For full SATA support you should use the libata sata_sil module.\n"); | ||
785 | first = 0; | ||
786 | } | ||
787 | } else | ||
788 | hwif->udma_filter = &sil_pata_udma_filter; | ||
789 | |||
790 | hwif->cable_detect = ata66_siimage; | ||
791 | |||
792 | if (hwif->dma_base == 0) | ||
793 | return; | ||
794 | 774 | ||
795 | if (sata) | 775 | static const struct ide_port_ops sil_sata_port_ops = { |
796 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | 776 | .set_pio_mode = sil_set_pio_mode, |
777 | .set_dma_mode = sil_set_dma_mode, | ||
778 | .reset_poll = sil_sata_reset_poll, | ||
779 | .pre_reset = sil_sata_pre_reset, | ||
780 | .quirkproc = sil_quirkproc, | ||
781 | .udma_filter = sil_sata_udma_filter, | ||
782 | .cable_detect = sil_cable_detect, | ||
783 | }; | ||
797 | 784 | ||
798 | if (hwif->mmio) { | 785 | static struct ide_dma_ops sil_dma_ops = { |
799 | hwif->ide_dma_test_irq = &siimage_mmio_ide_dma_test_irq; | 786 | .dma_test_irq = siimage_dma_test_irq, |
800 | } else { | 787 | }; |
801 | hwif->ide_dma_test_irq = & siimage_io_ide_dma_test_irq; | ||
802 | } | ||
803 | } | ||
804 | 788 | ||
805 | #define DECLARE_SII_DEV(name_str) \ | 789 | #define DECLARE_SII_DEV(name_str, p_ops) \ |
806 | { \ | 790 | { \ |
807 | .name = name_str, \ | 791 | .name = name_str, \ |
808 | .init_chipset = init_chipset_siimage, \ | 792 | .init_chipset = init_chipset_siimage, \ |
809 | .init_iops = init_iops_siimage, \ | 793 | .init_iops = init_iops_siimage, \ |
810 | .init_hwif = init_hwif_siimage, \ | 794 | .port_ops = p_ops, \ |
795 | .dma_ops = &sil_dma_ops, \ | ||
811 | .pio_mask = ATA_PIO4, \ | 796 | .pio_mask = ATA_PIO4, \ |
812 | .mwdma_mask = ATA_MWDMA2, \ | 797 | .mwdma_mask = ATA_MWDMA2, \ |
813 | .udma_mask = ATA_UDMA6, \ | 798 | .udma_mask = ATA_UDMA6, \ |
814 | } | 799 | } |
815 | 800 | ||
816 | static const struct ide_port_info siimage_chipsets[] __devinitdata = { | 801 | static const struct ide_port_info siimage_chipsets[] __devinitdata = { |
817 | /* 0 */ DECLARE_SII_DEV("SiI680"), | 802 | /* 0 */ DECLARE_SII_DEV("SiI680", &sil_pata_port_ops), |
818 | /* 1 */ DECLARE_SII_DEV("SiI3112 Serial ATA"), | 803 | /* 1 */ DECLARE_SII_DEV("SiI3112 Serial ATA", &sil_sata_port_ops), |
819 | /* 2 */ DECLARE_SII_DEV("Adaptec AAR-1210SA") | 804 | /* 2 */ DECLARE_SII_DEV("Adaptec AAR-1210SA", &sil_sata_port_ops) |
820 | }; | 805 | }; |
821 | 806 | ||
822 | /** | 807 | /** |
@@ -830,7 +815,24 @@ static const struct ide_port_info siimage_chipsets[] __devinitdata = { | |||
830 | 815 | ||
831 | static int __devinit siimage_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 816 | static int __devinit siimage_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
832 | { | 817 | { |
833 | return ide_setup_pci_device(dev, &siimage_chipsets[id->driver_data]); | 818 | struct ide_port_info d; |
819 | u8 idx = id->driver_data; | ||
820 | |||
821 | d = siimage_chipsets[idx]; | ||
822 | |||
823 | if (idx) { | ||
824 | static int first = 1; | ||
825 | |||
826 | if (first) { | ||
827 | printk(KERN_INFO "siimage: For full SATA support you " | ||
828 | "should use the libata sata_sil module.\n"); | ||
829 | first = 0; | ||
830 | } | ||
831 | |||
832 | d.host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | ||
833 | } | ||
834 | |||
835 | return ide_setup_pci_device(dev, &d); | ||
834 | } | 836 | } |
835 | 837 | ||
836 | static const struct pci_device_id siimage_pci_tbl[] = { | 838 | static const struct pci_device_id siimage_pci_tbl[] = { |
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c index 181b647e5ca9..4b0b85d8faf5 100644 --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c | |||
@@ -347,7 +347,7 @@ static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
347 | sis_program_timings(drive, speed); | 347 | sis_program_timings(drive, speed); |
348 | } | 348 | } |
349 | 349 | ||
350 | static u8 sis5513_ata133_udma_filter(ide_drive_t *drive) | 350 | static u8 sis_ata133_udma_filter(ide_drive_t *drive) |
351 | { | 351 | { |
352 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 352 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
353 | u32 regdw = 0; | 353 | u32 regdw = 0; |
@@ -514,7 +514,7 @@ static const struct sis_laptop sis_laptop[] = { | |||
514 | { 0, } | 514 | { 0, } |
515 | }; | 515 | }; |
516 | 516 | ||
517 | static u8 __devinit ata66_sis5513(ide_hwif_t *hwif) | 517 | static u8 __devinit sis_cable_detect(ide_hwif_t *hwif) |
518 | { | 518 | { |
519 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 519 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
520 | const struct sis_laptop *lap = &sis_laptop[0]; | 520 | const struct sis_laptop *lap = &sis_laptop[0]; |
@@ -543,21 +543,22 @@ static u8 __devinit ata66_sis5513(ide_hwif_t *hwif) | |||
543 | return ata66 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; | 543 | return ata66 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; |
544 | } | 544 | } |
545 | 545 | ||
546 | static void __devinit init_hwif_sis5513(ide_hwif_t *hwif) | 546 | static const struct ide_port_ops sis_port_ops = { |
547 | { | 547 | .set_pio_mode = sis_set_pio_mode, |
548 | hwif->set_pio_mode = &sis_set_pio_mode; | 548 | .set_dma_mode = sis_set_dma_mode, |
549 | hwif->set_dma_mode = &sis_set_dma_mode; | 549 | .cable_detect = sis_cable_detect, |
550 | 550 | }; | |
551 | if (chipset_family >= ATA_133) | ||
552 | hwif->udma_filter = sis5513_ata133_udma_filter; | ||
553 | 551 | ||
554 | hwif->cable_detect = ata66_sis5513; | 552 | static const struct ide_port_ops sis_ata133_port_ops = { |
555 | } | 553 | .set_pio_mode = sis_set_pio_mode, |
554 | .set_dma_mode = sis_set_dma_mode, | ||
555 | .udma_filter = sis_ata133_udma_filter, | ||
556 | .cable_detect = sis_cable_detect, | ||
557 | }; | ||
556 | 558 | ||
557 | static const struct ide_port_info sis5513_chipset __devinitdata = { | 559 | static const struct ide_port_info sis5513_chipset __devinitdata = { |
558 | .name = "SIS5513", | 560 | .name = "SIS5513", |
559 | .init_chipset = init_chipset_sis5513, | 561 | .init_chipset = init_chipset_sis5513, |
560 | .init_hwif = init_hwif_sis5513, | ||
561 | .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} }, | 562 | .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} }, |
562 | .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA, | 563 | .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA, |
563 | .pio_mask = ATA_PIO4, | 564 | .pio_mask = ATA_PIO4, |
@@ -572,6 +573,11 @@ static int __devinit sis5513_init_one(struct pci_dev *dev, const struct pci_devi | |||
572 | if (sis_find_family(dev) == 0) | 573 | if (sis_find_family(dev) == 0) |
573 | return -ENOTSUPP; | 574 | return -ENOTSUPP; |
574 | 575 | ||
576 | if (chipset_family >= ATA_133) | ||
577 | d.port_ops = &sis_ata133_port_ops; | ||
578 | else | ||
579 | d.port_ops = &sis_port_ops; | ||
580 | |||
575 | d.udma_mask = udma_rates[chipset_family]; | 581 | d.udma_mask = udma_rates[chipset_family]; |
576 | 582 | ||
577 | return ide_setup_pci_device(dev, &d); | 583 | return ide_setup_pci_device(dev, &d); |
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c index 40b3eeb2d847..ce84fa045d39 100644 --- a/drivers/ide/pci/sl82c105.c +++ b/drivers/ide/pci/sl82c105.c | |||
@@ -179,7 +179,7 @@ static void sl82c105_dma_start(ide_drive_t *drive) | |||
179 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 179 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
180 | int reg = 0x44 + drive->dn * 4; | 180 | int reg = 0x44 + drive->dn * 4; |
181 | 181 | ||
182 | DBG(("%s(drive:%s)\n", __FUNCTION__, drive->name)); | 182 | DBG(("%s(drive:%s)\n", __func__, drive->name)); |
183 | 183 | ||
184 | pci_write_config_word(dev, reg, drive->drive_data >> 16); | 184 | pci_write_config_word(dev, reg, drive->drive_data >> 16); |
185 | 185 | ||
@@ -203,7 +203,7 @@ static int sl82c105_dma_end(ide_drive_t *drive) | |||
203 | int reg = 0x44 + drive->dn * 4; | 203 | int reg = 0x44 + drive->dn * 4; |
204 | int ret; | 204 | int ret; |
205 | 205 | ||
206 | DBG(("%s(drive:%s)\n", __FUNCTION__, drive->name)); | 206 | DBG(("%s(drive:%s)\n", __func__, drive->name)); |
207 | 207 | ||
208 | ret = __ide_dma_end(drive); | 208 | ret = __ide_dma_end(drive); |
209 | 209 | ||
@@ -232,7 +232,7 @@ static void sl82c105_resetproc(ide_drive_t *drive) | |||
232 | * Return the revision of the Winbond bridge | 232 | * Return the revision of the Winbond bridge |
233 | * which this function is part of. | 233 | * which this function is part of. |
234 | */ | 234 | */ |
235 | static unsigned int sl82c105_bridge_revision(struct pci_dev *dev) | 235 | static u8 sl82c105_bridge_revision(struct pci_dev *dev) |
236 | { | 236 | { |
237 | struct pci_dev *bridge; | 237 | struct pci_dev *bridge; |
238 | 238 | ||
@@ -282,63 +282,59 @@ static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev, const c | |||
282 | return dev->irq; | 282 | return dev->irq; |
283 | } | 283 | } |
284 | 284 | ||
285 | /* | 285 | static const struct ide_port_ops sl82c105_port_ops = { |
286 | * Initialise IDE channel | 286 | .set_pio_mode = sl82c105_set_pio_mode, |
287 | */ | 287 | .set_dma_mode = sl82c105_set_dma_mode, |
288 | static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) | 288 | .resetproc = sl82c105_resetproc, |
289 | { | 289 | }; |
290 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
291 | unsigned int rev; | ||
292 | |||
293 | DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index)); | ||
294 | |||
295 | hwif->set_pio_mode = &sl82c105_set_pio_mode; | ||
296 | hwif->set_dma_mode = &sl82c105_set_dma_mode; | ||
297 | hwif->resetproc = &sl82c105_resetproc; | ||
298 | |||
299 | if (!hwif->dma_base) | ||
300 | return; | ||
301 | |||
302 | rev = sl82c105_bridge_revision(dev); | ||
303 | if (rev <= 5) { | ||
304 | /* | ||
305 | * Never ever EVER under any circumstances enable | ||
306 | * DMA when the bridge is this old. | ||
307 | */ | ||
308 | printk(" %s: Winbond W83C553 bridge revision %d, " | ||
309 | "BM-DMA disabled\n", hwif->name, rev); | ||
310 | return; | ||
311 | } | ||
312 | |||
313 | hwif->mwdma_mask = ATA_MWDMA2; | ||
314 | |||
315 | hwif->dma_lost_irq = &sl82c105_dma_lost_irq; | ||
316 | hwif->dma_start = &sl82c105_dma_start; | ||
317 | hwif->ide_dma_end = &sl82c105_dma_end; | ||
318 | hwif->dma_timeout = &sl82c105_dma_timeout; | ||
319 | 290 | ||
320 | if (hwif->mate) | 291 | static const struct ide_dma_ops sl82c105_dma_ops = { |
321 | hwif->serialized = hwif->mate->serialized = 1; | 292 | .dma_host_set = ide_dma_host_set, |
322 | } | 293 | .dma_setup = ide_dma_setup, |
294 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
295 | .dma_start = sl82c105_dma_start, | ||
296 | .dma_end = sl82c105_dma_end, | ||
297 | .dma_test_irq = ide_dma_test_irq, | ||
298 | .dma_lost_irq = sl82c105_dma_lost_irq, | ||
299 | .dma_timeout = sl82c105_dma_timeout, | ||
300 | }; | ||
323 | 301 | ||
324 | static const struct ide_port_info sl82c105_chipset __devinitdata = { | 302 | static const struct ide_port_info sl82c105_chipset __devinitdata = { |
325 | .name = "W82C105", | 303 | .name = "W82C105", |
326 | .init_chipset = init_chipset_sl82c105, | 304 | .init_chipset = init_chipset_sl82c105, |
327 | .init_hwif = init_hwif_sl82c105, | ||
328 | .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}}, | 305 | .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}}, |
306 | .port_ops = &sl82c105_port_ops, | ||
307 | .dma_ops = &sl82c105_dma_ops, | ||
329 | .host_flags = IDE_HFLAG_IO_32BIT | | 308 | .host_flags = IDE_HFLAG_IO_32BIT | |
330 | IDE_HFLAG_UNMASK_IRQS | | 309 | IDE_HFLAG_UNMASK_IRQS | |
331 | /* FIXME: check for Compatibility mode in generic IDE PCI code */ | 310 | /* FIXME: check for Compatibility mode in generic IDE PCI code */ |
332 | #if defined(CONFIG_LOPEC) || defined(CONFIG_SANDPOINT) | 311 | #if defined(CONFIG_LOPEC) || defined(CONFIG_SANDPOINT) |
333 | IDE_HFLAG_FORCE_LEGACY_IRQS | | 312 | IDE_HFLAG_FORCE_LEGACY_IRQS | |
334 | #endif | 313 | #endif |
314 | IDE_HFLAG_SERIALIZE_DMA | | ||
335 | IDE_HFLAG_NO_AUTODMA, | 315 | IDE_HFLAG_NO_AUTODMA, |
336 | .pio_mask = ATA_PIO5, | 316 | .pio_mask = ATA_PIO5, |
317 | .mwdma_mask = ATA_MWDMA2, | ||
337 | }; | 318 | }; |
338 | 319 | ||
339 | static int __devinit sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 320 | static int __devinit sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
340 | { | 321 | { |
341 | return ide_setup_pci_device(dev, &sl82c105_chipset); | 322 | struct ide_port_info d = sl82c105_chipset; |
323 | u8 rev = sl82c105_bridge_revision(dev); | ||
324 | |||
325 | if (rev <= 5) { | ||
326 | /* | ||
327 | * Never ever EVER under any circumstances enable | ||
328 | * DMA when the bridge is this old. | ||
329 | */ | ||
330 | printk(KERN_INFO "W82C105_IDE: Winbond W83C553 bridge " | ||
331 | "revision %d, BM-DMA disabled\n", rev); | ||
332 | d.dma_ops = NULL; | ||
333 | d.mwdma_mask = 0; | ||
334 | d.host_flags &= ~IDE_HFLAG_SERIALIZE_DMA; | ||
335 | } | ||
336 | |||
337 | return ide_setup_pci_device(dev, &d); | ||
342 | } | 338 | } |
343 | 339 | ||
344 | static const struct pci_device_id sl82c105_pci_tbl[] = { | 340 | static const struct pci_device_id sl82c105_pci_tbl[] = { |
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c index eab557c45d1b..dae6e2c94d86 100644 --- a/drivers/ide/pci/slc90e66.c +++ b/drivers/ide/pci/slc90e66.c | |||
@@ -125,18 +125,16 @@ static u8 __devinit slc90e66_cable_detect(ide_hwif_t *hwif) | |||
125 | return (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | 125 | return (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; |
126 | } | 126 | } |
127 | 127 | ||
128 | static void __devinit init_hwif_slc90e66(ide_hwif_t *hwif) | 128 | static const struct ide_port_ops slc90e66_port_ops = { |
129 | { | 129 | .set_pio_mode = slc90e66_set_pio_mode, |
130 | hwif->set_pio_mode = &slc90e66_set_pio_mode; | 130 | .set_dma_mode = slc90e66_set_dma_mode, |
131 | hwif->set_dma_mode = &slc90e66_set_dma_mode; | 131 | .cable_detect = slc90e66_cable_detect, |
132 | 132 | }; | |
133 | hwif->cable_detect = slc90e66_cable_detect; | ||
134 | } | ||
135 | 133 | ||
136 | static const struct ide_port_info slc90e66_chipset __devinitdata = { | 134 | static const struct ide_port_info slc90e66_chipset __devinitdata = { |
137 | .name = "SLC90E66", | 135 | .name = "SLC90E66", |
138 | .init_hwif = init_hwif_slc90e66, | ||
139 | .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} }, | 136 | .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} }, |
137 | .port_ops = &slc90e66_port_ops, | ||
140 | .host_flags = IDE_HFLAG_LEGACY_IRQS, | 138 | .host_flags = IDE_HFLAG_LEGACY_IRQS, |
141 | .pio_mask = ATA_PIO4, | 139 | .pio_mask = ATA_PIO4, |
142 | .swdma_mask = ATA_SWDMA2_ONLY, | 140 | .swdma_mask = ATA_SWDMA2_ONLY, |
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c index c15435182e3c..9b4b27a4c711 100644 --- a/drivers/ide/pci/tc86c001.c +++ b/drivers/ide/pci/tc86c001.c | |||
@@ -157,11 +157,6 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) | |||
157 | /* Store the system control register base for convenience... */ | 157 | /* Store the system control register base for convenience... */ |
158 | hwif->config_data = sc_base; | 158 | hwif->config_data = sc_base; |
159 | 159 | ||
160 | hwif->set_pio_mode = &tc86c001_set_pio_mode; | ||
161 | hwif->set_dma_mode = &tc86c001_set_mode; | ||
162 | |||
163 | hwif->cable_detect = tc86c001_cable_detect; | ||
164 | |||
165 | if (!hwif->dma_base) | 160 | if (!hwif->dma_base) |
166 | return; | 161 | return; |
167 | 162 | ||
@@ -173,8 +168,6 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) | |||
173 | 168 | ||
174 | /* Sector Count Register limit */ | 169 | /* Sector Count Register limit */ |
175 | hwif->rqsize = 0xffff; | 170 | hwif->rqsize = 0xffff; |
176 | |||
177 | hwif->dma_start = &tc86c001_dma_start; | ||
178 | } | 171 | } |
179 | 172 | ||
180 | static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev, | 173 | static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev, |
@@ -187,10 +180,29 @@ static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev, | |||
187 | return err; | 180 | return err; |
188 | } | 181 | } |
189 | 182 | ||
183 | static const struct ide_port_ops tc86c001_port_ops = { | ||
184 | .set_pio_mode = tc86c001_set_pio_mode, | ||
185 | .set_dma_mode = tc86c001_set_mode, | ||
186 | .cable_detect = tc86c001_cable_detect, | ||
187 | }; | ||
188 | |||
189 | static const struct ide_dma_ops tc86c001_dma_ops = { | ||
190 | .dma_host_set = ide_dma_host_set, | ||
191 | .dma_setup = ide_dma_setup, | ||
192 | .dma_exec_cmd = ide_dma_exec_cmd, | ||
193 | .dma_start = tc86c001_dma_start, | ||
194 | .dma_end = __ide_dma_end, | ||
195 | .dma_test_irq = ide_dma_test_irq, | ||
196 | .dma_lost_irq = ide_dma_lost_irq, | ||
197 | .dma_timeout = ide_dma_timeout, | ||
198 | }; | ||
199 | |||
190 | static const struct ide_port_info tc86c001_chipset __devinitdata = { | 200 | static const struct ide_port_info tc86c001_chipset __devinitdata = { |
191 | .name = "TC86C001", | 201 | .name = "TC86C001", |
192 | .init_chipset = init_chipset_tc86c001, | 202 | .init_chipset = init_chipset_tc86c001, |
193 | .init_hwif = init_hwif_tc86c001, | 203 | .init_hwif = init_hwif_tc86c001, |
204 | .port_ops = &tc86c001_port_ops, | ||
205 | .dma_ops = &tc86c001_dma_ops, | ||
194 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_OFF_BOARD | | 206 | .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_OFF_BOARD | |
195 | IDE_HFLAG_ABUSE_SET_DMA_MODE, | 207 | IDE_HFLAG_ABUSE_SET_DMA_MODE, |
196 | .pio_mask = ATA_PIO4, | 208 | .pio_mask = ATA_PIO4, |
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c index 3316b197c779..db65a558d4ec 100644 --- a/drivers/ide/pci/triflex.c +++ b/drivers/ide/pci/triflex.c | |||
@@ -87,16 +87,15 @@ static void triflex_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
87 | triflex_set_mode(drive, XFER_PIO_0 + pio); | 87 | triflex_set_mode(drive, XFER_PIO_0 + pio); |
88 | } | 88 | } |
89 | 89 | ||
90 | static void __devinit init_hwif_triflex(ide_hwif_t *hwif) | 90 | static const struct ide_port_ops triflex_port_ops = { |
91 | { | 91 | .set_pio_mode = triflex_set_pio_mode, |
92 | hwif->set_pio_mode = &triflex_set_pio_mode; | 92 | .set_dma_mode = triflex_set_mode, |
93 | hwif->set_dma_mode = &triflex_set_mode; | 93 | }; |
94 | } | ||
95 | 94 | ||
96 | static const struct ide_port_info triflex_device __devinitdata = { | 95 | static const struct ide_port_info triflex_device __devinitdata = { |
97 | .name = "TRIFLEX", | 96 | .name = "TRIFLEX", |
98 | .init_hwif = init_hwif_triflex, | ||
99 | .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}}, | 97 | .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}}, |
98 | .port_ops = &triflex_port_ops, | ||
100 | .pio_mask = ATA_PIO4, | 99 | .pio_mask = ATA_PIO4, |
101 | .swdma_mask = ATA_SWDMA2, | 100 | .swdma_mask = ATA_SWDMA2, |
102 | .mwdma_mask = ATA_MWDMA2, | 101 | .mwdma_mask = ATA_MWDMA2, |
diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c index 2b8f3a2837d7..15ee38f7ad3f 100644 --- a/drivers/ide/pci/trm290.c +++ b/drivers/ide/pci/trm290.c | |||
@@ -214,7 +214,7 @@ static void trm290_dma_start(ide_drive_t *drive) | |||
214 | { | 214 | { |
215 | } | 215 | } |
216 | 216 | ||
217 | static int trm290_ide_dma_end (ide_drive_t *drive) | 217 | static int trm290_dma_end(ide_drive_t *drive) |
218 | { | 218 | { |
219 | u16 status; | 219 | u16 status; |
220 | 220 | ||
@@ -225,7 +225,7 @@ static int trm290_ide_dma_end (ide_drive_t *drive) | |||
225 | return status != 0x00ff; | 225 | return status != 0x00ff; |
226 | } | 226 | } |
227 | 227 | ||
228 | static int trm290_ide_dma_test_irq (ide_drive_t *drive) | 228 | static int trm290_dma_test_irq(ide_drive_t *drive) |
229 | { | 229 | { |
230 | u16 status; | 230 | u16 status; |
231 | 231 | ||
@@ -254,22 +254,11 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif) | |||
254 | hwif->config_data = cfg_base; | 254 | hwif->config_data = cfg_base; |
255 | hwif->dma_base = (cfg_base + 4) ^ (hwif->channel ? 0x80 : 0); | 255 | hwif->dma_base = (cfg_base + 4) ^ (hwif->channel ? 0x80 : 0); |
256 | 256 | ||
257 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx", | 257 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", |
258 | hwif->name, hwif->dma_base, hwif->dma_base + 3); | 258 | hwif->name, hwif->dma_base, hwif->dma_base + 3); |
259 | 259 | ||
260 | if (!request_region(hwif->dma_base, 4, hwif->name)) { | 260 | if (ide_allocate_dma_engine(hwif)) |
261 | printk(KERN_CONT " -- Error, ports in use.\n"); | ||
262 | return; | 261 | return; |
263 | } | ||
264 | |||
265 | hwif->dmatable_cpu = pci_alloc_consistent(dev, PRD_ENTRIES * PRD_BYTES, | ||
266 | &hwif->dmatable_dma); | ||
267 | if (!hwif->dmatable_cpu) { | ||
268 | printk(KERN_CONT " -- Error, unable to allocate DMA table.\n"); | ||
269 | release_region(hwif->dma_base, 4); | ||
270 | return; | ||
271 | } | ||
272 | printk(KERN_CONT "\n"); | ||
273 | 262 | ||
274 | local_irq_save(flags); | 263 | local_irq_save(flags); |
275 | /* put config reg into first byte of hwif->select_data */ | 264 | /* put config reg into first byte of hwif->select_data */ |
@@ -291,14 +280,6 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif) | |||
291 | /* sharing IRQ with mate */ | 280 | /* sharing IRQ with mate */ |
292 | hwif->irq = hwif->mate->irq; | 281 | hwif->irq = hwif->mate->irq; |
293 | 282 | ||
294 | hwif->dma_host_set = &trm290_dma_host_set; | ||
295 | hwif->dma_setup = &trm290_dma_setup; | ||
296 | hwif->dma_exec_cmd = &trm290_dma_exec_cmd; | ||
297 | hwif->dma_start = &trm290_dma_start; | ||
298 | hwif->ide_dma_end = &trm290_ide_dma_end; | ||
299 | hwif->ide_dma_test_irq = &trm290_ide_dma_test_irq; | ||
300 | |||
301 | hwif->selectproc = &trm290_selectproc; | ||
302 | #if 1 | 283 | #if 1 |
303 | { | 284 | { |
304 | /* | 285 | /* |
@@ -328,10 +309,27 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif) | |||
328 | #endif | 309 | #endif |
329 | } | 310 | } |
330 | 311 | ||
312 | static const struct ide_port_ops trm290_port_ops = { | ||
313 | .selectproc = trm290_selectproc, | ||
314 | }; | ||
315 | |||
316 | static struct ide_dma_ops trm290_dma_ops = { | ||
317 | .dma_host_set = trm290_dma_host_set, | ||
318 | .dma_setup = trm290_dma_setup, | ||
319 | .dma_exec_cmd = trm290_dma_exec_cmd, | ||
320 | .dma_start = trm290_dma_start, | ||
321 | .dma_end = trm290_dma_end, | ||
322 | .dma_test_irq = trm290_dma_test_irq, | ||
323 | .dma_lost_irq = ide_dma_lost_irq, | ||
324 | .dma_timeout = ide_dma_timeout, | ||
325 | }; | ||
326 | |||
331 | static const struct ide_port_info trm290_chipset __devinitdata = { | 327 | static const struct ide_port_info trm290_chipset __devinitdata = { |
332 | .name = "TRM290", | 328 | .name = "TRM290", |
333 | .init_hwif = init_hwif_trm290, | 329 | .init_hwif = init_hwif_trm290, |
334 | .chipset = ide_trm290, | 330 | .chipset = ide_trm290, |
331 | .port_ops = &trm290_port_ops, | ||
332 | .dma_ops = &trm290_dma_ops, | ||
335 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | 333 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | |
336 | #if 0 /* play it safe for now */ | 334 | #if 0 /* play it safe for now */ |
337 | IDE_HFLAG_TRUST_BIOS_FOR_DMA | | 335 | IDE_HFLAG_TRUST_BIOS_FOR_DMA | |
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index cff3cafedc47..bbd17bec6ffe 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c | |||
@@ -415,19 +415,17 @@ static u8 __devinit via82cxxx_cable_detect(ide_hwif_t *hwif) | |||
415 | return ATA_CBL_PATA40; | 415 | return ATA_CBL_PATA40; |
416 | } | 416 | } |
417 | 417 | ||
418 | static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif) | 418 | static const struct ide_port_ops via_port_ops = { |
419 | { | 419 | .set_pio_mode = via_set_pio_mode, |
420 | hwif->set_pio_mode = &via_set_pio_mode; | 420 | .set_dma_mode = via_set_drive, |
421 | hwif->set_dma_mode = &via_set_drive; | 421 | .cable_detect = via82cxxx_cable_detect, |
422 | 422 | }; | |
423 | hwif->cable_detect = via82cxxx_cable_detect; | ||
424 | } | ||
425 | 423 | ||
426 | static const struct ide_port_info via82cxxx_chipset __devinitdata = { | 424 | static const struct ide_port_info via82cxxx_chipset __devinitdata = { |
427 | .name = "VP_IDE", | 425 | .name = "VP_IDE", |
428 | .init_chipset = init_chipset_via82cxxx, | 426 | .init_chipset = init_chipset_via82cxxx, |
429 | .init_hwif = init_hwif_via82cxxx, | ||
430 | .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, | 427 | .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, |
428 | .port_ops = &via_port_ops, | ||
431 | .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | | 429 | .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | |
432 | IDE_HFLAG_ABUSE_SET_DMA_MODE | | 430 | IDE_HFLAG_ABUSE_SET_DMA_MODE | |
433 | IDE_HFLAG_POST_SET_MODE | | 431 | IDE_HFLAG_POST_SET_MODE | |
diff --git a/drivers/ide/ppc/mpc8xx.c b/drivers/ide/ppc/mpc8xx.c index 467656f06ccc..a82f6efb660b 100644 --- a/drivers/ide/ppc/mpc8xx.c +++ b/drivers/ide/ppc/mpc8xx.c | |||
@@ -438,10 +438,14 @@ static void m8xx_ide_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
438 | #elif defined(CONFIG_IDE_EXT_DIRECT) | 438 | #elif defined(CONFIG_IDE_EXT_DIRECT) |
439 | 439 | ||
440 | printk("%s[%d] %s: not implemented yet!\n", | 440 | printk("%s[%d] %s: not implemented yet!\n", |
441 | __FILE__,__LINE__,__FUNCTION__); | 441 | __FILE__, __LINE__, __func__); |
442 | #endif /* defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_PCMCIA */ | 442 | #endif /* defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_PCMCIA */ |
443 | } | 443 | } |
444 | 444 | ||
445 | static const struct ide_port_ops m8xx_port_ops = { | ||
446 | .set_pio_mode = m8xx_ide_set_pio_mode, | ||
447 | }; | ||
448 | |||
445 | static void | 449 | static void |
446 | ide_interrupt_ack (void *dev) | 450 | ide_interrupt_ack (void *dev) |
447 | { | 451 | { |
@@ -810,9 +814,8 @@ static int __init mpc8xx_ide_probe(void) | |||
810 | ide_hwif_t *hwif = &ide_hwifs[0]; | 814 | ide_hwif_t *hwif = &ide_hwifs[0]; |
811 | 815 | ||
812 | ide_init_port_hw(hwif, &hw); | 816 | ide_init_port_hw(hwif, &hw); |
813 | hwif->mmio = 1; | ||
814 | hwif->pio_mask = ATA_PIO4; | 817 | hwif->pio_mask = ATA_PIO4; |
815 | hwif->set_pio_mode = m8xx_ide_set_pio_mode; | 818 | hwif->port_ops = &m8xx_port_ops; |
816 | 819 | ||
817 | idx[0] = 0; | 820 | idx[0] = 0; |
818 | } | 821 | } |
@@ -822,9 +825,8 @@ static int __init mpc8xx_ide_probe(void) | |||
822 | ide_hwif_t *mate = &ide_hwifs[1]; | 825 | ide_hwif_t *mate = &ide_hwifs[1]; |
823 | 826 | ||
824 | ide_init_port_hw(mate, &hw); | 827 | ide_init_port_hw(mate, &hw); |
825 | mate->mmio = 1; | ||
826 | mate->pio_mask = ATA_PIO4; | 828 | mate->pio_mask = ATA_PIO4; |
827 | mate->set_pio_mode = m8xx_ide_set_pio_mode; | 829 | mate->port_ops = &m8xx_port_ops; |
828 | 830 | ||
829 | idx[1] = 1; | 831 | idx[1] = 1; |
830 | } | 832 | } |
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index 177961edc430..185faa0dce94 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c | |||
@@ -409,7 +409,7 @@ kauai_lookup_timing(struct kauai_timing* table, int cycle_time) | |||
409 | */ | 409 | */ |
410 | #define IDE_WAKEUP_DELAY (1*HZ) | 410 | #define IDE_WAKEUP_DELAY (1*HZ) |
411 | 411 | ||
412 | static int pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif); | 412 | static int pmac_ide_init_dma(ide_hwif_t *, const struct ide_port_info *); |
413 | static int pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq); | 413 | static int pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq); |
414 | static void pmac_ide_selectproc(ide_drive_t *drive); | 414 | static void pmac_ide_selectproc(ide_drive_t *drive); |
415 | static void pmac_ide_kauai_selectproc(ide_drive_t *drive); | 415 | static void pmac_ide_kauai_selectproc(ide_drive_t *drive); |
@@ -918,11 +918,29 @@ pmac_ide_do_resume(ide_hwif_t *hwif) | |||
918 | return 0; | 918 | return 0; |
919 | } | 919 | } |
920 | 920 | ||
921 | static const struct ide_port_ops pmac_ide_ata6_port_ops = { | ||
922 | .set_pio_mode = pmac_ide_set_pio_mode, | ||
923 | .set_dma_mode = pmac_ide_set_dma_mode, | ||
924 | .selectproc = pmac_ide_kauai_selectproc, | ||
925 | }; | ||
926 | |||
927 | static const struct ide_port_ops pmac_ide_port_ops = { | ||
928 | .set_pio_mode = pmac_ide_set_pio_mode, | ||
929 | .set_dma_mode = pmac_ide_set_dma_mode, | ||
930 | .selectproc = pmac_ide_selectproc, | ||
931 | }; | ||
932 | |||
933 | static const struct ide_dma_ops pmac_dma_ops; | ||
934 | |||
921 | static const struct ide_port_info pmac_port_info = { | 935 | static const struct ide_port_info pmac_port_info = { |
936 | .init_dma = pmac_ide_init_dma, | ||
922 | .chipset = ide_pmac, | 937 | .chipset = ide_pmac, |
938 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC | ||
939 | .dma_ops = &pmac_dma_ops, | ||
940 | #endif | ||
941 | .port_ops = &pmac_ide_port_ops, | ||
923 | .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | | 942 | .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | |
924 | IDE_HFLAG_POST_SET_MODE | | 943 | IDE_HFLAG_POST_SET_MODE | |
925 | IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ | ||
926 | IDE_HFLAG_UNMASK_IRQS, | 944 | IDE_HFLAG_UNMASK_IRQS, |
927 | .pio_mask = ATA_PIO4, | 945 | .pio_mask = ATA_PIO4, |
928 | .mwdma_mask = ATA_MWDMA2, | 946 | .mwdma_mask = ATA_MWDMA2, |
@@ -947,12 +965,15 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) | |||
947 | pmif->broken_dma = pmif->broken_dma_warn = 0; | 965 | pmif->broken_dma = pmif->broken_dma_warn = 0; |
948 | if (of_device_is_compatible(np, "shasta-ata")) { | 966 | if (of_device_is_compatible(np, "shasta-ata")) { |
949 | pmif->kind = controller_sh_ata6; | 967 | pmif->kind = controller_sh_ata6; |
968 | d.port_ops = &pmac_ide_ata6_port_ops; | ||
950 | d.udma_mask = ATA_UDMA6; | 969 | d.udma_mask = ATA_UDMA6; |
951 | } else if (of_device_is_compatible(np, "kauai-ata")) { | 970 | } else if (of_device_is_compatible(np, "kauai-ata")) { |
952 | pmif->kind = controller_un_ata6; | 971 | pmif->kind = controller_un_ata6; |
972 | d.port_ops = &pmac_ide_ata6_port_ops; | ||
953 | d.udma_mask = ATA_UDMA5; | 973 | d.udma_mask = ATA_UDMA5; |
954 | } else if (of_device_is_compatible(np, "K2-UATA")) { | 974 | } else if (of_device_is_compatible(np, "K2-UATA")) { |
955 | pmif->kind = controller_k2_ata6; | 975 | pmif->kind = controller_k2_ata6; |
976 | d.port_ops = &pmac_ide_ata6_port_ops; | ||
956 | d.udma_mask = ATA_UDMA5; | 977 | d.udma_mask = ATA_UDMA5; |
957 | } else if (of_device_is_compatible(np, "keylargo-ata")) { | 978 | } else if (of_device_is_compatible(np, "keylargo-ata")) { |
958 | if (strcmp(np->name, "ata-4") == 0) { | 979 | if (strcmp(np->name, "ata-4") == 0) { |
@@ -1029,37 +1050,29 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) | |||
1029 | default_hwif_mmiops(hwif); | 1050 | default_hwif_mmiops(hwif); |
1030 | hwif->OUTBSYNC = pmac_outbsync; | 1051 | hwif->OUTBSYNC = pmac_outbsync; |
1031 | 1052 | ||
1032 | /* Tell common code _not_ to mess with resources */ | ||
1033 | hwif->mmio = 1; | ||
1034 | hwif->hwif_data = pmif; | 1053 | hwif->hwif_data = pmif; |
1035 | ide_init_port_hw(hwif, hw); | 1054 | ide_init_port_hw(hwif, hw); |
1036 | hwif->noprobe = pmif->mediabay; | ||
1037 | hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; | 1055 | hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; |
1038 | hwif->set_pio_mode = pmac_ide_set_pio_mode; | ||
1039 | if (pmif->kind == controller_un_ata6 | ||
1040 | || pmif->kind == controller_k2_ata6 | ||
1041 | || pmif->kind == controller_sh_ata6) | ||
1042 | hwif->selectproc = pmac_ide_kauai_selectproc; | ||
1043 | else | ||
1044 | hwif->selectproc = pmac_ide_selectproc; | ||
1045 | hwif->set_dma_mode = pmac_ide_set_dma_mode; | ||
1046 | 1056 | ||
1047 | printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n", | 1057 | printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n", |
1048 | hwif->index, model_name[pmif->kind], pmif->aapl_bus_id, | 1058 | hwif->index, model_name[pmif->kind], pmif->aapl_bus_id, |
1049 | pmif->mediabay ? " (mediabay)" : "", hwif->irq); | 1059 | pmif->mediabay ? " (mediabay)" : "", hwif->irq); |
1050 | 1060 | ||
1061 | if (pmif->mediabay) { | ||
1051 | #ifdef CONFIG_PMAC_MEDIABAY | 1062 | #ifdef CONFIG_PMAC_MEDIABAY |
1052 | if (pmif->mediabay && check_media_bay_by_base(pmif->regbase, MB_CD) == 0) | 1063 | if (check_media_bay_by_base(pmif->regbase, MB_CD)) { |
1053 | hwif->noprobe = 0; | 1064 | #else |
1054 | #endif /* CONFIG_PMAC_MEDIABAY */ | 1065 | if (1) { |
1066 | #endif | ||
1067 | hwif->drives[0].noprobe = 1; | ||
1068 | hwif->drives[1].noprobe = 1; | ||
1069 | } | ||
1070 | } | ||
1055 | 1071 | ||
1056 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC | 1072 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC |
1057 | if (pmif->cable_80 == 0) | 1073 | if (pmif->cable_80 == 0) |
1058 | d.udma_mask &= ATA_UDMA2; | 1074 | d.udma_mask &= ATA_UDMA2; |
1059 | /* has a DBDMA controller channel */ | ||
1060 | if (pmif->dma_regs == 0 || pmac_ide_setup_dma(pmif, hwif) < 0) | ||
1061 | #endif | 1075 | #endif |
1062 | d.udma_mask = d.mwdma_mask = 0; | ||
1063 | 1076 | ||
1064 | idx[0] = hwif->index; | 1077 | idx[0] = hwif->index; |
1065 | 1078 | ||
@@ -1662,18 +1675,31 @@ pmac_ide_dma_lost_irq (ide_drive_t *drive) | |||
1662 | printk(KERN_ERR "ide-pmac lost interrupt, dma status: %lx\n", status); | 1675 | printk(KERN_ERR "ide-pmac lost interrupt, dma status: %lx\n", status); |
1663 | } | 1676 | } |
1664 | 1677 | ||
1678 | static const struct ide_dma_ops pmac_dma_ops = { | ||
1679 | .dma_host_set = pmac_ide_dma_host_set, | ||
1680 | .dma_setup = pmac_ide_dma_setup, | ||
1681 | .dma_exec_cmd = pmac_ide_dma_exec_cmd, | ||
1682 | .dma_start = pmac_ide_dma_start, | ||
1683 | .dma_end = pmac_ide_dma_end, | ||
1684 | .dma_test_irq = pmac_ide_dma_test_irq, | ||
1685 | .dma_timeout = ide_dma_timeout, | ||
1686 | .dma_lost_irq = pmac_ide_dma_lost_irq, | ||
1687 | }; | ||
1688 | |||
1665 | /* | 1689 | /* |
1666 | * Allocate the data structures needed for using DMA with an interface | 1690 | * Allocate the data structures needed for using DMA with an interface |
1667 | * and fill the proper list of functions pointers | 1691 | * and fill the proper list of functions pointers |
1668 | */ | 1692 | */ |
1669 | static int __devinit pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | 1693 | static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif, |
1694 | const struct ide_port_info *d) | ||
1670 | { | 1695 | { |
1696 | pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data; | ||
1671 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 1697 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
1672 | 1698 | ||
1673 | /* We won't need pci_dev if we switch to generic consistent | 1699 | /* We won't need pci_dev if we switch to generic consistent |
1674 | * DMA routines ... | 1700 | * DMA routines ... |
1675 | */ | 1701 | */ |
1676 | if (dev == NULL) | 1702 | if (dev == NULL || pmif->dma_regs == 0) |
1677 | return -ENODEV; | 1703 | return -ENODEV; |
1678 | /* | 1704 | /* |
1679 | * Allocate space for the DBDMA commands. | 1705 | * Allocate space for the DBDMA commands. |
@@ -1692,18 +1718,14 @@ static int __devinit pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | |||
1692 | 1718 | ||
1693 | hwif->sg_max_nents = MAX_DCMDS; | 1719 | hwif->sg_max_nents = MAX_DCMDS; |
1694 | 1720 | ||
1695 | hwif->dma_host_set = &pmac_ide_dma_host_set; | ||
1696 | hwif->dma_setup = &pmac_ide_dma_setup; | ||
1697 | hwif->dma_exec_cmd = &pmac_ide_dma_exec_cmd; | ||
1698 | hwif->dma_start = &pmac_ide_dma_start; | ||
1699 | hwif->ide_dma_end = &pmac_ide_dma_end; | ||
1700 | hwif->ide_dma_test_irq = &pmac_ide_dma_test_irq; | ||
1701 | hwif->dma_timeout = &ide_dma_timeout; | ||
1702 | hwif->dma_lost_irq = &pmac_ide_dma_lost_irq; | ||
1703 | |||
1704 | return 0; | 1721 | return 0; |
1705 | } | 1722 | } |
1706 | 1723 | #else | |
1724 | static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif, | ||
1725 | const struct ide_port_info *d) | ||
1726 | { | ||
1727 | return -EOPNOTSUPP; | ||
1728 | } | ||
1707 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ | 1729 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ |
1708 | 1730 | ||
1709 | module_init(pmac_ide_probe); | 1731 | module_init(pmac_ide_probe); |
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 6302010fd8e2..5171601fb255 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -72,16 +72,16 @@ static void ide_pci_clear_simplex(unsigned long dma_base, const char *name) | |||
72 | } | 72 | } |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * ide_get_or_set_dma_base - setup BMIBA | 75 | * ide_pci_dma_base - setup BMIBA |
76 | * @d: IDE port info | ||
77 | * @hwif: IDE interface | 76 | * @hwif: IDE interface |
77 | * @d: IDE port info | ||
78 | * | 78 | * |
79 | * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space. | 79 | * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space. |
80 | * Where a device has a partner that is already in DMA mode we check | 80 | * Where a device has a partner that is already in DMA mode we check |
81 | * and enforce IDE simplex rules. | 81 | * and enforce IDE simplex rules. |
82 | */ | 82 | */ |
83 | 83 | ||
84 | static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_hwif_t *hwif) | 84 | unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d) |
85 | { | 85 | { |
86 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 86 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
87 | unsigned long dma_base = 0; | 87 | unsigned long dma_base = 0; |
@@ -132,6 +132,31 @@ static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_ | |||
132 | out: | 132 | out: |
133 | return dma_base; | 133 | return dma_base; |
134 | } | 134 | } |
135 | EXPORT_SYMBOL_GPL(ide_pci_dma_base); | ||
136 | |||
137 | /* | ||
138 | * Set up BM-DMA capability (PnP BIOS should have done this) | ||
139 | */ | ||
140 | int ide_pci_set_master(struct pci_dev *dev, const char *name) | ||
141 | { | ||
142 | u16 pcicmd; | ||
143 | |||
144 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); | ||
145 | |||
146 | if ((pcicmd & PCI_COMMAND_MASTER) == 0) { | ||
147 | pci_set_master(dev); | ||
148 | |||
149 | if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || | ||
150 | (pcicmd & PCI_COMMAND_MASTER) == 0) { | ||
151 | printk(KERN_ERR "%s: error updating PCICMD on %s\n", | ||
152 | name, pci_name(dev)); | ||
153 | return -EIO; | ||
154 | } | ||
155 | } | ||
156 | |||
157 | return 0; | ||
158 | } | ||
159 | EXPORT_SYMBOL_GPL(ide_pci_set_master); | ||
135 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | 160 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ |
136 | 161 | ||
137 | void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d) | 162 | void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d) |
@@ -158,7 +183,7 @@ EXPORT_SYMBOL_GPL(ide_setup_pci_noise); | |||
158 | 183 | ||
159 | static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d) | 184 | static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d) |
160 | { | 185 | { |
161 | int ret; | 186 | int ret, bars; |
162 | 187 | ||
163 | if (pci_enable_device(dev)) { | 188 | if (pci_enable_device(dev)) { |
164 | ret = pci_enable_device_io(dev); | 189 | ret = pci_enable_device_io(dev); |
@@ -181,13 +206,21 @@ static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d) | |||
181 | goto out; | 206 | goto out; |
182 | } | 207 | } |
183 | 208 | ||
184 | /* FIXME: Temporary - until we put in the hotplug interface logic | 209 | if (d->host_flags & IDE_HFLAG_SINGLE) |
185 | Check that the bits we want are not in use by someone else. */ | 210 | bars = (1 << 2) - 1; |
186 | ret = pci_request_region(dev, 4, "ide_tmp"); | 211 | else |
187 | if (ret < 0) | 212 | bars = (1 << 4) - 1; |
188 | goto out; | ||
189 | 213 | ||
190 | pci_release_region(dev, 4); | 214 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) { |
215 | if (d->host_flags & IDE_HFLAG_CS5520) | ||
216 | bars |= (1 << 2); | ||
217 | else | ||
218 | bars |= (1 << 4); | ||
219 | } | ||
220 | |||
221 | ret = pci_request_selected_regions(dev, bars, d->name); | ||
222 | if (ret < 0) | ||
223 | printk(KERN_ERR "%s: can't reserve resources\n", d->name); | ||
191 | out: | 224 | out: |
192 | return ret; | 225 | return ret; |
193 | } | 226 | } |
@@ -314,7 +347,6 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, | |||
314 | ide_init_port_hw(hwif, &hw); | 347 | ide_init_port_hw(hwif, &hw); |
315 | 348 | ||
316 | hwif->dev = &dev->dev; | 349 | hwif->dev = &dev->dev; |
317 | hwif->cds = d; | ||
318 | 350 | ||
319 | return hwif; | 351 | return hwif; |
320 | } | 352 | } |
@@ -330,40 +362,33 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, | |||
330 | * state | 362 | * state |
331 | */ | 363 | */ |
332 | 364 | ||
333 | void ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) | 365 | int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) |
334 | { | 366 | { |
335 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 367 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
336 | u16 pcicmd; | ||
337 | |||
338 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); | ||
339 | 368 | ||
340 | if ((d->host_flags & IDE_HFLAG_NO_AUTODMA) == 0 || | 369 | if ((d->host_flags & IDE_HFLAG_NO_AUTODMA) == 0 || |
341 | ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && | 370 | ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && |
342 | (dev->class & 0x80))) { | 371 | (dev->class & 0x80))) { |
343 | unsigned long dma_base = ide_get_or_set_dma_base(d, hwif); | 372 | unsigned long base = ide_pci_dma_base(hwif, d); |
344 | if (dma_base && !(pcicmd & PCI_COMMAND_MASTER)) { | 373 | |
345 | /* | 374 | if (base == 0 || ide_pci_set_master(dev, d->name) < 0) |
346 | * Set up BM-DMA capability | 375 | return -1; |
347 | * (PnP BIOS should have done this) | 376 | |
348 | */ | 377 | if (hwif->mmio) |
349 | pci_set_master(dev); | 378 | printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); |
350 | if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || !(pcicmd & PCI_COMMAND_MASTER)) { | 379 | else |
351 | printk(KERN_ERR "%s: %s error updating PCICMD\n", | 380 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", |
352 | hwif->name, d->name); | 381 | hwif->name, base, base + 7); |
353 | dma_base = 0; | 382 | |
354 | } | 383 | hwif->extra_base = base + (hwif->channel ? 8 : 16); |
355 | } | 384 | |
356 | if (dma_base) { | 385 | if (ide_allocate_dma_engine(hwif)) |
357 | if (d->init_dma) { | 386 | return -1; |
358 | d->init_dma(hwif, dma_base); | 387 | |
359 | } else { | 388 | ide_setup_dma(hwif, base); |
360 | ide_setup_dma(hwif, dma_base); | ||
361 | } | ||
362 | } else { | ||
363 | printk(KERN_INFO "%s: %s Bus-Master DMA disabled " | ||
364 | "(BIOS)\n", hwif->name, d->name); | ||
365 | } | ||
366 | } | 389 | } |
390 | |||
391 | return 0; | ||
367 | } | 392 | } |
368 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | 393 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ |
369 | 394 | ||
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 93c3fc20aa59..3638fa808ded 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
@@ -393,7 +393,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) | |||
393 | printk ("ide-scsi: %s: DMA complete\n", drive->name); | 393 | printk ("ide-scsi: %s: DMA complete\n", drive->name); |
394 | #endif /* IDESCSI_DEBUG_LOG */ | 394 | #endif /* IDESCSI_DEBUG_LOG */ |
395 | pc->xferred = pc->req_xfer; | 395 | pc->xferred = pc->req_xfer; |
396 | (void) HWIF(drive)->ide_dma_end(drive); | 396 | (void)hwif->dma_ops->dma_end(drive); |
397 | } | 397 | } |
398 | 398 | ||
399 | /* Clear the interrupt */ | 399 | /* Clear the interrupt */ |
@@ -498,7 +498,7 @@ static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive) | |||
498 | drive->hwif->atapi_output_bytes(drive, scsi->pc->c, 12); | 498 | drive->hwif->atapi_output_bytes(drive, scsi->pc->c, 12); |
499 | if (pc->flags & PC_FLAG_DMA_OK) { | 499 | if (pc->flags & PC_FLAG_DMA_OK) { |
500 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; | 500 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; |
501 | hwif->dma_start(drive); | 501 | hwif->dma_ops->dma_start(drive); |
502 | } | 502 | } |
503 | return ide_started; | 503 | return ide_started; |
504 | } | 504 | } |
@@ -560,7 +560,7 @@ static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive, | |||
560 | 560 | ||
561 | if (drive->using_dma && !idescsi_map_sg(drive, pc)) { | 561 | if (drive->using_dma && !idescsi_map_sg(drive, pc)) { |
562 | hwif->sg_mapped = 1; | 562 | hwif->sg_mapped = 1; |
563 | dma = !hwif->dma_setup(drive); | 563 | dma = !hwif->dma_ops->dma_setup(drive); |
564 | hwif->sg_mapped = 0; | 564 | hwif->sg_mapped = 0; |
565 | } | 565 | } |
566 | 566 | ||
diff --git a/include/asm-alpha/bitops.h b/include/asm-alpha/bitops.h index 9e19a704d484..15f3ae25c511 100644 --- a/include/asm-alpha/bitops.h +++ b/include/asm-alpha/bitops.h | |||
@@ -388,6 +388,11 @@ static inline int fls64(unsigned long x) | |||
388 | } | 388 | } |
389 | #endif | 389 | #endif |
390 | 390 | ||
391 | static inline unsigned long __fls(unsigned long x) | ||
392 | { | ||
393 | return fls64(x) - 1; | ||
394 | } | ||
395 | |||
391 | static inline int fls(int x) | 396 | static inline int fls(int x) |
392 | { | 397 | { |
393 | return fls64((unsigned int) x); | 398 | return fls64((unsigned int) x); |
diff --git a/include/asm-generic/bitops/__fls.h b/include/asm-generic/bitops/__fls.h new file mode 100644 index 000000000000..be24465403d6 --- /dev/null +++ b/include/asm-generic/bitops/__fls.h | |||
@@ -0,0 +1,43 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS___FLS_H_ | ||
2 | #define _ASM_GENERIC_BITOPS___FLS_H_ | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | |||
6 | /** | ||
7 | * __fls - find last (most-significant) set bit in a long word | ||
8 | * @word: the word to search | ||
9 | * | ||
10 | * Undefined if no set bit exists, so code should check against 0 first. | ||
11 | */ | ||
12 | static inline unsigned long __fls(unsigned long word) | ||
13 | { | ||
14 | int num = BITS_PER_LONG - 1; | ||
15 | |||
16 | #if BITS_PER_LONG == 64 | ||
17 | if (!(word & (~0ul << 32))) { | ||
18 | num -= 32; | ||
19 | word <<= 32; | ||
20 | } | ||
21 | #endif | ||
22 | if (!(word & (~0ul << (BITS_PER_LONG-16)))) { | ||
23 | num -= 16; | ||
24 | word <<= 16; | ||
25 | } | ||
26 | if (!(word & (~0ul << (BITS_PER_LONG-8)))) { | ||
27 | num -= 8; | ||
28 | word <<= 8; | ||
29 | } | ||
30 | if (!(word & (~0ul << (BITS_PER_LONG-4)))) { | ||
31 | num -= 4; | ||
32 | word <<= 4; | ||
33 | } | ||
34 | if (!(word & (~0ul << (BITS_PER_LONG-2)))) { | ||
35 | num -= 2; | ||
36 | word <<= 2; | ||
37 | } | ||
38 | if (!(word & (~0ul << (BITS_PER_LONG-1)))) | ||
39 | num -= 1; | ||
40 | return num; | ||
41 | } | ||
42 | |||
43 | #endif /* _ASM_GENERIC_BITOPS___FLS_H_ */ | ||
diff --git a/include/asm-generic/bitops/find.h b/include/asm-generic/bitops/find.h index 72a51e5a12ef..1914e9742512 100644 --- a/include/asm-generic/bitops/find.h +++ b/include/asm-generic/bitops/find.h | |||
@@ -1,11 +1,13 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS_FIND_H_ | 1 | #ifndef _ASM_GENERIC_BITOPS_FIND_H_ |
2 | #define _ASM_GENERIC_BITOPS_FIND_H_ | 2 | #define _ASM_GENERIC_BITOPS_FIND_H_ |
3 | 3 | ||
4 | #ifndef CONFIG_GENERIC_FIND_NEXT_BIT | ||
4 | extern unsigned long find_next_bit(const unsigned long *addr, unsigned long | 5 | extern unsigned long find_next_bit(const unsigned long *addr, unsigned long |
5 | size, unsigned long offset); | 6 | size, unsigned long offset); |
6 | 7 | ||
7 | extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned | 8 | extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned |
8 | long size, unsigned long offset); | 9 | long size, unsigned long offset); |
10 | #endif | ||
9 | 11 | ||
10 | #define find_first_bit(addr, size) find_next_bit((addr), (size), 0) | 12 | #define find_first_bit(addr, size) find_next_bit((addr), (size), 0) |
11 | #define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0) | 13 | #define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0) |
diff --git a/include/asm-generic/bitops/fls64.h b/include/asm-generic/bitops/fls64.h index 1b6b17ce2428..86d403f8b256 100644 --- a/include/asm-generic/bitops/fls64.h +++ b/include/asm-generic/bitops/fls64.h | |||
@@ -3,6 +3,18 @@ | |||
3 | 3 | ||
4 | #include <asm/types.h> | 4 | #include <asm/types.h> |
5 | 5 | ||
6 | /** | ||
7 | * fls64 - find last set bit in a 64-bit word | ||
8 | * @x: the word to search | ||
9 | * | ||
10 | * This is defined in a similar way as the libc and compiler builtin | ||
11 | * ffsll, but returns the position of the most significant set bit. | ||
12 | * | ||
13 | * fls64(value) returns 0 if value is 0 or the position of the last | ||
14 | * set bit if value is nonzero. The last (most significant) bit is | ||
15 | * at position 64. | ||
16 | */ | ||
17 | #if BITS_PER_LONG == 32 | ||
6 | static inline int fls64(__u64 x) | 18 | static inline int fls64(__u64 x) |
7 | { | 19 | { |
8 | __u32 h = x >> 32; | 20 | __u32 h = x >> 32; |
@@ -10,5 +22,15 @@ static inline int fls64(__u64 x) | |||
10 | return fls(h) + 32; | 22 | return fls(h) + 32; |
11 | return fls(x); | 23 | return fls(x); |
12 | } | 24 | } |
25 | #elif BITS_PER_LONG == 64 | ||
26 | static inline int fls64(__u64 x) | ||
27 | { | ||
28 | if (x == 0) | ||
29 | return 0; | ||
30 | return __fls(x) + 1; | ||
31 | } | ||
32 | #else | ||
33 | #error BITS_PER_LONG not 32 or 64 | ||
34 | #endif | ||
13 | 35 | ||
14 | #endif /* _ASM_GENERIC_BITOPS_FLS64_H_ */ | 36 | #endif /* _ASM_GENERIC_BITOPS_FLS64_H_ */ |
diff --git a/include/asm-ia64/bitops.h b/include/asm-ia64/bitops.h index 953d3df9dd22..e2ca80037335 100644 --- a/include/asm-ia64/bitops.h +++ b/include/asm-ia64/bitops.h | |||
@@ -407,6 +407,22 @@ fls (int t) | |||
407 | return ia64_popcnt(x); | 407 | return ia64_popcnt(x); |
408 | } | 408 | } |
409 | 409 | ||
410 | /* | ||
411 | * Find the last (most significant) bit set. Undefined for x==0. | ||
412 | * Bits are numbered from 0..63 (e.g., __fls(9) == 3). | ||
413 | */ | ||
414 | static inline unsigned long | ||
415 | __fls (unsigned long x) | ||
416 | { | ||
417 | x |= x >> 1; | ||
418 | x |= x >> 2; | ||
419 | x |= x >> 4; | ||
420 | x |= x >> 8; | ||
421 | x |= x >> 16; | ||
422 | x |= x >> 32; | ||
423 | return ia64_popcnt(x) - 1; | ||
424 | } | ||
425 | |||
410 | #include <asm-generic/bitops/fls64.h> | 426 | #include <asm-generic/bitops/fls64.h> |
411 | 427 | ||
412 | /* | 428 | /* |
diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h index ec75ce4cdb8c..c2bd126c3b4e 100644 --- a/include/asm-mips/bitops.h +++ b/include/asm-mips/bitops.h | |||
@@ -591,6 +591,11 @@ static inline int __ilog2(unsigned long x) | |||
591 | return 63 - lz; | 591 | return 63 - lz; |
592 | } | 592 | } |
593 | 593 | ||
594 | static inline unsigned long __fls(unsigned long x) | ||
595 | { | ||
596 | return __ilog2(x); | ||
597 | } | ||
598 | |||
594 | #if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64) | 599 | #if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64) |
595 | 600 | ||
596 | /* | 601 | /* |
diff --git a/include/asm-mips/mach-au1x00/au1xxx_ide.h b/include/asm-mips/mach-au1x00/au1xxx_ide.h index 89655c0cdcd6..b493a5e46c63 100644 --- a/include/asm-mips/mach-au1x00/au1xxx_ide.h +++ b/include/asm-mips/mach-au1x00/au1xxx_ide.h | |||
@@ -70,7 +70,6 @@ typedef struct | |||
70 | ide_hwif_t *hwif; | 70 | ide_hwif_t *hwif; |
71 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | 71 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA |
72 | ide_drive_t *drive; | 72 | ide_drive_t *drive; |
73 | u8 white_list, black_list; | ||
74 | struct dbdma_cmd *dma_table_cpu; | 73 | struct dbdma_cmd *dma_table_cpu; |
75 | dma_addr_t dma_table_dma; | 74 | dma_addr_t dma_table_dma; |
76 | #endif | 75 | #endif |
@@ -81,47 +80,6 @@ typedef struct | |||
81 | #endif | 80 | #endif |
82 | } _auide_hwif; | 81 | } _auide_hwif; |
83 | 82 | ||
84 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | ||
85 | /* HD white list */ | ||
86 | static const struct drive_list_entry dma_white_list [] = { | ||
87 | /* | ||
88 | * Hitachi | ||
89 | */ | ||
90 | { "HITACHI_DK14FA-20" , NULL }, | ||
91 | { "HTS726060M9AT00" , NULL }, | ||
92 | /* | ||
93 | * Maxtor | ||
94 | */ | ||
95 | { "Maxtor 6E040L0" , NULL }, | ||
96 | { "Maxtor 6Y080P0" , NULL }, | ||
97 | { "Maxtor 6Y160P0" , NULL }, | ||
98 | /* | ||
99 | * Seagate | ||
100 | */ | ||
101 | { "ST3120026A" , NULL }, | ||
102 | { "ST320014A" , NULL }, | ||
103 | { "ST94011A" , NULL }, | ||
104 | { "ST340016A" , NULL }, | ||
105 | /* | ||
106 | * Western Digital | ||
107 | */ | ||
108 | { "WDC WD400UE-00HCT0" , NULL }, | ||
109 | { "WDC WD400JB-00JJC0" , NULL }, | ||
110 | { NULL , NULL } | ||
111 | }; | ||
112 | |||
113 | /* HD black list */ | ||
114 | static const struct drive_list_entry dma_black_list [] = { | ||
115 | /* | ||
116 | * Western Digital | ||
117 | */ | ||
118 | { "WDC WD100EB-00CGH0" , NULL }, | ||
119 | { "WDC WD200BB-00AUA1" , NULL }, | ||
120 | { "WDC AC24300L" , NULL }, | ||
121 | { NULL , NULL } | ||
122 | }; | ||
123 | #endif | ||
124 | |||
125 | /******************************************************************************* | 83 | /******************************************************************************* |
126 | * PIO Mode timing calculation : * | 84 | * PIO Mode timing calculation : * |
127 | * * | 85 | * * |
diff --git a/include/asm-parisc/bitops.h b/include/asm-parisc/bitops.h index f8eebcbad01f..7a6ea10bd231 100644 --- a/include/asm-parisc/bitops.h +++ b/include/asm-parisc/bitops.h | |||
@@ -210,6 +210,7 @@ static __inline__ int fls(int x) | |||
210 | return ret; | 210 | return ret; |
211 | } | 211 | } |
212 | 212 | ||
213 | #include <asm-generic/bitops/__fls.h> | ||
213 | #include <asm-generic/bitops/fls64.h> | 214 | #include <asm-generic/bitops/fls64.h> |
214 | #include <asm-generic/bitops/hweight.h> | 215 | #include <asm-generic/bitops/hweight.h> |
215 | #include <asm-generic/bitops/lock.h> | 216 | #include <asm-generic/bitops/lock.h> |
diff --git a/include/asm-powerpc/bitops.h b/include/asm-powerpc/bitops.h index a99a74929475..897eade3afbe 100644 --- a/include/asm-powerpc/bitops.h +++ b/include/asm-powerpc/bitops.h | |||
@@ -313,6 +313,11 @@ static __inline__ int fls(unsigned int x) | |||
313 | return 32 - lz; | 313 | return 32 - lz; |
314 | } | 314 | } |
315 | 315 | ||
316 | static __inline__ unsigned long __fls(unsigned long x) | ||
317 | { | ||
318 | return __ilog2(x); | ||
319 | } | ||
320 | |||
316 | /* | 321 | /* |
317 | * 64-bit can do this using one cntlzd (count leading zeroes doubleword) | 322 | * 64-bit can do this using one cntlzd (count leading zeroes doubleword) |
318 | * instruction; for 32-bit we use the generic version, which does two | 323 | * instruction; for 32-bit we use the generic version, which does two |
diff --git a/include/asm-s390/bitops.h b/include/asm-s390/bitops.h index 965394e69452..b4eb24ab5af9 100644 --- a/include/asm-s390/bitops.h +++ b/include/asm-s390/bitops.h | |||
@@ -769,6 +769,7 @@ static inline int sched_find_first_bit(unsigned long *b) | |||
769 | } | 769 | } |
770 | 770 | ||
771 | #include <asm-generic/bitops/fls.h> | 771 | #include <asm-generic/bitops/fls.h> |
772 | #include <asm-generic/bitops/__fls.h> | ||
772 | #include <asm-generic/bitops/fls64.h> | 773 | #include <asm-generic/bitops/fls64.h> |
773 | 774 | ||
774 | #include <asm-generic/bitops/hweight.h> | 775 | #include <asm-generic/bitops/hweight.h> |
diff --git a/include/asm-sh/bitops.h b/include/asm-sh/bitops.h index b6ba5a60dec2..d7d382f63ee5 100644 --- a/include/asm-sh/bitops.h +++ b/include/asm-sh/bitops.h | |||
@@ -95,6 +95,7 @@ static inline unsigned long ffz(unsigned long word) | |||
95 | #include <asm-generic/bitops/ext2-atomic.h> | 95 | #include <asm-generic/bitops/ext2-atomic.h> |
96 | #include <asm-generic/bitops/minix.h> | 96 | #include <asm-generic/bitops/minix.h> |
97 | #include <asm-generic/bitops/fls.h> | 97 | #include <asm-generic/bitops/fls.h> |
98 | #include <asm-generic/bitops/__fls.h> | ||
98 | #include <asm-generic/bitops/fls64.h> | 99 | #include <asm-generic/bitops/fls64.h> |
99 | 100 | ||
100 | #endif /* __KERNEL__ */ | 101 | #endif /* __KERNEL__ */ |
diff --git a/include/asm-sparc64/bitops.h b/include/asm-sparc64/bitops.h index 982ce8992b91..11f9d8146cdf 100644 --- a/include/asm-sparc64/bitops.h +++ b/include/asm-sparc64/bitops.h | |||
@@ -34,6 +34,7 @@ extern void change_bit(unsigned long nr, volatile unsigned long *addr); | |||
34 | #include <asm-generic/bitops/ffz.h> | 34 | #include <asm-generic/bitops/ffz.h> |
35 | #include <asm-generic/bitops/__ffs.h> | 35 | #include <asm-generic/bitops/__ffs.h> |
36 | #include <asm-generic/bitops/fls.h> | 36 | #include <asm-generic/bitops/fls.h> |
37 | #include <asm-generic/bitops/__fls.h> | ||
37 | #include <asm-generic/bitops/fls64.h> | 38 | #include <asm-generic/bitops/fls64.h> |
38 | 39 | ||
39 | #ifdef __KERNEL__ | 40 | #ifdef __KERNEL__ |
diff --git a/include/asm-x86/bitops.h b/include/asm-x86/bitops.h index 1ae7b270a1ef..b81a4d4d3337 100644 --- a/include/asm-x86/bitops.h +++ b/include/asm-x86/bitops.h | |||
@@ -62,12 +62,9 @@ static inline void set_bit(int nr, volatile void *addr) | |||
62 | */ | 62 | */ |
63 | static inline void __set_bit(int nr, volatile void *addr) | 63 | static inline void __set_bit(int nr, volatile void *addr) |
64 | { | 64 | { |
65 | asm volatile("bts %1,%0" | 65 | asm volatile("bts %1,%0" : ADDR : "Ir" (nr) : "memory"); |
66 | : ADDR | ||
67 | : "Ir" (nr) : "memory"); | ||
68 | } | 66 | } |
69 | 67 | ||
70 | |||
71 | /** | 68 | /** |
72 | * clear_bit - Clears a bit in memory | 69 | * clear_bit - Clears a bit in memory |
73 | * @nr: Bit to clear | 70 | * @nr: Bit to clear |
@@ -297,19 +294,145 @@ static inline int variable_test_bit(int nr, volatile const void *addr) | |||
297 | static int test_bit(int nr, const volatile unsigned long *addr); | 294 | static int test_bit(int nr, const volatile unsigned long *addr); |
298 | #endif | 295 | #endif |
299 | 296 | ||
300 | #define test_bit(nr,addr) \ | 297 | #define test_bit(nr, addr) \ |
301 | (__builtin_constant_p(nr) ? \ | 298 | (__builtin_constant_p((nr)) \ |
302 | constant_test_bit((nr),(addr)) : \ | 299 | ? constant_test_bit((nr), (addr)) \ |
303 | variable_test_bit((nr),(addr))) | 300 | : variable_test_bit((nr), (addr))) |
301 | |||
302 | /** | ||
303 | * __ffs - find first set bit in word | ||
304 | * @word: The word to search | ||
305 | * | ||
306 | * Undefined if no bit exists, so code should check against 0 first. | ||
307 | */ | ||
308 | static inline unsigned long __ffs(unsigned long word) | ||
309 | { | ||
310 | asm("bsf %1,%0" | ||
311 | : "=r" (word) | ||
312 | : "rm" (word)); | ||
313 | return word; | ||
314 | } | ||
315 | |||
316 | /** | ||
317 | * ffz - find first zero bit in word | ||
318 | * @word: The word to search | ||
319 | * | ||
320 | * Undefined if no zero exists, so code should check against ~0UL first. | ||
321 | */ | ||
322 | static inline unsigned long ffz(unsigned long word) | ||
323 | { | ||
324 | asm("bsf %1,%0" | ||
325 | : "=r" (word) | ||
326 | : "r" (~word)); | ||
327 | return word; | ||
328 | } | ||
329 | |||
330 | /* | ||
331 | * __fls: find last set bit in word | ||
332 | * @word: The word to search | ||
333 | * | ||
334 | * Undefined if no zero exists, so code should check against ~0UL first. | ||
335 | */ | ||
336 | static inline unsigned long __fls(unsigned long word) | ||
337 | { | ||
338 | asm("bsr %1,%0" | ||
339 | : "=r" (word) | ||
340 | : "rm" (word)); | ||
341 | return word; | ||
342 | } | ||
343 | |||
344 | #ifdef __KERNEL__ | ||
345 | /** | ||
346 | * ffs - find first set bit in word | ||
347 | * @x: the word to search | ||
348 | * | ||
349 | * This is defined the same way as the libc and compiler builtin ffs | ||
350 | * routines, therefore differs in spirit from the other bitops. | ||
351 | * | ||
352 | * ffs(value) returns 0 if value is 0 or the position of the first | ||
353 | * set bit if value is nonzero. The first (least significant) bit | ||
354 | * is at position 1. | ||
355 | */ | ||
356 | static inline int ffs(int x) | ||
357 | { | ||
358 | int r; | ||
359 | #ifdef CONFIG_X86_CMOV | ||
360 | asm("bsfl %1,%0\n\t" | ||
361 | "cmovzl %2,%0" | ||
362 | : "=r" (r) : "rm" (x), "r" (-1)); | ||
363 | #else | ||
364 | asm("bsfl %1,%0\n\t" | ||
365 | "jnz 1f\n\t" | ||
366 | "movl $-1,%0\n" | ||
367 | "1:" : "=r" (r) : "rm" (x)); | ||
368 | #endif | ||
369 | return r + 1; | ||
370 | } | ||
371 | |||
372 | /** | ||
373 | * fls - find last set bit in word | ||
374 | * @x: the word to search | ||
375 | * | ||
376 | * This is defined in a similar way as the libc and compiler builtin | ||
377 | * ffs, but returns the position of the most significant set bit. | ||
378 | * | ||
379 | * fls(value) returns 0 if value is 0 or the position of the last | ||
380 | * set bit if value is nonzero. The last (most significant) bit is | ||
381 | * at position 32. | ||
382 | */ | ||
383 | static inline int fls(int x) | ||
384 | { | ||
385 | int r; | ||
386 | #ifdef CONFIG_X86_CMOV | ||
387 | asm("bsrl %1,%0\n\t" | ||
388 | "cmovzl %2,%0" | ||
389 | : "=&r" (r) : "rm" (x), "rm" (-1)); | ||
390 | #else | ||
391 | asm("bsrl %1,%0\n\t" | ||
392 | "jnz 1f\n\t" | ||
393 | "movl $-1,%0\n" | ||
394 | "1:" : "=r" (r) : "rm" (x)); | ||
395 | #endif | ||
396 | return r + 1; | ||
397 | } | ||
398 | #endif /* __KERNEL__ */ | ||
304 | 399 | ||
305 | #undef BASE_ADDR | 400 | #undef BASE_ADDR |
306 | #undef BIT_ADDR | 401 | #undef BIT_ADDR |
307 | #undef ADDR | 402 | #undef ADDR |
308 | 403 | ||
309 | #ifdef CONFIG_X86_32 | 404 | static inline void set_bit_string(unsigned long *bitmap, |
310 | # include "bitops_32.h" | 405 | unsigned long i, int len) |
311 | #else | 406 | { |
312 | # include "bitops_64.h" | 407 | unsigned long end = i + len; |
313 | #endif | 408 | while (i < end) { |
409 | __set_bit(i, bitmap); | ||
410 | i++; | ||
411 | } | ||
412 | } | ||
413 | |||
414 | #ifdef __KERNEL__ | ||
415 | |||
416 | #include <asm-generic/bitops/sched.h> | ||
417 | |||
418 | #define ARCH_HAS_FAST_MULTIPLIER 1 | ||
419 | |||
420 | #include <asm-generic/bitops/hweight.h> | ||
421 | |||
422 | #endif /* __KERNEL__ */ | ||
423 | |||
424 | #include <asm-generic/bitops/fls64.h> | ||
425 | |||
426 | #ifdef __KERNEL__ | ||
427 | |||
428 | #include <asm-generic/bitops/ext2-non-atomic.h> | ||
429 | |||
430 | #define ext2_set_bit_atomic(lock, nr, addr) \ | ||
431 | test_and_set_bit((nr), (unsigned long *)(addr)) | ||
432 | #define ext2_clear_bit_atomic(lock, nr, addr) \ | ||
433 | test_and_clear_bit((nr), (unsigned long *)(addr)) | ||
434 | |||
435 | #include <asm-generic/bitops/minix.h> | ||
314 | 436 | ||
437 | #endif /* __KERNEL__ */ | ||
315 | #endif /* _ASM_X86_BITOPS_H */ | 438 | #endif /* _ASM_X86_BITOPS_H */ |
diff --git a/include/asm-x86/bitops_32.h b/include/asm-x86/bitops_32.h deleted file mode 100644 index 2513a81f82aa..000000000000 --- a/include/asm-x86/bitops_32.h +++ /dev/null | |||
@@ -1,166 +0,0 @@ | |||
1 | #ifndef _I386_BITOPS_H | ||
2 | #define _I386_BITOPS_H | ||
3 | |||
4 | /* | ||
5 | * Copyright 1992, Linus Torvalds. | ||
6 | */ | ||
7 | |||
8 | /** | ||
9 | * find_first_zero_bit - find the first zero bit in a memory region | ||
10 | * @addr: The address to start the search at | ||
11 | * @size: The maximum size to search | ||
12 | * | ||
13 | * Returns the bit number of the first zero bit, not the number of the byte | ||
14 | * containing a bit. | ||
15 | */ | ||
16 | static inline int find_first_zero_bit(const unsigned long *addr, unsigned size) | ||
17 | { | ||
18 | int d0, d1, d2; | ||
19 | int res; | ||
20 | |||
21 | if (!size) | ||
22 | return 0; | ||
23 | /* This looks at memory. | ||
24 | * Mark it volatile to tell gcc not to move it around | ||
25 | */ | ||
26 | asm volatile("movl $-1,%%eax\n\t" | ||
27 | "xorl %%edx,%%edx\n\t" | ||
28 | "repe; scasl\n\t" | ||
29 | "je 1f\n\t" | ||
30 | "xorl -4(%%edi),%%eax\n\t" | ||
31 | "subl $4,%%edi\n\t" | ||
32 | "bsfl %%eax,%%edx\n" | ||
33 | "1:\tsubl %%ebx,%%edi\n\t" | ||
34 | "shll $3,%%edi\n\t" | ||
35 | "addl %%edi,%%edx" | ||
36 | : "=d" (res), "=&c" (d0), "=&D" (d1), "=&a" (d2) | ||
37 | : "1" ((size + 31) >> 5), "2" (addr), | ||
38 | "b" (addr) : "memory"); | ||
39 | return res; | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * find_next_zero_bit - find the first zero bit in a memory region | ||
44 | * @addr: The address to base the search on | ||
45 | * @offset: The bit number to start searching at | ||
46 | * @size: The maximum size to search | ||
47 | */ | ||
48 | int find_next_zero_bit(const unsigned long *addr, int size, int offset); | ||
49 | |||
50 | /** | ||
51 | * __ffs - find first bit in word. | ||
52 | * @word: The word to search | ||
53 | * | ||
54 | * Undefined if no bit exists, so code should check against 0 first. | ||
55 | */ | ||
56 | static inline unsigned long __ffs(unsigned long word) | ||
57 | { | ||
58 | __asm__("bsfl %1,%0" | ||
59 | :"=r" (word) | ||
60 | :"rm" (word)); | ||
61 | return word; | ||
62 | } | ||
63 | |||
64 | /** | ||
65 | * find_first_bit - find the first set bit in a memory region | ||
66 | * @addr: The address to start the search at | ||
67 | * @size: The maximum size to search | ||
68 | * | ||
69 | * Returns the bit number of the first set bit, not the number of the byte | ||
70 | * containing a bit. | ||
71 | */ | ||
72 | static inline unsigned find_first_bit(const unsigned long *addr, unsigned size) | ||
73 | { | ||
74 | unsigned x = 0; | ||
75 | |||
76 | while (x < size) { | ||
77 | unsigned long val = *addr++; | ||
78 | if (val) | ||
79 | return __ffs(val) + x; | ||
80 | x += sizeof(*addr) << 3; | ||
81 | } | ||
82 | return x; | ||
83 | } | ||
84 | |||
85 | /** | ||
86 | * find_next_bit - find the first set bit in a memory region | ||
87 | * @addr: The address to base the search on | ||
88 | * @offset: The bit number to start searching at | ||
89 | * @size: The maximum size to search | ||
90 | */ | ||
91 | int find_next_bit(const unsigned long *addr, int size, int offset); | ||
92 | |||
93 | /** | ||
94 | * ffz - find first zero in word. | ||
95 | * @word: The word to search | ||
96 | * | ||
97 | * Undefined if no zero exists, so code should check against ~0UL first. | ||
98 | */ | ||
99 | static inline unsigned long ffz(unsigned long word) | ||
100 | { | ||
101 | __asm__("bsfl %1,%0" | ||
102 | :"=r" (word) | ||
103 | :"r" (~word)); | ||
104 | return word; | ||
105 | } | ||
106 | |||
107 | #ifdef __KERNEL__ | ||
108 | |||
109 | #include <asm-generic/bitops/sched.h> | ||
110 | |||
111 | /** | ||
112 | * ffs - find first bit set | ||
113 | * @x: the word to search | ||
114 | * | ||
115 | * This is defined the same way as | ||
116 | * the libc and compiler builtin ffs routines, therefore | ||
117 | * differs in spirit from the above ffz() (man ffs). | ||
118 | */ | ||
119 | static inline int ffs(int x) | ||
120 | { | ||
121 | int r; | ||
122 | |||
123 | __asm__("bsfl %1,%0\n\t" | ||
124 | "jnz 1f\n\t" | ||
125 | "movl $-1,%0\n" | ||
126 | "1:" : "=r" (r) : "rm" (x)); | ||
127 | return r+1; | ||
128 | } | ||
129 | |||
130 | /** | ||
131 | * fls - find last bit set | ||
132 | * @x: the word to search | ||
133 | * | ||
134 | * This is defined the same way as ffs(). | ||
135 | */ | ||
136 | static inline int fls(int x) | ||
137 | { | ||
138 | int r; | ||
139 | |||
140 | __asm__("bsrl %1,%0\n\t" | ||
141 | "jnz 1f\n\t" | ||
142 | "movl $-1,%0\n" | ||
143 | "1:" : "=r" (r) : "rm" (x)); | ||
144 | return r+1; | ||
145 | } | ||
146 | |||
147 | #include <asm-generic/bitops/hweight.h> | ||
148 | |||
149 | #endif /* __KERNEL__ */ | ||
150 | |||
151 | #include <asm-generic/bitops/fls64.h> | ||
152 | |||
153 | #ifdef __KERNEL__ | ||
154 | |||
155 | #include <asm-generic/bitops/ext2-non-atomic.h> | ||
156 | |||
157 | #define ext2_set_bit_atomic(lock, nr, addr) \ | ||
158 | test_and_set_bit((nr), (unsigned long *)(addr)) | ||
159 | #define ext2_clear_bit_atomic(lock, nr, addr) \ | ||
160 | test_and_clear_bit((nr), (unsigned long *)(addr)) | ||
161 | |||
162 | #include <asm-generic/bitops/minix.h> | ||
163 | |||
164 | #endif /* __KERNEL__ */ | ||
165 | |||
166 | #endif /* _I386_BITOPS_H */ | ||
diff --git a/include/asm-x86/bitops_64.h b/include/asm-x86/bitops_64.h deleted file mode 100644 index 365f8207ea59..000000000000 --- a/include/asm-x86/bitops_64.h +++ /dev/null | |||
@@ -1,162 +0,0 @@ | |||
1 | #ifndef _X86_64_BITOPS_H | ||
2 | #define _X86_64_BITOPS_H | ||
3 | |||
4 | /* | ||
5 | * Copyright 1992, Linus Torvalds. | ||
6 | */ | ||
7 | |||
8 | extern long find_first_zero_bit(const unsigned long *addr, unsigned long size); | ||
9 | extern long find_next_zero_bit(const unsigned long *addr, long size, long offset); | ||
10 | extern long find_first_bit(const unsigned long *addr, unsigned long size); | ||
11 | extern long find_next_bit(const unsigned long *addr, long size, long offset); | ||
12 | |||
13 | /* return index of first bet set in val or max when no bit is set */ | ||
14 | static inline long __scanbit(unsigned long val, unsigned long max) | ||
15 | { | ||
16 | asm("bsfq %1,%0 ; cmovz %2,%0" : "=&r" (val) : "r" (val), "r" (max)); | ||
17 | return val; | ||
18 | } | ||
19 | |||
20 | #define find_next_bit(addr,size,off) \ | ||
21 | ((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \ | ||
22 | ((off) + (__scanbit((*(unsigned long *)addr) >> (off),(size)-(off)))) : \ | ||
23 | find_next_bit(addr,size,off))) | ||
24 | |||
25 | #define find_next_zero_bit(addr,size,off) \ | ||
26 | ((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \ | ||
27 | ((off)+(__scanbit(~(((*(unsigned long *)addr)) >> (off)),(size)-(off)))) : \ | ||
28 | find_next_zero_bit(addr,size,off))) | ||
29 | |||
30 | #define find_first_bit(addr, size) \ | ||
31 | ((__builtin_constant_p((size)) && (size) <= BITS_PER_LONG \ | ||
32 | ? (__scanbit(*(unsigned long *)(addr), (size))) \ | ||
33 | : find_first_bit((addr), (size)))) | ||
34 | |||
35 | #define find_first_zero_bit(addr, size) \ | ||
36 | ((__builtin_constant_p((size)) && (size) <= BITS_PER_LONG \ | ||
37 | ? (__scanbit(~*(unsigned long *)(addr), (size))) \ | ||
38 | : find_first_zero_bit((addr), (size)))) | ||
39 | |||
40 | static inline void set_bit_string(unsigned long *bitmap, unsigned long i, | ||
41 | int len) | ||
42 | { | ||
43 | unsigned long end = i + len; | ||
44 | while (i < end) { | ||
45 | __set_bit(i, bitmap); | ||
46 | i++; | ||
47 | } | ||
48 | } | ||
49 | |||
50 | /** | ||
51 | * ffz - find first zero in word. | ||
52 | * @word: The word to search | ||
53 | * | ||
54 | * Undefined if no zero exists, so code should check against ~0UL first. | ||
55 | */ | ||
56 | static inline unsigned long ffz(unsigned long word) | ||
57 | { | ||
58 | __asm__("bsfq %1,%0" | ||
59 | :"=r" (word) | ||
60 | :"r" (~word)); | ||
61 | return word; | ||
62 | } | ||
63 | |||
64 | /** | ||
65 | * __ffs - find first bit in word. | ||
66 | * @word: The word to search | ||
67 | * | ||
68 | * Undefined if no bit exists, so code should check against 0 first. | ||
69 | */ | ||
70 | static inline unsigned long __ffs(unsigned long word) | ||
71 | { | ||
72 | __asm__("bsfq %1,%0" | ||
73 | :"=r" (word) | ||
74 | :"rm" (word)); | ||
75 | return word; | ||
76 | } | ||
77 | |||
78 | /* | ||
79 | * __fls: find last bit set. | ||
80 | * @word: The word to search | ||
81 | * | ||
82 | * Undefined if no zero exists, so code should check against ~0UL first. | ||
83 | */ | ||
84 | static inline unsigned long __fls(unsigned long word) | ||
85 | { | ||
86 | __asm__("bsrq %1,%0" | ||
87 | :"=r" (word) | ||
88 | :"rm" (word)); | ||
89 | return word; | ||
90 | } | ||
91 | |||
92 | #ifdef __KERNEL__ | ||
93 | |||
94 | #include <asm-generic/bitops/sched.h> | ||
95 | |||
96 | /** | ||
97 | * ffs - find first bit set | ||
98 | * @x: the word to search | ||
99 | * | ||
100 | * This is defined the same way as | ||
101 | * the libc and compiler builtin ffs routines, therefore | ||
102 | * differs in spirit from the above ffz (man ffs). | ||
103 | */ | ||
104 | static inline int ffs(int x) | ||
105 | { | ||
106 | int r; | ||
107 | |||
108 | __asm__("bsfl %1,%0\n\t" | ||
109 | "cmovzl %2,%0" | ||
110 | : "=r" (r) : "rm" (x), "r" (-1)); | ||
111 | return r+1; | ||
112 | } | ||
113 | |||
114 | /** | ||
115 | * fls64 - find last bit set in 64 bit word | ||
116 | * @x: the word to search | ||
117 | * | ||
118 | * This is defined the same way as fls. | ||
119 | */ | ||
120 | static inline int fls64(__u64 x) | ||
121 | { | ||
122 | if (x == 0) | ||
123 | return 0; | ||
124 | return __fls(x) + 1; | ||
125 | } | ||
126 | |||
127 | /** | ||
128 | * fls - find last bit set | ||
129 | * @x: the word to search | ||
130 | * | ||
131 | * This is defined the same way as ffs. | ||
132 | */ | ||
133 | static inline int fls(int x) | ||
134 | { | ||
135 | int r; | ||
136 | |||
137 | __asm__("bsrl %1,%0\n\t" | ||
138 | "cmovzl %2,%0" | ||
139 | : "=&r" (r) : "rm" (x), "rm" (-1)); | ||
140 | return r+1; | ||
141 | } | ||
142 | |||
143 | #define ARCH_HAS_FAST_MULTIPLIER 1 | ||
144 | |||
145 | #include <asm-generic/bitops/hweight.h> | ||
146 | |||
147 | #endif /* __KERNEL__ */ | ||
148 | |||
149 | #ifdef __KERNEL__ | ||
150 | |||
151 | #include <asm-generic/bitops/ext2-non-atomic.h> | ||
152 | |||
153 | #define ext2_set_bit_atomic(lock, nr, addr) \ | ||
154 | test_and_set_bit((nr), (unsigned long *)(addr)) | ||
155 | #define ext2_clear_bit_atomic(lock, nr, addr) \ | ||
156 | test_and_clear_bit((nr), (unsigned long *)(addr)) | ||
157 | |||
158 | #include <asm-generic/bitops/minix.h> | ||
159 | |||
160 | #endif /* __KERNEL__ */ | ||
161 | |||
162 | #endif /* _X86_64_BITOPS_H */ | ||
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 40d54731de7e..48bde600a2db 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h | |||
@@ -112,4 +112,144 @@ static inline unsigned fls_long(unsigned long l) | |||
112 | return fls64(l); | 112 | return fls64(l); |
113 | } | 113 | } |
114 | 114 | ||
115 | #ifdef __KERNEL__ | ||
116 | #ifdef CONFIG_GENERIC_FIND_FIRST_BIT | ||
117 | extern unsigned long __find_first_bit(const unsigned long *addr, | ||
118 | unsigned long size); | ||
119 | |||
120 | /** | ||
121 | * find_first_bit - find the first set bit in a memory region | ||
122 | * @addr: The address to start the search at | ||
123 | * @size: The maximum size to search | ||
124 | * | ||
125 | * Returns the bit number of the first set bit. | ||
126 | */ | ||
127 | static __always_inline unsigned long | ||
128 | find_first_bit(const unsigned long *addr, unsigned long size) | ||
129 | { | ||
130 | /* Avoid a function call if the bitmap size is a constant */ | ||
131 | /* and not bigger than BITS_PER_LONG. */ | ||
132 | |||
133 | /* insert a sentinel so that __ffs returns size if there */ | ||
134 | /* are no set bits in the bitmap */ | ||
135 | if (__builtin_constant_p(size) && (size < BITS_PER_LONG)) | ||
136 | return __ffs((*addr) | (1ul << size)); | ||
137 | |||
138 | /* the result of __ffs(0) is undefined, so it needs to be */ | ||
139 | /* handled separately */ | ||
140 | if (__builtin_constant_p(size) && (size == BITS_PER_LONG)) | ||
141 | return ((*addr) == 0) ? BITS_PER_LONG : __ffs(*addr); | ||
142 | |||
143 | /* size is not constant or too big */ | ||
144 | return __find_first_bit(addr, size); | ||
145 | } | ||
146 | |||
147 | extern unsigned long __find_first_zero_bit(const unsigned long *addr, | ||
148 | unsigned long size); | ||
149 | |||
150 | /** | ||
151 | * find_first_zero_bit - find the first cleared bit in a memory region | ||
152 | * @addr: The address to start the search at | ||
153 | * @size: The maximum size to search | ||
154 | * | ||
155 | * Returns the bit number of the first cleared bit. | ||
156 | */ | ||
157 | static __always_inline unsigned long | ||
158 | find_first_zero_bit(const unsigned long *addr, unsigned long size) | ||
159 | { | ||
160 | /* Avoid a function call if the bitmap size is a constant */ | ||
161 | /* and not bigger than BITS_PER_LONG. */ | ||
162 | |||
163 | /* insert a sentinel so that __ffs returns size if there */ | ||
164 | /* are no set bits in the bitmap */ | ||
165 | if (__builtin_constant_p(size) && (size < BITS_PER_LONG)) { | ||
166 | return __ffs(~(*addr) | (1ul << size)); | ||
167 | } | ||
168 | |||
169 | /* the result of __ffs(0) is undefined, so it needs to be */ | ||
170 | /* handled separately */ | ||
171 | if (__builtin_constant_p(size) && (size == BITS_PER_LONG)) | ||
172 | return (~(*addr) == 0) ? BITS_PER_LONG : __ffs(~(*addr)); | ||
173 | |||
174 | /* size is not constant or too big */ | ||
175 | return __find_first_zero_bit(addr, size); | ||
176 | } | ||
177 | #endif /* CONFIG_GENERIC_FIND_FIRST_BIT */ | ||
178 | |||
179 | #ifdef CONFIG_GENERIC_FIND_NEXT_BIT | ||
180 | extern unsigned long __find_next_bit(const unsigned long *addr, | ||
181 | unsigned long size, unsigned long offset); | ||
182 | |||
183 | /** | ||
184 | * find_next_bit - find the next set bit in a memory region | ||
185 | * @addr: The address to base the search on | ||
186 | * @offset: The bitnumber to start searching at | ||
187 | * @size: The bitmap size in bits | ||
188 | */ | ||
189 | static __always_inline unsigned long | ||
190 | find_next_bit(const unsigned long *addr, unsigned long size, | ||
191 | unsigned long offset) | ||
192 | { | ||
193 | unsigned long value; | ||
194 | |||
195 | /* Avoid a function call if the bitmap size is a constant */ | ||
196 | /* and not bigger than BITS_PER_LONG. */ | ||
197 | |||
198 | /* insert a sentinel so that __ffs returns size if there */ | ||
199 | /* are no set bits in the bitmap */ | ||
200 | if (__builtin_constant_p(size) && (size < BITS_PER_LONG)) { | ||
201 | value = (*addr) & ((~0ul) << offset); | ||
202 | value |= (1ul << size); | ||
203 | return __ffs(value); | ||
204 | } | ||
205 | |||
206 | /* the result of __ffs(0) is undefined, so it needs to be */ | ||
207 | /* handled separately */ | ||
208 | if (__builtin_constant_p(size) && (size == BITS_PER_LONG)) { | ||
209 | value = (*addr) & ((~0ul) << offset); | ||
210 | return (value == 0) ? BITS_PER_LONG : __ffs(value); | ||
211 | } | ||
212 | |||
213 | /* size is not constant or too big */ | ||
214 | return __find_next_bit(addr, size, offset); | ||
215 | } | ||
216 | |||
217 | extern unsigned long __find_next_zero_bit(const unsigned long *addr, | ||
218 | unsigned long size, unsigned long offset); | ||
219 | |||
220 | /** | ||
221 | * find_next_zero_bit - find the next cleared bit in a memory region | ||
222 | * @addr: The address to base the search on | ||
223 | * @offset: The bitnumber to start searching at | ||
224 | * @size: The bitmap size in bits | ||
225 | */ | ||
226 | static __always_inline unsigned long | ||
227 | find_next_zero_bit(const unsigned long *addr, unsigned long size, | ||
228 | unsigned long offset) | ||
229 | { | ||
230 | unsigned long value; | ||
231 | |||
232 | /* Avoid a function call if the bitmap size is a constant */ | ||
233 | /* and not bigger than BITS_PER_LONG. */ | ||
234 | |||
235 | /* insert a sentinel so that __ffs returns size if there */ | ||
236 | /* are no set bits in the bitmap */ | ||
237 | if (__builtin_constant_p(size) && (size < BITS_PER_LONG)) { | ||
238 | value = (~(*addr)) & ((~0ul) << offset); | ||
239 | value |= (1ul << size); | ||
240 | return __ffs(value); | ||
241 | } | ||
242 | |||
243 | /* the result of __ffs(0) is undefined, so it needs to be */ | ||
244 | /* handled separately */ | ||
245 | if (__builtin_constant_p(size) && (size == BITS_PER_LONG)) { | ||
246 | value = (~(*addr)) & ((~0ul) << offset); | ||
247 | return (value == 0) ? BITS_PER_LONG : __ffs(value); | ||
248 | } | ||
249 | |||
250 | /* size is not constant or too big */ | ||
251 | return __find_next_zero_bit(addr, size, offset); | ||
252 | } | ||
253 | #endif /* CONFIG_GENERIC_FIND_NEXT_BIT */ | ||
254 | #endif /* __KERNEL__ */ | ||
115 | #endif | 255 | #endif |
diff --git a/include/linux/ide.h b/include/linux/ide.h index f20410dd4482..f0af504dfa42 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
@@ -387,6 +387,43 @@ typedef struct ide_drive_s { | |||
387 | 387 | ||
388 | struct ide_port_info; | 388 | struct ide_port_info; |
389 | 389 | ||
390 | struct ide_port_ops { | ||
391 | /* host specific initialization of devices on a port */ | ||
392 | void (*port_init_devs)(struct hwif_s *); | ||
393 | /* routine to program host for PIO mode */ | ||
394 | void (*set_pio_mode)(ide_drive_t *, const u8); | ||
395 | /* routine to program host for DMA mode */ | ||
396 | void (*set_dma_mode)(ide_drive_t *, const u8); | ||
397 | /* tweaks hardware to select drive */ | ||
398 | void (*selectproc)(ide_drive_t *); | ||
399 | /* chipset polling based on hba specifics */ | ||
400 | int (*reset_poll)(ide_drive_t *); | ||
401 | /* chipset specific changes to default for device-hba resets */ | ||
402 | void (*pre_reset)(ide_drive_t *); | ||
403 | /* routine to reset controller after a disk reset */ | ||
404 | void (*resetproc)(ide_drive_t *); | ||
405 | /* special host masking for drive selection */ | ||
406 | void (*maskproc)(ide_drive_t *, int); | ||
407 | /* check host's drive quirk list */ | ||
408 | void (*quirkproc)(ide_drive_t *); | ||
409 | |||
410 | u8 (*mdma_filter)(ide_drive_t *); | ||
411 | u8 (*udma_filter)(ide_drive_t *); | ||
412 | |||
413 | u8 (*cable_detect)(struct hwif_s *); | ||
414 | }; | ||
415 | |||
416 | struct ide_dma_ops { | ||
417 | void (*dma_host_set)(struct ide_drive_s *, int); | ||
418 | int (*dma_setup)(struct ide_drive_s *); | ||
419 | void (*dma_exec_cmd)(struct ide_drive_s *, u8); | ||
420 | void (*dma_start)(struct ide_drive_s *); | ||
421 | int (*dma_end)(struct ide_drive_s *); | ||
422 | int (*dma_test_irq)(struct ide_drive_s *); | ||
423 | void (*dma_lost_irq)(struct ide_drive_s *); | ||
424 | void (*dma_timeout)(struct ide_drive_s *); | ||
425 | }; | ||
426 | |||
390 | typedef struct hwif_s { | 427 | typedef struct hwif_s { |
391 | struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ | 428 | struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ |
392 | struct hwif_s *mate; /* other hwif from same PCI chip */ | 429 | struct hwif_s *mate; /* other hwif from same PCI chip */ |
@@ -420,38 +457,12 @@ typedef struct hwif_s { | |||
420 | 457 | ||
421 | struct device *dev; | 458 | struct device *dev; |
422 | 459 | ||
423 | const struct ide_port_info *cds; /* chipset device struct */ | ||
424 | |||
425 | ide_ack_intr_t *ack_intr; | 460 | ide_ack_intr_t *ack_intr; |
426 | 461 | ||
427 | void (*rw_disk)(ide_drive_t *, struct request *); | 462 | void (*rw_disk)(ide_drive_t *, struct request *); |
428 | 463 | ||
429 | #if 0 | 464 | const struct ide_port_ops *port_ops; |
430 | ide_hwif_ops_t *hwifops; | 465 | const struct ide_dma_ops *dma_ops; |
431 | #else | ||
432 | /* host specific initialization of devices on a port */ | ||
433 | void (*port_init_devs)(struct hwif_s *); | ||
434 | /* routine to program host for PIO mode */ | ||
435 | void (*set_pio_mode)(ide_drive_t *, const u8); | ||
436 | /* routine to program host for DMA mode */ | ||
437 | void (*set_dma_mode)(ide_drive_t *, const u8); | ||
438 | /* tweaks hardware to select drive */ | ||
439 | void (*selectproc)(ide_drive_t *); | ||
440 | /* chipset polling based on hba specifics */ | ||
441 | int (*reset_poll)(ide_drive_t *); | ||
442 | /* chipset specific changes to default for device-hba resets */ | ||
443 | void (*pre_reset)(ide_drive_t *); | ||
444 | /* routine to reset controller after a disk reset */ | ||
445 | void (*resetproc)(ide_drive_t *); | ||
446 | /* special host masking for drive selection */ | ||
447 | void (*maskproc)(ide_drive_t *, int); | ||
448 | /* check host's drive quirk list */ | ||
449 | void (*quirkproc)(ide_drive_t *); | ||
450 | #endif | ||
451 | u8 (*mdma_filter)(ide_drive_t *); | ||
452 | u8 (*udma_filter)(ide_drive_t *); | ||
453 | |||
454 | u8 (*cable_detect)(struct hwif_s *); | ||
455 | 466 | ||
456 | void (*ata_input_data)(ide_drive_t *, void *, u32); | 467 | void (*ata_input_data)(ide_drive_t *, void *, u32); |
457 | void (*ata_output_data)(ide_drive_t *, void *, u32); | 468 | void (*ata_output_data)(ide_drive_t *, void *, u32); |
@@ -459,15 +470,7 @@ typedef struct hwif_s { | |||
459 | void (*atapi_input_bytes)(ide_drive_t *, void *, u32); | 470 | void (*atapi_input_bytes)(ide_drive_t *, void *, u32); |
460 | void (*atapi_output_bytes)(ide_drive_t *, void *, u32); | 471 | void (*atapi_output_bytes)(ide_drive_t *, void *, u32); |
461 | 472 | ||
462 | void (*dma_host_set)(ide_drive_t *, int); | ||
463 | int (*dma_setup)(ide_drive_t *); | ||
464 | void (*dma_exec_cmd)(ide_drive_t *, u8); | ||
465 | void (*dma_start)(ide_drive_t *); | ||
466 | int (*ide_dma_end)(ide_drive_t *drive); | ||
467 | int (*ide_dma_test_irq)(ide_drive_t *drive); | ||
468 | void (*ide_dma_clear_irq)(ide_drive_t *drive); | 473 | void (*ide_dma_clear_irq)(ide_drive_t *drive); |
469 | void (*dma_lost_irq)(ide_drive_t *drive); | ||
470 | void (*dma_timeout)(ide_drive_t *drive); | ||
471 | 474 | ||
472 | void (*OUTB)(u8 addr, unsigned long port); | 475 | void (*OUTB)(u8 addr, unsigned long port); |
473 | void (*OUTBSYNC)(ide_drive_t *drive, u8 addr, unsigned long port); | 476 | void (*OUTBSYNC)(ide_drive_t *drive, u8 addr, unsigned long port); |
@@ -514,7 +517,6 @@ typedef struct hwif_s { | |||
514 | unsigned long extra_base; /* extra addr for dma ports */ | 517 | unsigned long extra_base; /* extra addr for dma ports */ |
515 | unsigned extra_ports; /* number of extra dma ports */ | 518 | unsigned extra_ports; /* number of extra dma ports */ |
516 | 519 | ||
517 | unsigned noprobe : 1; /* don't probe for this interface */ | ||
518 | unsigned present : 1; /* this interface exists */ | 520 | unsigned present : 1; /* this interface exists */ |
519 | unsigned serialized : 1; /* serialized all channel operation */ | 521 | unsigned serialized : 1; /* serialized all channel operation */ |
520 | unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ | 522 | unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ |
@@ -1009,10 +1011,15 @@ void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, u8 | |||
1009 | void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); | 1011 | void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); |
1010 | 1012 | ||
1011 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 1013 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
1012 | void ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); | 1014 | int ide_pci_set_master(struct pci_dev *, const char *); |
1015 | unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *); | ||
1016 | int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); | ||
1013 | #else | 1017 | #else |
1014 | static inline void ide_hwif_setup_dma(ide_hwif_t *hwif, | 1018 | static inline int ide_hwif_setup_dma(ide_hwif_t *hwif, |
1015 | const struct ide_port_info *d) { } | 1019 | const struct ide_port_info *d) |
1020 | { | ||
1021 | return -EINVAL; | ||
1022 | } | ||
1016 | #endif | 1023 | #endif |
1017 | 1024 | ||
1018 | extern void default_hwif_iops(ide_hwif_t *); | 1025 | extern void default_hwif_iops(ide_hwif_t *); |
@@ -1084,6 +1091,8 @@ enum { | |||
1084 | /* unmask IRQs */ | 1091 | /* unmask IRQs */ |
1085 | IDE_HFLAG_UNMASK_IRQS = (1 << 25), | 1092 | IDE_HFLAG_UNMASK_IRQS = (1 << 25), |
1086 | IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26), | 1093 | IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26), |
1094 | /* serialize ports if DMA is possible (for sl82c105) */ | ||
1095 | IDE_HFLAG_SERIALIZE_DMA = (1 << 27), | ||
1087 | /* force host out of "simplex" mode */ | 1096 | /* force host out of "simplex" mode */ |
1088 | IDE_HFLAG_CLEAR_SIMPLEX = (1 << 28), | 1097 | IDE_HFLAG_CLEAR_SIMPLEX = (1 << 28), |
1089 | /* DSC overlap is unsupported */ | 1098 | /* DSC overlap is unsupported */ |
@@ -1105,10 +1114,14 @@ struct ide_port_info { | |||
1105 | unsigned int (*init_chipset)(struct pci_dev *, const char *); | 1114 | unsigned int (*init_chipset)(struct pci_dev *, const char *); |
1106 | void (*init_iops)(ide_hwif_t *); | 1115 | void (*init_iops)(ide_hwif_t *); |
1107 | void (*init_hwif)(ide_hwif_t *); | 1116 | void (*init_hwif)(ide_hwif_t *); |
1108 | void (*init_dma)(ide_hwif_t *, unsigned long); | 1117 | int (*init_dma)(ide_hwif_t *, |
1118 | const struct ide_port_info *); | ||
1119 | |||
1120 | const struct ide_port_ops *port_ops; | ||
1121 | const struct ide_dma_ops *dma_ops; | ||
1122 | |||
1109 | ide_pci_enablebit_t enablebits[2]; | 1123 | ide_pci_enablebit_t enablebits[2]; |
1110 | hwif_chipset_t chipset; | 1124 | hwif_chipset_t chipset; |
1111 | u8 extra; | ||
1112 | u32 host_flags; | 1125 | u32 host_flags; |
1113 | u8 pio_mask; | 1126 | u8 pio_mask; |
1114 | u8 swdma_mask; | 1127 | u8 swdma_mask; |
@@ -1155,13 +1168,16 @@ void ide_destroy_dmatable(ide_drive_t *); | |||
1155 | 1168 | ||
1156 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF | 1169 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF |
1157 | extern int ide_build_dmatable(ide_drive_t *, struct request *); | 1170 | extern int ide_build_dmatable(ide_drive_t *, struct request *); |
1158 | extern int ide_release_dma(ide_hwif_t *); | 1171 | int ide_allocate_dma_engine(ide_hwif_t *); |
1159 | extern void ide_setup_dma(ide_hwif_t *, unsigned long); | 1172 | void ide_release_dma_engine(ide_hwif_t *); |
1173 | void ide_setup_dma(ide_hwif_t *, unsigned long); | ||
1160 | 1174 | ||
1161 | void ide_dma_host_set(ide_drive_t *, int); | 1175 | void ide_dma_host_set(ide_drive_t *, int); |
1162 | extern int ide_dma_setup(ide_drive_t *); | 1176 | extern int ide_dma_setup(ide_drive_t *); |
1177 | void ide_dma_exec_cmd(ide_drive_t *, u8); | ||
1163 | extern void ide_dma_start(ide_drive_t *); | 1178 | extern void ide_dma_start(ide_drive_t *); |
1164 | extern int __ide_dma_end(ide_drive_t *); | 1179 | extern int __ide_dma_end(ide_drive_t *); |
1180 | int ide_dma_test_irq(ide_drive_t *); | ||
1165 | extern void ide_dma_lost_irq(ide_drive_t *); | 1181 | extern void ide_dma_lost_irq(ide_drive_t *); |
1166 | extern void ide_dma_timeout(ide_drive_t *); | 1182 | extern void ide_dma_timeout(ide_drive_t *); |
1167 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ | 1183 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ |
@@ -1179,7 +1195,7 @@ static inline void ide_check_dma_crc(ide_drive_t *drive) { ; } | |||
1179 | #endif /* CONFIG_BLK_DEV_IDEDMA */ | 1195 | #endif /* CONFIG_BLK_DEV_IDEDMA */ |
1180 | 1196 | ||
1181 | #ifndef CONFIG_BLK_DEV_IDEDMA_SFF | 1197 | #ifndef CONFIG_BLK_DEV_IDEDMA_SFF |
1182 | static inline void ide_release_dma(ide_hwif_t *drive) {;} | 1198 | static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } |
1183 | #endif | 1199 | #endif |
1184 | 1200 | ||
1185 | #ifdef CONFIG_BLK_DEV_IDEACPI | 1201 | #ifdef CONFIG_BLK_DEV_IDEACPI |
@@ -1199,8 +1215,6 @@ static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {} | |||
1199 | #endif | 1215 | #endif |
1200 | 1216 | ||
1201 | void ide_remove_port_from_hwgroup(ide_hwif_t *); | 1217 | void ide_remove_port_from_hwgroup(ide_hwif_t *); |
1202 | extern int ide_hwif_request_regions(ide_hwif_t *hwif); | ||
1203 | extern void ide_hwif_release_regions(ide_hwif_t* hwif); | ||
1204 | void ide_unregister(unsigned int); | 1218 | void ide_unregister(unsigned int); |
1205 | 1219 | ||
1206 | void ide_register_region(struct gendisk *); | 1220 | void ide_register_region(struct gendisk *); |
@@ -1210,6 +1224,7 @@ void ide_undecoded_slave(ide_drive_t *); | |||
1210 | 1224 | ||
1211 | int ide_device_add_all(u8 *idx, const struct ide_port_info *); | 1225 | int ide_device_add_all(u8 *idx, const struct ide_port_info *); |
1212 | int ide_device_add(u8 idx[4], const struct ide_port_info *); | 1226 | int ide_device_add(u8 idx[4], const struct ide_port_info *); |
1227 | int ide_legacy_device_add(const struct ide_port_info *, unsigned long); | ||
1213 | void ide_port_unregister_devices(ide_hwif_t *); | 1228 | void ide_port_unregister_devices(ide_hwif_t *); |
1214 | void ide_port_scan(ide_hwif_t *); | 1229 | void ide_port_scan(ide_hwif_t *); |
1215 | 1230 | ||
diff --git a/lib/Kconfig b/lib/Kconfig index 2d53dc092e8b..8cc8e8722a3f 100644 --- a/lib/Kconfig +++ b/lib/Kconfig | |||
@@ -7,6 +7,12 @@ menu "Library routines" | |||
7 | config BITREVERSE | 7 | config BITREVERSE |
8 | tristate | 8 | tristate |
9 | 9 | ||
10 | config GENERIC_FIND_FIRST_BIT | ||
11 | def_bool n | ||
12 | |||
13 | config GENERIC_FIND_NEXT_BIT | ||
14 | def_bool n | ||
15 | |||
10 | config CRC_CCITT | 16 | config CRC_CCITT |
11 | tristate "CRC-CCITT functions" | 17 | tristate "CRC-CCITT functions" |
12 | help | 18 | help |
diff --git a/lib/Makefile b/lib/Makefile index bf8000fc7d48..2d7001b7f5a4 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
@@ -29,6 +29,7 @@ obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o | |||
29 | obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock_debug.o | 29 | obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock_debug.o |
30 | lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o | 30 | lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o |
31 | lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o | 31 | lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o |
32 | lib-$(CONFIG_GENERIC_FIND_FIRST_BIT) += find_next_bit.o | ||
32 | lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o | 33 | lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o |
33 | obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o | 34 | obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o |
34 | obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o | 35 | obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o |
diff --git a/lib/find_next_bit.c b/lib/find_next_bit.c index 78ccd73a8841..d3f5784807b4 100644 --- a/lib/find_next_bit.c +++ b/lib/find_next_bit.c | |||
@@ -16,14 +16,12 @@ | |||
16 | 16 | ||
17 | #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) | 17 | #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) |
18 | 18 | ||
19 | /** | 19 | #ifdef CONFIG_GENERIC_FIND_NEXT_BIT |
20 | * find_next_bit - find the next set bit in a memory region | 20 | /* |
21 | * @addr: The address to base the search on | 21 | * Find the next set bit in a memory region. |
22 | * @offset: The bitnumber to start searching at | ||
23 | * @size: The maximum size to search | ||
24 | */ | 22 | */ |
25 | unsigned long find_next_bit(const unsigned long *addr, unsigned long size, | 23 | unsigned long __find_next_bit(const unsigned long *addr, |
26 | unsigned long offset) | 24 | unsigned long size, unsigned long offset) |
27 | { | 25 | { |
28 | const unsigned long *p = addr + BITOP_WORD(offset); | 26 | const unsigned long *p = addr + BITOP_WORD(offset); |
29 | unsigned long result = offset & ~(BITS_PER_LONG-1); | 27 | unsigned long result = offset & ~(BITS_PER_LONG-1); |
@@ -60,15 +58,14 @@ found_first: | |||
60 | found_middle: | 58 | found_middle: |
61 | return result + __ffs(tmp); | 59 | return result + __ffs(tmp); |
62 | } | 60 | } |
63 | 61 | EXPORT_SYMBOL(__find_next_bit); | |
64 | EXPORT_SYMBOL(find_next_bit); | ||
65 | 62 | ||
66 | /* | 63 | /* |
67 | * This implementation of find_{first,next}_zero_bit was stolen from | 64 | * This implementation of find_{first,next}_zero_bit was stolen from |
68 | * Linus' asm-alpha/bitops.h. | 65 | * Linus' asm-alpha/bitops.h. |
69 | */ | 66 | */ |
70 | unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size, | 67 | unsigned long __find_next_zero_bit(const unsigned long *addr, |
71 | unsigned long offset) | 68 | unsigned long size, unsigned long offset) |
72 | { | 69 | { |
73 | const unsigned long *p = addr + BITOP_WORD(offset); | 70 | const unsigned long *p = addr + BITOP_WORD(offset); |
74 | unsigned long result = offset & ~(BITS_PER_LONG-1); | 71 | unsigned long result = offset & ~(BITS_PER_LONG-1); |
@@ -105,8 +102,64 @@ found_first: | |||
105 | found_middle: | 102 | found_middle: |
106 | return result + ffz(tmp); | 103 | return result + ffz(tmp); |
107 | } | 104 | } |
105 | EXPORT_SYMBOL(__find_next_zero_bit); | ||
106 | #endif /* CONFIG_GENERIC_FIND_NEXT_BIT */ | ||
107 | |||
108 | #ifdef CONFIG_GENERIC_FIND_FIRST_BIT | ||
109 | /* | ||
110 | * Find the first set bit in a memory region. | ||
111 | */ | ||
112 | unsigned long __find_first_bit(const unsigned long *addr, | ||
113 | unsigned long size) | ||
114 | { | ||
115 | const unsigned long *p = addr; | ||
116 | unsigned long result = 0; | ||
117 | unsigned long tmp; | ||
108 | 118 | ||
109 | EXPORT_SYMBOL(find_next_zero_bit); | 119 | while (size & ~(BITS_PER_LONG-1)) { |
120 | if ((tmp = *(p++))) | ||
121 | goto found; | ||
122 | result += BITS_PER_LONG; | ||
123 | size -= BITS_PER_LONG; | ||
124 | } | ||
125 | if (!size) | ||
126 | return result; | ||
127 | |||
128 | tmp = (*p) & (~0UL >> (BITS_PER_LONG - size)); | ||
129 | if (tmp == 0UL) /* Are any bits set? */ | ||
130 | return result + size; /* Nope. */ | ||
131 | found: | ||
132 | return result + __ffs(tmp); | ||
133 | } | ||
134 | EXPORT_SYMBOL(__find_first_bit); | ||
135 | |||
136 | /* | ||
137 | * Find the first cleared bit in a memory region. | ||
138 | */ | ||
139 | unsigned long __find_first_zero_bit(const unsigned long *addr, | ||
140 | unsigned long size) | ||
141 | { | ||
142 | const unsigned long *p = addr; | ||
143 | unsigned long result = 0; | ||
144 | unsigned long tmp; | ||
145 | |||
146 | while (size & ~(BITS_PER_LONG-1)) { | ||
147 | if (~(tmp = *(p++))) | ||
148 | goto found; | ||
149 | result += BITS_PER_LONG; | ||
150 | size -= BITS_PER_LONG; | ||
151 | } | ||
152 | if (!size) | ||
153 | return result; | ||
154 | |||
155 | tmp = (*p) | (~0UL << size); | ||
156 | if (tmp == ~0UL) /* Are any bits zero? */ | ||
157 | return result + size; /* Nope. */ | ||
158 | found: | ||
159 | return result + ffz(tmp); | ||
160 | } | ||
161 | EXPORT_SYMBOL(__find_first_zero_bit); | ||
162 | #endif /* CONFIG_GENERIC_FIND_FIRST_BIT */ | ||
110 | 163 | ||
111 | #ifdef __BIG_ENDIAN | 164 | #ifdef __BIG_ENDIAN |
112 | 165 | ||
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 24b3c8fe6bca..a098a0454dc8 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost | |||
@@ -76,7 +76,7 @@ modpost = scripts/mod/modpost \ | |||
76 | $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \ | 76 | $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \ |
77 | $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ | 77 | $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ |
78 | $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ | 78 | $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ |
79 | $(if $(iKBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(EXTRA_SYMBOLS))) \ | 79 | $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(EXTRA_SYMBOLS))) \ |
80 | $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ | 80 | $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ |
81 | $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ | 81 | $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ |
82 | $(if $(CONFIG_MARKERS),-K $(kernelmarkersfile)) \ | 82 | $(if $(CONFIG_MARKERS),-K $(kernelmarkersfile)) \ |
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index f8b42ab0724b..757294b4f322 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -1552,10 +1552,10 @@ static void read_symbols(char *modname) | |||
1552 | } | 1552 | } |
1553 | 1553 | ||
1554 | license = get_modinfo(info.modinfo, info.modinfo_len, "license"); | 1554 | license = get_modinfo(info.modinfo, info.modinfo_len, "license"); |
1555 | if (!license && !is_vmlinux(modname)) | 1555 | if (info.modinfo && !license && !is_vmlinux(modname)) |
1556 | fatal("modpost: missing MODULE_LICENSE() in %s\n" | 1556 | warn("modpost: missing MODULE_LICENSE() in %s\n" |
1557 | "see include/linux/module.h for " | 1557 | "see include/linux/module.h for " |
1558 | "more information\n", modname); | 1558 | "more information\n", modname); |
1559 | while (license) { | 1559 | while (license) { |
1560 | if (license_is_gpl_compatible(license)) | 1560 | if (license_is_gpl_compatible(license)) |
1561 | mod->gpl_compatible = 1; | 1561 | mod->gpl_compatible = 1; |