diff options
author | David S. Miller <davem@davemloft.net> | 2009-03-19 02:53:57 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-03-19 02:53:57 -0400 |
commit | 0702b30dd821ac8a4103ddbe545518713fdca9be (patch) | |
tree | 8ce0c9f5e58c5ccb99870505eecd139986caa05e /drivers/ide | |
parent | 192d7a4667c6d11d1a174ec4cad9a3c5d5f9043c (diff) | |
parent | a1e4ee22863d41a6fbb24310d7951836cb6dafe7 (diff) |
Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/Kconfig | 7 | ||||
-rw-r--r-- | drivers/ide/Makefile | 1 | ||||
-rw-r--r-- | drivers/ide/amd74xx.c | 2 | ||||
-rw-r--r-- | drivers/ide/at91_ide.c | 467 | ||||
-rw-r--r-- | drivers/ide/atiixp.c | 4 | ||||
-rw-r--r-- | drivers/ide/ide-atapi.c | 12 | ||||
-rw-r--r-- | drivers/ide/ide-cd.c | 35 | ||||
-rw-r--r-- | drivers/ide/ide-cd.h | 2 | ||||
-rw-r--r-- | drivers/ide/ide-disk_proc.c | 2 | ||||
-rw-r--r-- | drivers/ide/ide-dma.c | 12 | ||||
-rw-r--r-- | drivers/ide/ide-floppy.c | 6 | ||||
-rw-r--r-- | drivers/ide/ide-floppy_proc.c | 2 | ||||
-rw-r--r-- | drivers/ide/ide-gd.c | 26 | ||||
-rw-r--r-- | drivers/ide/ide-gd.h | 2 | ||||
-rw-r--r-- | drivers/ide/ide-io.c | 3 | ||||
-rw-r--r-- | drivers/ide/ide-iops.c | 2 | ||||
-rw-r--r-- | drivers/ide/ide-probe.c | 7 | ||||
-rw-r--r-- | drivers/ide/ide-proc.c | 2 | ||||
-rw-r--r-- | drivers/ide/ide-tape.c | 31 | ||||
-rw-r--r-- | drivers/ide/ide.c | 11 | ||||
-rw-r--r-- | drivers/ide/it821x.c | 5 |
21 files changed, 590 insertions, 51 deletions
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 3dad2299d9c..5ea3bfad172 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -46,7 +46,7 @@ menuconfig IDE | |||
46 | SMART parameters from disk drives. | 46 | SMART parameters from disk drives. |
47 | 47 | ||
48 | To compile this driver as a module, choose M here: the | 48 | To compile this driver as a module, choose M here: the |
49 | module will be called ide. | 49 | module will be called ide-core.ko. |
50 | 50 | ||
51 | For further information, please read <file:Documentation/ide/ide.txt>. | 51 | For further information, please read <file:Documentation/ide/ide.txt>. |
52 | 52 | ||
@@ -721,6 +721,11 @@ config BLK_DEV_IDE_TX4939 | |||
721 | depends on SOC_TX4939 | 721 | depends on SOC_TX4939 |
722 | select BLK_DEV_IDEDMA_SFF | 722 | select BLK_DEV_IDEDMA_SFF |
723 | 723 | ||
724 | config BLK_DEV_IDE_AT91 | ||
725 | tristate "Atmel AT91 (SAM9, CAP9, AT572D940HF) IDE support" | ||
726 | depends on ARM && ARCH_AT91 && !ARCH_AT91RM9200 && !ARCH_AT91X40 | ||
727 | select IDE_TIMINGS | ||
728 | |||
724 | config IDE_ARM | 729 | config IDE_ARM |
725 | tristate "ARM IDE support" | 730 | tristate "ARM IDE support" |
726 | depends on ARM && (ARCH_RPC || ARCH_SHARK) | 731 | depends on ARM && (ARCH_RPC || ARCH_SHARK) |
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile index d0e3d7d5b46..1c326d94aa6 100644 --- a/drivers/ide/Makefile +++ b/drivers/ide/Makefile | |||
@@ -116,3 +116,4 @@ obj-$(CONFIG_BLK_DEV_IDE_AU1XXX) += au1xxx-ide.o | |||
116 | 116 | ||
117 | obj-$(CONFIG_BLK_DEV_IDE_TX4938) += tx4938ide.o | 117 | obj-$(CONFIG_BLK_DEV_IDE_TX4938) += tx4938ide.o |
118 | obj-$(CONFIG_BLK_DEV_IDE_TX4939) += tx4939ide.o | 118 | obj-$(CONFIG_BLK_DEV_IDE_TX4939) += tx4939ide.o |
119 | obj-$(CONFIG_BLK_DEV_IDE_AT91) += at91_ide.o | ||
diff --git a/drivers/ide/amd74xx.c b/drivers/ide/amd74xx.c index 69660a431cd..77267c85996 100644 --- a/drivers/ide/amd74xx.c +++ b/drivers/ide/amd74xx.c | |||
@@ -166,7 +166,7 @@ static unsigned int init_chipset_amd74xx(struct pci_dev *dev) | |||
166 | * Check for broken FIFO support. | 166 | * Check for broken FIFO support. |
167 | */ | 167 | */ |
168 | if (dev->vendor == PCI_VENDOR_ID_AMD && | 168 | if (dev->vendor == PCI_VENDOR_ID_AMD && |
169 | dev->vendor == PCI_DEVICE_ID_AMD_VIPER_7411) | 169 | dev->device == PCI_DEVICE_ID_AMD_VIPER_7411) |
170 | t &= 0x0f; | 170 | t &= 0x0f; |
171 | else | 171 | else |
172 | t |= 0xf0; | 172 | t |= 0xf0; |
diff --git a/drivers/ide/at91_ide.c b/drivers/ide/at91_ide.c new file mode 100644 index 00000000000..1bb50f46388 --- /dev/null +++ b/drivers/ide/at91_ide.c | |||
@@ -0,0 +1,467 @@ | |||
1 | /* | ||
2 | * IDE host driver for AT91 (SAM9, CAP9, AT572D940HF) Static Memory Controller | ||
3 | * with Compact Flash True IDE logic | ||
4 | * | ||
5 | * Copyright (c) 2008, 2009 Kelvatek Ltd. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <linux/version.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/clk.h> | ||
27 | #include <linux/err.h> | ||
28 | #include <linux/ide.h> | ||
29 | #include <linux/platform_device.h> | ||
30 | |||
31 | #include <mach/board.h> | ||
32 | #include <mach/gpio.h> | ||
33 | #include <mach/at91sam9263.h> | ||
34 | #include <mach/at91sam9_smc.h> | ||
35 | #include <mach/at91sam9263_matrix.h> | ||
36 | |||
37 | #define DRV_NAME "at91_ide" | ||
38 | |||
39 | #define perr(fmt, args...) pr_err(DRV_NAME ": " fmt, ##args) | ||
40 | #define pdbg(fmt, args...) pr_debug("%s " fmt, __func__, ##args) | ||
41 | |||
42 | /* | ||
43 | * Access to IDE device is possible through EBI Static Memory Controller | ||
44 | * with Compact Flash logic. For details see EBI and SMC datasheet sections | ||
45 | * of any microcontroller from AT91SAM9 family. | ||
46 | * | ||
47 | * Within SMC chip select address space, lines A[23:21] distinguish Compact | ||
48 | * Flash modes (I/O, common memory, attribute memory, True IDE). IDE modes are: | ||
49 | * 0x00c0000 - True IDE | ||
50 | * 0x00e0000 - Alternate True IDE (Alt Status Register) | ||
51 | * | ||
52 | * On True IDE mode Task File and Data Register are mapped at the same address. | ||
53 | * To distinguish access between these two different bus data width is used: | ||
54 | * 8Bit for Task File, 16Bit for Data I/O. | ||
55 | * | ||
56 | * After initialization we do 8/16 bit flipping (changes in SMC MODE register) | ||
57 | * only inside IDE callback routines which are serialized by IDE layer, | ||
58 | * so no additional locking needed. | ||
59 | */ | ||
60 | |||
61 | #define TASK_FILE 0x00c00000 | ||
62 | #define ALT_MODE 0x00e00000 | ||
63 | #define REGS_SIZE 8 | ||
64 | |||
65 | #define enter_16bit(cs, mode) do { \ | ||
66 | mode = at91_sys_read(AT91_SMC_MODE(cs)); \ | ||
67 | at91_sys_write(AT91_SMC_MODE(cs), mode | AT91_SMC_DBW_16); \ | ||
68 | } while (0) | ||
69 | |||
70 | #define leave_16bit(cs, mode) at91_sys_write(AT91_SMC_MODE(cs), mode); | ||
71 | |||
72 | static void set_smc_timings(const u8 chipselect, const u16 cycle, | ||
73 | const u16 setup, const u16 pulse, | ||
74 | const u16 data_float, int use_iordy) | ||
75 | { | ||
76 | unsigned long mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | | ||
77 | AT91_SMC_BAT_SELECT; | ||
78 | |||
79 | /* disable or enable waiting for IORDY signal */ | ||
80 | if (use_iordy) | ||
81 | mode |= AT91_SMC_EXNWMODE_READY; | ||
82 | |||
83 | /* add data float cycles if needed */ | ||
84 | if (data_float) | ||
85 | mode |= AT91_SMC_TDF_(data_float); | ||
86 | |||
87 | at91_sys_write(AT91_SMC_MODE(chipselect), mode); | ||
88 | |||
89 | /* setup timings in SMC */ | ||
90 | at91_sys_write(AT91_SMC_SETUP(chipselect), AT91_SMC_NWESETUP_(setup) | | ||
91 | AT91_SMC_NCS_WRSETUP_(0) | | ||
92 | AT91_SMC_NRDSETUP_(setup) | | ||
93 | AT91_SMC_NCS_RDSETUP_(0)); | ||
94 | at91_sys_write(AT91_SMC_PULSE(chipselect), AT91_SMC_NWEPULSE_(pulse) | | ||
95 | AT91_SMC_NCS_WRPULSE_(cycle) | | ||
96 | AT91_SMC_NRDPULSE_(pulse) | | ||
97 | AT91_SMC_NCS_RDPULSE_(cycle)); | ||
98 | at91_sys_write(AT91_SMC_CYCLE(chipselect), AT91_SMC_NWECYCLE_(cycle) | | ||
99 | AT91_SMC_NRDCYCLE_(cycle)); | ||
100 | } | ||
101 | |||
102 | static unsigned int calc_mck_cycles(unsigned int ns, unsigned int mck_hz) | ||
103 | { | ||
104 | u64 tmp = ns; | ||
105 | |||
106 | tmp *= mck_hz; | ||
107 | tmp += 1000*1000*1000 - 1; /* round up */ | ||
108 | do_div(tmp, 1000*1000*1000); | ||
109 | return (unsigned int) tmp; | ||
110 | } | ||
111 | |||
112 | static void apply_timings(const u8 chipselect, const u8 pio, | ||
113 | const struct ide_timing *timing, int use_iordy) | ||
114 | { | ||
115 | unsigned int t0, t1, t2, t6z; | ||
116 | unsigned int cycle, setup, pulse, data_float; | ||
117 | unsigned int mck_hz; | ||
118 | struct clk *mck; | ||
119 | |||
120 | /* see table 22 of Compact Flash standard 4.1 for the meaning, | ||
121 | * we do not stretch active (t2) time, so setup (t1) + hold time (th) | ||
122 | * assure at least minimal recovery (t2i) time */ | ||
123 | t0 = timing->cyc8b; | ||
124 | t1 = timing->setup; | ||
125 | t2 = timing->act8b; | ||
126 | t6z = (pio < 5) ? 30 : 20; | ||
127 | |||
128 | pdbg("t0=%u t1=%u t2=%u t6z=%u\n", t0, t1, t2, t6z); | ||
129 | |||
130 | mck = clk_get(NULL, "mck"); | ||
131 | BUG_ON(IS_ERR(mck)); | ||
132 | mck_hz = clk_get_rate(mck); | ||
133 | pdbg("mck_hz=%u\n", mck_hz); | ||
134 | |||
135 | cycle = calc_mck_cycles(t0, mck_hz); | ||
136 | setup = calc_mck_cycles(t1, mck_hz); | ||
137 | pulse = calc_mck_cycles(t2, mck_hz); | ||
138 | data_float = calc_mck_cycles(t6z, mck_hz); | ||
139 | |||
140 | pdbg("cycle=%u setup=%u pulse=%u data_float=%u\n", | ||
141 | cycle, setup, pulse, data_float); | ||
142 | |||
143 | set_smc_timings(chipselect, cycle, setup, pulse, data_float, use_iordy); | ||
144 | } | ||
145 | |||
146 | static void at91_ide_input_data(ide_drive_t *drive, struct request *rq, | ||
147 | void *buf, unsigned int len) | ||
148 | { | ||
149 | ide_hwif_t *hwif = drive->hwif; | ||
150 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
151 | u8 chipselect = hwif->select_data; | ||
152 | unsigned long mode; | ||
153 | |||
154 | pdbg("cs %u buf %p len %d\n", chipselect, buf, len); | ||
155 | |||
156 | len++; | ||
157 | |||
158 | enter_16bit(chipselect, mode); | ||
159 | __ide_mm_insw((void __iomem *) io_ports->data_addr, buf, len / 2); | ||
160 | leave_16bit(chipselect, mode); | ||
161 | } | ||
162 | |||
163 | static void at91_ide_output_data(ide_drive_t *drive, struct request *rq, | ||
164 | void *buf, unsigned int len) | ||
165 | { | ||
166 | ide_hwif_t *hwif = drive->hwif; | ||
167 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
168 | u8 chipselect = hwif->select_data; | ||
169 | unsigned long mode; | ||
170 | |||
171 | pdbg("cs %u buf %p len %d\n", chipselect, buf, len); | ||
172 | |||
173 | enter_16bit(chipselect, mode); | ||
174 | __ide_mm_outsw((void __iomem *) io_ports->data_addr, buf, len / 2); | ||
175 | leave_16bit(chipselect, mode); | ||
176 | } | ||
177 | |||
178 | static u8 ide_mm_inb(unsigned long port) | ||
179 | { | ||
180 | return readb((void __iomem *) port); | ||
181 | } | ||
182 | |||
183 | static void ide_mm_outb(u8 value, unsigned long port) | ||
184 | { | ||
185 | writeb(value, (void __iomem *) port); | ||
186 | } | ||
187 | |||
188 | static void at91_ide_tf_load(ide_drive_t *drive, ide_task_t *task) | ||
189 | { | ||
190 | ide_hwif_t *hwif = drive->hwif; | ||
191 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
192 | struct ide_taskfile *tf = &task->tf; | ||
193 | u8 HIHI = (task->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF; | ||
194 | |||
195 | if (task->tf_flags & IDE_TFLAG_FLAGGED) | ||
196 | HIHI = 0xFF; | ||
197 | |||
198 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) { | ||
199 | u16 data = (tf->hob_data << 8) | tf->data; | ||
200 | |||
201 | at91_ide_output_data(drive, NULL, &data, 2); | ||
202 | } | ||
203 | |||
204 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE) | ||
205 | ide_mm_outb(tf->hob_feature, io_ports->feature_addr); | ||
206 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_NSECT) | ||
207 | ide_mm_outb(tf->hob_nsect, io_ports->nsect_addr); | ||
208 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAL) | ||
209 | ide_mm_outb(tf->hob_lbal, io_ports->lbal_addr); | ||
210 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAM) | ||
211 | ide_mm_outb(tf->hob_lbam, io_ports->lbam_addr); | ||
212 | if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAH) | ||
213 | ide_mm_outb(tf->hob_lbah, io_ports->lbah_addr); | ||
214 | |||
215 | if (task->tf_flags & IDE_TFLAG_OUT_FEATURE) | ||
216 | ide_mm_outb(tf->feature, io_ports->feature_addr); | ||
217 | if (task->tf_flags & IDE_TFLAG_OUT_NSECT) | ||
218 | ide_mm_outb(tf->nsect, io_ports->nsect_addr); | ||
219 | if (task->tf_flags & IDE_TFLAG_OUT_LBAL) | ||
220 | ide_mm_outb(tf->lbal, io_ports->lbal_addr); | ||
221 | if (task->tf_flags & IDE_TFLAG_OUT_LBAM) | ||
222 | ide_mm_outb(tf->lbam, io_ports->lbam_addr); | ||
223 | if (task->tf_flags & IDE_TFLAG_OUT_LBAH) | ||
224 | ide_mm_outb(tf->lbah, io_ports->lbah_addr); | ||
225 | |||
226 | if (task->tf_flags & IDE_TFLAG_OUT_DEVICE) | ||
227 | ide_mm_outb((tf->device & HIHI) | drive->select, io_ports->device_addr); | ||
228 | } | ||
229 | |||
230 | static void at91_ide_tf_read(ide_drive_t *drive, ide_task_t *task) | ||
231 | { | ||
232 | ide_hwif_t *hwif = drive->hwif; | ||
233 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
234 | struct ide_taskfile *tf = &task->tf; | ||
235 | |||
236 | if (task->tf_flags & IDE_TFLAG_IN_DATA) { | ||
237 | u16 data; | ||
238 | |||
239 | at91_ide_input_data(drive, NULL, &data, 2); | ||
240 | tf->data = data & 0xff; | ||
241 | tf->hob_data = (data >> 8) & 0xff; | ||
242 | } | ||
243 | |||
244 | /* be sure we're looking at the low order bits */ | ||
245 | ide_mm_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); | ||
246 | |||
247 | if (task->tf_flags & IDE_TFLAG_IN_FEATURE) | ||
248 | tf->feature = ide_mm_inb(io_ports->feature_addr); | ||
249 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | ||
250 | tf->nsect = ide_mm_inb(io_ports->nsect_addr); | ||
251 | if (task->tf_flags & IDE_TFLAG_IN_LBAL) | ||
252 | tf->lbal = ide_mm_inb(io_ports->lbal_addr); | ||
253 | if (task->tf_flags & IDE_TFLAG_IN_LBAM) | ||
254 | tf->lbam = ide_mm_inb(io_ports->lbam_addr); | ||
255 | if (task->tf_flags & IDE_TFLAG_IN_LBAH) | ||
256 | tf->lbah = ide_mm_inb(io_ports->lbah_addr); | ||
257 | if (task->tf_flags & IDE_TFLAG_IN_DEVICE) | ||
258 | tf->device = ide_mm_inb(io_ports->device_addr); | ||
259 | |||
260 | if (task->tf_flags & IDE_TFLAG_LBA48) { | ||
261 | ide_mm_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr); | ||
262 | |||
263 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) | ||
264 | tf->hob_feature = ide_mm_inb(io_ports->feature_addr); | ||
265 | if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT) | ||
266 | tf->hob_nsect = ide_mm_inb(io_ports->nsect_addr); | ||
267 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL) | ||
268 | tf->hob_lbal = ide_mm_inb(io_ports->lbal_addr); | ||
269 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM) | ||
270 | tf->hob_lbam = ide_mm_inb(io_ports->lbam_addr); | ||
271 | if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH) | ||
272 | tf->hob_lbah = ide_mm_inb(io_ports->lbah_addr); | ||
273 | } | ||
274 | } | ||
275 | |||
276 | static void at91_ide_set_pio_mode(ide_drive_t *drive, const u8 pio) | ||
277 | { | ||
278 | struct ide_timing *timing; | ||
279 | u8 chipselect = drive->hwif->select_data; | ||
280 | int use_iordy = 0; | ||
281 | |||
282 | pdbg("chipselect %u pio %u\n", chipselect, pio); | ||
283 | |||
284 | timing = ide_timing_find_mode(XFER_PIO_0 + pio); | ||
285 | BUG_ON(!timing); | ||
286 | |||
287 | if ((pio > 2 || ata_id_has_iordy(drive->id)) && | ||
288 | !(ata_id_is_cfa(drive->id) && pio > 4)) | ||
289 | use_iordy = 1; | ||
290 | |||
291 | apply_timings(chipselect, pio, timing, use_iordy); | ||
292 | } | ||
293 | |||
294 | static const struct ide_tp_ops at91_ide_tp_ops = { | ||
295 | .exec_command = ide_exec_command, | ||
296 | .read_status = ide_read_status, | ||
297 | .read_altstatus = ide_read_altstatus, | ||
298 | .set_irq = ide_set_irq, | ||
299 | |||
300 | .tf_load = at91_ide_tf_load, | ||
301 | .tf_read = at91_ide_tf_read, | ||
302 | |||
303 | .input_data = at91_ide_input_data, | ||
304 | .output_data = at91_ide_output_data, | ||
305 | }; | ||
306 | |||
307 | static const struct ide_port_ops at91_ide_port_ops = { | ||
308 | .set_pio_mode = at91_ide_set_pio_mode, | ||
309 | }; | ||
310 | |||
311 | static const struct ide_port_info at91_ide_port_info __initdata = { | ||
312 | .port_ops = &at91_ide_port_ops, | ||
313 | .tp_ops = &at91_ide_tp_ops, | ||
314 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA | IDE_HFLAG_SINGLE | | ||
315 | IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_UNMASK_IRQS, | ||
316 | .pio_mask = ATA_PIO5, | ||
317 | }; | ||
318 | |||
319 | /* | ||
320 | * If interrupt is delivered through GPIO, IRQ are triggered on falling | ||
321 | * and rising edge of signal. Whereas IDE device request interrupt on high | ||
322 | * level (rising edge in our case). This mean we have fake interrupts, so | ||
323 | * we need to check interrupt pin and exit instantly from ISR when line | ||
324 | * is on low level. | ||
325 | */ | ||
326 | |||
327 | irqreturn_t at91_irq_handler(int irq, void *dev_id) | ||
328 | { | ||
329 | int ntries = 8; | ||
330 | int pin_val1, pin_val2; | ||
331 | |||
332 | /* additional deglitch, line can be noisy in badly designed PCB */ | ||
333 | do { | ||
334 | pin_val1 = at91_get_gpio_value(irq); | ||
335 | pin_val2 = at91_get_gpio_value(irq); | ||
336 | } while (pin_val1 != pin_val2 && --ntries > 0); | ||
337 | |||
338 | if (pin_val1 == 0 || ntries <= 0) | ||
339 | return IRQ_HANDLED; | ||
340 | |||
341 | return ide_intr(irq, dev_id); | ||
342 | } | ||
343 | |||
344 | static int __init at91_ide_probe(struct platform_device *pdev) | ||
345 | { | ||
346 | int ret; | ||
347 | hw_regs_t hw; | ||
348 | hw_regs_t *hws[] = { &hw, NULL, NULL, NULL }; | ||
349 | struct ide_host *host; | ||
350 | struct resource *res; | ||
351 | unsigned long tf_base = 0, ctl_base = 0; | ||
352 | struct at91_cf_data *board = pdev->dev.platform_data; | ||
353 | |||
354 | if (!board) | ||
355 | return -ENODEV; | ||
356 | |||
357 | if (board->det_pin && at91_get_gpio_value(board->det_pin) != 0) { | ||
358 | perr("no device detected\n"); | ||
359 | return -ENODEV; | ||
360 | } | ||
361 | |||
362 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
363 | if (!res) { | ||
364 | perr("can't get memory resource\n"); | ||
365 | return -ENODEV; | ||
366 | } | ||
367 | |||
368 | if (!devm_request_mem_region(&pdev->dev, res->start + TASK_FILE, | ||
369 | REGS_SIZE, "ide") || | ||
370 | !devm_request_mem_region(&pdev->dev, res->start + ALT_MODE, | ||
371 | REGS_SIZE, "alt")) { | ||
372 | perr("memory resources in use\n"); | ||
373 | return -EBUSY; | ||
374 | } | ||
375 | |||
376 | pdbg("chipselect %u irq %u res %08lx\n", board->chipselect, | ||
377 | board->irq_pin, (unsigned long) res->start); | ||
378 | |||
379 | tf_base = (unsigned long) devm_ioremap(&pdev->dev, res->start + TASK_FILE, | ||
380 | REGS_SIZE); | ||
381 | ctl_base = (unsigned long) devm_ioremap(&pdev->dev, res->start + ALT_MODE, | ||
382 | REGS_SIZE); | ||
383 | if (!tf_base || !ctl_base) { | ||
384 | perr("can't map memory regions\n"); | ||
385 | return -EBUSY; | ||
386 | } | ||
387 | |||
388 | memset(&hw, 0, sizeof(hw)); | ||
389 | |||
390 | if (board->flags & AT91_IDE_SWAP_A0_A2) { | ||
391 | /* workaround for stupid hardware bug */ | ||
392 | hw.io_ports.data_addr = tf_base + 0; | ||
393 | hw.io_ports.error_addr = tf_base + 4; | ||
394 | hw.io_ports.nsect_addr = tf_base + 2; | ||
395 | hw.io_ports.lbal_addr = tf_base + 6; | ||
396 | hw.io_ports.lbam_addr = tf_base + 1; | ||
397 | hw.io_ports.lbah_addr = tf_base + 5; | ||
398 | hw.io_ports.device_addr = tf_base + 3; | ||
399 | hw.io_ports.command_addr = tf_base + 7; | ||
400 | hw.io_ports.ctl_addr = ctl_base + 3; | ||
401 | } else | ||
402 | ide_std_init_ports(&hw, tf_base, ctl_base + 6); | ||
403 | |||
404 | hw.irq = board->irq_pin; | ||
405 | hw.chipset = ide_generic; | ||
406 | hw.dev = &pdev->dev; | ||
407 | |||
408 | host = ide_host_alloc(&at91_ide_port_info, hws); | ||
409 | if (!host) { | ||
410 | perr("failed to allocate ide host\n"); | ||
411 | return -ENOMEM; | ||
412 | } | ||
413 | |||
414 | /* setup Static Memory Controller - PIO 0 as default */ | ||
415 | apply_timings(board->chipselect, 0, ide_timing_find_mode(XFER_PIO_0), 0); | ||
416 | |||
417 | /* with GPIO interrupt we have to do quirks in handler */ | ||
418 | if (board->irq_pin >= PIN_BASE) | ||
419 | host->irq_handler = at91_irq_handler; | ||
420 | |||
421 | host->ports[0]->select_data = board->chipselect; | ||
422 | |||
423 | ret = ide_host_register(host, &at91_ide_port_info, hws); | ||
424 | if (ret) { | ||
425 | perr("failed to register ide host\n"); | ||
426 | goto err_free_host; | ||
427 | } | ||
428 | platform_set_drvdata(pdev, host); | ||
429 | return 0; | ||
430 | |||
431 | err_free_host: | ||
432 | ide_host_free(host); | ||
433 | return ret; | ||
434 | } | ||
435 | |||
436 | static int __exit at91_ide_remove(struct platform_device *pdev) | ||
437 | { | ||
438 | struct ide_host *host = platform_get_drvdata(pdev); | ||
439 | |||
440 | ide_host_remove(host); | ||
441 | return 0; | ||
442 | } | ||
443 | |||
444 | static struct platform_driver at91_ide_driver = { | ||
445 | .driver = { | ||
446 | .name = DRV_NAME, | ||
447 | .owner = THIS_MODULE, | ||
448 | }, | ||
449 | .remove = __exit_p(at91_ide_remove), | ||
450 | }; | ||
451 | |||
452 | static int __init at91_ide_init(void) | ||
453 | { | ||
454 | return platform_driver_probe(&at91_ide_driver, at91_ide_probe); | ||
455 | } | ||
456 | |||
457 | static void __exit at91_ide_exit(void) | ||
458 | { | ||
459 | platform_driver_unregister(&at91_ide_driver); | ||
460 | } | ||
461 | |||
462 | module_init(at91_ide_init); | ||
463 | module_exit(at91_ide_exit); | ||
464 | |||
465 | MODULE_LICENSE("GPL"); | ||
466 | MODULE_AUTHOR("Stanislaw Gruszka <stf_xl@wp.pl>"); | ||
467 | |||
diff --git a/drivers/ide/atiixp.c b/drivers/ide/atiixp.c index b2735d28f5c..ecd1e62ca91 100644 --- a/drivers/ide/atiixp.c +++ b/drivers/ide/atiixp.c | |||
@@ -52,7 +52,7 @@ static void atiixp_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
52 | { | 52 | { |
53 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 53 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
54 | unsigned long flags; | 54 | unsigned long flags; |
55 | int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8; | 55 | int timing_shift = (drive->dn ^ 1) * 8; |
56 | u32 pio_timing_data; | 56 | u32 pio_timing_data; |
57 | u16 pio_mode_data; | 57 | u16 pio_mode_data; |
58 | 58 | ||
@@ -85,7 +85,7 @@ static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
85 | { | 85 | { |
86 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 86 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
87 | unsigned long flags; | 87 | unsigned long flags; |
88 | int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8; | 88 | int timing_shift = (drive->dn ^ 1) * 8; |
89 | u32 tmp32; | 89 | u32 tmp32; |
90 | u16 tmp16; | 90 | u16 tmp16; |
91 | u16 udma_ctl = 0; | 91 | u16 udma_ctl = 0; |
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index e96c0126059..e9d042dba0e 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c | |||
@@ -140,6 +140,12 @@ static void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk, | |||
140 | rq->cmd_flags |= REQ_PREEMPT; | 140 | rq->cmd_flags |= REQ_PREEMPT; |
141 | rq->buffer = (char *)pc; | 141 | rq->buffer = (char *)pc; |
142 | rq->rq_disk = disk; | 142 | rq->rq_disk = disk; |
143 | |||
144 | if (pc->req_xfer) { | ||
145 | rq->data = pc->buf; | ||
146 | rq->data_len = pc->req_xfer; | ||
147 | } | ||
148 | |||
143 | memcpy(rq->cmd, pc->c, 12); | 149 | memcpy(rq->cmd, pc->c, 12); |
144 | if (drive->media == ide_tape) | 150 | if (drive->media == ide_tape) |
145 | rq->cmd[13] = REQ_IDETAPE_PC1; | 151 | rq->cmd[13] = REQ_IDETAPE_PC1; |
@@ -159,6 +165,12 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk, | |||
159 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | 165 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
160 | rq->cmd_type = REQ_TYPE_SPECIAL; | 166 | rq->cmd_type = REQ_TYPE_SPECIAL; |
161 | rq->buffer = (char *)pc; | 167 | rq->buffer = (char *)pc; |
168 | |||
169 | if (pc->req_xfer) { | ||
170 | rq->data = pc->buf; | ||
171 | rq->data_len = pc->req_xfer; | ||
172 | } | ||
173 | |||
162 | memcpy(rq->cmd, pc->c, 12); | 174 | memcpy(rq->cmd, pc->c, 12); |
163 | if (drive->media == ide_tape) | 175 | if (drive->media == ide_tape) |
164 | rq->cmd[13] = REQ_IDETAPE_PC1; | 176 | rq->cmd[13] = REQ_IDETAPE_PC1; |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 0bfeb0c79d6..ddfbea41d29 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -55,7 +55,7 @@ | |||
55 | 55 | ||
56 | static DEFINE_MUTEX(idecd_ref_mutex); | 56 | static DEFINE_MUTEX(idecd_ref_mutex); |
57 | 57 | ||
58 | static void ide_cd_release(struct kref *); | 58 | static void ide_cd_release(struct device *); |
59 | 59 | ||
60 | static struct cdrom_info *ide_cd_get(struct gendisk *disk) | 60 | static struct cdrom_info *ide_cd_get(struct gendisk *disk) |
61 | { | 61 | { |
@@ -67,7 +67,7 @@ static struct cdrom_info *ide_cd_get(struct gendisk *disk) | |||
67 | if (ide_device_get(cd->drive)) | 67 | if (ide_device_get(cd->drive)) |
68 | cd = NULL; | 68 | cd = NULL; |
69 | else | 69 | else |
70 | kref_get(&cd->kref); | 70 | get_device(&cd->dev); |
71 | 71 | ||
72 | } | 72 | } |
73 | mutex_unlock(&idecd_ref_mutex); | 73 | mutex_unlock(&idecd_ref_mutex); |
@@ -79,7 +79,7 @@ static void ide_cd_put(struct cdrom_info *cd) | |||
79 | ide_drive_t *drive = cd->drive; | 79 | ide_drive_t *drive = cd->drive; |
80 | 80 | ||
81 | mutex_lock(&idecd_ref_mutex); | 81 | mutex_lock(&idecd_ref_mutex); |
82 | kref_put(&cd->kref, ide_cd_release); | 82 | put_device(&cd->dev); |
83 | ide_device_put(drive); | 83 | ide_device_put(drive); |
84 | mutex_unlock(&idecd_ref_mutex); | 84 | mutex_unlock(&idecd_ref_mutex); |
85 | } | 85 | } |
@@ -194,6 +194,14 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
194 | bio_sectors = max(bio_sectors(failed_command->bio), 4U); | 194 | bio_sectors = max(bio_sectors(failed_command->bio), 4U); |
195 | sector &= ~(bio_sectors - 1); | 195 | sector &= ~(bio_sectors - 1); |
196 | 196 | ||
197 | /* | ||
198 | * The SCSI specification allows for the value | ||
199 | * returned by READ CAPACITY to be up to 75 2K | ||
200 | * sectors past the last readable block. | ||
201 | * Therefore, if we hit a medium error within the | ||
202 | * last 75 2K sectors, we decrease the saved size | ||
203 | * value. | ||
204 | */ | ||
197 | if (sector < get_capacity(info->disk) && | 205 | if (sector < get_capacity(info->disk) && |
198 | drive->probed_capacity - sector < 4 * 75) | 206 | drive->probed_capacity - sector < 4 * 75) |
199 | set_capacity(info->disk, sector); | 207 | set_capacity(info->disk, sector); |
@@ -1790,15 +1798,17 @@ static void ide_cd_remove(ide_drive_t *drive) | |||
1790 | ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); | 1798 | ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); |
1791 | 1799 | ||
1792 | ide_proc_unregister_driver(drive, info->driver); | 1800 | ide_proc_unregister_driver(drive, info->driver); |
1793 | 1801 | device_del(&info->dev); | |
1794 | del_gendisk(info->disk); | 1802 | del_gendisk(info->disk); |
1795 | 1803 | ||
1796 | ide_cd_put(info); | 1804 | mutex_lock(&idecd_ref_mutex); |
1805 | put_device(&info->dev); | ||
1806 | mutex_unlock(&idecd_ref_mutex); | ||
1797 | } | 1807 | } |
1798 | 1808 | ||
1799 | static void ide_cd_release(struct kref *kref) | 1809 | static void ide_cd_release(struct device *dev) |
1800 | { | 1810 | { |
1801 | struct cdrom_info *info = to_ide_drv(kref, cdrom_info); | 1811 | struct cdrom_info *info = to_ide_drv(dev, cdrom_info); |
1802 | struct cdrom_device_info *devinfo = &info->devinfo; | 1812 | struct cdrom_device_info *devinfo = &info->devinfo; |
1803 | ide_drive_t *drive = info->drive; | 1813 | ide_drive_t *drive = info->drive; |
1804 | struct gendisk *g = info->disk; | 1814 | struct gendisk *g = info->disk; |
@@ -1997,7 +2007,12 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
1997 | 2007 | ||
1998 | ide_init_disk(g, drive); | 2008 | ide_init_disk(g, drive); |
1999 | 2009 | ||
2000 | kref_init(&info->kref); | 2010 | info->dev.parent = &drive->gendev; |
2011 | info->dev.release = ide_cd_release; | ||
2012 | dev_set_name(&info->dev, dev_name(&drive->gendev)); | ||
2013 | |||
2014 | if (device_register(&info->dev)) | ||
2015 | goto out_free_disk; | ||
2001 | 2016 | ||
2002 | info->drive = drive; | 2017 | info->drive = drive; |
2003 | info->driver = &ide_cdrom_driver; | 2018 | info->driver = &ide_cdrom_driver; |
@@ -2011,7 +2026,7 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
2011 | g->driverfs_dev = &drive->gendev; | 2026 | g->driverfs_dev = &drive->gendev; |
2012 | g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE; | 2027 | g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE; |
2013 | if (ide_cdrom_setup(drive)) { | 2028 | if (ide_cdrom_setup(drive)) { |
2014 | ide_cd_release(&info->kref); | 2029 | put_device(&info->dev); |
2015 | goto failed; | 2030 | goto failed; |
2016 | } | 2031 | } |
2017 | 2032 | ||
@@ -2021,6 +2036,8 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
2021 | add_disk(g); | 2036 | add_disk(g); |
2022 | return 0; | 2037 | return 0; |
2023 | 2038 | ||
2039 | out_free_disk: | ||
2040 | put_disk(g); | ||
2024 | out_free_cd: | 2041 | out_free_cd: |
2025 | kfree(info); | 2042 | kfree(info); |
2026 | failed: | 2043 | failed: |
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h index ac40d6cb90a..c878bfcf111 100644 --- a/drivers/ide/ide-cd.h +++ b/drivers/ide/ide-cd.h | |||
@@ -80,7 +80,7 @@ struct cdrom_info { | |||
80 | ide_drive_t *drive; | 80 | ide_drive_t *drive; |
81 | struct ide_driver *driver; | 81 | struct ide_driver *driver; |
82 | struct gendisk *disk; | 82 | struct gendisk *disk; |
83 | struct kref kref; | 83 | struct device dev; |
84 | 84 | ||
85 | /* Buffer for table of contents. NULL if we haven't allocated | 85 | /* Buffer for table of contents. NULL if we haven't allocated |
86 | a TOC buffer for this device yet. */ | 86 | a TOC buffer for this device yet. */ |
diff --git a/drivers/ide/ide-disk_proc.c b/drivers/ide/ide-disk_proc.c index 1146f4204c6..1f86dcbd2b1 100644 --- a/drivers/ide/ide-disk_proc.c +++ b/drivers/ide/ide-disk_proc.c | |||
@@ -125,5 +125,5 @@ const struct ide_proc_devset ide_disk_settings[] = { | |||
125 | IDE_PROC_DEVSET(multcount, 0, 16), | 125 | IDE_PROC_DEVSET(multcount, 0, 16), |
126 | IDE_PROC_DEVSET(nowerr, 0, 1), | 126 | IDE_PROC_DEVSET(nowerr, 0, 1), |
127 | IDE_PROC_DEVSET(wcache, 0, 1), | 127 | IDE_PROC_DEVSET(wcache, 0, 1), |
128 | { 0 }, | 128 | { NULL }, |
129 | }; | 129 | }; |
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 72ebab0bc75..059c90bb5ad 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -128,6 +128,7 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq) | |||
128 | { | 128 | { |
129 | ide_hwif_t *hwif = drive->hwif; | 129 | ide_hwif_t *hwif = drive->hwif; |
130 | struct scatterlist *sg = hwif->sg_table; | 130 | struct scatterlist *sg = hwif->sg_table; |
131 | int i; | ||
131 | 132 | ||
132 | ide_map_sg(drive, rq); | 133 | ide_map_sg(drive, rq); |
133 | 134 | ||
@@ -136,8 +137,13 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq) | |||
136 | else | 137 | else |
137 | hwif->sg_dma_direction = DMA_TO_DEVICE; | 138 | hwif->sg_dma_direction = DMA_TO_DEVICE; |
138 | 139 | ||
139 | return dma_map_sg(hwif->dev, sg, hwif->sg_nents, | 140 | i = dma_map_sg(hwif->dev, sg, hwif->sg_nents, hwif->sg_dma_direction); |
140 | hwif->sg_dma_direction); | 141 | if (i) { |
142 | hwif->orig_sg_nents = hwif->sg_nents; | ||
143 | hwif->sg_nents = i; | ||
144 | } | ||
145 | |||
146 | return i; | ||
141 | } | 147 | } |
142 | EXPORT_SYMBOL_GPL(ide_build_sglist); | 148 | EXPORT_SYMBOL_GPL(ide_build_sglist); |
143 | 149 | ||
@@ -156,7 +162,7 @@ void ide_destroy_dmatable(ide_drive_t *drive) | |||
156 | { | 162 | { |
157 | ide_hwif_t *hwif = drive->hwif; | 163 | ide_hwif_t *hwif = drive->hwif; |
158 | 164 | ||
159 | dma_unmap_sg(hwif->dev, hwif->sg_table, hwif->sg_nents, | 165 | dma_unmap_sg(hwif->dev, hwif->sg_table, hwif->orig_sg_nents, |
160 | hwif->sg_dma_direction); | 166 | hwif->sg_dma_direction); |
161 | } | 167 | } |
162 | EXPORT_SYMBOL_GPL(ide_destroy_dmatable); | 168 | EXPORT_SYMBOL_GPL(ide_destroy_dmatable); |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 3eab1c6c9b3..317ec62c33d 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -327,8 +327,10 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, | |||
327 | return ide_stopped; | 327 | return ide_stopped; |
328 | } | 328 | } |
329 | 329 | ||
330 | ide_init_sg_cmd(drive, rq); | 330 | if (blk_fs_request(rq) || pc->req_xfer) { |
331 | ide_map_sg(drive, rq); | 331 | ide_init_sg_cmd(drive, rq); |
332 | ide_map_sg(drive, rq); | ||
333 | } | ||
332 | 334 | ||
333 | pc->sg = hwif->sg_table; | 335 | pc->sg = hwif->sg_table; |
334 | pc->sg_cnt = hwif->sg_nents; | 336 | pc->sg_cnt = hwif->sg_nents; |
diff --git a/drivers/ide/ide-floppy_proc.c b/drivers/ide/ide-floppy_proc.c index 3ec762cb60a..fcd4d8153df 100644 --- a/drivers/ide/ide-floppy_proc.c +++ b/drivers/ide/ide-floppy_proc.c | |||
@@ -29,5 +29,5 @@ const struct ide_proc_devset ide_floppy_settings[] = { | |||
29 | IDE_PROC_DEVSET(bios_head, 0, 255), | 29 | IDE_PROC_DEVSET(bios_head, 0, 255), |
30 | IDE_PROC_DEVSET(bios_sect, 0, 63), | 30 | IDE_PROC_DEVSET(bios_sect, 0, 63), |
31 | IDE_PROC_DEVSET(ticks, 0, 255), | 31 | IDE_PROC_DEVSET(ticks, 0, 255), |
32 | { 0 }, | 32 | { NULL }, |
33 | }; | 33 | }; |
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c index 7857b209c6d..04710941990 100644 --- a/drivers/ide/ide-gd.c +++ b/drivers/ide/ide-gd.c | |||
@@ -25,7 +25,7 @@ module_param(debug_mask, ulong, 0644); | |||
25 | 25 | ||
26 | static DEFINE_MUTEX(ide_disk_ref_mutex); | 26 | static DEFINE_MUTEX(ide_disk_ref_mutex); |
27 | 27 | ||
28 | static void ide_disk_release(struct kref *); | 28 | static void ide_disk_release(struct device *); |
29 | 29 | ||
30 | static struct ide_disk_obj *ide_disk_get(struct gendisk *disk) | 30 | static struct ide_disk_obj *ide_disk_get(struct gendisk *disk) |
31 | { | 31 | { |
@@ -37,7 +37,7 @@ static struct ide_disk_obj *ide_disk_get(struct gendisk *disk) | |||
37 | if (ide_device_get(idkp->drive)) | 37 | if (ide_device_get(idkp->drive)) |
38 | idkp = NULL; | 38 | idkp = NULL; |
39 | else | 39 | else |
40 | kref_get(&idkp->kref); | 40 | get_device(&idkp->dev); |
41 | } | 41 | } |
42 | mutex_unlock(&ide_disk_ref_mutex); | 42 | mutex_unlock(&ide_disk_ref_mutex); |
43 | return idkp; | 43 | return idkp; |
@@ -48,7 +48,7 @@ static void ide_disk_put(struct ide_disk_obj *idkp) | |||
48 | ide_drive_t *drive = idkp->drive; | 48 | ide_drive_t *drive = idkp->drive; |
49 | 49 | ||
50 | mutex_lock(&ide_disk_ref_mutex); | 50 | mutex_lock(&ide_disk_ref_mutex); |
51 | kref_put(&idkp->kref, ide_disk_release); | 51 | put_device(&idkp->dev); |
52 | ide_device_put(drive); | 52 | ide_device_put(drive); |
53 | mutex_unlock(&ide_disk_ref_mutex); | 53 | mutex_unlock(&ide_disk_ref_mutex); |
54 | } | 54 | } |
@@ -66,17 +66,18 @@ static void ide_gd_remove(ide_drive_t *drive) | |||
66 | struct gendisk *g = idkp->disk; | 66 | struct gendisk *g = idkp->disk; |
67 | 67 | ||
68 | ide_proc_unregister_driver(drive, idkp->driver); | 68 | ide_proc_unregister_driver(drive, idkp->driver); |
69 | 69 | device_del(&idkp->dev); | |
70 | del_gendisk(g); | 70 | del_gendisk(g); |
71 | |||
72 | drive->disk_ops->flush(drive); | 71 | drive->disk_ops->flush(drive); |
73 | 72 | ||
74 | ide_disk_put(idkp); | 73 | mutex_lock(&ide_disk_ref_mutex); |
74 | put_device(&idkp->dev); | ||
75 | mutex_unlock(&ide_disk_ref_mutex); | ||
75 | } | 76 | } |
76 | 77 | ||
77 | static void ide_disk_release(struct kref *kref) | 78 | static void ide_disk_release(struct device *dev) |
78 | { | 79 | { |
79 | struct ide_disk_obj *idkp = to_ide_drv(kref, ide_disk_obj); | 80 | struct ide_disk_obj *idkp = to_ide_drv(dev, ide_disk_obj); |
80 | ide_drive_t *drive = idkp->drive; | 81 | ide_drive_t *drive = idkp->drive; |
81 | struct gendisk *g = idkp->disk; | 82 | struct gendisk *g = idkp->disk; |
82 | 83 | ||
@@ -348,7 +349,12 @@ static int ide_gd_probe(ide_drive_t *drive) | |||
348 | 349 | ||
349 | ide_init_disk(g, drive); | 350 | ide_init_disk(g, drive); |
350 | 351 | ||
351 | kref_init(&idkp->kref); | 352 | idkp->dev.parent = &drive->gendev; |
353 | idkp->dev.release = ide_disk_release; | ||
354 | dev_set_name(&idkp->dev, dev_name(&drive->gendev)); | ||
355 | |||
356 | if (device_register(&idkp->dev)) | ||
357 | goto out_free_disk; | ||
352 | 358 | ||
353 | idkp->drive = drive; | 359 | idkp->drive = drive; |
354 | idkp->driver = &ide_gd_driver; | 360 | idkp->driver = &ide_gd_driver; |
@@ -373,6 +379,8 @@ static int ide_gd_probe(ide_drive_t *drive) | |||
373 | add_disk(g); | 379 | add_disk(g); |
374 | return 0; | 380 | return 0; |
375 | 381 | ||
382 | out_free_disk: | ||
383 | put_disk(g); | ||
376 | out_free_idkp: | 384 | out_free_idkp: |
377 | kfree(idkp); | 385 | kfree(idkp); |
378 | failed: | 386 | failed: |
diff --git a/drivers/ide/ide-gd.h b/drivers/ide/ide-gd.h index a86779f0756..b604bdd318a 100644 --- a/drivers/ide/ide-gd.h +++ b/drivers/ide/ide-gd.h | |||
@@ -17,7 +17,7 @@ struct ide_disk_obj { | |||
17 | ide_drive_t *drive; | 17 | ide_drive_t *drive; |
18 | struct ide_driver *driver; | 18 | struct ide_driver *driver; |
19 | struct gendisk *disk; | 19 | struct gendisk *disk; |
20 | struct kref kref; | 20 | struct device dev; |
21 | unsigned int openers; /* protected by BKL for now */ | 21 | unsigned int openers; /* protected by BKL for now */ |
22 | 22 | ||
23 | /* Last failed packet command */ | 23 | /* Last failed packet command */ |
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 9ee51adf567..a9a6c208288 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -908,7 +908,7 @@ void ide_timer_expiry (unsigned long data) | |||
908 | ide_drive_t *uninitialized_var(drive); | 908 | ide_drive_t *uninitialized_var(drive); |
909 | ide_handler_t *handler; | 909 | ide_handler_t *handler; |
910 | unsigned long flags; | 910 | unsigned long flags; |
911 | unsigned long wait = -1; | 911 | int wait = -1; |
912 | int plug_device = 0; | 912 | int plug_device = 0; |
913 | 913 | ||
914 | spin_lock_irqsave(&hwif->lock, flags); | 914 | spin_lock_irqsave(&hwif->lock, flags); |
@@ -1162,6 +1162,7 @@ out_early: | |||
1162 | 1162 | ||
1163 | return irq_ret; | 1163 | return irq_ret; |
1164 | } | 1164 | } |
1165 | EXPORT_SYMBOL_GPL(ide_intr); | ||
1165 | 1166 | ||
1166 | /** | 1167 | /** |
1167 | * ide_do_drive_cmd - issue IDE special command | 1168 | * ide_do_drive_cmd - issue IDE special command |
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 753b92ebe0a..b1892bd95c6 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -315,6 +315,8 @@ void ide_output_data(ide_drive_t *drive, struct request *rq, void *buf, | |||
315 | u8 io_32bit = drive->io_32bit; | 315 | u8 io_32bit = drive->io_32bit; |
316 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | 316 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; |
317 | 317 | ||
318 | len++; | ||
319 | |||
318 | if (io_32bit) { | 320 | if (io_32bit) { |
319 | unsigned long uninitialized_var(flags); | 321 | unsigned long uninitialized_var(flags); |
320 | 322 | ||
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index ce0818a993f..ee8e3e7cad5 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -950,6 +950,7 @@ static int ide_port_setup_devices(ide_hwif_t *hwif) | |||
950 | static int init_irq (ide_hwif_t *hwif) | 950 | static int init_irq (ide_hwif_t *hwif) |
951 | { | 951 | { |
952 | struct ide_io_ports *io_ports = &hwif->io_ports; | 952 | struct ide_io_ports *io_ports = &hwif->io_ports; |
953 | irq_handler_t irq_handler; | ||
953 | int sa = 0; | 954 | int sa = 0; |
954 | 955 | ||
955 | mutex_lock(&ide_cfg_mtx); | 956 | mutex_lock(&ide_cfg_mtx); |
@@ -959,6 +960,10 @@ static int init_irq (ide_hwif_t *hwif) | |||
959 | hwif->timer.function = &ide_timer_expiry; | 960 | hwif->timer.function = &ide_timer_expiry; |
960 | hwif->timer.data = (unsigned long)hwif; | 961 | hwif->timer.data = (unsigned long)hwif; |
961 | 962 | ||
963 | irq_handler = hwif->host->irq_handler; | ||
964 | if (irq_handler == NULL) | ||
965 | irq_handler = ide_intr; | ||
966 | |||
962 | #if defined(__mc68000__) | 967 | #if defined(__mc68000__) |
963 | sa = IRQF_SHARED; | 968 | sa = IRQF_SHARED; |
964 | #endif /* __mc68000__ */ | 969 | #endif /* __mc68000__ */ |
@@ -969,7 +974,7 @@ static int init_irq (ide_hwif_t *hwif) | |||
969 | if (io_ports->ctl_addr) | 974 | if (io_ports->ctl_addr) |
970 | hwif->tp_ops->set_irq(hwif, 1); | 975 | hwif->tp_ops->set_irq(hwif, 1); |
971 | 976 | ||
972 | if (request_irq(hwif->irq, &ide_intr, sa, hwif->name, hwif)) | 977 | if (request_irq(hwif->irq, irq_handler, sa, hwif->name, hwif)) |
973 | goto out_up; | 978 | goto out_up; |
974 | 979 | ||
975 | if (!hwif->rqsize) { | 980 | if (!hwif->rqsize) { |
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index 1d8978b3314..a7b9287ee0d 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
@@ -231,7 +231,7 @@ static const struct ide_proc_devset ide_generic_settings[] = { | |||
231 | IDE_PROC_DEVSET(pio_mode, 0, 255), | 231 | IDE_PROC_DEVSET(pio_mode, 0, 255), |
232 | IDE_PROC_DEVSET(unmaskirq, 0, 1), | 232 | IDE_PROC_DEVSET(unmaskirq, 0, 1), |
233 | IDE_PROC_DEVSET(using_dma, 0, 1), | 233 | IDE_PROC_DEVSET(using_dma, 0, 1), |
234 | { 0 }, | 234 | { NULL }, |
235 | }; | 235 | }; |
236 | 236 | ||
237 | static void proc_ide_settings_warn(void) | 237 | static void proc_ide_settings_warn(void) |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index d7ecd3c7975..4e6181c7bbd 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -169,7 +169,7 @@ typedef struct ide_tape_obj { | |||
169 | ide_drive_t *drive; | 169 | ide_drive_t *drive; |
170 | struct ide_driver *driver; | 170 | struct ide_driver *driver; |
171 | struct gendisk *disk; | 171 | struct gendisk *disk; |
172 | struct kref kref; | 172 | struct device dev; |
173 | 173 | ||
174 | /* | 174 | /* |
175 | * failed_pc points to the last failed packet command, or contains | 175 | * failed_pc points to the last failed packet command, or contains |
@@ -267,7 +267,7 @@ static DEFINE_MUTEX(idetape_ref_mutex); | |||
267 | 267 | ||
268 | static struct class *idetape_sysfs_class; | 268 | static struct class *idetape_sysfs_class; |
269 | 269 | ||
270 | static void ide_tape_release(struct kref *); | 270 | static void ide_tape_release(struct device *); |
271 | 271 | ||
272 | static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) | 272 | static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) |
273 | { | 273 | { |
@@ -279,7 +279,7 @@ static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) | |||
279 | if (ide_device_get(tape->drive)) | 279 | if (ide_device_get(tape->drive)) |
280 | tape = NULL; | 280 | tape = NULL; |
281 | else | 281 | else |
282 | kref_get(&tape->kref); | 282 | get_device(&tape->dev); |
283 | } | 283 | } |
284 | mutex_unlock(&idetape_ref_mutex); | 284 | mutex_unlock(&idetape_ref_mutex); |
285 | return tape; | 285 | return tape; |
@@ -290,7 +290,7 @@ static void ide_tape_put(struct ide_tape_obj *tape) | |||
290 | ide_drive_t *drive = tape->drive; | 290 | ide_drive_t *drive = tape->drive; |
291 | 291 | ||
292 | mutex_lock(&idetape_ref_mutex); | 292 | mutex_lock(&idetape_ref_mutex); |
293 | kref_put(&tape->kref, ide_tape_release); | 293 | put_device(&tape->dev); |
294 | ide_device_put(drive); | 294 | ide_device_put(drive); |
295 | mutex_unlock(&idetape_ref_mutex); | 295 | mutex_unlock(&idetape_ref_mutex); |
296 | } | 296 | } |
@@ -308,7 +308,7 @@ static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i) | |||
308 | mutex_lock(&idetape_ref_mutex); | 308 | mutex_lock(&idetape_ref_mutex); |
309 | tape = idetape_devs[i]; | 309 | tape = idetape_devs[i]; |
310 | if (tape) | 310 | if (tape) |
311 | kref_get(&tape->kref); | 311 | get_device(&tape->dev); |
312 | mutex_unlock(&idetape_ref_mutex); | 312 | mutex_unlock(&idetape_ref_mutex); |
313 | return tape; | 313 | return tape; |
314 | } | 314 | } |
@@ -2166,7 +2166,7 @@ static const struct ide_proc_devset idetape_settings[] = { | |||
2166 | __IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL), | 2166 | __IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL), |
2167 | __IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, | 2167 | __IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, |
2168 | mulf_tdsc, divf_tdsc), | 2168 | mulf_tdsc, divf_tdsc), |
2169 | { 0 }, | 2169 | { NULL }, |
2170 | }; | 2170 | }; |
2171 | #endif | 2171 | #endif |
2172 | 2172 | ||
@@ -2256,15 +2256,17 @@ static void ide_tape_remove(ide_drive_t *drive) | |||
2256 | idetape_tape_t *tape = drive->driver_data; | 2256 | idetape_tape_t *tape = drive->driver_data; |
2257 | 2257 | ||
2258 | ide_proc_unregister_driver(drive, tape->driver); | 2258 | ide_proc_unregister_driver(drive, tape->driver); |
2259 | 2259 | device_del(&tape->dev); | |
2260 | ide_unregister_region(tape->disk); | 2260 | ide_unregister_region(tape->disk); |
2261 | 2261 | ||
2262 | ide_tape_put(tape); | 2262 | mutex_lock(&idetape_ref_mutex); |
2263 | put_device(&tape->dev); | ||
2264 | mutex_unlock(&idetape_ref_mutex); | ||
2263 | } | 2265 | } |
2264 | 2266 | ||
2265 | static void ide_tape_release(struct kref *kref) | 2267 | static void ide_tape_release(struct device *dev) |
2266 | { | 2268 | { |
2267 | struct ide_tape_obj *tape = to_ide_drv(kref, ide_tape_obj); | 2269 | struct ide_tape_obj *tape = to_ide_drv(dev, ide_tape_obj); |
2268 | ide_drive_t *drive = tape->drive; | 2270 | ide_drive_t *drive = tape->drive; |
2269 | struct gendisk *g = tape->disk; | 2271 | struct gendisk *g = tape->disk; |
2270 | 2272 | ||
@@ -2407,7 +2409,12 @@ static int ide_tape_probe(ide_drive_t *drive) | |||
2407 | 2409 | ||
2408 | ide_init_disk(g, drive); | 2410 | ide_init_disk(g, drive); |
2409 | 2411 | ||
2410 | kref_init(&tape->kref); | 2412 | tape->dev.parent = &drive->gendev; |
2413 | tape->dev.release = ide_tape_release; | ||
2414 | dev_set_name(&tape->dev, dev_name(&drive->gendev)); | ||
2415 | |||
2416 | if (device_register(&tape->dev)) | ||
2417 | goto out_free_disk; | ||
2411 | 2418 | ||
2412 | tape->drive = drive; | 2419 | tape->drive = drive; |
2413 | tape->driver = &idetape_driver; | 2420 | tape->driver = &idetape_driver; |
@@ -2436,6 +2443,8 @@ static int ide_tape_probe(ide_drive_t *drive) | |||
2436 | 2443 | ||
2437 | return 0; | 2444 | return 0; |
2438 | 2445 | ||
2446 | out_free_disk: | ||
2447 | put_disk(g); | ||
2439 | out_free_tape: | 2448 | out_free_tape: |
2440 | kfree(tape); | 2449 | kfree(tape); |
2441 | failed: | 2450 | failed: |
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 258805da15c..0920e3b0c96 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -337,6 +337,7 @@ static int ide_set_dev_param_mask(const char *s, struct kernel_param *kp) | |||
337 | int a, b, i, j = 1; | 337 | int a, b, i, j = 1; |
338 | unsigned int *dev_param_mask = (unsigned int *)kp->arg; | 338 | unsigned int *dev_param_mask = (unsigned int *)kp->arg; |
339 | 339 | ||
340 | /* controller . device (0 or 1) [ : 1 (set) | 0 (clear) ] */ | ||
340 | if (sscanf(s, "%d.%d:%d", &a, &b, &j) != 3 && | 341 | if (sscanf(s, "%d.%d:%d", &a, &b, &j) != 3 && |
341 | sscanf(s, "%d.%d", &a, &b) != 2) | 342 | sscanf(s, "%d.%d", &a, &b) != 2) |
342 | return -EINVAL; | 343 | return -EINVAL; |
@@ -349,7 +350,7 @@ static int ide_set_dev_param_mask(const char *s, struct kernel_param *kp) | |||
349 | if (j) | 350 | if (j) |
350 | *dev_param_mask |= (1 << i); | 351 | *dev_param_mask |= (1 << i); |
351 | else | 352 | else |
352 | *dev_param_mask &= (1 << i); | 353 | *dev_param_mask &= ~(1 << i); |
353 | 354 | ||
354 | return 0; | 355 | return 0; |
355 | } | 356 | } |
@@ -392,6 +393,8 @@ static int ide_set_disk_chs(const char *str, struct kernel_param *kp) | |||
392 | { | 393 | { |
393 | int a, b, c = 0, h = 0, s = 0, i, j = 1; | 394 | int a, b, c = 0, h = 0, s = 0, i, j = 1; |
394 | 395 | ||
396 | /* controller . device (0 or 1) : Cylinders , Heads , Sectors */ | ||
397 | /* controller . device (0 or 1) : 1 (use CHS) | 0 (ignore CHS) */ | ||
395 | if (sscanf(str, "%d.%d:%d,%d,%d", &a, &b, &c, &h, &s) != 5 && | 398 | if (sscanf(str, "%d.%d:%d,%d,%d", &a, &b, &c, &h, &s) != 5 && |
396 | sscanf(str, "%d.%d:%d", &a, &b, &j) != 3) | 399 | sscanf(str, "%d.%d:%d", &a, &b, &j) != 3) |
397 | return -EINVAL; | 400 | return -EINVAL; |
@@ -407,7 +410,7 @@ static int ide_set_disk_chs(const char *str, struct kernel_param *kp) | |||
407 | if (j) | 410 | if (j) |
408 | ide_disks |= (1 << i); | 411 | ide_disks |= (1 << i); |
409 | else | 412 | else |
410 | ide_disks &= (1 << i); | 413 | ide_disks &= ~(1 << i); |
411 | 414 | ||
412 | ide_disks_chs[i].cyl = c; | 415 | ide_disks_chs[i].cyl = c; |
413 | ide_disks_chs[i].head = h; | 416 | ide_disks_chs[i].head = h; |
@@ -469,6 +472,8 @@ static int ide_set_ignore_cable(const char *s, struct kernel_param *kp) | |||
469 | { | 472 | { |
470 | int i, j = 1; | 473 | int i, j = 1; |
471 | 474 | ||
475 | /* controller (ignore) */ | ||
476 | /* controller : 1 (ignore) | 0 (use) */ | ||
472 | if (sscanf(s, "%d:%d", &i, &j) != 2 && sscanf(s, "%d", &i) != 1) | 477 | if (sscanf(s, "%d:%d", &i, &j) != 2 && sscanf(s, "%d", &i) != 1) |
473 | return -EINVAL; | 478 | return -EINVAL; |
474 | 479 | ||
@@ -478,7 +483,7 @@ static int ide_set_ignore_cable(const char *s, struct kernel_param *kp) | |||
478 | if (j) | 483 | if (j) |
479 | ide_ignore_cable |= (1 << i); | 484 | ide_ignore_cable |= (1 << i); |
480 | else | 485 | else |
481 | ide_ignore_cable &= (1 << i); | 486 | ide_ignore_cable &= ~(1 << i); |
482 | 487 | ||
483 | return 0; | 488 | return 0; |
484 | } | 489 | } |
diff --git a/drivers/ide/it821x.c b/drivers/ide/it821x.c index e1c4f543739..13b8153112e 100644 --- a/drivers/ide/it821x.c +++ b/drivers/ide/it821x.c | |||
@@ -5,9 +5,8 @@ | |||
5 | * May be copied or modified under the terms of the GNU General Public License | 5 | * May be copied or modified under the terms of the GNU General Public License |
6 | * Based in part on the ITE vendor provided SCSI driver. | 6 | * Based in part on the ITE vendor provided SCSI driver. |
7 | * | 7 | * |
8 | * Documentation available from | 8 | * Documentation: |
9 | * http://www.ite.com.tw/pc/IT8212F_V04.pdf | 9 | * Datasheet is freely available, some other documents under NDA. |
10 | * Some other documents are NDA. | ||
11 | * | 10 | * |
12 | * The ITE8212 isn't exactly a standard IDE controller. It has two | 11 | * The ITE8212 isn't exactly a standard IDE controller. It has two |
13 | * modes. In pass through mode then it is an IDE controller. In its smart | 12 | * modes. In pass through mode then it is an IDE controller. In its smart |