diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-06 20:00:50 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-06 20:00:50 -0500 |
commit | 59e3af21e94bd56f6a31ba774786a2bfc753581b (patch) | |
tree | ce535150d8edd5648a6fc81fdc2387a6813b7e08 | |
parent | f59abb161c955b68fd3d473368420c5919733e09 (diff) | |
parent | c2ce5ca047ff6bbc41d491451c39e597c4537cd3 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (41 commits)
scc_pata: make use of scc_dma_sff_read_status()
ide-dma-sff: factor out ide_dma_sff_write_status()
ide: move read_sff_dma_status() method to 'struct ide_dma_ops'
ide: don't set hwif->dma_ops in init_dma() method
Resurrect IT8172 IDE controller driver
piix: sync ich_laptop[] with ata_piix.c
ide: update warm-plug HOWTO
ide: fix ide_port_scan() to do ACPI setup after initializing request queues
ide: remove now redundant ->cur_dev checks
ide: remove unused ide_hwif_t.sg_mapped field
ide: struct ide_atapi_pc - remove unused fields and update documentation
ide: remove superfluous hwif variable assignment from ide_timer_expiry()
ide: use ide_pci_is_in_compatibility_mode() helper in setup-pci.c
ide: make "paranoia" ->handler check in ide_intr() more strict
ide-cd: convert to ide-atapi facilities
ide-cd: start DMA before sending the actual packet command
ide-cd: wait for DRQ to get set per default
ide: Fix drive's DWORD-IO handling
ide: add port and host iterators
ide: dynamic allocation of device structures
...
64 files changed, 1036 insertions, 1184 deletions
diff --git a/Documentation/ide/warm-plug-howto.txt b/Documentation/ide/warm-plug-howto.txt index d5885468b072..98152bcd515a 100644 --- a/Documentation/ide/warm-plug-howto.txt +++ b/Documentation/ide/warm-plug-howto.txt | |||
@@ -11,3 +11,8 @@ unplug old device(s) and plug new device(s) | |||
11 | # echo -n "1" > /sys/class/ide_port/idex/scan | 11 | # echo -n "1" > /sys/class/ide_port/idex/scan |
12 | 12 | ||
13 | done | 13 | done |
14 | |||
15 | NOTE: please make sure that partitions are unmounted and that there are | ||
16 | no other active references to devices before doing "delete_devices" step, | ||
17 | also do not attempt "scan" step on devices currently in use -- otherwise | ||
18 | results may be unpredictable and lead to data loss if you're unlucky | ||
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 4ee85fcf9aaf..3f9503867e6b 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -511,6 +511,13 @@ config BLK_DEV_PIIX | |||
511 | This allows the kernel to change PIO, DMA and UDMA speeds and to | 511 | This allows the kernel to change PIO, DMA and UDMA speeds and to |
512 | configure the chip to optimum performance. | 512 | configure the chip to optimum performance. |
513 | 513 | ||
514 | config BLK_DEV_IT8172 | ||
515 | tristate "IT8172 IDE support" | ||
516 | select BLK_DEV_IDEDMA_PCI | ||
517 | help | ||
518 | This driver adds support for the IDE controller on the | ||
519 | IT8172 System Controller. | ||
520 | |||
514 | config BLK_DEV_IT8213 | 521 | config BLK_DEV_IT8213 |
515 | tristate "IT8213 IDE support" | 522 | tristate "IT8213 IDE support" |
516 | select BLK_DEV_IDEDMA_PCI | 523 | select BLK_DEV_IDEDMA_PCI |
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile index 410728992e6a..c2b9c93f0095 100644 --- a/drivers/ide/Makefile +++ b/drivers/ide/Makefile | |||
@@ -47,6 +47,7 @@ obj-$(CONFIG_BLK_DEV_SC1200) += sc1200.o | |||
47 | obj-$(CONFIG_BLK_DEV_CY82C693) += cy82c693.o | 47 | obj-$(CONFIG_BLK_DEV_CY82C693) += cy82c693.o |
48 | obj-$(CONFIG_BLK_DEV_DELKIN) += delkin_cb.o | 48 | obj-$(CONFIG_BLK_DEV_DELKIN) += delkin_cb.o |
49 | obj-$(CONFIG_BLK_DEV_HPT366) += hpt366.o | 49 | obj-$(CONFIG_BLK_DEV_HPT366) += hpt366.o |
50 | obj-$(CONFIG_BLK_DEV_IT8172) += it8172.o | ||
50 | obj-$(CONFIG_BLK_DEV_IT8213) += it8213.o | 51 | obj-$(CONFIG_BLK_DEV_IT8213) += it8213.o |
51 | obj-$(CONFIG_BLK_DEV_IT821X) += it821x.o | 52 | obj-$(CONFIG_BLK_DEV_IT821X) += it821x.o |
52 | obj-$(CONFIG_BLK_DEV_JMICRON) += jmicron.o | 53 | obj-$(CONFIG_BLK_DEV_JMICRON) += jmicron.o |
diff --git a/drivers/ide/aec62xx.c b/drivers/ide/aec62xx.c index 4142c698e0d3..4485b9c6f0e6 100644 --- a/drivers/ide/aec62xx.c +++ b/drivers/ide/aec62xx.c | |||
@@ -83,7 +83,7 @@ static u8 pci_bus_clock_list_ultra (u8 speed, struct chipset_bus_clock_list_entr | |||
83 | 83 | ||
84 | static void aec6210_set_mode(ide_drive_t *drive, const u8 speed) | 84 | static void aec6210_set_mode(ide_drive_t *drive, const u8 speed) |
85 | { | 85 | { |
86 | ide_hwif_t *hwif = HWIF(drive); | 86 | ide_hwif_t *hwif = drive->hwif; |
87 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 87 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
88 | struct ide_host *host = pci_get_drvdata(dev); | 88 | struct ide_host *host = pci_get_drvdata(dev); |
89 | struct chipset_bus_clock_list_entry *bus_clock = host->host_priv; | 89 | struct chipset_bus_clock_list_entry *bus_clock = host->host_priv; |
@@ -111,7 +111,7 @@ static void aec6210_set_mode(ide_drive_t *drive, const u8 speed) | |||
111 | 111 | ||
112 | static void aec6260_set_mode(ide_drive_t *drive, const u8 speed) | 112 | static void aec6260_set_mode(ide_drive_t *drive, const u8 speed) |
113 | { | 113 | { |
114 | ide_hwif_t *hwif = HWIF(drive); | 114 | ide_hwif_t *hwif = drive->hwif; |
115 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 115 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
116 | struct ide_host *host = pci_get_drvdata(dev); | 116 | struct ide_host *host = pci_get_drvdata(dev); |
117 | struct chipset_bus_clock_list_entry *bus_clock = host->host_priv; | 117 | struct chipset_bus_clock_list_entry *bus_clock = host->host_priv; |
diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c index 45d2356bb725..66f43083408b 100644 --- a/drivers/ide/alim15x3.c +++ b/drivers/ide/alim15x3.c | |||
@@ -68,7 +68,7 @@ static struct pci_dev *isa_dev; | |||
68 | 68 | ||
69 | static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio) | 69 | static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio) |
70 | { | 70 | { |
71 | ide_hwif_t *hwif = HWIF(drive); | 71 | ide_hwif_t *hwif = drive->hwif; |
72 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 72 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
73 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); | 73 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); |
74 | int s_time = t->setup, a_time = t->active, c_time = t->cycle; | 74 | int s_time = t->setup, a_time = t->active, c_time = t->cycle; |
@@ -150,7 +150,7 @@ static u8 ali_udma_filter(ide_drive_t *drive) | |||
150 | 150 | ||
151 | static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed) | 151 | static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed) |
152 | { | 152 | { |
153 | ide_hwif_t *hwif = HWIF(drive); | 153 | ide_hwif_t *hwif = drive->hwif; |
154 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 154 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
155 | u8 speed1 = speed; | 155 | u8 speed1 = speed; |
156 | u8 unit = drive->dn & 1; | 156 | u8 unit = drive->dn & 1; |
@@ -198,7 +198,7 @@ static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
198 | static int ali15x3_dma_setup(ide_drive_t *drive) | 198 | static int ali15x3_dma_setup(ide_drive_t *drive) |
199 | { | 199 | { |
200 | if (m5229_revision < 0xC2 && drive->media != ide_disk) { | 200 | if (m5229_revision < 0xC2 && drive->media != ide_disk) { |
201 | if (rq_data_dir(drive->hwif->hwgroup->rq)) | 201 | if (rq_data_dir(drive->hwif->rq)) |
202 | return 1; /* try PIO instead of DMA */ | 202 | return 1; /* try PIO instead of DMA */ |
203 | } | 203 | } |
204 | return ide_dma_setup(drive); | 204 | return ide_dma_setup(drive); |
@@ -490,8 +490,6 @@ static int __devinit init_dma_ali15x3(ide_hwif_t *hwif, | |||
490 | if (ide_allocate_dma_engine(hwif)) | 490 | if (ide_allocate_dma_engine(hwif)) |
491 | return -1; | 491 | return -1; |
492 | 492 | ||
493 | hwif->dma_ops = &sff_dma_ops; | ||
494 | |||
495 | return 0; | 493 | return 0; |
496 | } | 494 | } |
497 | 495 | ||
@@ -511,6 +509,7 @@ static const struct ide_dma_ops ali_dma_ops = { | |||
511 | .dma_test_irq = ide_dma_test_irq, | 509 | .dma_test_irq = ide_dma_test_irq, |
512 | .dma_lost_irq = ide_dma_lost_irq, | 510 | .dma_lost_irq = ide_dma_lost_irq, |
513 | .dma_timeout = ide_dma_timeout, | 511 | .dma_timeout = ide_dma_timeout, |
512 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
514 | }; | 513 | }; |
515 | 514 | ||
516 | static const struct ide_port_info ali15x3_chipset __devinitdata = { | 515 | static const struct ide_port_info ali15x3_chipset __devinitdata = { |
@@ -519,6 +518,7 @@ static const struct ide_port_info ali15x3_chipset __devinitdata = { | |||
519 | .init_hwif = init_hwif_ali15x3, | 518 | .init_hwif = init_hwif_ali15x3, |
520 | .init_dma = init_dma_ali15x3, | 519 | .init_dma = init_dma_ali15x3, |
521 | .port_ops = &ali_port_ops, | 520 | .port_ops = &ali_port_ops, |
521 | .dma_ops = &sff_dma_ops, | ||
522 | .pio_mask = ATA_PIO5, | 522 | .pio_mask = ATA_PIO5, |
523 | .swdma_mask = ATA_SWDMA2, | 523 | .swdma_mask = ATA_SWDMA2, |
524 | .mwdma_mask = ATA_MWDMA2, | 524 | .mwdma_mask = ATA_MWDMA2, |
diff --git a/drivers/ide/amd74xx.c b/drivers/ide/amd74xx.c index c6bcd3014a29..69660a431cd9 100644 --- a/drivers/ide/amd74xx.c +++ b/drivers/ide/amd74xx.c | |||
@@ -82,7 +82,7 @@ static void amd_set_drive(ide_drive_t *drive, const u8 speed) | |||
82 | { | 82 | { |
83 | ide_hwif_t *hwif = drive->hwif; | 83 | ide_hwif_t *hwif = drive->hwif; |
84 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 84 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
85 | ide_drive_t *peer = hwif->drives + (~drive->dn & 1); | 85 | ide_drive_t *peer = ide_get_pair_dev(drive); |
86 | struct ide_timing t, p; | 86 | struct ide_timing t, p; |
87 | int T, UT; | 87 | int T, UT; |
88 | u8 udma_mask = hwif->ultra_mask; | 88 | u8 udma_mask = hwif->ultra_mask; |
@@ -92,7 +92,7 @@ static void amd_set_drive(ide_drive_t *drive, const u8 speed) | |||
92 | 92 | ||
93 | ide_timing_compute(drive, speed, &t, T, UT); | 93 | ide_timing_compute(drive, speed, &t, T, UT); |
94 | 94 | ||
95 | if (peer->dev_flags & IDE_DFLAG_PRESENT) { | 95 | if (peer) { |
96 | ide_timing_compute(peer, peer->current_speed, &p, T, UT); | 96 | ide_timing_compute(peer, peer->current_speed, &p, T, UT); |
97 | ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); | 97 | ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); |
98 | } | 98 | } |
diff --git a/drivers/ide/au1xxx-ide.c b/drivers/ide/au1xxx-ide.c index 0ec8fd1e4dcb..79a2dfed8eb7 100644 --- a/drivers/ide/au1xxx-ide.c +++ b/drivers/ide/au1xxx-ide.c | |||
@@ -212,8 +212,8 @@ static void auide_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
212 | static int auide_build_dmatable(ide_drive_t *drive) | 212 | static int auide_build_dmatable(ide_drive_t *drive) |
213 | { | 213 | { |
214 | int i, iswrite, count = 0; | 214 | int i, iswrite, count = 0; |
215 | ide_hwif_t *hwif = HWIF(drive); | 215 | ide_hwif_t *hwif = drive->hwif; |
216 | struct request *rq = HWGROUP(drive)->rq; | 216 | struct request *rq = hwif->rq; |
217 | _auide_hwif *ahwif = &auide_hwif; | 217 | _auide_hwif *ahwif = &auide_hwif; |
218 | struct scatterlist *sg; | 218 | struct scatterlist *sg; |
219 | 219 | ||
@@ -286,7 +286,7 @@ static int auide_build_dmatable(ide_drive_t *drive) | |||
286 | 286 | ||
287 | static int auide_dma_end(ide_drive_t *drive) | 287 | static int auide_dma_end(ide_drive_t *drive) |
288 | { | 288 | { |
289 | ide_hwif_t *hwif = HWIF(drive); | 289 | ide_hwif_t *hwif = drive->hwif; |
290 | 290 | ||
291 | if (hwif->sg_nents) { | 291 | if (hwif->sg_nents) { |
292 | ide_destroy_dmatable(drive); | 292 | ide_destroy_dmatable(drive); |
@@ -309,8 +309,8 @@ static void auide_dma_exec_cmd(ide_drive_t *drive, u8 command) | |||
309 | } | 309 | } |
310 | 310 | ||
311 | static int auide_dma_setup(ide_drive_t *drive) | 311 | static int auide_dma_setup(ide_drive_t *drive) |
312 | { | 312 | { |
313 | struct request *rq = HWGROUP(drive)->rq; | 313 | struct request *rq = drive->hwif->rq; |
314 | 314 | ||
315 | if (!auide_build_dmatable(drive)) { | 315 | if (!auide_build_dmatable(drive)) { |
316 | ide_map_sg(drive, rq); | 316 | ide_map_sg(drive, rq); |
@@ -502,7 +502,6 @@ static const struct ide_tp_ops au1xxx_tp_ops = { | |||
502 | .exec_command = ide_exec_command, | 502 | .exec_command = ide_exec_command, |
503 | .read_status = ide_read_status, | 503 | .read_status = ide_read_status, |
504 | .read_altstatus = ide_read_altstatus, | 504 | .read_altstatus = ide_read_altstatus, |
505 | .read_sff_dma_status = ide_read_sff_dma_status, | ||
506 | 505 | ||
507 | .set_irq = ide_set_irq, | 506 | .set_irq = ide_set_irq, |
508 | 507 | ||
diff --git a/drivers/ide/cmd640.c b/drivers/ide/cmd640.c index e4306647d00d..8890276fef7f 100644 --- a/drivers/ide/cmd640.c +++ b/drivers/ide/cmd640.c | |||
@@ -467,11 +467,10 @@ static void program_drive_counts(ide_drive_t *drive, unsigned int index) | |||
467 | * so we merge the timings, using the slowest value for each timing. | 467 | * so we merge the timings, using the slowest value for each timing. |
468 | */ | 468 | */ |
469 | if (index > 1) { | 469 | if (index > 1) { |
470 | ide_hwif_t *hwif = drive->hwif; | 470 | ide_drive_t *peer = ide_get_pair_dev(drive); |
471 | ide_drive_t *peer = &hwif->drives[!(drive->dn & 1)]; | ||
472 | unsigned int mate = index ^ 1; | 471 | unsigned int mate = index ^ 1; |
473 | 472 | ||
474 | if (peer->dev_flags & IDE_DFLAG_PRESENT) { | 473 | if (peer) { |
475 | if (setup_count < setup_counts[mate]) | 474 | if (setup_count < setup_counts[mate]) |
476 | setup_count = setup_counts[mate]; | 475 | setup_count = setup_counts[mate]; |
477 | if (active_count < active_counts[mate]) | 476 | if (active_count < active_counts[mate]) |
diff --git a/drivers/ide/cmd64x.c b/drivers/ide/cmd64x.c index 3623bf013bcf..2f9688d87ecd 100644 --- a/drivers/ide/cmd64x.c +++ b/drivers/ide/cmd64x.c | |||
@@ -115,7 +115,7 @@ static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_ | |||
115 | */ | 115 | */ |
116 | static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio) | 116 | static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio) |
117 | { | 117 | { |
118 | ide_hwif_t *hwif = HWIF(drive); | 118 | ide_hwif_t *hwif = drive->hwif; |
119 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 119 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
120 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); | 120 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); |
121 | unsigned int cycle_time; | 121 | unsigned int cycle_time; |
@@ -138,10 +138,12 @@ static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio) | |||
138 | * the slowest address setup timing ourselves. | 138 | * the slowest address setup timing ourselves. |
139 | */ | 139 | */ |
140 | if (hwif->channel) { | 140 | if (hwif->channel) { |
141 | ide_drive_t *drives = hwif->drives; | 141 | ide_drive_t *pair = ide_get_pair_dev(drive); |
142 | 142 | ||
143 | drive->drive_data = setup_count; | 143 | drive->drive_data = setup_count; |
144 | setup_count = max(drives[0].drive_data, drives[1].drive_data); | 144 | |
145 | if (pair) | ||
146 | setup_count = max_t(u8, setup_count, pair->drive_data); | ||
145 | } | 147 | } |
146 | 148 | ||
147 | if (setup_count > 5) /* shouldn't actually happen... */ | 149 | if (setup_count > 5) /* shouldn't actually happen... */ |
@@ -180,7 +182,7 @@ static void cmd64x_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
180 | 182 | ||
181 | static void cmd64x_set_dma_mode(ide_drive_t *drive, const u8 speed) | 183 | static void cmd64x_set_dma_mode(ide_drive_t *drive, const u8 speed) |
182 | { | 184 | { |
183 | ide_hwif_t *hwif = HWIF(drive); | 185 | ide_hwif_t *hwif = drive->hwif; |
184 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 186 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
185 | u8 unit = drive->dn & 0x01; | 187 | u8 unit = drive->dn & 0x01; |
186 | u8 regU = 0, pciU = hwif->channel ? UDIDETCR1 : UDIDETCR0; | 188 | u8 regU = 0, pciU = hwif->channel ? UDIDETCR1 : UDIDETCR0; |
@@ -226,7 +228,7 @@ static void cmd64x_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
226 | 228 | ||
227 | static int cmd648_dma_end(ide_drive_t *drive) | 229 | static int cmd648_dma_end(ide_drive_t *drive) |
228 | { | 230 | { |
229 | ide_hwif_t *hwif = HWIF(drive); | 231 | ide_hwif_t *hwif = drive->hwif; |
230 | unsigned long base = hwif->dma_base - (hwif->channel * 8); | 232 | unsigned long base = hwif->dma_base - (hwif->channel * 8); |
231 | int err = ide_dma_end(drive); | 233 | int err = ide_dma_end(drive); |
232 | u8 irq_mask = hwif->channel ? MRDMODE_INTR_CH1 : | 234 | u8 irq_mask = hwif->channel ? MRDMODE_INTR_CH1 : |
@@ -242,7 +244,7 @@ static int cmd648_dma_end(ide_drive_t *drive) | |||
242 | 244 | ||
243 | static int cmd64x_dma_end(ide_drive_t *drive) | 245 | static int cmd64x_dma_end(ide_drive_t *drive) |
244 | { | 246 | { |
245 | ide_hwif_t *hwif = HWIF(drive); | 247 | ide_hwif_t *hwif = drive->hwif; |
246 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 248 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
247 | int irq_reg = hwif->channel ? ARTTIM23 : CFR; | 249 | int irq_reg = hwif->channel ? ARTTIM23 : CFR; |
248 | u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : | 250 | u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : |
@@ -259,7 +261,7 @@ static int cmd64x_dma_end(ide_drive_t *drive) | |||
259 | 261 | ||
260 | static int cmd648_dma_test_irq(ide_drive_t *drive) | 262 | static int cmd648_dma_test_irq(ide_drive_t *drive) |
261 | { | 263 | { |
262 | ide_hwif_t *hwif = HWIF(drive); | 264 | ide_hwif_t *hwif = drive->hwif; |
263 | unsigned long base = hwif->dma_base - (hwif->channel * 8); | 265 | unsigned long base = hwif->dma_base - (hwif->channel * 8); |
264 | u8 irq_mask = hwif->channel ? MRDMODE_INTR_CH1 : | 266 | u8 irq_mask = hwif->channel ? MRDMODE_INTR_CH1 : |
265 | MRDMODE_INTR_CH0; | 267 | MRDMODE_INTR_CH0; |
@@ -282,7 +284,7 @@ static int cmd648_dma_test_irq(ide_drive_t *drive) | |||
282 | 284 | ||
283 | static int cmd64x_dma_test_irq(ide_drive_t *drive) | 285 | static int cmd64x_dma_test_irq(ide_drive_t *drive) |
284 | { | 286 | { |
285 | ide_hwif_t *hwif = HWIF(drive); | 287 | ide_hwif_t *hwif = drive->hwif; |
286 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 288 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
287 | int irq_reg = hwif->channel ? ARTTIM23 : CFR; | 289 | int irq_reg = hwif->channel ? ARTTIM23 : CFR; |
288 | u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : | 290 | u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : |
@@ -313,7 +315,7 @@ static int cmd64x_dma_test_irq(ide_drive_t *drive) | |||
313 | 315 | ||
314 | static int cmd646_1_dma_end(ide_drive_t *drive) | 316 | static int cmd646_1_dma_end(ide_drive_t *drive) |
315 | { | 317 | { |
316 | ide_hwif_t *hwif = HWIF(drive); | 318 | ide_hwif_t *hwif = drive->hwif; |
317 | u8 dma_stat = 0, dma_cmd = 0; | 319 | u8 dma_stat = 0, dma_cmd = 0; |
318 | 320 | ||
319 | drive->waiting_for_dma = 0; | 321 | drive->waiting_for_dma = 0; |
@@ -383,6 +385,7 @@ static const struct ide_dma_ops cmd64x_dma_ops = { | |||
383 | .dma_test_irq = cmd64x_dma_test_irq, | 385 | .dma_test_irq = cmd64x_dma_test_irq, |
384 | .dma_lost_irq = ide_dma_lost_irq, | 386 | .dma_lost_irq = ide_dma_lost_irq, |
385 | .dma_timeout = ide_dma_timeout, | 387 | .dma_timeout = ide_dma_timeout, |
388 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
386 | }; | 389 | }; |
387 | 390 | ||
388 | static const struct ide_dma_ops cmd646_rev1_dma_ops = { | 391 | static const struct ide_dma_ops cmd646_rev1_dma_ops = { |
@@ -394,6 +397,7 @@ static const struct ide_dma_ops cmd646_rev1_dma_ops = { | |||
394 | .dma_test_irq = ide_dma_test_irq, | 397 | .dma_test_irq = ide_dma_test_irq, |
395 | .dma_lost_irq = ide_dma_lost_irq, | 398 | .dma_lost_irq = ide_dma_lost_irq, |
396 | .dma_timeout = ide_dma_timeout, | 399 | .dma_timeout = ide_dma_timeout, |
400 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
397 | }; | 401 | }; |
398 | 402 | ||
399 | static const struct ide_dma_ops cmd648_dma_ops = { | 403 | static const struct ide_dma_ops cmd648_dma_ops = { |
@@ -405,6 +409,7 @@ static const struct ide_dma_ops cmd648_dma_ops = { | |||
405 | .dma_test_irq = cmd648_dma_test_irq, | 409 | .dma_test_irq = cmd648_dma_test_irq, |
406 | .dma_lost_irq = ide_dma_lost_irq, | 410 | .dma_lost_irq = ide_dma_lost_irq, |
407 | .dma_timeout = ide_dma_timeout, | 411 | .dma_timeout = ide_dma_timeout, |
412 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
408 | }; | 413 | }; |
409 | 414 | ||
410 | static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { | 415 | static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { |
diff --git a/drivers/ide/cs5520.c b/drivers/ide/cs5520.c index 5efb467f8fa0..d003bec56ff9 100644 --- a/drivers/ide/cs5520.c +++ b/drivers/ide/cs5520.c | |||
@@ -59,7 +59,7 @@ static struct pio_clocks cs5520_pio_clocks[]={ | |||
59 | 59 | ||
60 | static void cs5520_set_pio_mode(ide_drive_t *drive, const u8 pio) | 60 | static void cs5520_set_pio_mode(ide_drive_t *drive, const u8 pio) |
61 | { | 61 | { |
62 | ide_hwif_t *hwif = HWIF(drive); | 62 | ide_hwif_t *hwif = drive->hwif; |
63 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 63 | struct pci_dev *pdev = to_pci_dev(hwif->dev); |
64 | int controller = drive->dn > 1 ? 1 : 0; | 64 | int controller = drive->dn > 1 ? 1 : 0; |
65 | 65 | ||
diff --git a/drivers/ide/cy82c693.c b/drivers/ide/cy82c693.c index d37baf8ecc5f..74fc5401f407 100644 --- a/drivers/ide/cy82c693.c +++ b/drivers/ide/cy82c693.c | |||
@@ -203,7 +203,7 @@ static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
203 | 203 | ||
204 | static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) | 204 | static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) |
205 | { | 205 | { |
206 | ide_hwif_t *hwif = HWIF(drive); | 206 | ide_hwif_t *hwif = drive->hwif; |
207 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 207 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
208 | pio_clocks_t pclk; | 208 | pio_clocks_t pclk; |
209 | unsigned int addrCtrl; | 209 | unsigned int addrCtrl; |
diff --git a/drivers/ide/falconide.c b/drivers/ide/falconide.c index 39d500d84b07..a5ba820d69bb 100644 --- a/drivers/ide/falconide.c +++ b/drivers/ide/falconide.c | |||
@@ -70,7 +70,6 @@ static const struct ide_tp_ops falconide_tp_ops = { | |||
70 | .exec_command = ide_exec_command, | 70 | .exec_command = ide_exec_command, |
71 | .read_status = ide_read_status, | 71 | .read_status = ide_read_status, |
72 | .read_altstatus = ide_read_altstatus, | 72 | .read_altstatus = ide_read_altstatus, |
73 | .read_sff_dma_status = ide_read_sff_dma_status, | ||
74 | 73 | ||
75 | .set_irq = ide_set_irq, | 74 | .set_irq = ide_set_irq, |
76 | 75 | ||
diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c index b18e10d99d2e..3eb9b5c63a0f 100644 --- a/drivers/ide/hpt366.c +++ b/drivers/ide/hpt366.c | |||
@@ -626,7 +626,7 @@ static struct hpt_info *hpt3xx_get_info(struct device *dev) | |||
626 | 626 | ||
627 | static u8 hpt3xx_udma_filter(ide_drive_t *drive) | 627 | static u8 hpt3xx_udma_filter(ide_drive_t *drive) |
628 | { | 628 | { |
629 | ide_hwif_t *hwif = HWIF(drive); | 629 | ide_hwif_t *hwif = drive->hwif; |
630 | struct hpt_info *info = hpt3xx_get_info(hwif->dev); | 630 | struct hpt_info *info = hpt3xx_get_info(hwif->dev); |
631 | u8 mask = hwif->ultra_mask; | 631 | u8 mask = hwif->ultra_mask; |
632 | 632 | ||
@@ -665,7 +665,7 @@ static u8 hpt3xx_udma_filter(ide_drive_t *drive) | |||
665 | 665 | ||
666 | static u8 hpt3xx_mdma_filter(ide_drive_t *drive) | 666 | static u8 hpt3xx_mdma_filter(ide_drive_t *drive) |
667 | { | 667 | { |
668 | ide_hwif_t *hwif = HWIF(drive); | 668 | ide_hwif_t *hwif = drive->hwif; |
669 | struct hpt_info *info = hpt3xx_get_info(hwif->dev); | 669 | struct hpt_info *info = hpt3xx_get_info(hwif->dev); |
670 | 670 | ||
671 | switch (info->chip_type) { | 671 | switch (info->chip_type) { |
@@ -743,7 +743,7 @@ static void hpt3xx_quirkproc(ide_drive_t *drive) | |||
743 | 743 | ||
744 | static void hpt3xx_maskproc(ide_drive_t *drive, int mask) | 744 | static void hpt3xx_maskproc(ide_drive_t *drive, int mask) |
745 | { | 745 | { |
746 | ide_hwif_t *hwif = HWIF(drive); | 746 | ide_hwif_t *hwif = drive->hwif; |
747 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 747 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
748 | struct hpt_info *info = hpt3xx_get_info(hwif->dev); | 748 | struct hpt_info *info = hpt3xx_get_info(hwif->dev); |
749 | 749 | ||
@@ -788,7 +788,7 @@ static void hpt366_dma_lost_irq(ide_drive_t *drive) | |||
788 | 788 | ||
789 | static void hpt370_clear_engine(ide_drive_t *drive) | 789 | static void hpt370_clear_engine(ide_drive_t *drive) |
790 | { | 790 | { |
791 | ide_hwif_t *hwif = HWIF(drive); | 791 | ide_hwif_t *hwif = drive->hwif; |
792 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 792 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
793 | 793 | ||
794 | pci_write_config_byte(dev, hwif->select_data, 0x37); | 794 | pci_write_config_byte(dev, hwif->select_data, 0x37); |
@@ -797,7 +797,7 @@ static void hpt370_clear_engine(ide_drive_t *drive) | |||
797 | 797 | ||
798 | static void hpt370_irq_timeout(ide_drive_t *drive) | 798 | static void hpt370_irq_timeout(ide_drive_t *drive) |
799 | { | 799 | { |
800 | ide_hwif_t *hwif = HWIF(drive); | 800 | ide_hwif_t *hwif = drive->hwif; |
801 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 801 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
802 | u16 bfifo = 0; | 802 | u16 bfifo = 0; |
803 | u8 dma_cmd; | 803 | u8 dma_cmd; |
@@ -822,7 +822,7 @@ static void hpt370_dma_start(ide_drive_t *drive) | |||
822 | 822 | ||
823 | static int hpt370_dma_end(ide_drive_t *drive) | 823 | static int hpt370_dma_end(ide_drive_t *drive) |
824 | { | 824 | { |
825 | ide_hwif_t *hwif = HWIF(drive); | 825 | ide_hwif_t *hwif = drive->hwif; |
826 | u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); | 826 | u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); |
827 | 827 | ||
828 | if (dma_stat & 0x01) { | 828 | if (dma_stat & 0x01) { |
@@ -844,7 +844,7 @@ static void hpt370_dma_timeout(ide_drive_t *drive) | |||
844 | /* returns 1 if DMA IRQ issued, 0 otherwise */ | 844 | /* returns 1 if DMA IRQ issued, 0 otherwise */ |
845 | static int hpt374_dma_test_irq(ide_drive_t *drive) | 845 | static int hpt374_dma_test_irq(ide_drive_t *drive) |
846 | { | 846 | { |
847 | ide_hwif_t *hwif = HWIF(drive); | 847 | ide_hwif_t *hwif = drive->hwif; |
848 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 848 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
849 | u16 bfifo = 0; | 849 | u16 bfifo = 0; |
850 | u8 dma_stat; | 850 | u8 dma_stat; |
@@ -865,7 +865,7 @@ static int hpt374_dma_test_irq(ide_drive_t *drive) | |||
865 | 865 | ||
866 | static int hpt374_dma_end(ide_drive_t *drive) | 866 | static int hpt374_dma_end(ide_drive_t *drive) |
867 | { | 867 | { |
868 | ide_hwif_t *hwif = HWIF(drive); | 868 | ide_hwif_t *hwif = drive->hwif; |
869 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 869 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
870 | u8 mcr = 0, mcr_addr = hwif->select_data; | 870 | u8 mcr = 0, mcr_addr = hwif->select_data; |
871 | u8 bwsr = 0, mask = hwif->channel ? 0x02 : 0x01; | 871 | u8 bwsr = 0, mask = hwif->channel ? 0x02 : 0x01; |
@@ -927,7 +927,7 @@ static void hpt3xxn_set_clock(ide_hwif_t *hwif, u8 mode) | |||
927 | 927 | ||
928 | static void hpt3xxn_rw_disk(ide_drive_t *drive, struct request *rq) | 928 | static void hpt3xxn_rw_disk(ide_drive_t *drive, struct request *rq) |
929 | { | 929 | { |
930 | hpt3xxn_set_clock(HWIF(drive), rq_data_dir(rq) ? 0x23 : 0x21); | 930 | hpt3xxn_set_clock(drive->hwif, rq_data_dir(rq) ? 0x23 : 0x21); |
931 | } | 931 | } |
932 | 932 | ||
933 | /** | 933 | /** |
@@ -1349,8 +1349,6 @@ static int __devinit init_dma_hpt366(ide_hwif_t *hwif, | |||
1349 | if (ide_allocate_dma_engine(hwif)) | 1349 | if (ide_allocate_dma_engine(hwif)) |
1350 | return -1; | 1350 | return -1; |
1351 | 1351 | ||
1352 | hwif->dma_ops = &sff_dma_ops; | ||
1353 | |||
1354 | return 0; | 1352 | return 0; |
1355 | } | 1353 | } |
1356 | 1354 | ||
@@ -1426,6 +1424,7 @@ static const struct ide_dma_ops hpt37x_dma_ops = { | |||
1426 | .dma_test_irq = hpt374_dma_test_irq, | 1424 | .dma_test_irq = hpt374_dma_test_irq, |
1427 | .dma_lost_irq = ide_dma_lost_irq, | 1425 | .dma_lost_irq = ide_dma_lost_irq, |
1428 | .dma_timeout = ide_dma_timeout, | 1426 | .dma_timeout = ide_dma_timeout, |
1427 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
1429 | }; | 1428 | }; |
1430 | 1429 | ||
1431 | static const struct ide_dma_ops hpt370_dma_ops = { | 1430 | static const struct ide_dma_ops hpt370_dma_ops = { |
@@ -1437,6 +1436,7 @@ static const struct ide_dma_ops hpt370_dma_ops = { | |||
1437 | .dma_test_irq = ide_dma_test_irq, | 1436 | .dma_test_irq = ide_dma_test_irq, |
1438 | .dma_lost_irq = ide_dma_lost_irq, | 1437 | .dma_lost_irq = ide_dma_lost_irq, |
1439 | .dma_timeout = hpt370_dma_timeout, | 1438 | .dma_timeout = hpt370_dma_timeout, |
1439 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
1440 | }; | 1440 | }; |
1441 | 1441 | ||
1442 | static const struct ide_dma_ops hpt36x_dma_ops = { | 1442 | static const struct ide_dma_ops hpt36x_dma_ops = { |
@@ -1448,6 +1448,7 @@ static const struct ide_dma_ops hpt36x_dma_ops = { | |||
1448 | .dma_test_irq = ide_dma_test_irq, | 1448 | .dma_test_irq = ide_dma_test_irq, |
1449 | .dma_lost_irq = hpt366_dma_lost_irq, | 1449 | .dma_lost_irq = hpt366_dma_lost_irq, |
1450 | .dma_timeout = ide_dma_timeout, | 1450 | .dma_timeout = ide_dma_timeout, |
1451 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
1451 | }; | 1452 | }; |
1452 | 1453 | ||
1453 | static const struct ide_port_info hpt366_chipsets[] __devinitdata = { | 1454 | static const struct ide_port_info hpt366_chipsets[] __devinitdata = { |
diff --git a/drivers/ide/icside.c b/drivers/ide/icside.c index 81f70caeb40f..97a35c667aee 100644 --- a/drivers/ide/icside.c +++ b/drivers/ide/icside.c | |||
@@ -166,7 +166,7 @@ static const expansioncard_ops_t icside_ops_arcin_v6 = { | |||
166 | */ | 166 | */ |
167 | static void icside_maskproc(ide_drive_t *drive, int mask) | 167 | static void icside_maskproc(ide_drive_t *drive, int mask) |
168 | { | 168 | { |
169 | ide_hwif_t *hwif = HWIF(drive); | 169 | ide_hwif_t *hwif = drive->hwif; |
170 | struct expansion_card *ec = ECARD_DEV(hwif->dev); | 170 | struct expansion_card *ec = ECARD_DEV(hwif->dev); |
171 | struct icside_state *state = ecard_get_drvdata(ec); | 171 | struct icside_state *state = ecard_get_drvdata(ec); |
172 | unsigned long flags; | 172 | unsigned long flags; |
@@ -284,7 +284,7 @@ static void icside_dma_host_set(ide_drive_t *drive, int on) | |||
284 | 284 | ||
285 | static int icside_dma_end(ide_drive_t *drive) | 285 | static int icside_dma_end(ide_drive_t *drive) |
286 | { | 286 | { |
287 | ide_hwif_t *hwif = HWIF(drive); | 287 | ide_hwif_t *hwif = drive->hwif; |
288 | struct expansion_card *ec = ECARD_DEV(hwif->dev); | 288 | struct expansion_card *ec = ECARD_DEV(hwif->dev); |
289 | 289 | ||
290 | drive->waiting_for_dma = 0; | 290 | drive->waiting_for_dma = 0; |
@@ -299,7 +299,7 @@ static int icside_dma_end(ide_drive_t *drive) | |||
299 | 299 | ||
300 | static void icside_dma_start(ide_drive_t *drive) | 300 | static void icside_dma_start(ide_drive_t *drive) |
301 | { | 301 | { |
302 | ide_hwif_t *hwif = HWIF(drive); | 302 | ide_hwif_t *hwif = drive->hwif; |
303 | struct expansion_card *ec = ECARD_DEV(hwif->dev); | 303 | struct expansion_card *ec = ECARD_DEV(hwif->dev); |
304 | 304 | ||
305 | /* We can not enable DMA on both channels simultaneously. */ | 305 | /* We can not enable DMA on both channels simultaneously. */ |
@@ -309,10 +309,10 @@ static void icside_dma_start(ide_drive_t *drive) | |||
309 | 309 | ||
310 | static int icside_dma_setup(ide_drive_t *drive) | 310 | static int icside_dma_setup(ide_drive_t *drive) |
311 | { | 311 | { |
312 | ide_hwif_t *hwif = HWIF(drive); | 312 | ide_hwif_t *hwif = drive->hwif; |
313 | struct expansion_card *ec = ECARD_DEV(hwif->dev); | 313 | struct expansion_card *ec = ECARD_DEV(hwif->dev); |
314 | struct icside_state *state = ecard_get_drvdata(ec); | 314 | struct icside_state *state = ecard_get_drvdata(ec); |
315 | struct request *rq = hwif->hwgroup->rq; | 315 | struct request *rq = hwif->rq; |
316 | unsigned int dma_mode; | 316 | unsigned int dma_mode; |
317 | 317 | ||
318 | if (rq_data_dir(rq)) | 318 | if (rq_data_dir(rq)) |
@@ -362,7 +362,7 @@ static void icside_dma_exec_cmd(ide_drive_t *drive, u8 cmd) | |||
362 | 362 | ||
363 | static int icside_dma_test_irq(ide_drive_t *drive) | 363 | static int icside_dma_test_irq(ide_drive_t *drive) |
364 | { | 364 | { |
365 | ide_hwif_t *hwif = HWIF(drive); | 365 | ide_hwif_t *hwif = drive->hwif; |
366 | struct expansion_card *ec = ECARD_DEV(hwif->dev); | 366 | struct expansion_card *ec = ECARD_DEV(hwif->dev); |
367 | struct icside_state *state = ecard_get_drvdata(ec); | 367 | struct icside_state *state = ecard_get_drvdata(ec); |
368 | 368 | ||
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index fd4a36433050..2f9e941968d6 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c | |||
@@ -218,7 +218,7 @@ static acpi_handle ide_acpi_hwif_get_handle(ide_hwif_t *hwif) | |||
218 | */ | 218 | */ |
219 | static acpi_handle ide_acpi_drive_get_handle(ide_drive_t *drive) | 219 | static acpi_handle ide_acpi_drive_get_handle(ide_drive_t *drive) |
220 | { | 220 | { |
221 | ide_hwif_t *hwif = HWIF(drive); | 221 | ide_hwif_t *hwif = drive->hwif; |
222 | int port; | 222 | int port; |
223 | acpi_handle drive_handle; | 223 | acpi_handle drive_handle; |
224 | 224 | ||
@@ -263,7 +263,7 @@ static int do_drive_get_GTF(ide_drive_t *drive, | |||
263 | acpi_status status; | 263 | acpi_status status; |
264 | struct acpi_buffer output; | 264 | struct acpi_buffer output; |
265 | union acpi_object *out_obj; | 265 | union acpi_object *out_obj; |
266 | ide_hwif_t *hwif = HWIF(drive); | 266 | ide_hwif_t *hwif = drive->hwif; |
267 | struct device *dev = hwif->gendev.parent; | 267 | struct device *dev = hwif->gendev.parent; |
268 | int err = -ENODEV; | 268 | int err = -ENODEV; |
269 | int port; | 269 | int port; |
@@ -641,7 +641,8 @@ void ide_acpi_push_timing(ide_hwif_t *hwif) | |||
641 | */ | 641 | */ |
642 | void ide_acpi_set_state(ide_hwif_t *hwif, int on) | 642 | void ide_acpi_set_state(ide_hwif_t *hwif, int on) |
643 | { | 643 | { |
644 | int unit; | 644 | ide_drive_t *drive; |
645 | int i; | ||
645 | 646 | ||
646 | if (ide_noacpi || ide_noacpi_psx) | 647 | if (ide_noacpi || ide_noacpi_psx) |
647 | return; | 648 | return; |
@@ -655,9 +656,8 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on) | |||
655 | /* channel first and then drives for power on and verse versa for power off */ | 656 | /* channel first and then drives for power on and verse versa for power off */ |
656 | if (on) | 657 | if (on) |
657 | acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0); | 658 | acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0); |
658 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | ||
659 | ide_drive_t *drive = &hwif->drives[unit]; | ||
660 | 659 | ||
660 | ide_port_for_each_dev(i, drive, hwif) { | ||
661 | if (!drive->acpidata->obj_handle) | 661 | if (!drive->acpidata->obj_handle) |
662 | drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive); | 662 | drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive); |
663 | 663 | ||
@@ -711,15 +711,13 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif) | |||
711 | * for both drives, regardless whether they are connected | 711 | * for both drives, regardless whether they are connected |
712 | * or not. | 712 | * or not. |
713 | */ | 713 | */ |
714 | hwif->drives[0].acpidata = &hwif->acpidata->master; | 714 | hwif->devices[0]->acpidata = &hwif->acpidata->master; |
715 | hwif->drives[1].acpidata = &hwif->acpidata->slave; | 715 | hwif->devices[1]->acpidata = &hwif->acpidata->slave; |
716 | 716 | ||
717 | /* | 717 | /* |
718 | * Send IDENTIFY for each drive | 718 | * Send IDENTIFY for each drive |
719 | */ | 719 | */ |
720 | for (i = 0; i < MAX_DRIVES; i++) { | 720 | ide_port_for_each_dev(i, drive, hwif) { |
721 | drive = &hwif->drives[i]; | ||
722 | |||
723 | memset(drive->acpidata, 0, sizeof(*drive->acpidata)); | 721 | memset(drive->acpidata, 0, sizeof(*drive->acpidata)); |
724 | 722 | ||
725 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) | 723 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) |
@@ -744,9 +742,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif) | |||
744 | ide_acpi_get_timing(hwif); | 742 | ide_acpi_get_timing(hwif); |
745 | ide_acpi_push_timing(hwif); | 743 | ide_acpi_push_timing(hwif); |
746 | 744 | ||
747 | for (i = 0; i < MAX_DRIVES; i++) { | 745 | ide_port_for_each_dev(i, drive, hwif) { |
748 | drive = &hwif->drives[i]; | ||
749 | |||
750 | if (drive->dev_flags & IDE_DFLAG_PRESENT) | 746 | if (drive->dev_flags & IDE_DFLAG_PRESENT) |
751 | /* Execute ACPI startup code */ | 747 | /* Execute ACPI startup code */ |
752 | ide_acpi_exec_tfs(drive); | 748 | ide_acpi_exec_tfs(drive); |
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index e8688c0f8645..e96c01260598 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c | |||
@@ -243,7 +243,7 @@ EXPORT_SYMBOL_GPL(ide_retry_pc); | |||
243 | 243 | ||
244 | int ide_cd_expiry(ide_drive_t *drive) | 244 | int ide_cd_expiry(ide_drive_t *drive) |
245 | { | 245 | { |
246 | struct request *rq = HWGROUP(drive)->rq; | 246 | struct request *rq = drive->hwif->rq; |
247 | unsigned long wait = 0; | 247 | unsigned long wait = 0; |
248 | 248 | ||
249 | debug_log("%s: rq->cmd[0]: 0x%x\n", __func__, rq->cmd[0]); | 249 | debug_log("%s: rq->cmd[0]: 0x%x\n", __func__, rq->cmd[0]); |
@@ -294,7 +294,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
294 | { | 294 | { |
295 | struct ide_atapi_pc *pc = drive->pc; | 295 | struct ide_atapi_pc *pc = drive->pc; |
296 | ide_hwif_t *hwif = drive->hwif; | 296 | ide_hwif_t *hwif = drive->hwif; |
297 | struct request *rq = hwif->hwgroup->rq; | 297 | struct request *rq = hwif->rq; |
298 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 298 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
299 | xfer_func_t *xferfunc; | 299 | xfer_func_t *xferfunc; |
300 | unsigned int timeout, temp; | 300 | unsigned int timeout, temp; |
@@ -491,7 +491,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) | |||
491 | { | 491 | { |
492 | struct ide_atapi_pc *uninitialized_var(pc); | 492 | struct ide_atapi_pc *uninitialized_var(pc); |
493 | ide_hwif_t *hwif = drive->hwif; | 493 | ide_hwif_t *hwif = drive->hwif; |
494 | struct request *rq = hwif->hwgroup->rq; | 494 | struct request *rq = hwif->rq; |
495 | ide_expiry_t *expiry; | 495 | ide_expiry_t *expiry; |
496 | unsigned int timeout; | 496 | unsigned int timeout; |
497 | int cmd_len; | 497 | int cmd_len; |
@@ -549,7 +549,10 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) | |||
549 | } | 549 | } |
550 | 550 | ||
551 | /* Set the interrupt routine */ | 551 | /* Set the interrupt routine */ |
552 | ide_set_handler(drive, ide_pc_intr, timeout, expiry); | 552 | ide_set_handler(drive, |
553 | (dev_is_idecd(drive) ? drive->irq_handler | ||
554 | : ide_pc_intr), | ||
555 | timeout, expiry); | ||
553 | 556 | ||
554 | /* Begin DMA, if necessary */ | 557 | /* Begin DMA, if necessary */ |
555 | if (dev_is_idecd(drive)) { | 558 | if (dev_is_idecd(drive)) { |
@@ -580,7 +583,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive) | |||
580 | 583 | ||
581 | if (dev_is_idecd(drive)) { | 584 | if (dev_is_idecd(drive)) { |
582 | tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL; | 585 | tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL; |
583 | bcount = ide_cd_get_xferlen(hwif->hwgroup->rq); | 586 | bcount = ide_cd_get_xferlen(hwif->rq); |
584 | expiry = ide_cd_expiry; | 587 | expiry = ide_cd_expiry; |
585 | timeout = ATAPI_WAIT_PC; | 588 | timeout = ATAPI_WAIT_PC; |
586 | 589 | ||
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 1a7410f88249..cae69372cf45 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -239,7 +239,7 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | |||
239 | 239 | ||
240 | static void cdrom_end_request(ide_drive_t *drive, int uptodate) | 240 | static void cdrom_end_request(ide_drive_t *drive, int uptodate) |
241 | { | 241 | { |
242 | struct request *rq = HWGROUP(drive)->rq; | 242 | struct request *rq = drive->hwif->rq; |
243 | int nsectors = rq->hard_cur_sectors; | 243 | int nsectors = rq->hard_cur_sectors; |
244 | 244 | ||
245 | ide_debug_log(IDE_DBG_FUNC, "Call %s, cmd: 0x%x, uptodate: 0x%x, " | 245 | ide_debug_log(IDE_DBG_FUNC, "Call %s, cmd: 0x%x, uptodate: 0x%x, " |
@@ -306,8 +306,7 @@ static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 st) | |||
306 | static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | 306 | static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) |
307 | { | 307 | { |
308 | ide_hwif_t *hwif = drive->hwif; | 308 | ide_hwif_t *hwif = drive->hwif; |
309 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | 309 | struct request *rq = hwif->rq; |
310 | struct request *rq = hwgroup->rq; | ||
311 | int stat, err, sense_key; | 310 | int stat, err, sense_key; |
312 | 311 | ||
313 | /* check for errors */ | 312 | /* check for errors */ |
@@ -502,7 +501,7 @@ end_request: | |||
502 | blkdev_dequeue_request(rq); | 501 | blkdev_dequeue_request(rq); |
503 | spin_unlock_irqrestore(q->queue_lock, flags); | 502 | spin_unlock_irqrestore(q->queue_lock, flags); |
504 | 503 | ||
505 | hwgroup->rq = NULL; | 504 | hwif->rq = NULL; |
506 | 505 | ||
507 | cdrom_queue_request_sense(drive, rq->sense, rq); | 506 | cdrom_queue_request_sense(drive, rq->sense, rq); |
508 | } else | 507 | } else |
@@ -511,106 +510,6 @@ end_request: | |||
511 | return 1; | 510 | return 1; |
512 | } | 511 | } |
513 | 512 | ||
514 | static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *); | ||
515 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); | ||
516 | |||
517 | /* | ||
518 | * Set up the device registers for transferring a packet command on DEV, | ||
519 | * expecting to later transfer XFERLEN bytes. HANDLER is the routine | ||
520 | * which actually transfers the command to the drive. If this is a | ||
521 | * drq_interrupt device, this routine will arrange for HANDLER to be | ||
522 | * called when the interrupt from the drive arrives. Otherwise, HANDLER | ||
523 | * will be called immediately after the drive is prepared for the transfer. | ||
524 | */ | ||
525 | static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive) | ||
526 | { | ||
527 | ide_hwif_t *hwif = drive->hwif; | ||
528 | struct request *rq = hwif->hwgroup->rq; | ||
529 | int xferlen; | ||
530 | |||
531 | xferlen = ide_cd_get_xferlen(rq); | ||
532 | |||
533 | ide_debug_log(IDE_DBG_PC, "Call %s, xferlen: %d\n", __func__, xferlen); | ||
534 | |||
535 | /* FIXME: for Virtual DMA we must check harder */ | ||
536 | if (drive->dma) | ||
537 | drive->dma = !hwif->dma_ops->dma_setup(drive); | ||
538 | |||
539 | /* set up the controller registers */ | ||
540 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL, | ||
541 | xferlen, drive->dma); | ||
542 | |||
543 | if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { | ||
544 | /* waiting for CDB interrupt, not DMA yet. */ | ||
545 | if (drive->dma) | ||
546 | drive->waiting_for_dma = 0; | ||
547 | |||
548 | /* packet command */ | ||
549 | ide_execute_command(drive, ATA_CMD_PACKET, | ||
550 | cdrom_transfer_packet_command, | ||
551 | ATAPI_WAIT_PC, ide_cd_expiry); | ||
552 | return ide_started; | ||
553 | } else { | ||
554 | ide_execute_pkt_cmd(drive); | ||
555 | |||
556 | return cdrom_transfer_packet_command(drive); | ||
557 | } | ||
558 | } | ||
559 | |||
560 | /* | ||
561 | * Send a packet command to DRIVE described by CMD_BUF and CMD_LEN. The device | ||
562 | * registers must have already been prepared by cdrom_start_packet_command. | ||
563 | * HANDLER is the interrupt handler to call when the command completes or | ||
564 | * there's data ready. | ||
565 | */ | ||
566 | #define ATAPI_MIN_CDB_BYTES 12 | ||
567 | static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive) | ||
568 | { | ||
569 | ide_hwif_t *hwif = drive->hwif; | ||
570 | struct request *rq = hwif->hwgroup->rq; | ||
571 | int cmd_len; | ||
572 | ide_startstop_t startstop; | ||
573 | |||
574 | ide_debug_log(IDE_DBG_PC, "Call %s\n", __func__); | ||
575 | |||
576 | if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { | ||
577 | /* | ||
578 | * Here we should have been called after receiving an interrupt | ||
579 | * from the device. DRQ should how be set. | ||
580 | */ | ||
581 | |||
582 | /* check for errors */ | ||
583 | if (cdrom_decode_status(drive, ATA_DRQ, NULL)) | ||
584 | return ide_stopped; | ||
585 | |||
586 | /* ok, next interrupt will be DMA interrupt */ | ||
587 | if (drive->dma) | ||
588 | drive->waiting_for_dma = 1; | ||
589 | } else { | ||
590 | /* otherwise, we must wait for DRQ to get set */ | ||
591 | if (ide_wait_stat(&startstop, drive, ATA_DRQ, | ||
592 | ATA_BUSY, WAIT_READY)) | ||
593 | return startstop; | ||
594 | } | ||
595 | |||
596 | /* arm the interrupt handler */ | ||
597 | ide_set_handler(drive, cdrom_newpc_intr, rq->timeout, ide_cd_expiry); | ||
598 | |||
599 | /* ATAPI commands get padded out to 12 bytes minimum */ | ||
600 | cmd_len = COMMAND_SIZE(rq->cmd[0]); | ||
601 | if (cmd_len < ATAPI_MIN_CDB_BYTES) | ||
602 | cmd_len = ATAPI_MIN_CDB_BYTES; | ||
603 | |||
604 | /* send the command to the device */ | ||
605 | hwif->tp_ops->output_data(drive, NULL, rq->cmd, cmd_len); | ||
606 | |||
607 | /* start the DMA if need be */ | ||
608 | if (drive->dma) | ||
609 | hwif->dma_ops->dma_start(drive); | ||
610 | |||
611 | return ide_started; | ||
612 | } | ||
613 | |||
614 | /* | 513 | /* |
615 | * Check the contents of the interrupt reason register from the cdrom | 514 | * Check the contents of the interrupt reason register from the cdrom |
616 | * and attempt to recover if there are problems. Returns 0 if everything's | 515 | * and attempt to recover if there are problems. Returns 0 if everything's |
@@ -854,8 +753,7 @@ static int cdrom_newpc_intr_dummy_cb(struct request *rq) | |||
854 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | 753 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) |
855 | { | 754 | { |
856 | ide_hwif_t *hwif = drive->hwif; | 755 | ide_hwif_t *hwif = drive->hwif; |
857 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | 756 | struct request *rq = hwif->rq; |
858 | struct request *rq = hwgroup->rq; | ||
859 | xfer_func_t *xferfunc; | 757 | xfer_func_t *xferfunc; |
860 | ide_expiry_t *expiry = NULL; | 758 | ide_expiry_t *expiry = NULL; |
861 | int dma_error = 0, dma, stat, thislen, uptodate = 0; | 759 | int dma_error = 0, dma, stat, thislen, uptodate = 0; |
@@ -1061,7 +959,7 @@ end_request: | |||
1061 | if (blk_end_request(rq, 0, dlen)) | 959 | if (blk_end_request(rq, 0, dlen)) |
1062 | BUG(); | 960 | BUG(); |
1063 | 961 | ||
1064 | hwgroup->rq = NULL; | 962 | hwif->rq = NULL; |
1065 | } else { | 963 | } else { |
1066 | if (!uptodate) | 964 | if (!uptodate) |
1067 | rq->cmd_flags |= REQ_FAILED; | 965 | rq->cmd_flags |= REQ_FAILED; |
@@ -1183,7 +1081,7 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, | |||
1183 | return ide_stopped; | 1081 | return ide_stopped; |
1184 | } | 1082 | } |
1185 | 1083 | ||
1186 | return cdrom_start_packet_command(drive); | 1084 | return ide_issue_pc(drive); |
1187 | } | 1085 | } |
1188 | 1086 | ||
1189 | /* | 1087 | /* |
@@ -1916,7 +1814,7 @@ static void ide_cd_release(struct kref *kref) | |||
1916 | 1814 | ||
1917 | static int ide_cd_probe(ide_drive_t *); | 1815 | static int ide_cd_probe(ide_drive_t *); |
1918 | 1816 | ||
1919 | static ide_driver_t ide_cdrom_driver = { | 1817 | static struct ide_driver ide_cdrom_driver = { |
1920 | .gen_driver = { | 1818 | .gen_driver = { |
1921 | .owner = THIS_MODULE, | 1819 | .owner = THIS_MODULE, |
1922 | .name = "ide-cdrom", | 1820 | .name = "ide-cdrom", |
@@ -1927,7 +1825,6 @@ static ide_driver_t ide_cdrom_driver = { | |||
1927 | .version = IDECD_VERSION, | 1825 | .version = IDECD_VERSION, |
1928 | .do_request = ide_cd_do_request, | 1826 | .do_request = ide_cd_do_request, |
1929 | .end_request = ide_end_request, | 1827 | .end_request = ide_end_request, |
1930 | .error = __ide_error, | ||
1931 | #ifdef CONFIG_IDE_PROC_FS | 1828 | #ifdef CONFIG_IDE_PROC_FS |
1932 | .proc_entries = ide_cd_proc_entries, | 1829 | .proc_entries = ide_cd_proc_entries, |
1933 | .proc_devsets = ide_cd_proc_devsets, | 1830 | .proc_devsets = ide_cd_proc_devsets, |
@@ -2082,6 +1979,7 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
2082 | } | 1979 | } |
2083 | 1980 | ||
2084 | drive->debug_mask = debug_mask; | 1981 | drive->debug_mask = debug_mask; |
1982 | drive->irq_handler = cdrom_newpc_intr; | ||
2085 | 1983 | ||
2086 | info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); | 1984 | info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); |
2087 | if (info == NULL) { | 1985 | if (info == NULL) { |
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h index bf676b262181..ac40d6cb90a2 100644 --- a/drivers/ide/ide-cd.h +++ b/drivers/ide/ide-cd.h | |||
@@ -33,33 +33,33 @@ | |||
33 | 33 | ||
34 | /* Structure of a MSF cdrom address. */ | 34 | /* Structure of a MSF cdrom address. */ |
35 | struct atapi_msf { | 35 | struct atapi_msf { |
36 | byte reserved; | 36 | u8 reserved; |
37 | byte minute; | 37 | u8 minute; |
38 | byte second; | 38 | u8 second; |
39 | byte frame; | 39 | u8 frame; |
40 | }; | 40 | }; |
41 | 41 | ||
42 | /* Space to hold the disk TOC. */ | 42 | /* Space to hold the disk TOC. */ |
43 | #define MAX_TRACKS 99 | 43 | #define MAX_TRACKS 99 |
44 | struct atapi_toc_header { | 44 | struct atapi_toc_header { |
45 | unsigned short toc_length; | 45 | unsigned short toc_length; |
46 | byte first_track; | 46 | u8 first_track; |
47 | byte last_track; | 47 | u8 last_track; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | struct atapi_toc_entry { | 50 | struct atapi_toc_entry { |
51 | byte reserved1; | 51 | u8 reserved1; |
52 | #if defined(__BIG_ENDIAN_BITFIELD) | 52 | #if defined(__BIG_ENDIAN_BITFIELD) |
53 | __u8 adr : 4; | 53 | u8 adr : 4; |
54 | __u8 control : 4; | 54 | u8 control : 4; |
55 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | 55 | #elif defined(__LITTLE_ENDIAN_BITFIELD) |
56 | __u8 control : 4; | 56 | u8 control : 4; |
57 | __u8 adr : 4; | 57 | u8 adr : 4; |
58 | #else | 58 | #else |
59 | #error "Please fix <asm/byteorder.h>" | 59 | #error "Please fix <asm/byteorder.h>" |
60 | #endif | 60 | #endif |
61 | byte track; | 61 | u8 track; |
62 | byte reserved2; | 62 | u8 reserved2; |
63 | union { | 63 | union { |
64 | unsigned lba; | 64 | unsigned lba; |
65 | struct atapi_msf msf; | 65 | struct atapi_msf msf; |
@@ -77,10 +77,10 @@ struct atapi_toc { | |||
77 | 77 | ||
78 | /* Extra per-device info for cdrom drives. */ | 78 | /* Extra per-device info for cdrom drives. */ |
79 | struct cdrom_info { | 79 | struct cdrom_info { |
80 | ide_drive_t *drive; | 80 | ide_drive_t *drive; |
81 | ide_driver_t *driver; | 81 | struct ide_driver *driver; |
82 | struct gendisk *disk; | 82 | struct gendisk *disk; |
83 | struct kref kref; | 83 | struct kref kref; |
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.c b/drivers/ide/ide-disk.c index eb9fac4d0f0c..4088a622873e 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -89,7 +89,7 @@ static void ide_tf_set_cmd(ide_drive_t *drive, ide_task_t *task, u8 dma) | |||
89 | static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | 89 | static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, |
90 | sector_t block) | 90 | sector_t block) |
91 | { | 91 | { |
92 | ide_hwif_t *hwif = HWIF(drive); | 92 | ide_hwif_t *hwif = drive->hwif; |
93 | u16 nsectors = (u16)rq->nr_sectors; | 93 | u16 nsectors = (u16)rq->nr_sectors; |
94 | u8 lba48 = !!(drive->dev_flags & IDE_DFLAG_LBA48); | 94 | u8 lba48 = !!(drive->dev_flags & IDE_DFLAG_LBA48); |
95 | u8 dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); | 95 | u8 dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); |
@@ -187,7 +187,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | |||
187 | static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | 187 | static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq, |
188 | sector_t block) | 188 | sector_t block) |
189 | { | 189 | { |
190 | ide_hwif_t *hwif = HWIF(drive); | 190 | ide_hwif_t *hwif = drive->hwif; |
191 | 191 | ||
192 | BUG_ON(drive->dev_flags & IDE_DFLAG_BLOCKED); | 192 | BUG_ON(drive->dev_flags & IDE_DFLAG_BLOCKED); |
193 | 193 | ||
diff --git a/drivers/ide/ide-dma-sff.c b/drivers/ide/ide-dma-sff.c index f6d2d44d8a9a..123d393658af 100644 --- a/drivers/ide/ide-dma-sff.c +++ b/drivers/ide/ide-dma-sff.c | |||
@@ -50,6 +50,27 @@ int config_drive_for_dma(ide_drive_t *drive) | |||
50 | return 0; | 50 | return 0; |
51 | } | 51 | } |
52 | 52 | ||
53 | u8 ide_dma_sff_read_status(ide_hwif_t *hwif) | ||
54 | { | ||
55 | unsigned long addr = hwif->dma_base + ATA_DMA_STATUS; | ||
56 | |||
57 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
58 | return readb((void __iomem *)addr); | ||
59 | else | ||
60 | return inb(addr); | ||
61 | } | ||
62 | EXPORT_SYMBOL_GPL(ide_dma_sff_read_status); | ||
63 | |||
64 | static void ide_dma_sff_write_status(ide_hwif_t *hwif, u8 val) | ||
65 | { | ||
66 | unsigned long addr = hwif->dma_base + ATA_DMA_STATUS; | ||
67 | |||
68 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
69 | writeb(val, (void __iomem *)addr); | ||
70 | else | ||
71 | outb(val, addr); | ||
72 | } | ||
73 | |||
53 | /** | 74 | /** |
54 | * ide_dma_host_set - Enable/disable DMA on a host | 75 | * ide_dma_host_set - Enable/disable DMA on a host |
55 | * @drive: drive to control | 76 | * @drive: drive to control |
@@ -62,18 +83,14 @@ void ide_dma_host_set(ide_drive_t *drive, int on) | |||
62 | { | 83 | { |
63 | ide_hwif_t *hwif = drive->hwif; | 84 | ide_hwif_t *hwif = drive->hwif; |
64 | u8 unit = drive->dn & 1; | 85 | u8 unit = drive->dn & 1; |
65 | u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); | 86 | u8 dma_stat = hwif->dma_ops->dma_sff_read_status(hwif); |
66 | 87 | ||
67 | if (on) | 88 | if (on) |
68 | dma_stat |= (1 << (5 + unit)); | 89 | dma_stat |= (1 << (5 + unit)); |
69 | else | 90 | else |
70 | dma_stat &= ~(1 << (5 + unit)); | 91 | dma_stat &= ~(1 << (5 + unit)); |
71 | 92 | ||
72 | if (hwif->host_flags & IDE_HFLAG_MMIO) | 93 | ide_dma_sff_write_status(hwif, dma_stat); |
73 | writeb(dma_stat, | ||
74 | (void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); | ||
75 | else | ||
76 | outb(dma_stat, hwif->dma_base + ATA_DMA_STATUS); | ||
77 | } | 94 | } |
78 | EXPORT_SYMBOL_GPL(ide_dma_host_set); | 95 | EXPORT_SYMBOL_GPL(ide_dma_host_set); |
79 | 96 | ||
@@ -175,7 +192,7 @@ EXPORT_SYMBOL_GPL(ide_build_dmatable); | |||
175 | int ide_dma_setup(ide_drive_t *drive) | 192 | int ide_dma_setup(ide_drive_t *drive) |
176 | { | 193 | { |
177 | ide_hwif_t *hwif = drive->hwif; | 194 | ide_hwif_t *hwif = drive->hwif; |
178 | struct request *rq = hwif->hwgroup->rq; | 195 | struct request *rq = hwif->rq; |
179 | unsigned int reading = rq_data_dir(rq) ? 0 : ATA_DMA_WR; | 196 | unsigned int reading = rq_data_dir(rq) ? 0 : ATA_DMA_WR; |
180 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | 197 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; |
181 | u8 dma_stat; | 198 | u8 dma_stat; |
@@ -187,7 +204,7 @@ int ide_dma_setup(ide_drive_t *drive) | |||
187 | } | 204 | } |
188 | 205 | ||
189 | /* PRD table */ | 206 | /* PRD table */ |
190 | if (hwif->host_flags & IDE_HFLAG_MMIO) | 207 | if (mmio) |
191 | writel(hwif->dmatable_dma, | 208 | writel(hwif->dmatable_dma, |
192 | (void __iomem *)(hwif->dma_base + ATA_DMA_TABLE_OFS)); | 209 | (void __iomem *)(hwif->dma_base + ATA_DMA_TABLE_OFS)); |
193 | else | 210 | else |
@@ -200,15 +217,10 @@ int ide_dma_setup(ide_drive_t *drive) | |||
200 | outb(reading, hwif->dma_base + ATA_DMA_CMD); | 217 | outb(reading, hwif->dma_base + ATA_DMA_CMD); |
201 | 218 | ||
202 | /* read DMA status for INTR & ERROR flags */ | 219 | /* read DMA status for INTR & ERROR flags */ |
203 | dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); | 220 | dma_stat = hwif->dma_ops->dma_sff_read_status(hwif); |
204 | 221 | ||
205 | /* clear INTR & ERROR flags */ | 222 | /* clear INTR & ERROR flags */ |
206 | if (mmio) | 223 | ide_dma_sff_write_status(hwif, dma_stat | ATA_DMA_ERR | ATA_DMA_INTR); |
207 | writeb(dma_stat | ATA_DMA_ERR | ATA_DMA_INTR, | ||
208 | (void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); | ||
209 | else | ||
210 | outb(dma_stat | ATA_DMA_ERR | ATA_DMA_INTR, | ||
211 | hwif->dma_base + ATA_DMA_STATUS); | ||
212 | 224 | ||
213 | drive->waiting_for_dma = 1; | 225 | drive->waiting_for_dma = 1; |
214 | return 0; | 226 | return 0; |
@@ -232,7 +244,7 @@ EXPORT_SYMBOL_GPL(ide_dma_setup); | |||
232 | static int dma_timer_expiry(ide_drive_t *drive) | 244 | static int dma_timer_expiry(ide_drive_t *drive) |
233 | { | 245 | { |
234 | ide_hwif_t *hwif = drive->hwif; | 246 | ide_hwif_t *hwif = drive->hwif; |
235 | u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); | 247 | u8 dma_stat = hwif->dma_ops->dma_sff_read_status(hwif); |
236 | 248 | ||
237 | printk(KERN_WARNING "%s: %s: DMA status (0x%02x)\n", | 249 | printk(KERN_WARNING "%s: %s: DMA status (0x%02x)\n", |
238 | drive->name, __func__, dma_stat); | 250 | drive->name, __func__, dma_stat); |
@@ -240,7 +252,7 @@ static int dma_timer_expiry(ide_drive_t *drive) | |||
240 | if ((dma_stat & 0x18) == 0x18) /* BUSY Stupid Early Timer !! */ | 252 | if ((dma_stat & 0x18) == 0x18) /* BUSY Stupid Early Timer !! */ |
241 | return WAIT_CMD; | 253 | return WAIT_CMD; |
242 | 254 | ||
243 | hwif->hwgroup->expiry = NULL; /* one free ride for now */ | 255 | hwif->expiry = NULL; /* one free ride for now */ |
244 | 256 | ||
245 | if (dma_stat & ATA_DMA_ERR) /* ERROR */ | 257 | if (dma_stat & ATA_DMA_ERR) /* ERROR */ |
246 | return -1; | 258 | return -1; |
@@ -289,13 +301,12 @@ EXPORT_SYMBOL_GPL(ide_dma_start); | |||
289 | int ide_dma_end(ide_drive_t *drive) | 301 | int ide_dma_end(ide_drive_t *drive) |
290 | { | 302 | { |
291 | ide_hwif_t *hwif = drive->hwif; | 303 | ide_hwif_t *hwif = drive->hwif; |
292 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; | ||
293 | u8 dma_stat = 0, dma_cmd = 0, mask; | 304 | u8 dma_stat = 0, dma_cmd = 0, mask; |
294 | 305 | ||
295 | drive->waiting_for_dma = 0; | 306 | drive->waiting_for_dma = 0; |
296 | 307 | ||
297 | /* stop DMA */ | 308 | /* stop DMA */ |
298 | if (mmio) { | 309 | if (hwif->host_flags & IDE_HFLAG_MMIO) { |
299 | dma_cmd = readb((void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); | 310 | dma_cmd = readb((void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); |
300 | writeb(dma_cmd & ~ATA_DMA_START, | 311 | writeb(dma_cmd & ~ATA_DMA_START, |
301 | (void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); | 312 | (void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); |
@@ -305,15 +316,10 @@ int ide_dma_end(ide_drive_t *drive) | |||
305 | } | 316 | } |
306 | 317 | ||
307 | /* get DMA status */ | 318 | /* get DMA status */ |
308 | dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); | 319 | dma_stat = hwif->dma_ops->dma_sff_read_status(hwif); |
309 | 320 | ||
310 | if (mmio) | 321 | /* clear INTR & ERROR bits */ |
311 | /* clear the INTR & ERROR bits */ | 322 | ide_dma_sff_write_status(hwif, dma_stat | ATA_DMA_ERR | ATA_DMA_INTR); |
312 | writeb(dma_stat | ATA_DMA_ERR | ATA_DMA_INTR, | ||
313 | (void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); | ||
314 | else | ||
315 | outb(dma_stat | ATA_DMA_ERR | ATA_DMA_INTR, | ||
316 | hwif->dma_base + ATA_DMA_STATUS); | ||
317 | 323 | ||
318 | /* purge DMA mappings */ | 324 | /* purge DMA mappings */ |
319 | ide_destroy_dmatable(drive); | 325 | ide_destroy_dmatable(drive); |
@@ -331,7 +337,7 @@ EXPORT_SYMBOL_GPL(ide_dma_end); | |||
331 | int ide_dma_test_irq(ide_drive_t *drive) | 337 | int ide_dma_test_irq(ide_drive_t *drive) |
332 | { | 338 | { |
333 | ide_hwif_t *hwif = drive->hwif; | 339 | ide_hwif_t *hwif = drive->hwif; |
334 | u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); | 340 | u8 dma_stat = hwif->dma_ops->dma_sff_read_status(hwif); |
335 | 341 | ||
336 | return (dma_stat & ATA_DMA_INTR) ? 1 : 0; | 342 | return (dma_stat & ATA_DMA_INTR) ? 1 : 0; |
337 | } | 343 | } |
@@ -346,5 +352,6 @@ const struct ide_dma_ops sff_dma_ops = { | |||
346 | .dma_test_irq = ide_dma_test_irq, | 352 | .dma_test_irq = ide_dma_test_irq, |
347 | .dma_timeout = ide_dma_timeout, | 353 | .dma_timeout = ide_dma_timeout, |
348 | .dma_lost_irq = ide_dma_lost_irq, | 354 | .dma_lost_irq = ide_dma_lost_irq, |
355 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
349 | }; | 356 | }; |
350 | EXPORT_SYMBOL_GPL(sff_dma_ops); | 357 | EXPORT_SYMBOL_GPL(sff_dma_ops); |
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index fffd11717b2d..72ebab0bc755 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -96,7 +96,7 @@ ide_startstop_t ide_dma_intr(ide_drive_t *drive) | |||
96 | 96 | ||
97 | if (OK_STAT(stat, DRIVE_READY, drive->bad_wstat | ATA_DRQ)) { | 97 | if (OK_STAT(stat, DRIVE_READY, drive->bad_wstat | ATA_DRQ)) { |
98 | if (!dma_stat) { | 98 | if (!dma_stat) { |
99 | struct request *rq = hwif->hwgroup->rq; | 99 | struct request *rq = hwif->rq; |
100 | 100 | ||
101 | task_end_request(drive, rq, stat); | 101 | task_end_request(drive, rq, stat); |
102 | return ide_stopped; | 102 | return ide_stopped; |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 0a48e2dc53a2..3eab1c6c9b31 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -71,7 +71,7 @@ | |||
71 | static int ide_floppy_end_request(ide_drive_t *drive, int uptodate, int nsecs) | 71 | static int ide_floppy_end_request(ide_drive_t *drive, int uptodate, int nsecs) |
72 | { | 72 | { |
73 | struct ide_disk_obj *floppy = drive->driver_data; | 73 | struct ide_disk_obj *floppy = drive->driver_data; |
74 | struct request *rq = HWGROUP(drive)->rq; | 74 | struct request *rq = drive->hwif->rq; |
75 | int error; | 75 | int error; |
76 | 76 | ||
77 | ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); | 77 | ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); |
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c index b8078b3231f7..7857b209c6df 100644 --- a/drivers/ide/ide-gd.c +++ b/drivers/ide/ide-gd.c | |||
@@ -149,7 +149,7 @@ static int ide_gd_end_request(ide_drive_t *drive, int uptodate, int nrsecs) | |||
149 | return drive->disk_ops->end_request(drive, uptodate, nrsecs); | 149 | return drive->disk_ops->end_request(drive, uptodate, nrsecs); |
150 | } | 150 | } |
151 | 151 | ||
152 | static ide_driver_t ide_gd_driver = { | 152 | static struct ide_driver ide_gd_driver = { |
153 | .gen_driver = { | 153 | .gen_driver = { |
154 | .owner = THIS_MODULE, | 154 | .owner = THIS_MODULE, |
155 | .name = "ide-gd", | 155 | .name = "ide-gd", |
@@ -162,7 +162,6 @@ static ide_driver_t ide_gd_driver = { | |||
162 | .version = IDE_GD_VERSION, | 162 | .version = IDE_GD_VERSION, |
163 | .do_request = ide_gd_do_request, | 163 | .do_request = ide_gd_do_request, |
164 | .end_request = ide_gd_end_request, | 164 | .end_request = ide_gd_end_request, |
165 | .error = __ide_error, | ||
166 | #ifdef CONFIG_IDE_PROC_FS | 165 | #ifdef CONFIG_IDE_PROC_FS |
167 | .proc_entries = ide_disk_proc_entries, | 166 | .proc_entries = ide_disk_proc_entries, |
168 | .proc_devsets = ide_disk_proc_devsets, | 167 | .proc_devsets = ide_disk_proc_devsets, |
diff --git a/drivers/ide/ide-gd.h b/drivers/ide/ide-gd.h index 7d3d101713e0..a86779f0756b 100644 --- a/drivers/ide/ide-gd.h +++ b/drivers/ide/ide-gd.h | |||
@@ -14,11 +14,11 @@ | |||
14 | #endif | 14 | #endif |
15 | 15 | ||
16 | struct ide_disk_obj { | 16 | struct ide_disk_obj { |
17 | ide_drive_t *drive; | 17 | ide_drive_t *drive; |
18 | ide_driver_t *driver; | 18 | struct ide_driver *driver; |
19 | struct gendisk *disk; | 19 | struct gendisk *disk; |
20 | struct kref kref; | 20 | struct kref kref; |
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 */ |
24 | struct ide_atapi_pc *failed_pc; | 24 | struct ide_atapi_pc *failed_pc; |
diff --git a/drivers/ide/ide-h8300.c b/drivers/ide/ide-h8300.c index e2cdd2e9cdec..9270d3255ee0 100644 --- a/drivers/ide/ide-h8300.c +++ b/drivers/ide/ide-h8300.c | |||
@@ -159,7 +159,6 @@ static const struct ide_tp_ops h8300_tp_ops = { | |||
159 | .exec_command = ide_exec_command, | 159 | .exec_command = ide_exec_command, |
160 | .read_status = ide_read_status, | 160 | .read_status = ide_read_status, |
161 | .read_altstatus = ide_read_altstatus, | 161 | .read_altstatus = ide_read_altstatus, |
162 | .read_sff_dma_status = ide_read_sff_dma_status, | ||
163 | 162 | ||
164 | .set_irq = ide_set_irq, | 163 | .set_irq = ide_set_irq, |
165 | 164 | ||
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 1c36a8e83d36..cc163319dfbd 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -88,7 +88,7 @@ static int __ide_end_request(ide_drive_t *drive, struct request *rq, | |||
88 | ret = 0; | 88 | ret = 0; |
89 | 89 | ||
90 | if (ret == 0 && dequeue) | 90 | if (ret == 0 && dequeue) |
91 | drive->hwif->hwgroup->rq = NULL; | 91 | drive->hwif->rq = NULL; |
92 | 92 | ||
93 | return ret; | 93 | return ret; |
94 | } | 94 | } |
@@ -107,7 +107,7 @@ static int __ide_end_request(ide_drive_t *drive, struct request *rq, | |||
107 | int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors) | 107 | int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors) |
108 | { | 108 | { |
109 | unsigned int nr_bytes = nr_sectors << 9; | 109 | unsigned int nr_bytes = nr_sectors << 9; |
110 | struct request *rq = drive->hwif->hwgroup->rq; | 110 | struct request *rq = drive->hwif->rq; |
111 | 111 | ||
112 | if (!nr_bytes) { | 112 | if (!nr_bytes) { |
113 | if (blk_pc_request(rq)) | 113 | if (blk_pc_request(rq)) |
@@ -160,8 +160,8 @@ EXPORT_SYMBOL_GPL(ide_end_dequeued_request); | |||
160 | 160 | ||
161 | void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) | 161 | void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) |
162 | { | 162 | { |
163 | ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; | 163 | ide_hwif_t *hwif = drive->hwif; |
164 | struct request *rq = hwgroup->rq; | 164 | struct request *rq = hwif->rq; |
165 | 165 | ||
166 | if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { | 166 | if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { |
167 | ide_task_t *task = (ide_task_t *)rq->special; | 167 | ide_task_t *task = (ide_task_t *)rq->special; |
@@ -186,7 +186,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) | |||
186 | return; | 186 | return; |
187 | } | 187 | } |
188 | 188 | ||
189 | hwgroup->rq = NULL; | 189 | hwif->rq = NULL; |
190 | 190 | ||
191 | rq->errors = err; | 191 | rq->errors = err; |
192 | 192 | ||
@@ -199,9 +199,9 @@ EXPORT_SYMBOL(ide_end_drive_cmd); | |||
199 | static void ide_kill_rq(ide_drive_t *drive, struct request *rq) | 199 | static void ide_kill_rq(ide_drive_t *drive, struct request *rq) |
200 | { | 200 | { |
201 | if (rq->rq_disk) { | 201 | if (rq->rq_disk) { |
202 | ide_driver_t *drv; | 202 | struct ide_driver *drv; |
203 | 203 | ||
204 | drv = *(ide_driver_t **)rq->rq_disk->private_data; | 204 | drv = *(struct ide_driver **)rq->rq_disk->private_data; |
205 | drv->end_request(drive, 0, 0); | 205 | drv->end_request(drive, 0, 0); |
206 | } else | 206 | } else |
207 | ide_end_request(drive, 0, 0); | 207 | ide_end_request(drive, 0, 0); |
@@ -291,7 +291,7 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u | |||
291 | return ide_stopped; | 291 | return ide_stopped; |
292 | } | 292 | } |
293 | 293 | ||
294 | ide_startstop_t | 294 | static ide_startstop_t |
295 | __ide_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) | 295 | __ide_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) |
296 | { | 296 | { |
297 | if (drive->media == ide_disk) | 297 | if (drive->media == ide_disk) |
@@ -299,8 +299,6 @@ __ide_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) | |||
299 | return ide_atapi_error(drive, rq, stat, err); | 299 | return ide_atapi_error(drive, rq, stat, err); |
300 | } | 300 | } |
301 | 301 | ||
302 | EXPORT_SYMBOL_GPL(__ide_error); | ||
303 | |||
304 | /** | 302 | /** |
305 | * ide_error - handle an error on the IDE | 303 | * ide_error - handle an error on the IDE |
306 | * @drive: drive the error occurred on | 304 | * @drive: drive the error occurred on |
@@ -321,7 +319,8 @@ ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, u8 stat) | |||
321 | 319 | ||
322 | err = ide_dump_status(drive, msg, stat); | 320 | err = ide_dump_status(drive, msg, stat); |
323 | 321 | ||
324 | if ((rq = HWGROUP(drive)->rq) == NULL) | 322 | rq = drive->hwif->rq; |
323 | if (rq == NULL) | ||
325 | return ide_stopped; | 324 | return ide_stopped; |
326 | 325 | ||
327 | /* retry only "normal" I/O: */ | 326 | /* retry only "normal" I/O: */ |
@@ -331,15 +330,8 @@ ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, u8 stat) | |||
331 | return ide_stopped; | 330 | return ide_stopped; |
332 | } | 331 | } |
333 | 332 | ||
334 | if (rq->rq_disk) { | 333 | return __ide_error(drive, rq, stat, err); |
335 | ide_driver_t *drv; | ||
336 | |||
337 | drv = *(ide_driver_t **)rq->rq_disk->private_data; | ||
338 | return drv->error(drive, rq, stat, err); | ||
339 | } else | ||
340 | return __ide_error(drive, rq, stat, err); | ||
341 | } | 334 | } |
342 | |||
343 | EXPORT_SYMBOL_GPL(ide_error); | 335 | EXPORT_SYMBOL_GPL(ide_error); |
344 | 336 | ||
345 | static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) | 337 | static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) |
@@ -462,7 +454,7 @@ EXPORT_SYMBOL_GPL(ide_init_sg_cmd); | |||
462 | static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, | 454 | static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, |
463 | struct request *rq) | 455 | struct request *rq) |
464 | { | 456 | { |
465 | ide_hwif_t *hwif = HWIF(drive); | 457 | ide_hwif_t *hwif = drive->hwif; |
466 | ide_task_t *task = rq->special; | 458 | ide_task_t *task = rq->special; |
467 | 459 | ||
468 | if (task) { | 460 | if (task) { |
@@ -586,7 +578,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) | |||
586 | 578 | ||
587 | #ifdef DEBUG | 579 | #ifdef DEBUG |
588 | printk("%s: start_request: current=0x%08lx\n", | 580 | printk("%s: start_request: current=0x%08lx\n", |
589 | HWIF(drive)->name, (unsigned long) rq); | 581 | drive->hwif->name, (unsigned long) rq); |
590 | #endif | 582 | #endif |
591 | 583 | ||
592 | /* bail early if we've exceeded max_failures */ | 584 | /* bail early if we've exceeded max_failures */ |
@@ -605,7 +597,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) | |||
605 | return startstop; | 597 | return startstop; |
606 | } | 598 | } |
607 | if (!drive->special.all) { | 599 | if (!drive->special.all) { |
608 | ide_driver_t *drv; | 600 | struct ide_driver *drv; |
609 | 601 | ||
610 | /* | 602 | /* |
611 | * We reset the drive so we need to issue a SETFEATURES. | 603 | * We reset the drive so we need to issue a SETFEATURES. |
@@ -638,7 +630,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) | |||
638 | */ | 630 | */ |
639 | return ide_special_rq(drive, rq); | 631 | return ide_special_rq(drive, rq); |
640 | 632 | ||
641 | drv = *(ide_driver_t **)rq->rq_disk->private_data; | 633 | drv = *(struct ide_driver **)rq->rq_disk->private_data; |
642 | 634 | ||
643 | return drv->do_request(drive, rq, rq->sector); | 635 | return drv->do_request(drive, rq, rq->sector); |
644 | } | 636 | } |
@@ -654,7 +646,7 @@ kill_rq: | |||
654 | * @timeout: time to stall for (jiffies) | 646 | * @timeout: time to stall for (jiffies) |
655 | * | 647 | * |
656 | * ide_stall_queue() can be used by a drive to give excess bandwidth back | 648 | * ide_stall_queue() can be used by a drive to give excess bandwidth back |
657 | * to the hwgroup by sleeping for timeout jiffies. | 649 | * to the port by sleeping for timeout jiffies. |
658 | */ | 650 | */ |
659 | 651 | ||
660 | void ide_stall_queue (ide_drive_t *drive, unsigned long timeout) | 652 | void ide_stall_queue (ide_drive_t *drive, unsigned long timeout) |
@@ -666,45 +658,53 @@ void ide_stall_queue (ide_drive_t *drive, unsigned long timeout) | |||
666 | } | 658 | } |
667 | EXPORT_SYMBOL(ide_stall_queue); | 659 | EXPORT_SYMBOL(ide_stall_queue); |
668 | 660 | ||
661 | static inline int ide_lock_port(ide_hwif_t *hwif) | ||
662 | { | ||
663 | if (hwif->busy) | ||
664 | return 1; | ||
665 | |||
666 | hwif->busy = 1; | ||
667 | |||
668 | return 0; | ||
669 | } | ||
670 | |||
671 | static inline void ide_unlock_port(ide_hwif_t *hwif) | ||
672 | { | ||
673 | hwif->busy = 0; | ||
674 | } | ||
675 | |||
676 | static inline int ide_lock_host(struct ide_host *host, ide_hwif_t *hwif) | ||
677 | { | ||
678 | int rc = 0; | ||
679 | |||
680 | if (host->host_flags & IDE_HFLAG_SERIALIZE) { | ||
681 | rc = test_and_set_bit_lock(IDE_HOST_BUSY, &host->host_busy); | ||
682 | if (rc == 0) { | ||
683 | /* for atari only */ | ||
684 | ide_get_lock(ide_intr, hwif); | ||
685 | } | ||
686 | } | ||
687 | return rc; | ||
688 | } | ||
689 | |||
690 | static inline void ide_unlock_host(struct ide_host *host) | ||
691 | { | ||
692 | if (host->host_flags & IDE_HFLAG_SERIALIZE) { | ||
693 | /* for atari only */ | ||
694 | ide_release_lock(); | ||
695 | clear_bit_unlock(IDE_HOST_BUSY, &host->host_busy); | ||
696 | } | ||
697 | } | ||
698 | |||
669 | /* | 699 | /* |
670 | * Issue a new request to a drive from hwgroup | 700 | * Issue a new request to a device. |
671 | * | ||
672 | * A hwgroup is a serialized group of IDE interfaces. Usually there is | ||
673 | * exactly one hwif (interface) per hwgroup, but buggy controllers (eg. CMD640) | ||
674 | * may have both interfaces in a single hwgroup to "serialize" access. | ||
675 | * Or possibly multiple ISA interfaces can share a common IRQ by being grouped | ||
676 | * together into one hwgroup for serialized access. | ||
677 | * | ||
678 | * Note also that several hwgroups can end up sharing a single IRQ, | ||
679 | * possibly along with many other devices. This is especially common in | ||
680 | * PCI-based systems with off-board IDE controller cards. | ||
681 | * | ||
682 | * The IDE driver uses a per-hwgroup lock to protect the hwgroup->busy flag. | ||
683 | * | ||
684 | * The first thread into the driver for a particular hwgroup sets the | ||
685 | * hwgroup->busy flag to indicate that this hwgroup is now active, | ||
686 | * and then initiates processing of the top request from the request queue. | ||
687 | * | ||
688 | * Other threads attempting entry notice the busy setting, and will simply | ||
689 | * queue their new requests and exit immediately. Note that hwgroup->busy | ||
690 | * remains set even when the driver is merely awaiting the next interrupt. | ||
691 | * Thus, the meaning is "this hwgroup is busy processing a request". | ||
692 | * | ||
693 | * When processing of a request completes, the completing thread or IRQ-handler | ||
694 | * will start the next request from the queue. If no more work remains, | ||
695 | * the driver will clear the hwgroup->busy flag and exit. | ||
696 | * | ||
697 | * The per-hwgroup spinlock is used to protect all access to the | ||
698 | * hwgroup->busy flag, but is otherwise not needed for most processing in | ||
699 | * the driver. This makes the driver much more friendlier to shared IRQs | ||
700 | * than previous designs, while remaining 100% (?) SMP safe and capable. | ||
701 | */ | 701 | */ |
702 | void do_ide_request(struct request_queue *q) | 702 | void do_ide_request(struct request_queue *q) |
703 | { | 703 | { |
704 | ide_drive_t *drive = q->queuedata; | 704 | ide_drive_t *drive = q->queuedata; |
705 | ide_hwif_t *hwif = drive->hwif; | 705 | ide_hwif_t *hwif = drive->hwif; |
706 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | 706 | struct ide_host *host = hwif->host; |
707 | struct request *rq; | 707 | struct request *rq = NULL; |
708 | ide_startstop_t startstop; | 708 | ide_startstop_t startstop; |
709 | 709 | ||
710 | /* | 710 | /* |
@@ -721,32 +721,40 @@ void do_ide_request(struct request_queue *q) | |||
721 | blk_remove_plug(q); | 721 | blk_remove_plug(q); |
722 | 722 | ||
723 | spin_unlock_irq(q->queue_lock); | 723 | spin_unlock_irq(q->queue_lock); |
724 | spin_lock_irq(&hwgroup->lock); | ||
725 | 724 | ||
726 | if (!ide_lock_hwgroup(hwgroup)) { | 725 | if (ide_lock_host(host, hwif)) |
726 | goto plug_device_2; | ||
727 | |||
728 | spin_lock_irq(&hwif->lock); | ||
729 | |||
730 | if (!ide_lock_port(hwif)) { | ||
731 | ide_hwif_t *prev_port; | ||
727 | repeat: | 732 | repeat: |
728 | hwgroup->rq = NULL; | 733 | prev_port = hwif->host->cur_port; |
734 | hwif->rq = NULL; | ||
729 | 735 | ||
730 | if (drive->dev_flags & IDE_DFLAG_SLEEPING) { | 736 | if (drive->dev_flags & IDE_DFLAG_SLEEPING) { |
731 | if (time_before(drive->sleep, jiffies)) { | 737 | if (time_before(drive->sleep, jiffies)) { |
732 | ide_unlock_hwgroup(hwgroup); | 738 | ide_unlock_port(hwif); |
733 | goto plug_device; | 739 | goto plug_device; |
734 | } | 740 | } |
735 | } | 741 | } |
736 | 742 | ||
737 | if (hwif != hwgroup->hwif) { | 743 | if ((hwif->host->host_flags & IDE_HFLAG_SERIALIZE) && |
744 | hwif != prev_port) { | ||
738 | /* | 745 | /* |
739 | * set nIEN for previous hwif, drives in the | 746 | * set nIEN for previous port, drives in the |
740 | * quirk_list may not like intr setups/cleanups | 747 | * quirk_list may not like intr setups/cleanups |
741 | */ | 748 | */ |
742 | if (drive->quirk_list == 0) | 749 | if (prev_port && prev_port->cur_dev->quirk_list == 0) |
743 | hwif->tp_ops->set_irq(hwif, 0); | 750 | prev_port->tp_ops->set_irq(prev_port, 0); |
751 | |||
752 | hwif->host->cur_port = hwif; | ||
744 | } | 753 | } |
745 | hwgroup->hwif = hwif; | 754 | hwif->cur_dev = drive; |
746 | hwgroup->drive = drive; | ||
747 | drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED); | 755 | drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED); |
748 | 756 | ||
749 | spin_unlock_irq(&hwgroup->lock); | 757 | spin_unlock_irq(&hwif->lock); |
750 | spin_lock_irq(q->queue_lock); | 758 | spin_lock_irq(q->queue_lock); |
751 | /* | 759 | /* |
752 | * we know that the queue isn't empty, but this can happen | 760 | * we know that the queue isn't empty, but this can happen |
@@ -754,10 +762,10 @@ repeat: | |||
754 | */ | 762 | */ |
755 | rq = elv_next_request(drive->queue); | 763 | rq = elv_next_request(drive->queue); |
756 | spin_unlock_irq(q->queue_lock); | 764 | spin_unlock_irq(q->queue_lock); |
757 | spin_lock_irq(&hwgroup->lock); | 765 | spin_lock_irq(&hwif->lock); |
758 | 766 | ||
759 | if (!rq) { | 767 | if (!rq) { |
760 | ide_unlock_hwgroup(hwgroup); | 768 | ide_unlock_port(hwif); |
761 | goto out; | 769 | goto out; |
762 | } | 770 | } |
763 | 771 | ||
@@ -778,27 +786,31 @@ repeat: | |||
778 | blk_pm_request(rq) == 0 && | 786 | blk_pm_request(rq) == 0 && |
779 | (rq->cmd_flags & REQ_PREEMPT) == 0) { | 787 | (rq->cmd_flags & REQ_PREEMPT) == 0) { |
780 | /* there should be no pending command at this point */ | 788 | /* there should be no pending command at this point */ |
781 | ide_unlock_hwgroup(hwgroup); | 789 | ide_unlock_port(hwif); |
782 | goto plug_device; | 790 | goto plug_device; |
783 | } | 791 | } |
784 | 792 | ||
785 | hwgroup->rq = rq; | 793 | hwif->rq = rq; |
786 | 794 | ||
787 | spin_unlock_irq(&hwgroup->lock); | 795 | spin_unlock_irq(&hwif->lock); |
788 | startstop = start_request(drive, rq); | 796 | startstop = start_request(drive, rq); |
789 | spin_lock_irq(&hwgroup->lock); | 797 | spin_lock_irq(&hwif->lock); |
790 | 798 | ||
791 | if (startstop == ide_stopped) | 799 | if (startstop == ide_stopped) |
792 | goto repeat; | 800 | goto repeat; |
793 | } else | 801 | } else |
794 | goto plug_device; | 802 | goto plug_device; |
795 | out: | 803 | out: |
796 | spin_unlock_irq(&hwgroup->lock); | 804 | spin_unlock_irq(&hwif->lock); |
805 | if (rq == NULL) | ||
806 | ide_unlock_host(host); | ||
797 | spin_lock_irq(q->queue_lock); | 807 | spin_lock_irq(q->queue_lock); |
798 | return; | 808 | return; |
799 | 809 | ||
800 | plug_device: | 810 | plug_device: |
801 | spin_unlock_irq(&hwgroup->lock); | 811 | spin_unlock_irq(&hwif->lock); |
812 | ide_unlock_host(host); | ||
813 | plug_device_2: | ||
802 | spin_lock_irq(q->queue_lock); | 814 | spin_lock_irq(q->queue_lock); |
803 | 815 | ||
804 | if (!elv_queue_empty(q)) | 816 | if (!elv_queue_empty(q)) |
@@ -806,13 +818,13 @@ plug_device: | |||
806 | } | 818 | } |
807 | 819 | ||
808 | /* | 820 | /* |
809 | * un-busy the hwgroup etc, and clear any pending DMA status. we want to | 821 | * un-busy the port etc, and clear any pending DMA status. we want to |
810 | * retry the current request in pio mode instead of risking tossing it | 822 | * retry the current request in pio mode instead of risking tossing it |
811 | * all away | 823 | * all away |
812 | */ | 824 | */ |
813 | static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) | 825 | static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) |
814 | { | 826 | { |
815 | ide_hwif_t *hwif = HWIF(drive); | 827 | ide_hwif_t *hwif = drive->hwif; |
816 | struct request *rq; | 828 | struct request *rq; |
817 | ide_startstop_t ret = ide_stopped; | 829 | ide_startstop_t ret = ide_stopped; |
818 | 830 | ||
@@ -840,15 +852,14 @@ static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error) | |||
840 | ide_dma_off_quietly(drive); | 852 | ide_dma_off_quietly(drive); |
841 | 853 | ||
842 | /* | 854 | /* |
843 | * un-busy drive etc (hwgroup->busy is cleared on return) and | 855 | * un-busy drive etc and make sure request is sane |
844 | * make sure request is sane | ||
845 | */ | 856 | */ |
846 | rq = HWGROUP(drive)->rq; | ||
847 | 857 | ||
858 | rq = hwif->rq; | ||
848 | if (!rq) | 859 | if (!rq) |
849 | goto out; | 860 | goto out; |
850 | 861 | ||
851 | HWGROUP(drive)->rq = NULL; | 862 | hwif->rq = NULL; |
852 | 863 | ||
853 | rq->errors = 0; | 864 | rq->errors = 0; |
854 | 865 | ||
@@ -876,7 +887,7 @@ static void ide_plug_device(ide_drive_t *drive) | |||
876 | 887 | ||
877 | /** | 888 | /** |
878 | * ide_timer_expiry - handle lack of an IDE interrupt | 889 | * ide_timer_expiry - handle lack of an IDE interrupt |
879 | * @data: timer callback magic (hwgroup) | 890 | * @data: timer callback magic (hwif) |
880 | * | 891 | * |
881 | * An IDE command has timed out before the expected drive return | 892 | * An IDE command has timed out before the expected drive return |
882 | * occurred. At this point we attempt to clean up the current | 893 | * occurred. At this point we attempt to clean up the current |
@@ -890,18 +901,18 @@ static void ide_plug_device(ide_drive_t *drive) | |||
890 | 901 | ||
891 | void ide_timer_expiry (unsigned long data) | 902 | void ide_timer_expiry (unsigned long data) |
892 | { | 903 | { |
893 | ide_hwgroup_t *hwgroup = (ide_hwgroup_t *) data; | 904 | ide_hwif_t *hwif = (ide_hwif_t *)data; |
894 | ide_drive_t *uninitialized_var(drive); | 905 | ide_drive_t *uninitialized_var(drive); |
895 | ide_handler_t *handler; | 906 | ide_handler_t *handler; |
896 | ide_expiry_t *expiry; | ||
897 | unsigned long flags; | 907 | unsigned long flags; |
898 | unsigned long wait = -1; | 908 | unsigned long wait = -1; |
899 | int plug_device = 0; | 909 | int plug_device = 0; |
900 | 910 | ||
901 | spin_lock_irqsave(&hwgroup->lock, flags); | 911 | spin_lock_irqsave(&hwif->lock, flags); |
902 | 912 | ||
903 | if (((handler = hwgroup->handler) == NULL) || | 913 | handler = hwif->handler; |
904 | (hwgroup->req_gen != hwgroup->req_gen_timer)) { | 914 | |
915 | if (handler == NULL || hwif->req_gen != hwif->req_gen_timer) { | ||
905 | /* | 916 | /* |
906 | * Either a marginal timeout occurred | 917 | * Either a marginal timeout occurred |
907 | * (got the interrupt just as timer expired), | 918 | * (got the interrupt just as timer expired), |
@@ -909,72 +920,68 @@ void ide_timer_expiry (unsigned long data) | |||
909 | * Either way, we don't really want to complain about anything. | 920 | * Either way, we don't really want to complain about anything. |
910 | */ | 921 | */ |
911 | } else { | 922 | } else { |
912 | drive = hwgroup->drive; | 923 | ide_expiry_t *expiry = hwif->expiry; |
913 | if (!drive) { | 924 | ide_startstop_t startstop = ide_stopped; |
914 | printk(KERN_ERR "ide_timer_expiry: hwgroup->drive was NULL\n"); | 925 | |
915 | hwgroup->handler = NULL; | 926 | drive = hwif->cur_dev; |
916 | } else { | 927 | |
917 | ide_hwif_t *hwif; | 928 | if (expiry) { |
918 | ide_startstop_t startstop = ide_stopped; | 929 | wait = expiry(drive); |
919 | 930 | if (wait > 0) { /* continue */ | |
920 | if ((expiry = hwgroup->expiry) != NULL) { | 931 | /* reset timer */ |
921 | /* continue */ | 932 | hwif->timer.expires = jiffies + wait; |
922 | if ((wait = expiry(drive)) > 0) { | 933 | hwif->req_gen_timer = hwif->req_gen; |
923 | /* reset timer */ | 934 | add_timer(&hwif->timer); |
924 | hwgroup->timer.expires = jiffies + wait; | 935 | spin_unlock_irqrestore(&hwif->lock, flags); |
925 | hwgroup->req_gen_timer = hwgroup->req_gen; | 936 | return; |
926 | add_timer(&hwgroup->timer); | ||
927 | spin_unlock_irqrestore(&hwgroup->lock, flags); | ||
928 | return; | ||
929 | } | ||
930 | } | ||
931 | hwgroup->handler = NULL; | ||
932 | /* | ||
933 | * We need to simulate a real interrupt when invoking | ||
934 | * the handler() function, which means we need to | ||
935 | * globally mask the specific IRQ: | ||
936 | */ | ||
937 | spin_unlock(&hwgroup->lock); | ||
938 | hwif = HWIF(drive); | ||
939 | /* disable_irq_nosync ?? */ | ||
940 | disable_irq(hwif->irq); | ||
941 | /* local CPU only, | ||
942 | * as if we were handling an interrupt */ | ||
943 | local_irq_disable(); | ||
944 | if (hwgroup->polling) { | ||
945 | startstop = handler(drive); | ||
946 | } else if (drive_is_ready(drive)) { | ||
947 | if (drive->waiting_for_dma) | ||
948 | hwif->dma_ops->dma_lost_irq(drive); | ||
949 | (void)ide_ack_intr(hwif); | ||
950 | printk(KERN_WARNING "%s: lost interrupt\n", drive->name); | ||
951 | startstop = handler(drive); | ||
952 | } else { | ||
953 | if (drive->waiting_for_dma) { | ||
954 | startstop = ide_dma_timeout_retry(drive, wait); | ||
955 | } else | ||
956 | startstop = | ||
957 | ide_error(drive, "irq timeout", | ||
958 | hwif->tp_ops->read_status(hwif)); | ||
959 | } | ||
960 | spin_lock_irq(&hwgroup->lock); | ||
961 | enable_irq(hwif->irq); | ||
962 | if (startstop == ide_stopped) { | ||
963 | ide_unlock_hwgroup(hwgroup); | ||
964 | plug_device = 1; | ||
965 | } | 937 | } |
966 | } | 938 | } |
939 | hwif->handler = NULL; | ||
940 | /* | ||
941 | * We need to simulate a real interrupt when invoking | ||
942 | * the handler() function, which means we need to | ||
943 | * globally mask the specific IRQ: | ||
944 | */ | ||
945 | spin_unlock(&hwif->lock); | ||
946 | /* disable_irq_nosync ?? */ | ||
947 | disable_irq(hwif->irq); | ||
948 | /* local CPU only, as if we were handling an interrupt */ | ||
949 | local_irq_disable(); | ||
950 | if (hwif->polling) { | ||
951 | startstop = handler(drive); | ||
952 | } else if (drive_is_ready(drive)) { | ||
953 | if (drive->waiting_for_dma) | ||
954 | hwif->dma_ops->dma_lost_irq(drive); | ||
955 | (void)ide_ack_intr(hwif); | ||
956 | printk(KERN_WARNING "%s: lost interrupt\n", | ||
957 | drive->name); | ||
958 | startstop = handler(drive); | ||
959 | } else { | ||
960 | if (drive->waiting_for_dma) | ||
961 | startstop = ide_dma_timeout_retry(drive, wait); | ||
962 | else | ||
963 | startstop = ide_error(drive, "irq timeout", | ||
964 | hwif->tp_ops->read_status(hwif)); | ||
965 | } | ||
966 | spin_lock_irq(&hwif->lock); | ||
967 | enable_irq(hwif->irq); | ||
968 | if (startstop == ide_stopped) { | ||
969 | ide_unlock_port(hwif); | ||
970 | plug_device = 1; | ||
971 | } | ||
967 | } | 972 | } |
968 | spin_unlock_irqrestore(&hwgroup->lock, flags); | 973 | spin_unlock_irqrestore(&hwif->lock, flags); |
969 | 974 | ||
970 | if (plug_device) | 975 | if (plug_device) { |
976 | ide_unlock_host(hwif->host); | ||
971 | ide_plug_device(drive); | 977 | ide_plug_device(drive); |
978 | } | ||
972 | } | 979 | } |
973 | 980 | ||
974 | /** | 981 | /** |
975 | * unexpected_intr - handle an unexpected IDE interrupt | 982 | * unexpected_intr - handle an unexpected IDE interrupt |
976 | * @irq: interrupt line | 983 | * @irq: interrupt line |
977 | * @hwgroup: hwgroup being processed | 984 | * @hwif: port being processed |
978 | * | 985 | * |
979 | * There's nothing really useful we can do with an unexpected interrupt, | 986 | * There's nothing really useful we can do with an unexpected interrupt, |
980 | * other than reading the status register (to clear it), and logging it. | 987 | * other than reading the status register (to clear it), and logging it. |
@@ -998,52 +1005,38 @@ void ide_timer_expiry (unsigned long data) | |||
998 | * before completing the issuance of any new drive command, so we will not | 1005 | * before completing the issuance of any new drive command, so we will not |
999 | * be accidentally invoked as a result of any valid command completion | 1006 | * be accidentally invoked as a result of any valid command completion |
1000 | * interrupt. | 1007 | * interrupt. |
1001 | * | ||
1002 | * Note that we must walk the entire hwgroup here. We know which hwif | ||
1003 | * is doing the current command, but we don't know which hwif burped | ||
1004 | * mysteriously. | ||
1005 | */ | 1008 | */ |
1006 | |||
1007 | static void unexpected_intr (int irq, ide_hwgroup_t *hwgroup) | ||
1008 | { | ||
1009 | u8 stat; | ||
1010 | ide_hwif_t *hwif = hwgroup->hwif; | ||
1011 | 1009 | ||
1012 | /* | 1010 | static void unexpected_intr(int irq, ide_hwif_t *hwif) |
1013 | * handle the unexpected interrupt | 1011 | { |
1014 | */ | 1012 | u8 stat = hwif->tp_ops->read_status(hwif); |
1015 | do { | 1013 | |
1016 | if (hwif->irq == irq) { | 1014 | if (!OK_STAT(stat, ATA_DRDY, BAD_STAT)) { |
1017 | stat = hwif->tp_ops->read_status(hwif); | 1015 | /* Try to not flood the console with msgs */ |
1018 | 1016 | static unsigned long last_msgtime, count; | |
1019 | if (!OK_STAT(stat, ATA_DRDY, BAD_STAT)) { | 1017 | ++count; |
1020 | /* Try to not flood the console with msgs */ | 1018 | |
1021 | static unsigned long last_msgtime, count; | 1019 | if (time_after(jiffies, last_msgtime + HZ)) { |
1022 | ++count; | 1020 | last_msgtime = jiffies; |
1023 | if (time_after(jiffies, last_msgtime + HZ)) { | 1021 | printk(KERN_ERR "%s: unexpected interrupt, " |
1024 | last_msgtime = jiffies; | 1022 | "status=0x%02x, count=%ld\n", |
1025 | printk(KERN_ERR "%s%s: unexpected interrupt, " | 1023 | hwif->name, stat, count); |
1026 | "status=0x%02x, count=%ld\n", | ||
1027 | hwif->name, | ||
1028 | (hwif->next==hwgroup->hwif) ? "" : "(?)", stat, count); | ||
1029 | } | ||
1030 | } | ||
1031 | } | 1024 | } |
1032 | } while ((hwif = hwif->next) != hwgroup->hwif); | 1025 | } |
1033 | } | 1026 | } |
1034 | 1027 | ||
1035 | /** | 1028 | /** |
1036 | * ide_intr - default IDE interrupt handler | 1029 | * ide_intr - default IDE interrupt handler |
1037 | * @irq: interrupt number | 1030 | * @irq: interrupt number |
1038 | * @dev_id: hwif group | 1031 | * @dev_id: hwif |
1039 | * @regs: unused weirdness from the kernel irq layer | 1032 | * @regs: unused weirdness from the kernel irq layer |
1040 | * | 1033 | * |
1041 | * This is the default IRQ handler for the IDE layer. You should | 1034 | * This is the default IRQ handler for the IDE layer. You should |
1042 | * not need to override it. If you do be aware it is subtle in | 1035 | * not need to override it. If you do be aware it is subtle in |
1043 | * places | 1036 | * places |
1044 | * | 1037 | * |
1045 | * hwgroup->hwif is the interface in the group currently performing | 1038 | * hwif is the interface in the group currently performing |
1046 | * a command. hwgroup->drive is the drive and hwgroup->handler is | 1039 | * a command. hwif->cur_dev is the drive and hwif->handler is |
1047 | * the IRQ handler to call. As we issue a command the handlers | 1040 | * the IRQ handler to call. As we issue a command the handlers |
1048 | * step through multiple states, reassigning the handler to the | 1041 | * step through multiple states, reassigning the handler to the |
1049 | * next step in the process. Unlike a smart SCSI controller IDE | 1042 | * next step in the process. Unlike a smart SCSI controller IDE |
@@ -1054,26 +1047,32 @@ static void unexpected_intr (int irq, ide_hwgroup_t *hwgroup) | |||
1054 | * | 1047 | * |
1055 | * The handler eventually returns ide_stopped to indicate the | 1048 | * The handler eventually returns ide_stopped to indicate the |
1056 | * request completed. At this point we issue the next request | 1049 | * request completed. At this point we issue the next request |
1057 | * on the hwgroup and the process begins again. | 1050 | * on the port and the process begins again. |
1058 | */ | 1051 | */ |
1059 | 1052 | ||
1060 | irqreturn_t ide_intr (int irq, void *dev_id) | 1053 | irqreturn_t ide_intr (int irq, void *dev_id) |
1061 | { | 1054 | { |
1062 | unsigned long flags; | 1055 | ide_hwif_t *hwif = (ide_hwif_t *)dev_id; |
1063 | ide_hwgroup_t *hwgroup = (ide_hwgroup_t *)dev_id; | ||
1064 | ide_hwif_t *hwif = hwgroup->hwif; | ||
1065 | ide_drive_t *uninitialized_var(drive); | 1056 | ide_drive_t *uninitialized_var(drive); |
1066 | ide_handler_t *handler; | 1057 | ide_handler_t *handler; |
1058 | unsigned long flags; | ||
1067 | ide_startstop_t startstop; | 1059 | ide_startstop_t startstop; |
1068 | irqreturn_t irq_ret = IRQ_NONE; | 1060 | irqreturn_t irq_ret = IRQ_NONE; |
1069 | int plug_device = 0; | 1061 | int plug_device = 0; |
1070 | 1062 | ||
1071 | spin_lock_irqsave(&hwgroup->lock, flags); | 1063 | if (hwif->host->host_flags & IDE_HFLAG_SERIALIZE) { |
1064 | if (hwif != hwif->host->cur_port) | ||
1065 | goto out_early; | ||
1066 | } | ||
1067 | |||
1068 | spin_lock_irqsave(&hwif->lock, flags); | ||
1072 | 1069 | ||
1073 | if (!ide_ack_intr(hwif)) | 1070 | if (!ide_ack_intr(hwif)) |
1074 | goto out; | 1071 | goto out; |
1075 | 1072 | ||
1076 | if ((handler = hwgroup->handler) == NULL || hwgroup->polling) { | 1073 | handler = hwif->handler; |
1074 | |||
1075 | if (handler == NULL || hwif->polling) { | ||
1077 | /* | 1076 | /* |
1078 | * Not expecting an interrupt from this drive. | 1077 | * Not expecting an interrupt from this drive. |
1079 | * That means this could be: | 1078 | * That means this could be: |
@@ -1097,7 +1096,7 @@ irqreturn_t ide_intr (int irq, void *dev_id) | |||
1097 | * Probably not a shared PCI interrupt, | 1096 | * Probably not a shared PCI interrupt, |
1098 | * so we can safely try to do something about it: | 1097 | * so we can safely try to do something about it: |
1099 | */ | 1098 | */ |
1100 | unexpected_intr(irq, hwgroup); | 1099 | unexpected_intr(irq, hwif); |
1101 | #ifdef CONFIG_BLK_DEV_IDEPCI | 1100 | #ifdef CONFIG_BLK_DEV_IDEPCI |
1102 | } else { | 1101 | } else { |
1103 | /* | 1102 | /* |
@@ -1110,16 +1109,7 @@ irqreturn_t ide_intr (int irq, void *dev_id) | |||
1110 | goto out; | 1109 | goto out; |
1111 | } | 1110 | } |
1112 | 1111 | ||
1113 | drive = hwgroup->drive; | 1112 | drive = hwif->cur_dev; |
1114 | if (!drive) { | ||
1115 | /* | ||
1116 | * This should NEVER happen, and there isn't much | ||
1117 | * we could do about it here. | ||
1118 | * | ||
1119 | * [Note - this can occur if the drive is hot unplugged] | ||
1120 | */ | ||
1121 | goto out_handled; | ||
1122 | } | ||
1123 | 1113 | ||
1124 | if (!drive_is_ready(drive)) | 1114 | if (!drive_is_ready(drive)) |
1125 | /* | 1115 | /* |
@@ -1131,10 +1121,10 @@ irqreturn_t ide_intr (int irq, void *dev_id) | |||
1131 | */ | 1121 | */ |
1132 | goto out; | 1122 | goto out; |
1133 | 1123 | ||
1134 | hwgroup->handler = NULL; | 1124 | hwif->handler = NULL; |
1135 | hwgroup->req_gen++; | 1125 | hwif->req_gen++; |
1136 | del_timer(&hwgroup->timer); | 1126 | del_timer(&hwif->timer); |
1137 | spin_unlock(&hwgroup->lock); | 1127 | spin_unlock(&hwif->lock); |
1138 | 1128 | ||
1139 | if (hwif->port_ops && hwif->port_ops->clear_irq) | 1129 | if (hwif->port_ops && hwif->port_ops->clear_irq) |
1140 | hwif->port_ops->clear_irq(drive); | 1130 | hwif->port_ops->clear_irq(drive); |
@@ -1145,7 +1135,7 @@ irqreturn_t ide_intr (int irq, void *dev_id) | |||
1145 | /* service this interrupt, may set handler for next interrupt */ | 1135 | /* service this interrupt, may set handler for next interrupt */ |
1146 | startstop = handler(drive); | 1136 | startstop = handler(drive); |
1147 | 1137 | ||
1148 | spin_lock_irq(&hwgroup->lock); | 1138 | spin_lock_irq(&hwif->lock); |
1149 | /* | 1139 | /* |
1150 | * Note that handler() may have set things up for another | 1140 | * Note that handler() may have set things up for another |
1151 | * interrupt to occur soon, but it cannot happen until | 1141 | * interrupt to occur soon, but it cannot happen until |
@@ -1154,20 +1144,18 @@ irqreturn_t ide_intr (int irq, void *dev_id) | |||
1154 | * won't allow another of the same (on any CPU) until we return. | 1144 | * won't allow another of the same (on any CPU) until we return. |
1155 | */ | 1145 | */ |
1156 | if (startstop == ide_stopped) { | 1146 | if (startstop == ide_stopped) { |
1157 | if (hwgroup->handler == NULL) { /* paranoia */ | 1147 | BUG_ON(hwif->handler); |
1158 | ide_unlock_hwgroup(hwgroup); | 1148 | ide_unlock_port(hwif); |
1159 | plug_device = 1; | 1149 | plug_device = 1; |
1160 | } else | ||
1161 | printk(KERN_ERR "%s: %s: huh? expected NULL handler " | ||
1162 | "on exit\n", __func__, drive->name); | ||
1163 | } | 1150 | } |
1164 | out_handled: | ||
1165 | irq_ret = IRQ_HANDLED; | 1151 | irq_ret = IRQ_HANDLED; |
1166 | out: | 1152 | out: |
1167 | spin_unlock_irqrestore(&hwgroup->lock, flags); | 1153 | spin_unlock_irqrestore(&hwif->lock, flags); |
1168 | 1154 | out_early: | |
1169 | if (plug_device) | 1155 | if (plug_device) { |
1156 | ide_unlock_host(hwif->host); | ||
1170 | ide_plug_device(drive); | 1157 | ide_plug_device(drive); |
1158 | } | ||
1171 | 1159 | ||
1172 | return irq_ret; | 1160 | return irq_ret; |
1173 | } | 1161 | } |
@@ -1189,15 +1177,13 @@ out: | |||
1189 | 1177 | ||
1190 | void ide_do_drive_cmd(ide_drive_t *drive, struct request *rq) | 1178 | void ide_do_drive_cmd(ide_drive_t *drive, struct request *rq) |
1191 | { | 1179 | { |
1192 | ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; | ||
1193 | struct request_queue *q = drive->queue; | 1180 | struct request_queue *q = drive->queue; |
1194 | unsigned long flags; | 1181 | unsigned long flags; |
1195 | 1182 | ||
1196 | hwgroup->rq = NULL; | 1183 | drive->hwif->rq = NULL; |
1197 | 1184 | ||
1198 | spin_lock_irqsave(q->queue_lock, flags); | 1185 | spin_lock_irqsave(q->queue_lock, flags); |
1199 | __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0); | 1186 | __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0); |
1200 | blk_start_queueing(q); | ||
1201 | spin_unlock_irqrestore(q->queue_lock, flags); | 1187 | spin_unlock_irqrestore(q->queue_lock, flags); |
1202 | } | 1188 | } |
1203 | EXPORT_SYMBOL(ide_do_drive_cmd); | 1189 | EXPORT_SYMBOL(ide_do_drive_cmd); |
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index ad8bd6539283..e728cfe7273f 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -105,15 +105,6 @@ u8 ide_read_altstatus(ide_hwif_t *hwif) | |||
105 | } | 105 | } |
106 | EXPORT_SYMBOL_GPL(ide_read_altstatus); | 106 | EXPORT_SYMBOL_GPL(ide_read_altstatus); |
107 | 107 | ||
108 | u8 ide_read_sff_dma_status(ide_hwif_t *hwif) | ||
109 | { | ||
110 | if (hwif->host_flags & IDE_HFLAG_MMIO) | ||
111 | return readb((void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); | ||
112 | else | ||
113 | return inb(hwif->dma_base + ATA_DMA_STATUS); | ||
114 | } | ||
115 | EXPORT_SYMBOL_GPL(ide_read_sff_dma_status); | ||
116 | |||
117 | void ide_set_irq(ide_hwif_t *hwif, int on) | 108 | void ide_set_irq(ide_hwif_t *hwif, int on) |
118 | { | 109 | { |
119 | u8 ctl = ATA_DEVCTL_OBS; | 110 | u8 ctl = ATA_DEVCTL_OBS; |
@@ -388,7 +379,6 @@ const struct ide_tp_ops default_tp_ops = { | |||
388 | .exec_command = ide_exec_command, | 379 | .exec_command = ide_exec_command, |
389 | .read_status = ide_read_status, | 380 | .read_status = ide_read_status, |
390 | .read_altstatus = ide_read_altstatus, | 381 | .read_altstatus = ide_read_altstatus, |
391 | .read_sff_dma_status = ide_read_sff_dma_status, | ||
392 | 382 | ||
393 | .set_irq = ide_set_irq, | 383 | .set_irq = ide_set_irq, |
394 | 384 | ||
@@ -451,7 +441,7 @@ EXPORT_SYMBOL(ide_fixstring); | |||
451 | */ | 441 | */ |
452 | int drive_is_ready (ide_drive_t *drive) | 442 | int drive_is_ready (ide_drive_t *drive) |
453 | { | 443 | { |
454 | ide_hwif_t *hwif = HWIF(drive); | 444 | ide_hwif_t *hwif = drive->hwif; |
455 | u8 stat = 0; | 445 | u8 stat = 0; |
456 | 446 | ||
457 | if (drive->waiting_for_dma) | 447 | if (drive->waiting_for_dma) |
@@ -503,7 +493,8 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti | |||
503 | stat = tp_ops->read_status(hwif); | 493 | stat = tp_ops->read_status(hwif); |
504 | 494 | ||
505 | if (stat & ATA_BUSY) { | 495 | if (stat & ATA_BUSY) { |
506 | local_irq_set(flags); | 496 | local_irq_save(flags); |
497 | local_irq_enable_in_hardirq(); | ||
507 | timeout += jiffies; | 498 | timeout += jiffies; |
508 | while ((stat = tp_ops->read_status(hwif)) & ATA_BUSY) { | 499 | while ((stat = tp_ops->read_status(hwif)) & ATA_BUSY) { |
509 | if (time_after(jiffies, timeout)) { | 500 | if (time_after(jiffies, timeout)) { |
@@ -822,25 +813,25 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
822 | static void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, | 813 | static void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, |
823 | unsigned int timeout, ide_expiry_t *expiry) | 814 | unsigned int timeout, ide_expiry_t *expiry) |
824 | { | 815 | { |
825 | ide_hwgroup_t *hwgroup = HWGROUP(drive); | 816 | ide_hwif_t *hwif = drive->hwif; |
826 | 817 | ||
827 | BUG_ON(hwgroup->handler); | 818 | BUG_ON(hwif->handler); |
828 | hwgroup->handler = handler; | 819 | hwif->handler = handler; |
829 | hwgroup->expiry = expiry; | 820 | hwif->expiry = expiry; |
830 | hwgroup->timer.expires = jiffies + timeout; | 821 | hwif->timer.expires = jiffies + timeout; |
831 | hwgroup->req_gen_timer = hwgroup->req_gen; | 822 | hwif->req_gen_timer = hwif->req_gen; |
832 | add_timer(&hwgroup->timer); | 823 | add_timer(&hwif->timer); |
833 | } | 824 | } |
834 | 825 | ||
835 | void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, | 826 | void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, |
836 | unsigned int timeout, ide_expiry_t *expiry) | 827 | unsigned int timeout, ide_expiry_t *expiry) |
837 | { | 828 | { |
838 | ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; | 829 | ide_hwif_t *hwif = drive->hwif; |
839 | unsigned long flags; | 830 | unsigned long flags; |
840 | 831 | ||
841 | spin_lock_irqsave(&hwgroup->lock, flags); | 832 | spin_lock_irqsave(&hwif->lock, flags); |
842 | __ide_set_handler(drive, handler, timeout, expiry); | 833 | __ide_set_handler(drive, handler, timeout, expiry); |
843 | spin_unlock_irqrestore(&hwgroup->lock, flags); | 834 | spin_unlock_irqrestore(&hwif->lock, flags); |
844 | } | 835 | } |
845 | 836 | ||
846 | EXPORT_SYMBOL(ide_set_handler); | 837 | EXPORT_SYMBOL(ide_set_handler); |
@@ -863,10 +854,9 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler, | |||
863 | unsigned timeout, ide_expiry_t *expiry) | 854 | unsigned timeout, ide_expiry_t *expiry) |
864 | { | 855 | { |
865 | ide_hwif_t *hwif = drive->hwif; | 856 | ide_hwif_t *hwif = drive->hwif; |
866 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | ||
867 | unsigned long flags; | 857 | unsigned long flags; |
868 | 858 | ||
869 | spin_lock_irqsave(&hwgroup->lock, flags); | 859 | spin_lock_irqsave(&hwif->lock, flags); |
870 | __ide_set_handler(drive, handler, timeout, expiry); | 860 | __ide_set_handler(drive, handler, timeout, expiry); |
871 | hwif->tp_ops->exec_command(hwif, cmd); | 861 | hwif->tp_ops->exec_command(hwif, cmd); |
872 | /* | 862 | /* |
@@ -876,26 +866,25 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler, | |||
876 | * FIXME: we could skip this delay with care on non shared devices | 866 | * FIXME: we could skip this delay with care on non shared devices |
877 | */ | 867 | */ |
878 | ndelay(400); | 868 | ndelay(400); |
879 | spin_unlock_irqrestore(&hwgroup->lock, flags); | 869 | spin_unlock_irqrestore(&hwif->lock, flags); |
880 | } | 870 | } |
881 | EXPORT_SYMBOL(ide_execute_command); | 871 | EXPORT_SYMBOL(ide_execute_command); |
882 | 872 | ||
883 | void ide_execute_pkt_cmd(ide_drive_t *drive) | 873 | void ide_execute_pkt_cmd(ide_drive_t *drive) |
884 | { | 874 | { |
885 | ide_hwif_t *hwif = drive->hwif; | 875 | ide_hwif_t *hwif = drive->hwif; |
886 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | ||
887 | unsigned long flags; | 876 | unsigned long flags; |
888 | 877 | ||
889 | spin_lock_irqsave(&hwgroup->lock, flags); | 878 | spin_lock_irqsave(&hwif->lock, flags); |
890 | hwif->tp_ops->exec_command(hwif, ATA_CMD_PACKET); | 879 | hwif->tp_ops->exec_command(hwif, ATA_CMD_PACKET); |
891 | ndelay(400); | 880 | ndelay(400); |
892 | spin_unlock_irqrestore(&hwgroup->lock, flags); | 881 | spin_unlock_irqrestore(&hwif->lock, flags); |
893 | } | 882 | } |
894 | EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd); | 883 | EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd); |
895 | 884 | ||
896 | static inline void ide_complete_drive_reset(ide_drive_t *drive, int err) | 885 | static inline void ide_complete_drive_reset(ide_drive_t *drive, int err) |
897 | { | 886 | { |
898 | struct request *rq = drive->hwif->hwgroup->rq; | 887 | struct request *rq = drive->hwif->rq; |
899 | 888 | ||
900 | if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET) | 889 | if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET) |
901 | ide_end_request(drive, err ? err : 1, 0); | 890 | ide_end_request(drive, err ? err : 1, 0); |
@@ -913,7 +902,6 @@ static ide_startstop_t do_reset1 (ide_drive_t *, int); | |||
913 | static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) | 902 | static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) |
914 | { | 903 | { |
915 | ide_hwif_t *hwif = drive->hwif; | 904 | ide_hwif_t *hwif = drive->hwif; |
916 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | ||
917 | u8 stat; | 905 | u8 stat; |
918 | 906 | ||
919 | SELECT_DRIVE(drive); | 907 | SELECT_DRIVE(drive); |
@@ -923,20 +911,20 @@ static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) | |||
923 | if (OK_STAT(stat, 0, ATA_BUSY)) | 911 | if (OK_STAT(stat, 0, ATA_BUSY)) |
924 | printk("%s: ATAPI reset complete\n", drive->name); | 912 | printk("%s: ATAPI reset complete\n", drive->name); |
925 | else { | 913 | else { |
926 | if (time_before(jiffies, hwgroup->poll_timeout)) { | 914 | if (time_before(jiffies, hwif->poll_timeout)) { |
927 | ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); | 915 | ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); |
928 | /* continue polling */ | 916 | /* continue polling */ |
929 | return ide_started; | 917 | return ide_started; |
930 | } | 918 | } |
931 | /* end of polling */ | 919 | /* end of polling */ |
932 | hwgroup->polling = 0; | 920 | hwif->polling = 0; |
933 | printk("%s: ATAPI reset timed-out, status=0x%02x\n", | 921 | printk("%s: ATAPI reset timed-out, status=0x%02x\n", |
934 | drive->name, stat); | 922 | drive->name, stat); |
935 | /* do it the old fashioned way */ | 923 | /* do it the old fashioned way */ |
936 | return do_reset1(drive, 1); | 924 | return do_reset1(drive, 1); |
937 | } | 925 | } |
938 | /* done polling */ | 926 | /* done polling */ |
939 | hwgroup->polling = 0; | 927 | hwif->polling = 0; |
940 | ide_complete_drive_reset(drive, 0); | 928 | ide_complete_drive_reset(drive, 0); |
941 | return ide_stopped; | 929 | return ide_stopped; |
942 | } | 930 | } |
@@ -968,8 +956,7 @@ static void ide_reset_report_error(ide_hwif_t *hwif, u8 err) | |||
968 | */ | 956 | */ |
969 | static ide_startstop_t reset_pollfunc (ide_drive_t *drive) | 957 | static ide_startstop_t reset_pollfunc (ide_drive_t *drive) |
970 | { | 958 | { |
971 | ide_hwgroup_t *hwgroup = HWGROUP(drive); | 959 | ide_hwif_t *hwif = drive->hwif; |
972 | ide_hwif_t *hwif = HWIF(drive); | ||
973 | const struct ide_port_ops *port_ops = hwif->port_ops; | 960 | const struct ide_port_ops *port_ops = hwif->port_ops; |
974 | u8 tmp; | 961 | u8 tmp; |
975 | int err = 0; | 962 | int err = 0; |
@@ -986,7 +973,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive) | |||
986 | tmp = hwif->tp_ops->read_status(hwif); | 973 | tmp = hwif->tp_ops->read_status(hwif); |
987 | 974 | ||
988 | if (!OK_STAT(tmp, 0, ATA_BUSY)) { | 975 | if (!OK_STAT(tmp, 0, ATA_BUSY)) { |
989 | if (time_before(jiffies, hwgroup->poll_timeout)) { | 976 | if (time_before(jiffies, hwif->poll_timeout)) { |
990 | ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); | 977 | ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); |
991 | /* continue polling */ | 978 | /* continue polling */ |
992 | return ide_started; | 979 | return ide_started; |
@@ -1007,7 +994,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive) | |||
1007 | } | 994 | } |
1008 | } | 995 | } |
1009 | out: | 996 | out: |
1010 | hwgroup->polling = 0; /* done polling */ | 997 | hwif->polling = 0; /* done polling */ |
1011 | ide_complete_drive_reset(drive, err); | 998 | ide_complete_drive_reset(drive, err); |
1012 | return ide_stopped; | 999 | return ide_stopped; |
1013 | } | 1000 | } |
@@ -1081,18 +1068,18 @@ static void pre_reset(ide_drive_t *drive) | |||
1081 | static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | 1068 | static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) |
1082 | { | 1069 | { |
1083 | ide_hwif_t *hwif = drive->hwif; | 1070 | ide_hwif_t *hwif = drive->hwif; |
1084 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | ||
1085 | struct ide_io_ports *io_ports = &hwif->io_ports; | 1071 | struct ide_io_ports *io_ports = &hwif->io_ports; |
1086 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 1072 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
1087 | const struct ide_port_ops *port_ops; | 1073 | const struct ide_port_ops *port_ops; |
1074 | ide_drive_t *tdrive; | ||
1088 | unsigned long flags, timeout; | 1075 | unsigned long flags, timeout; |
1089 | unsigned int unit; | 1076 | int i; |
1090 | DEFINE_WAIT(wait); | 1077 | DEFINE_WAIT(wait); |
1091 | 1078 | ||
1092 | spin_lock_irqsave(&hwgroup->lock, flags); | 1079 | spin_lock_irqsave(&hwif->lock, flags); |
1093 | 1080 | ||
1094 | /* We must not reset with running handlers */ | 1081 | /* We must not reset with running handlers */ |
1095 | BUG_ON(hwgroup->handler != NULL); | 1082 | BUG_ON(hwif->handler != NULL); |
1096 | 1083 | ||
1097 | /* For an ATAPI device, first try an ATAPI SRST. */ | 1084 | /* For an ATAPI device, first try an ATAPI SRST. */ |
1098 | if (drive->media != ide_disk && !do_not_try_atapi) { | 1085 | if (drive->media != ide_disk && !do_not_try_atapi) { |
@@ -1101,10 +1088,10 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1101 | udelay (20); | 1088 | udelay (20); |
1102 | tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); | 1089 | tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); |
1103 | ndelay(400); | 1090 | ndelay(400); |
1104 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; | 1091 | hwif->poll_timeout = jiffies + WAIT_WORSTCASE; |
1105 | hwgroup->polling = 1; | 1092 | hwif->polling = 1; |
1106 | __ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); | 1093 | __ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); |
1107 | spin_unlock_irqrestore(&hwgroup->lock, flags); | 1094 | spin_unlock_irqrestore(&hwif->lock, flags); |
1108 | return ide_started; | 1095 | return ide_started; |
1109 | } | 1096 | } |
1110 | 1097 | ||
@@ -1114,9 +1101,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1114 | 1101 | ||
1115 | prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE); | 1102 | prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE); |
1116 | timeout = jiffies; | 1103 | timeout = jiffies; |
1117 | for (unit = 0; unit < MAX_DRIVES; unit++) { | 1104 | ide_port_for_each_dev(i, tdrive, hwif) { |
1118 | ide_drive_t *tdrive = &hwif->drives[unit]; | ||
1119 | |||
1120 | if (tdrive->dev_flags & IDE_DFLAG_PRESENT && | 1105 | if (tdrive->dev_flags & IDE_DFLAG_PRESENT && |
1121 | tdrive->dev_flags & IDE_DFLAG_PARKED && | 1106 | tdrive->dev_flags & IDE_DFLAG_PARKED && |
1122 | time_after(tdrive->sleep, timeout)) | 1107 | time_after(tdrive->sleep, timeout)) |
@@ -1127,9 +1112,9 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1127 | if (time_before_eq(timeout, now)) | 1112 | if (time_before_eq(timeout, now)) |
1128 | break; | 1113 | break; |
1129 | 1114 | ||
1130 | spin_unlock_irqrestore(&hwgroup->lock, flags); | 1115 | spin_unlock_irqrestore(&hwif->lock, flags); |
1131 | timeout = schedule_timeout_uninterruptible(timeout - now); | 1116 | timeout = schedule_timeout_uninterruptible(timeout - now); |
1132 | spin_lock_irqsave(&hwgroup->lock, flags); | 1117 | spin_lock_irqsave(&hwif->lock, flags); |
1133 | } while (timeout); | 1118 | } while (timeout); |
1134 | finish_wait(&ide_park_wq, &wait); | 1119 | finish_wait(&ide_park_wq, &wait); |
1135 | 1120 | ||
@@ -1137,11 +1122,11 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1137 | * First, reset any device state data we were maintaining | 1122 | * First, reset any device state data we were maintaining |
1138 | * for any of the drives on this interface. | 1123 | * for any of the drives on this interface. |
1139 | */ | 1124 | */ |
1140 | for (unit = 0; unit < MAX_DRIVES; ++unit) | 1125 | ide_port_for_each_dev(i, tdrive, hwif) |
1141 | pre_reset(&hwif->drives[unit]); | 1126 | pre_reset(tdrive); |
1142 | 1127 | ||
1143 | if (io_ports->ctl_addr == 0) { | 1128 | if (io_ports->ctl_addr == 0) { |
1144 | spin_unlock_irqrestore(&hwgroup->lock, flags); | 1129 | spin_unlock_irqrestore(&hwif->lock, flags); |
1145 | ide_complete_drive_reset(drive, -ENXIO); | 1130 | ide_complete_drive_reset(drive, -ENXIO); |
1146 | return ide_stopped; | 1131 | return ide_stopped; |
1147 | } | 1132 | } |
@@ -1164,8 +1149,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1164 | tp_ops->set_irq(hwif, drive->quirk_list == 2); | 1149 | tp_ops->set_irq(hwif, drive->quirk_list == 2); |
1165 | /* more than enough time */ | 1150 | /* more than enough time */ |
1166 | udelay(10); | 1151 | udelay(10); |
1167 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; | 1152 | hwif->poll_timeout = jiffies + WAIT_WORSTCASE; |
1168 | hwgroup->polling = 1; | 1153 | hwif->polling = 1; |
1169 | __ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); | 1154 | __ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); |
1170 | 1155 | ||
1171 | /* | 1156 | /* |
@@ -1177,7 +1162,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1177 | if (port_ops && port_ops->resetproc) | 1162 | if (port_ops && port_ops->resetproc) |
1178 | port_ops->resetproc(drive); | 1163 | port_ops->resetproc(drive); |
1179 | 1164 | ||
1180 | spin_unlock_irqrestore(&hwgroup->lock, flags); | 1165 | spin_unlock_irqrestore(&hwif->lock, flags); |
1181 | return ide_started; | 1166 | return ide_started; |
1182 | } | 1167 | } |
1183 | 1168 | ||
@@ -1221,6 +1206,3 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout) | |||
1221 | } | 1206 | } |
1222 | return -EBUSY; | 1207 | return -EBUSY; |
1223 | } | 1208 | } |
1224 | |||
1225 | EXPORT_SYMBOL_GPL(ide_wait_not_busy); | ||
1226 | |||
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 9f6e33d8a8b2..09526a0de734 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c | |||
@@ -273,7 +273,7 @@ int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) | |||
273 | 273 | ||
274 | static void ide_dump_opcode(ide_drive_t *drive) | 274 | static void ide_dump_opcode(ide_drive_t *drive) |
275 | { | 275 | { |
276 | struct request *rq = drive->hwif->hwgroup->rq; | 276 | struct request *rq = drive->hwif->rq; |
277 | ide_task_t *task = NULL; | 277 | ide_task_t *task = NULL; |
278 | 278 | ||
279 | if (!rq) | 279 | if (!rq) |
@@ -346,10 +346,13 @@ static void ide_dump_ata_error(ide_drive_t *drive, u8 err) | |||
346 | printk(KERN_CONT "}"); | 346 | printk(KERN_CONT "}"); |
347 | if ((err & (ATA_BBK | ATA_ABORTED)) == ATA_BBK || | 347 | if ((err & (ATA_BBK | ATA_ABORTED)) == ATA_BBK || |
348 | (err & (ATA_UNC | ATA_IDNF | ATA_AMNF))) { | 348 | (err & (ATA_UNC | ATA_IDNF | ATA_AMNF))) { |
349 | struct request *rq = drive->hwif->rq; | ||
350 | |||
349 | ide_dump_sector(drive); | 351 | ide_dump_sector(drive); |
350 | if (HWGROUP(drive) && HWGROUP(drive)->rq) | 352 | |
353 | if (rq) | ||
351 | printk(KERN_CONT ", sector=%llu", | 354 | printk(KERN_CONT ", sector=%llu", |
352 | (unsigned long long)HWGROUP(drive)->rq->sector); | 355 | (unsigned long long)rq->sector); |
353 | } | 356 | } |
354 | printk(KERN_CONT "\n"); | 357 | printk(KERN_CONT "\n"); |
355 | } | 358 | } |
diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c index 678454ac2483..c875a957596c 100644 --- a/drivers/ide/ide-park.c +++ b/drivers/ide/ide-park.c | |||
@@ -7,22 +7,22 @@ DECLARE_WAIT_QUEUE_HEAD(ide_park_wq); | |||
7 | 7 | ||
8 | static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout) | 8 | static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout) |
9 | { | 9 | { |
10 | ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; | 10 | ide_hwif_t *hwif = drive->hwif; |
11 | struct request_queue *q = drive->queue; | 11 | struct request_queue *q = drive->queue; |
12 | struct request *rq; | 12 | struct request *rq; |
13 | int rc; | 13 | int rc; |
14 | 14 | ||
15 | timeout += jiffies; | 15 | timeout += jiffies; |
16 | spin_lock_irq(&hwgroup->lock); | 16 | spin_lock_irq(&hwif->lock); |
17 | if (drive->dev_flags & IDE_DFLAG_PARKED) { | 17 | if (drive->dev_flags & IDE_DFLAG_PARKED) { |
18 | int reset_timer = time_before(timeout, drive->sleep); | 18 | int reset_timer = time_before(timeout, drive->sleep); |
19 | int start_queue = 0; | 19 | int start_queue = 0; |
20 | 20 | ||
21 | drive->sleep = timeout; | 21 | drive->sleep = timeout; |
22 | wake_up_all(&ide_park_wq); | 22 | wake_up_all(&ide_park_wq); |
23 | if (reset_timer && del_timer(&hwgroup->timer)) | 23 | if (reset_timer && del_timer(&hwif->timer)) |
24 | start_queue = 1; | 24 | start_queue = 1; |
25 | spin_unlock_irq(&hwgroup->lock); | 25 | spin_unlock_irq(&hwif->lock); |
26 | 26 | ||
27 | if (start_queue) { | 27 | if (start_queue) { |
28 | spin_lock_irq(q->queue_lock); | 28 | spin_lock_irq(q->queue_lock); |
@@ -31,7 +31,7 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout) | |||
31 | } | 31 | } |
32 | return; | 32 | return; |
33 | } | 33 | } |
34 | spin_unlock_irq(&hwgroup->lock); | 34 | spin_unlock_irq(&hwif->lock); |
35 | 35 | ||
36 | rq = blk_get_request(q, READ, __GFP_WAIT); | 36 | rq = blk_get_request(q, READ, __GFP_WAIT); |
37 | rq->cmd[0] = REQ_PARK_HEADS; | 37 | rq->cmd[0] = REQ_PARK_HEADS; |
@@ -64,21 +64,21 @@ ssize_t ide_park_show(struct device *dev, struct device_attribute *attr, | |||
64 | char *buf) | 64 | char *buf) |
65 | { | 65 | { |
66 | ide_drive_t *drive = to_ide_device(dev); | 66 | ide_drive_t *drive = to_ide_device(dev); |
67 | ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; | 67 | ide_hwif_t *hwif = drive->hwif; |
68 | unsigned long now; | 68 | unsigned long now; |
69 | unsigned int msecs; | 69 | unsigned int msecs; |
70 | 70 | ||
71 | if (drive->dev_flags & IDE_DFLAG_NO_UNLOAD) | 71 | if (drive->dev_flags & IDE_DFLAG_NO_UNLOAD) |
72 | return -EOPNOTSUPP; | 72 | return -EOPNOTSUPP; |
73 | 73 | ||
74 | spin_lock_irq(&hwgroup->lock); | 74 | spin_lock_irq(&hwif->lock); |
75 | now = jiffies; | 75 | now = jiffies; |
76 | if (drive->dev_flags & IDE_DFLAG_PARKED && | 76 | if (drive->dev_flags & IDE_DFLAG_PARKED && |
77 | time_after(drive->sleep, now)) | 77 | time_after(drive->sleep, now)) |
78 | msecs = jiffies_to_msecs(drive->sleep - now); | 78 | msecs = jiffies_to_msecs(drive->sleep - now); |
79 | else | 79 | else |
80 | msecs = 0; | 80 | msecs = 0; |
81 | spin_unlock_irq(&hwgroup->lock); | 81 | spin_unlock_irq(&hwif->lock); |
82 | 82 | ||
83 | return snprintf(buf, 20, "%u\n", msecs); | 83 | return snprintf(buf, 20, "%u\n", msecs); |
84 | } | 84 | } |
diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c index 8282c6086e6a..4b3bf6a06b70 100644 --- a/drivers/ide/ide-pm.c +++ b/drivers/ide/ide-pm.c | |||
@@ -5,7 +5,7 @@ | |||
5 | int generic_ide_suspend(struct device *dev, pm_message_t mesg) | 5 | int generic_ide_suspend(struct device *dev, pm_message_t mesg) |
6 | { | 6 | { |
7 | ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive); | 7 | ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive); |
8 | ide_hwif_t *hwif = HWIF(drive); | 8 | ide_hwif_t *hwif = drive->hwif; |
9 | struct request *rq; | 9 | struct request *rq; |
10 | struct request_pm_state rqpm; | 10 | struct request_pm_state rqpm; |
11 | ide_task_t args; | 11 | ide_task_t args; |
@@ -39,7 +39,7 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg) | |||
39 | int generic_ide_resume(struct device *dev) | 39 | int generic_ide_resume(struct device *dev) |
40 | { | 40 | { |
41 | ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive); | 41 | ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive); |
42 | ide_hwif_t *hwif = HWIF(drive); | 42 | ide_hwif_t *hwif = drive->hwif; |
43 | struct request *rq; | 43 | struct request *rq; |
44 | struct request_pm_state rqpm; | 44 | struct request_pm_state rqpm; |
45 | ide_task_t args; | 45 | ide_task_t args; |
@@ -67,7 +67,7 @@ int generic_ide_resume(struct device *dev) | |||
67 | blk_put_request(rq); | 67 | blk_put_request(rq); |
68 | 68 | ||
69 | if (err == 0 && dev->driver) { | 69 | if (err == 0 && dev->driver) { |
70 | ide_driver_t *drv = to_ide_driver(dev->driver); | 70 | struct ide_driver *drv = to_ide_driver(dev->driver); |
71 | 71 | ||
72 | if (drv->resume) | 72 | if (drv->resume) |
73 | drv->resume(drive); | 73 | drv->resume(drive); |
@@ -194,7 +194,7 @@ void ide_complete_pm_request(ide_drive_t *drive, struct request *rq) | |||
194 | } | 194 | } |
195 | spin_unlock_irqrestore(q->queue_lock, flags); | 195 | spin_unlock_irqrestore(q->queue_lock, flags); |
196 | 196 | ||
197 | drive->hwif->hwgroup->rq = NULL; | 197 | drive->hwif->rq = NULL; |
198 | 198 | ||
199 | if (blk_end_request(rq, 0, 0)) | 199 | if (blk_end_request(rq, 0, 0)) |
200 | BUG(); | 200 | BUG(); |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index c5adb7b9c5b5..0ccbb4459fb9 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -189,7 +189,7 @@ static void ide_classify_atapi_dev(ide_drive_t *drive) | |||
189 | 189 | ||
190 | static void do_identify(ide_drive_t *drive, u8 cmd) | 190 | static void do_identify(ide_drive_t *drive, u8 cmd) |
191 | { | 191 | { |
192 | ide_hwif_t *hwif = HWIF(drive); | 192 | ide_hwif_t *hwif = drive->hwif; |
193 | u16 *id = drive->id; | 193 | u16 *id = drive->id; |
194 | char *m = (char *)&id[ATA_ID_PROD]; | 194 | char *m = (char *)&id[ATA_ID_PROD]; |
195 | unsigned long flags; | 195 | unsigned long flags; |
@@ -266,7 +266,7 @@ err_misc: | |||
266 | 266 | ||
267 | static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | 267 | static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) |
268 | { | 268 | { |
269 | ide_hwif_t *hwif = HWIF(drive); | 269 | ide_hwif_t *hwif = drive->hwif; |
270 | struct ide_io_ports *io_ports = &hwif->io_ports; | 270 | struct ide_io_ports *io_ports = &hwif->io_ports; |
271 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 271 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
272 | int use_altstatus = 0, rc; | 272 | int use_altstatus = 0, rc; |
@@ -341,7 +341,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
341 | 341 | ||
342 | static int try_to_identify (ide_drive_t *drive, u8 cmd) | 342 | static int try_to_identify (ide_drive_t *drive, u8 cmd) |
343 | { | 343 | { |
344 | ide_hwif_t *hwif = HWIF(drive); | 344 | ide_hwif_t *hwif = drive->hwif; |
345 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 345 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
346 | int retval; | 346 | int retval; |
347 | int autoprobe = 0; | 347 | int autoprobe = 0; |
@@ -438,7 +438,7 @@ static u8 ide_read_device(ide_drive_t *drive) | |||
438 | 438 | ||
439 | static int do_probe (ide_drive_t *drive, u8 cmd) | 439 | static int do_probe (ide_drive_t *drive, u8 cmd) |
440 | { | 440 | { |
441 | ide_hwif_t *hwif = HWIF(drive); | 441 | ide_hwif_t *hwif = drive->hwif; |
442 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 442 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
443 | int rc; | 443 | int rc; |
444 | u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat; | 444 | u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat; |
@@ -463,7 +463,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
463 | if (ide_read_device(drive) != drive->select && present == 0) { | 463 | if (ide_read_device(drive) != drive->select && present == 0) { |
464 | if (drive->dn & 1) { | 464 | if (drive->dn & 1) { |
465 | /* exit with drive0 selected */ | 465 | /* exit with drive0 selected */ |
466 | SELECT_DRIVE(&hwif->drives[0]); | 466 | SELECT_DRIVE(hwif->devices[0]); |
467 | /* allow ATA_BUSY to assert & clear */ | 467 | /* allow ATA_BUSY to assert & clear */ |
468 | msleep(50); | 468 | msleep(50); |
469 | } | 469 | } |
@@ -509,7 +509,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
509 | } | 509 | } |
510 | if (drive->dn & 1) { | 510 | if (drive->dn & 1) { |
511 | /* exit with drive0 selected */ | 511 | /* exit with drive0 selected */ |
512 | SELECT_DRIVE(&hwif->drives[0]); | 512 | SELECT_DRIVE(hwif->devices[0]); |
513 | msleep(50); | 513 | msleep(50); |
514 | /* ensure drive irq is clear */ | 514 | /* ensure drive irq is clear */ |
515 | (void)tp_ops->read_status(hwif); | 515 | (void)tp_ops->read_status(hwif); |
@@ -522,7 +522,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
522 | */ | 522 | */ |
523 | static void enable_nest (ide_drive_t *drive) | 523 | static void enable_nest (ide_drive_t *drive) |
524 | { | 524 | { |
525 | ide_hwif_t *hwif = HWIF(drive); | 525 | ide_hwif_t *hwif = drive->hwif; |
526 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 526 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
527 | u8 stat; | 527 | u8 stat; |
528 | 528 | ||
@@ -697,7 +697,8 @@ out: | |||
697 | 697 | ||
698 | static int ide_port_wait_ready(ide_hwif_t *hwif) | 698 | static int ide_port_wait_ready(ide_hwif_t *hwif) |
699 | { | 699 | { |
700 | int unit, rc; | 700 | ide_drive_t *drive; |
701 | int i, rc; | ||
701 | 702 | ||
702 | printk(KERN_DEBUG "Probing IDE interface %s...\n", hwif->name); | 703 | printk(KERN_DEBUG "Probing IDE interface %s...\n", hwif->name); |
703 | 704 | ||
@@ -714,9 +715,7 @@ static int ide_port_wait_ready(ide_hwif_t *hwif) | |||
714 | return rc; | 715 | return rc; |
715 | 716 | ||
716 | /* Now make sure both master & slave are ready */ | 717 | /* Now make sure both master & slave are ready */ |
717 | for (unit = 0; unit < MAX_DRIVES; unit++) { | 718 | ide_port_for_each_dev(i, drive, hwif) { |
718 | ide_drive_t *drive = &hwif->drives[unit]; | ||
719 | |||
720 | /* Ignore disks that we will not probe for later. */ | 719 | /* Ignore disks that we will not probe for later. */ |
721 | if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0 || | 720 | if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0 || |
722 | (drive->dev_flags & IDE_DFLAG_PRESENT)) { | 721 | (drive->dev_flags & IDE_DFLAG_PRESENT)) { |
@@ -732,8 +731,8 @@ static int ide_port_wait_ready(ide_hwif_t *hwif) | |||
732 | } | 731 | } |
733 | out: | 732 | out: |
734 | /* Exit function with master reselected (let's be sane) */ | 733 | /* Exit function with master reselected (let's be sane) */ |
735 | if (unit) | 734 | if (i) |
736 | SELECT_DRIVE(&hwif->drives[0]); | 735 | SELECT_DRIVE(hwif->devices[0]); |
737 | 736 | ||
738 | return rc; | 737 | return rc; |
739 | } | 738 | } |
@@ -749,7 +748,7 @@ out: | |||
749 | 748 | ||
750 | void ide_undecoded_slave(ide_drive_t *dev1) | 749 | void ide_undecoded_slave(ide_drive_t *dev1) |
751 | { | 750 | { |
752 | ide_drive_t *dev0 = &dev1->hwif->drives[0]; | 751 | ide_drive_t *dev0 = dev1->hwif->devices[0]; |
753 | 752 | ||
754 | if ((dev1->dn & 1) == 0 || (dev0->dev_flags & IDE_DFLAG_PRESENT) == 0) | 753 | if ((dev1->dn & 1) == 0 || (dev0->dev_flags & IDE_DFLAG_PRESENT) == 0) |
755 | return; | 754 | return; |
@@ -778,14 +777,15 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave); | |||
778 | 777 | ||
779 | static int ide_probe_port(ide_hwif_t *hwif) | 778 | static int ide_probe_port(ide_hwif_t *hwif) |
780 | { | 779 | { |
780 | ide_drive_t *drive; | ||
781 | unsigned long flags; | 781 | unsigned long flags; |
782 | unsigned int irqd; | 782 | unsigned int irqd; |
783 | int unit, rc = -ENODEV; | 783 | int i, rc = -ENODEV; |
784 | 784 | ||
785 | BUG_ON(hwif->present); | 785 | BUG_ON(hwif->present); |
786 | 786 | ||
787 | if ((hwif->drives[0].dev_flags & IDE_DFLAG_NOPROBE) && | 787 | if ((hwif->devices[0]->dev_flags & IDE_DFLAG_NOPROBE) && |
788 | (hwif->drives[1].dev_flags & IDE_DFLAG_NOPROBE)) | 788 | (hwif->devices[1]->dev_flags & IDE_DFLAG_NOPROBE)) |
789 | return -EACCES; | 789 | return -EACCES; |
790 | 790 | ||
791 | /* | 791 | /* |
@@ -796,7 +796,8 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
796 | if (irqd) | 796 | if (irqd) |
797 | disable_irq(hwif->irq); | 797 | disable_irq(hwif->irq); |
798 | 798 | ||
799 | local_irq_set(flags); | 799 | local_irq_save(flags); |
800 | local_irq_enable_in_hardirq(); | ||
800 | 801 | ||
801 | if (ide_port_wait_ready(hwif) == -EBUSY) | 802 | if (ide_port_wait_ready(hwif) == -EBUSY) |
802 | printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); | 803 | printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); |
@@ -805,9 +806,7 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
805 | * Second drive should only exist if first drive was found, | 806 | * Second drive should only exist if first drive was found, |
806 | * but a lot of cdrom drives are configured as single slaves. | 807 | * but a lot of cdrom drives are configured as single slaves. |
807 | */ | 808 | */ |
808 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | 809 | ide_port_for_each_dev(i, drive, hwif) { |
809 | ide_drive_t *drive = &hwif->drives[unit]; | ||
810 | |||
811 | (void) probe_for_drive(drive); | 810 | (void) probe_for_drive(drive); |
812 | if (drive->dev_flags & IDE_DFLAG_PRESENT) | 811 | if (drive->dev_flags & IDE_DFLAG_PRESENT) |
813 | rc = 0; | 812 | rc = 0; |
@@ -828,20 +827,17 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
828 | static void ide_port_tune_devices(ide_hwif_t *hwif) | 827 | static void ide_port_tune_devices(ide_hwif_t *hwif) |
829 | { | 828 | { |
830 | const struct ide_port_ops *port_ops = hwif->port_ops; | 829 | const struct ide_port_ops *port_ops = hwif->port_ops; |
831 | int unit; | 830 | ide_drive_t *drive; |
832 | 831 | int i; | |
833 | for (unit = 0; unit < MAX_DRIVES; unit++) { | ||
834 | ide_drive_t *drive = &hwif->drives[unit]; | ||
835 | 832 | ||
833 | ide_port_for_each_dev(i, drive, hwif) { | ||
836 | if (drive->dev_flags & IDE_DFLAG_PRESENT) { | 834 | if (drive->dev_flags & IDE_DFLAG_PRESENT) { |
837 | if (port_ops && port_ops->quirkproc) | 835 | if (port_ops && port_ops->quirkproc) |
838 | port_ops->quirkproc(drive); | 836 | port_ops->quirkproc(drive); |
839 | } | 837 | } |
840 | } | 838 | } |
841 | 839 | ||
842 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | 840 | ide_port_for_each_dev(i, drive, hwif) { |
843 | ide_drive_t *drive = &hwif->drives[unit]; | ||
844 | |||
845 | if (drive->dev_flags & IDE_DFLAG_PRESENT) { | 841 | if (drive->dev_flags & IDE_DFLAG_PRESENT) { |
846 | ide_set_max_pio(drive); | 842 | ide_set_max_pio(drive); |
847 | 843 | ||
@@ -852,11 +848,8 @@ static void ide_port_tune_devices(ide_hwif_t *hwif) | |||
852 | } | 848 | } |
853 | } | 849 | } |
854 | 850 | ||
855 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | 851 | ide_port_for_each_dev(i, drive, hwif) { |
856 | ide_drive_t *drive = &hwif->drives[unit]; | 852 | if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) |
857 | |||
858 | if ((hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) || | ||
859 | drive->id[ATA_ID_DWORD_IO]) | ||
860 | drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT; | 853 | drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT; |
861 | else | 854 | else |
862 | drive->dev_flags &= ~IDE_DFLAG_NO_IO_32BIT; | 855 | drive->dev_flags &= ~IDE_DFLAG_NO_IO_32BIT; |
@@ -869,7 +862,7 @@ static void ide_port_tune_devices(ide_hwif_t *hwif) | |||
869 | static int ide_init_queue(ide_drive_t *drive) | 862 | static int ide_init_queue(ide_drive_t *drive) |
870 | { | 863 | { |
871 | struct request_queue *q; | 864 | struct request_queue *q; |
872 | ide_hwif_t *hwif = HWIF(drive); | 865 | ide_hwif_t *hwif = drive->hwif; |
873 | int max_sectors = 256; | 866 | int max_sectors = 256; |
874 | int max_sg_entries = PRD_ENTRIES; | 867 | int max_sg_entries = PRD_ENTRIES; |
875 | 868 | ||
@@ -918,36 +911,19 @@ static int ide_init_queue(ide_drive_t *drive) | |||
918 | return 0; | 911 | return 0; |
919 | } | 912 | } |
920 | 913 | ||
921 | static void ide_add_drive_to_hwgroup(ide_drive_t *drive) | 914 | static DEFINE_MUTEX(ide_cfg_mtx); |
922 | { | ||
923 | ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; | ||
924 | |||
925 | spin_lock_irq(&hwgroup->lock); | ||
926 | if (!hwgroup->drive) { | ||
927 | /* first drive for hwgroup. */ | ||
928 | drive->next = drive; | ||
929 | hwgroup->drive = drive; | ||
930 | hwgroup->hwif = HWIF(hwgroup->drive); | ||
931 | } else { | ||
932 | drive->next = hwgroup->drive->next; | ||
933 | hwgroup->drive->next = drive; | ||
934 | } | ||
935 | spin_unlock_irq(&hwgroup->lock); | ||
936 | } | ||
937 | 915 | ||
938 | /* | 916 | /* |
939 | * For any present drive: | 917 | * For any present drive: |
940 | * - allocate the block device queue | 918 | * - allocate the block device queue |
941 | * - link drive into the hwgroup | ||
942 | */ | 919 | */ |
943 | static int ide_port_setup_devices(ide_hwif_t *hwif) | 920 | static int ide_port_setup_devices(ide_hwif_t *hwif) |
944 | { | 921 | { |
922 | ide_drive_t *drive; | ||
945 | int i, j = 0; | 923 | int i, j = 0; |
946 | 924 | ||
947 | mutex_lock(&ide_cfg_mtx); | 925 | mutex_lock(&ide_cfg_mtx); |
948 | for (i = 0; i < MAX_DRIVES; i++) { | 926 | ide_port_for_each_dev(i, drive, hwif) { |
949 | ide_drive_t *drive = &hwif->drives[i]; | ||
950 | |||
951 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) | 927 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) |
952 | continue; | 928 | continue; |
953 | 929 | ||
@@ -961,139 +937,39 @@ static int ide_port_setup_devices(ide_hwif_t *hwif) | |||
961 | } | 937 | } |
962 | 938 | ||
963 | j++; | 939 | j++; |
964 | |||
965 | ide_add_drive_to_hwgroup(drive); | ||
966 | } | 940 | } |
967 | mutex_unlock(&ide_cfg_mtx); | 941 | mutex_unlock(&ide_cfg_mtx); |
968 | 942 | ||
969 | return j; | 943 | return j; |
970 | } | 944 | } |
971 | 945 | ||
972 | static ide_hwif_t *ide_ports[MAX_HWIFS]; | ||
973 | |||
974 | void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) | ||
975 | { | ||
976 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | ||
977 | |||
978 | ide_ports[hwif->index] = NULL; | ||
979 | |||
980 | spin_lock_irq(&hwgroup->lock); | ||
981 | /* | ||
982 | * Remove us from the hwgroup, and free | ||
983 | * the hwgroup if we were the only member | ||
984 | */ | ||
985 | if (hwif->next == hwif) { | ||
986 | BUG_ON(hwgroup->hwif != hwif); | ||
987 | kfree(hwgroup); | ||
988 | } else { | ||
989 | /* There is another interface in hwgroup. | ||
990 | * Unlink us, and set hwgroup->drive and ->hwif to | ||
991 | * something sane. | ||
992 | */ | ||
993 | ide_hwif_t *g = hwgroup->hwif; | ||
994 | |||
995 | while (g->next != hwif) | ||
996 | g = g->next; | ||
997 | g->next = hwif->next; | ||
998 | if (hwgroup->hwif == hwif) { | ||
999 | /* Chose a random hwif for hwgroup->hwif. | ||
1000 | * It's guaranteed that there are no drives | ||
1001 | * left in the hwgroup. | ||
1002 | */ | ||
1003 | BUG_ON(hwgroup->drive != NULL); | ||
1004 | hwgroup->hwif = g; | ||
1005 | } | ||
1006 | BUG_ON(hwgroup->hwif == hwif); | ||
1007 | } | ||
1008 | spin_unlock_irq(&hwgroup->lock); | ||
1009 | } | ||
1010 | |||
1011 | /* | 946 | /* |
1012 | * This routine sets up the irq for an ide interface, and creates a new | 947 | * This routine sets up the IRQ for an IDE interface. |
1013 | * hwgroup for the irq/hwif if none was previously assigned. | ||
1014 | * | ||
1015 | * Much of the code is for correctly detecting/handling irq sharing | ||
1016 | * and irq serialization situations. This is somewhat complex because | ||
1017 | * it handles static as well as dynamic (PCMCIA) IDE interfaces. | ||
1018 | */ | 948 | */ |
1019 | static int init_irq (ide_hwif_t *hwif) | 949 | static int init_irq (ide_hwif_t *hwif) |
1020 | { | 950 | { |
1021 | struct ide_io_ports *io_ports = &hwif->io_ports; | 951 | struct ide_io_ports *io_ports = &hwif->io_ports; |
1022 | unsigned int index; | 952 | int sa = 0; |
1023 | ide_hwgroup_t *hwgroup; | ||
1024 | ide_hwif_t *match = NULL; | ||
1025 | 953 | ||
1026 | mutex_lock(&ide_cfg_mtx); | 954 | mutex_lock(&ide_cfg_mtx); |
1027 | hwif->hwgroup = NULL; | 955 | spin_lock_init(&hwif->lock); |
1028 | 956 | ||
1029 | for (index = 0; index < MAX_HWIFS; index++) { | 957 | init_timer(&hwif->timer); |
1030 | ide_hwif_t *h = ide_ports[index]; | 958 | hwif->timer.function = &ide_timer_expiry; |
959 | hwif->timer.data = (unsigned long)hwif; | ||
1031 | 960 | ||
1032 | if (h && h->hwgroup) { /* scan only initialized ports */ | ||
1033 | if (hwif->host->host_flags & IDE_HFLAG_SERIALIZE) { | ||
1034 | if (hwif->host == h->host) | ||
1035 | match = h; | ||
1036 | } | ||
1037 | } | ||
1038 | } | ||
1039 | |||
1040 | /* | ||
1041 | * If we are still without a hwgroup, then form a new one | ||
1042 | */ | ||
1043 | if (match) { | ||
1044 | hwgroup = match->hwgroup; | ||
1045 | hwif->hwgroup = hwgroup; | ||
1046 | /* | ||
1047 | * Link us into the hwgroup. | ||
1048 | * This must be done early, do ensure that unexpected_intr | ||
1049 | * can find the hwif and prevent irq storms. | ||
1050 | * No drives are attached to the new hwif, choose_drive | ||
1051 | * can't do anything stupid (yet). | ||
1052 | * Add ourself as the 2nd entry to the hwgroup->hwif | ||
1053 | * linked list, the first entry is the hwif that owns | ||
1054 | * hwgroup->handler - do not change that. | ||
1055 | */ | ||
1056 | spin_lock_irq(&hwgroup->lock); | ||
1057 | hwif->next = hwgroup->hwif->next; | ||
1058 | hwgroup->hwif->next = hwif; | ||
1059 | BUG_ON(hwif->next == hwif); | ||
1060 | spin_unlock_irq(&hwgroup->lock); | ||
1061 | } else { | ||
1062 | hwgroup = kmalloc_node(sizeof(*hwgroup), GFP_KERNEL|__GFP_ZERO, | ||
1063 | hwif_to_node(hwif)); | ||
1064 | if (hwgroup == NULL) | ||
1065 | goto out_up; | ||
1066 | |||
1067 | spin_lock_init(&hwgroup->lock); | ||
1068 | |||
1069 | hwif->hwgroup = hwgroup; | ||
1070 | hwgroup->hwif = hwif->next = hwif; | ||
1071 | |||
1072 | init_timer(&hwgroup->timer); | ||
1073 | hwgroup->timer.function = &ide_timer_expiry; | ||
1074 | hwgroup->timer.data = (unsigned long) hwgroup; | ||
1075 | } | ||
1076 | |||
1077 | ide_ports[hwif->index] = hwif; | ||
1078 | |||
1079 | /* | ||
1080 | * Allocate the irq, if not already obtained for another hwif | ||
1081 | */ | ||
1082 | if (!match || match->irq != hwif->irq) { | ||
1083 | int sa = 0; | ||
1084 | #if defined(__mc68000__) | 961 | #if defined(__mc68000__) |
1085 | sa = IRQF_SHARED; | 962 | sa = IRQF_SHARED; |
1086 | #endif /* __mc68000__ */ | 963 | #endif /* __mc68000__ */ |
1087 | 964 | ||
1088 | if (hwif->chipset == ide_pci) | 965 | if (hwif->chipset == ide_pci) |
1089 | sa = IRQF_SHARED; | 966 | sa = IRQF_SHARED; |
1090 | 967 | ||
1091 | if (io_ports->ctl_addr) | 968 | if (io_ports->ctl_addr) |
1092 | hwif->tp_ops->set_irq(hwif, 1); | 969 | hwif->tp_ops->set_irq(hwif, 1); |
1093 | 970 | ||
1094 | if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) | 971 | if (request_irq(hwif->irq, &ide_intr, sa, hwif->name, hwif)) |
1095 | goto out_unlink; | 972 | goto out_up; |
1096 | } | ||
1097 | 973 | ||
1098 | if (!hwif->rqsize) { | 974 | if (!hwif->rqsize) { |
1099 | if ((hwif->host_flags & IDE_HFLAG_NO_LBA48) || | 975 | if ((hwif->host_flags & IDE_HFLAG_NO_LBA48) || |
@@ -1111,14 +987,12 @@ static int init_irq (ide_hwif_t *hwif) | |||
1111 | printk(KERN_INFO "%s at 0x%08lx on irq %d", hwif->name, | 987 | printk(KERN_INFO "%s at 0x%08lx on irq %d", hwif->name, |
1112 | io_ports->data_addr, hwif->irq); | 988 | io_ports->data_addr, hwif->irq); |
1113 | #endif /* __mc68000__ */ | 989 | #endif /* __mc68000__ */ |
1114 | if (match) | 990 | if (hwif->host->host_flags & IDE_HFLAG_SERIALIZE) |
1115 | printk(KERN_CONT " (serialized with %s)", match->name); | 991 | printk(KERN_CONT " (serialized)"); |
1116 | printk(KERN_CONT "\n"); | 992 | printk(KERN_CONT "\n"); |
1117 | 993 | ||
1118 | mutex_unlock(&ide_cfg_mtx); | 994 | mutex_unlock(&ide_cfg_mtx); |
1119 | return 0; | 995 | return 0; |
1120 | out_unlink: | ||
1121 | ide_remove_port_from_hwgroup(hwif); | ||
1122 | out_up: | 996 | out_up: |
1123 | mutex_unlock(&ide_cfg_mtx); | 997 | mutex_unlock(&ide_cfg_mtx); |
1124 | return 1; | 998 | return 1; |
@@ -1134,7 +1008,7 @@ static struct kobject *ata_probe(dev_t dev, int *part, void *data) | |||
1134 | { | 1008 | { |
1135 | ide_hwif_t *hwif = data; | 1009 | ide_hwif_t *hwif = data; |
1136 | int unit = *part >> PARTN_BITS; | 1010 | int unit = *part >> PARTN_BITS; |
1137 | ide_drive_t *drive = &hwif->drives[unit]; | 1011 | ide_drive_t *drive = hwif->devices[unit]; |
1138 | 1012 | ||
1139 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) | 1013 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) |
1140 | return NULL; | 1014 | return NULL; |
@@ -1196,47 +1070,23 @@ void ide_init_disk(struct gendisk *disk, ide_drive_t *drive) | |||
1196 | 1070 | ||
1197 | EXPORT_SYMBOL_GPL(ide_init_disk); | 1071 | EXPORT_SYMBOL_GPL(ide_init_disk); |
1198 | 1072 | ||
1199 | static void ide_remove_drive_from_hwgroup(ide_drive_t *drive) | ||
1200 | { | ||
1201 | ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; | ||
1202 | |||
1203 | if (drive == drive->next) { | ||
1204 | /* special case: last drive from hwgroup. */ | ||
1205 | BUG_ON(hwgroup->drive != drive); | ||
1206 | hwgroup->drive = NULL; | ||
1207 | } else { | ||
1208 | ide_drive_t *walk; | ||
1209 | |||
1210 | walk = hwgroup->drive; | ||
1211 | while (walk->next != drive) | ||
1212 | walk = walk->next; | ||
1213 | walk->next = drive->next; | ||
1214 | if (hwgroup->drive == drive) { | ||
1215 | hwgroup->drive = drive->next; | ||
1216 | hwgroup->hwif = hwgroup->drive->hwif; | ||
1217 | } | ||
1218 | } | ||
1219 | BUG_ON(hwgroup->drive == drive); | ||
1220 | } | ||
1221 | |||
1222 | static void drive_release_dev (struct device *dev) | 1073 | static void drive_release_dev (struct device *dev) |
1223 | { | 1074 | { |
1224 | ide_drive_t *drive = container_of(dev, ide_drive_t, gendev); | 1075 | ide_drive_t *drive = container_of(dev, ide_drive_t, gendev); |
1225 | ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; | 1076 | ide_hwif_t *hwif = drive->hwif; |
1226 | 1077 | ||
1227 | ide_proc_unregister_device(drive); | 1078 | ide_proc_unregister_device(drive); |
1228 | 1079 | ||
1229 | spin_lock_irq(&hwgroup->lock); | 1080 | spin_lock_irq(&hwif->lock); |
1230 | ide_remove_drive_from_hwgroup(drive); | ||
1231 | kfree(drive->id); | 1081 | kfree(drive->id); |
1232 | drive->id = NULL; | 1082 | drive->id = NULL; |
1233 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; | 1083 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; |
1234 | /* Messed up locking ... */ | 1084 | /* Messed up locking ... */ |
1235 | spin_unlock_irq(&hwgroup->lock); | 1085 | spin_unlock_irq(&hwif->lock); |
1236 | blk_cleanup_queue(drive->queue); | 1086 | blk_cleanup_queue(drive->queue); |
1237 | spin_lock_irq(&hwgroup->lock); | 1087 | spin_lock_irq(&hwif->lock); |
1238 | drive->queue = NULL; | 1088 | drive->queue = NULL; |
1239 | spin_unlock_irq(&hwgroup->lock); | 1089 | spin_unlock_irq(&hwif->lock); |
1240 | 1090 | ||
1241 | complete(&drive->gendev_rel_comp); | 1091 | complete(&drive->gendev_rel_comp); |
1242 | } | 1092 | } |
@@ -1302,10 +1152,10 @@ out: | |||
1302 | 1152 | ||
1303 | static void hwif_register_devices(ide_hwif_t *hwif) | 1153 | static void hwif_register_devices(ide_hwif_t *hwif) |
1304 | { | 1154 | { |
1155 | ide_drive_t *drive; | ||
1305 | unsigned int i; | 1156 | unsigned int i; |
1306 | 1157 | ||
1307 | for (i = 0; i < MAX_DRIVES; i++) { | 1158 | ide_port_for_each_dev(i, drive, hwif) { |
1308 | ide_drive_t *drive = &hwif->drives[i]; | ||
1309 | struct device *dev = &drive->gendev; | 1159 | struct device *dev = &drive->gendev; |
1310 | int ret; | 1160 | int ret; |
1311 | 1161 | ||
@@ -1328,11 +1178,10 @@ static void hwif_register_devices(ide_hwif_t *hwif) | |||
1328 | static void ide_port_init_devices(ide_hwif_t *hwif) | 1178 | static void ide_port_init_devices(ide_hwif_t *hwif) |
1329 | { | 1179 | { |
1330 | const struct ide_port_ops *port_ops = hwif->port_ops; | 1180 | const struct ide_port_ops *port_ops = hwif->port_ops; |
1181 | ide_drive_t *drive; | ||
1331 | int i; | 1182 | int i; |
1332 | 1183 | ||
1333 | for (i = 0; i < MAX_DRIVES; i++) { | 1184 | ide_port_for_each_dev(i, drive, hwif) { |
1334 | ide_drive_t *drive = &hwif->drives[i]; | ||
1335 | |||
1336 | drive->dn = i + hwif->channel * 2; | 1185 | drive->dn = i + hwif->channel * 2; |
1337 | 1186 | ||
1338 | if (hwif->host_flags & IDE_HFLAG_IO_32BIT) | 1187 | if (hwif->host_flags & IDE_HFLAG_IO_32BIT) |
@@ -1380,6 +1229,8 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | |||
1380 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) { | 1229 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) { |
1381 | int rc; | 1230 | int rc; |
1382 | 1231 | ||
1232 | hwif->dma_ops = d->dma_ops; | ||
1233 | |||
1383 | if (d->init_dma) | 1234 | if (d->init_dma) |
1384 | rc = d->init_dma(hwif, d); | 1235 | rc = d->init_dma(hwif, d); |
1385 | else | 1236 | else |
@@ -1387,12 +1238,13 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | |||
1387 | 1238 | ||
1388 | if (rc < 0) { | 1239 | if (rc < 0) { |
1389 | printk(KERN_INFO "%s: DMA disabled\n", hwif->name); | 1240 | printk(KERN_INFO "%s: DMA disabled\n", hwif->name); |
1241 | |||
1242 | hwif->dma_ops = NULL; | ||
1390 | hwif->dma_base = 0; | 1243 | hwif->dma_base = 0; |
1391 | hwif->swdma_mask = 0; | 1244 | hwif->swdma_mask = 0; |
1392 | hwif->mwdma_mask = 0; | 1245 | hwif->mwdma_mask = 0; |
1393 | hwif->ultra_mask = 0; | 1246 | hwif->ultra_mask = 0; |
1394 | } else if (d->dma_ops) | 1247 | } |
1395 | hwif->dma_ops = d->dma_ops; | ||
1396 | } | 1248 | } |
1397 | 1249 | ||
1398 | if ((d->host_flags & IDE_HFLAG_SERIALIZE) || | 1250 | if ((d->host_flags & IDE_HFLAG_SERIALIZE) || |
@@ -1417,6 +1269,66 @@ static void ide_port_cable_detect(ide_hwif_t *hwif) | |||
1417 | } | 1269 | } |
1418 | } | 1270 | } |
1419 | 1271 | ||
1272 | static const u8 ide_hwif_to_major[] = | ||
1273 | { IDE0_MAJOR, IDE1_MAJOR, IDE2_MAJOR, IDE3_MAJOR, IDE4_MAJOR, | ||
1274 | IDE5_MAJOR, IDE6_MAJOR, IDE7_MAJOR, IDE8_MAJOR, IDE9_MAJOR }; | ||
1275 | |||
1276 | static void ide_port_init_devices_data(ide_hwif_t *hwif) | ||
1277 | { | ||
1278 | ide_drive_t *drive; | ||
1279 | int i; | ||
1280 | |||
1281 | ide_port_for_each_dev(i, drive, hwif) { | ||
1282 | u8 j = (hwif->index * MAX_DRIVES) + i; | ||
1283 | |||
1284 | memset(drive, 0, sizeof(*drive)); | ||
1285 | |||
1286 | drive->media = ide_disk; | ||
1287 | drive->select = (i << 4) | ATA_DEVICE_OBS; | ||
1288 | drive->hwif = hwif; | ||
1289 | drive->ready_stat = ATA_DRDY; | ||
1290 | drive->bad_wstat = BAD_W_STAT; | ||
1291 | drive->special.b.recalibrate = 1; | ||
1292 | drive->special.b.set_geometry = 1; | ||
1293 | drive->name[0] = 'h'; | ||
1294 | drive->name[1] = 'd'; | ||
1295 | drive->name[2] = 'a' + j; | ||
1296 | drive->max_failures = IDE_DEFAULT_MAX_FAILURES; | ||
1297 | |||
1298 | INIT_LIST_HEAD(&drive->list); | ||
1299 | init_completion(&drive->gendev_rel_comp); | ||
1300 | } | ||
1301 | } | ||
1302 | |||
1303 | static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index) | ||
1304 | { | ||
1305 | /* fill in any non-zero initial values */ | ||
1306 | hwif->index = index; | ||
1307 | hwif->major = ide_hwif_to_major[index]; | ||
1308 | |||
1309 | hwif->name[0] = 'i'; | ||
1310 | hwif->name[1] = 'd'; | ||
1311 | hwif->name[2] = 'e'; | ||
1312 | hwif->name[3] = '0' + index; | ||
1313 | |||
1314 | init_completion(&hwif->gendev_rel_comp); | ||
1315 | |||
1316 | hwif->tp_ops = &default_tp_ops; | ||
1317 | |||
1318 | ide_port_init_devices_data(hwif); | ||
1319 | } | ||
1320 | |||
1321 | static void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) | ||
1322 | { | ||
1323 | memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); | ||
1324 | hwif->irq = hw->irq; | ||
1325 | hwif->chipset = hw->chipset; | ||
1326 | hwif->dev = hw->dev; | ||
1327 | hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; | ||
1328 | hwif->ack_intr = hw->ack_intr; | ||
1329 | hwif->config_data = hw->config; | ||
1330 | } | ||
1331 | |||
1420 | static unsigned int ide_indexes; | 1332 | static unsigned int ide_indexes; |
1421 | 1333 | ||
1422 | /** | 1334 | /** |
@@ -1466,12 +1378,43 @@ static void ide_free_port_slot(int idx) | |||
1466 | mutex_unlock(&ide_cfg_mtx); | 1378 | mutex_unlock(&ide_cfg_mtx); |
1467 | } | 1379 | } |
1468 | 1380 | ||
1381 | static void ide_port_free_devices(ide_hwif_t *hwif) | ||
1382 | { | ||
1383 | ide_drive_t *drive; | ||
1384 | int i; | ||
1385 | |||
1386 | ide_port_for_each_dev(i, drive, hwif) | ||
1387 | kfree(drive); | ||
1388 | } | ||
1389 | |||
1390 | static int ide_port_alloc_devices(ide_hwif_t *hwif, int node) | ||
1391 | { | ||
1392 | int i; | ||
1393 | |||
1394 | for (i = 0; i < MAX_DRIVES; i++) { | ||
1395 | ide_drive_t *drive; | ||
1396 | |||
1397 | drive = kzalloc_node(sizeof(*drive), GFP_KERNEL, node); | ||
1398 | if (drive == NULL) | ||
1399 | goto out_nomem; | ||
1400 | |||
1401 | hwif->devices[i] = drive; | ||
1402 | } | ||
1403 | return 0; | ||
1404 | |||
1405 | out_nomem: | ||
1406 | ide_port_free_devices(hwif); | ||
1407 | return -ENOMEM; | ||
1408 | } | ||
1409 | |||
1469 | struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) | 1410 | struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) |
1470 | { | 1411 | { |
1471 | struct ide_host *host; | 1412 | struct ide_host *host; |
1413 | struct device *dev = hws[0] ? hws[0]->dev : NULL; | ||
1414 | int node = dev ? dev_to_node(dev) : -1; | ||
1472 | int i; | 1415 | int i; |
1473 | 1416 | ||
1474 | host = kzalloc(sizeof(*host), GFP_KERNEL); | 1417 | host = kzalloc_node(sizeof(*host), GFP_KERNEL, node); |
1475 | if (host == NULL) | 1418 | if (host == NULL) |
1476 | return NULL; | 1419 | return NULL; |
1477 | 1420 | ||
@@ -1482,10 +1425,15 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) | |||
1482 | if (hws[i] == NULL) | 1425 | if (hws[i] == NULL) |
1483 | continue; | 1426 | continue; |
1484 | 1427 | ||
1485 | hwif = kzalloc(sizeof(*hwif), GFP_KERNEL); | 1428 | hwif = kzalloc_node(sizeof(*hwif), GFP_KERNEL, node); |
1486 | if (hwif == NULL) | 1429 | if (hwif == NULL) |
1487 | continue; | 1430 | continue; |
1488 | 1431 | ||
1432 | if (ide_port_alloc_devices(hwif, node) < 0) { | ||
1433 | kfree(hwif); | ||
1434 | continue; | ||
1435 | } | ||
1436 | |||
1489 | idx = ide_find_port_slot(d); | 1437 | idx = ide_find_port_slot(d); |
1490 | if (idx < 0) { | 1438 | if (idx < 0) { |
1491 | printk(KERN_ERR "%s: no free slot for interface\n", | 1439 | printk(KERN_ERR "%s: no free slot for interface\n", |
@@ -1507,8 +1455,7 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) | |||
1507 | return NULL; | 1455 | return NULL; |
1508 | } | 1456 | } |
1509 | 1457 | ||
1510 | if (hws[0]) | 1458 | host->dev[0] = dev; |
1511 | host->dev[0] = hws[0]->dev; | ||
1512 | 1459 | ||
1513 | if (d) { | 1460 | if (d) { |
1514 | host->init_chipset = d->init_chipset; | 1461 | host->init_chipset = d->init_chipset; |
@@ -1525,9 +1472,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1525 | ide_hwif_t *hwif, *mate = NULL; | 1472 | ide_hwif_t *hwif, *mate = NULL; |
1526 | int i, j = 0; | 1473 | int i, j = 0; |
1527 | 1474 | ||
1528 | for (i = 0; i < MAX_HOST_PORTS; i++) { | 1475 | ide_host_for_each_port(i, hwif, host) { |
1529 | hwif = host->ports[i]; | ||
1530 | |||
1531 | if (hwif == NULL) { | 1476 | if (hwif == NULL) { |
1532 | mate = NULL; | 1477 | mate = NULL; |
1533 | continue; | 1478 | continue; |
@@ -1553,9 +1498,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1553 | ide_port_init_devices(hwif); | 1498 | ide_port_init_devices(hwif); |
1554 | } | 1499 | } |
1555 | 1500 | ||
1556 | for (i = 0; i < MAX_HOST_PORTS; i++) { | 1501 | ide_host_for_each_port(i, hwif, host) { |
1557 | hwif = host->ports[i]; | ||
1558 | |||
1559 | if (hwif == NULL) | 1502 | if (hwif == NULL) |
1560 | continue; | 1503 | continue; |
1561 | 1504 | ||
@@ -1570,9 +1513,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1570 | ide_port_tune_devices(hwif); | 1513 | ide_port_tune_devices(hwif); |
1571 | } | 1514 | } |
1572 | 1515 | ||
1573 | for (i = 0; i < MAX_HOST_PORTS; i++) { | 1516 | ide_host_for_each_port(i, hwif, host) { |
1574 | hwif = host->ports[i]; | ||
1575 | |||
1576 | if (hwif == NULL) | 1517 | if (hwif == NULL) |
1577 | continue; | 1518 | continue; |
1578 | 1519 | ||
@@ -1597,9 +1538,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1597 | ide_acpi_port_init_devices(hwif); | 1538 | ide_acpi_port_init_devices(hwif); |
1598 | } | 1539 | } |
1599 | 1540 | ||
1600 | for (i = 0; i < MAX_HOST_PORTS; i++) { | 1541 | ide_host_for_each_port(i, hwif, host) { |
1601 | hwif = host->ports[i]; | ||
1602 | |||
1603 | if (hwif == NULL) | 1542 | if (hwif == NULL) |
1604 | continue; | 1543 | continue; |
1605 | 1544 | ||
@@ -1607,9 +1546,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1607 | hwif_register_devices(hwif); | 1546 | hwif_register_devices(hwif); |
1608 | } | 1547 | } |
1609 | 1548 | ||
1610 | for (i = 0; i < MAX_HOST_PORTS; i++) { | 1549 | ide_host_for_each_port(i, hwif, host) { |
1611 | hwif = host->ports[i]; | ||
1612 | |||
1613 | if (hwif == NULL) | 1550 | if (hwif == NULL) |
1614 | continue; | 1551 | continue; |
1615 | 1552 | ||
@@ -1647,17 +1584,85 @@ int ide_host_add(const struct ide_port_info *d, hw_regs_t **hws, | |||
1647 | } | 1584 | } |
1648 | EXPORT_SYMBOL_GPL(ide_host_add); | 1585 | EXPORT_SYMBOL_GPL(ide_host_add); |
1649 | 1586 | ||
1587 | static void __ide_port_unregister_devices(ide_hwif_t *hwif) | ||
1588 | { | ||
1589 | ide_drive_t *drive; | ||
1590 | int i; | ||
1591 | |||
1592 | ide_port_for_each_dev(i, drive, hwif) { | ||
1593 | if (drive->dev_flags & IDE_DFLAG_PRESENT) { | ||
1594 | device_unregister(&drive->gendev); | ||
1595 | wait_for_completion(&drive->gendev_rel_comp); | ||
1596 | } | ||
1597 | } | ||
1598 | } | ||
1599 | |||
1600 | void ide_port_unregister_devices(ide_hwif_t *hwif) | ||
1601 | { | ||
1602 | mutex_lock(&ide_cfg_mtx); | ||
1603 | __ide_port_unregister_devices(hwif); | ||
1604 | hwif->present = 0; | ||
1605 | ide_port_init_devices_data(hwif); | ||
1606 | mutex_unlock(&ide_cfg_mtx); | ||
1607 | } | ||
1608 | EXPORT_SYMBOL_GPL(ide_port_unregister_devices); | ||
1609 | |||
1610 | /** | ||
1611 | * ide_unregister - free an IDE interface | ||
1612 | * @hwif: IDE interface | ||
1613 | * | ||
1614 | * Perform the final unregister of an IDE interface. | ||
1615 | * | ||
1616 | * Locking: | ||
1617 | * The caller must not hold the IDE locks. | ||
1618 | * | ||
1619 | * It is up to the caller to be sure there is no pending I/O here, | ||
1620 | * and that the interface will not be reopened (present/vanishing | ||
1621 | * locking isn't yet done BTW). | ||
1622 | */ | ||
1623 | |||
1624 | static void ide_unregister(ide_hwif_t *hwif) | ||
1625 | { | ||
1626 | BUG_ON(in_interrupt()); | ||
1627 | BUG_ON(irqs_disabled()); | ||
1628 | |||
1629 | mutex_lock(&ide_cfg_mtx); | ||
1630 | |||
1631 | if (hwif->present) { | ||
1632 | __ide_port_unregister_devices(hwif); | ||
1633 | hwif->present = 0; | ||
1634 | } | ||
1635 | |||
1636 | ide_proc_unregister_port(hwif); | ||
1637 | |||
1638 | free_irq(hwif->irq, hwif); | ||
1639 | |||
1640 | device_unregister(hwif->portdev); | ||
1641 | device_unregister(&hwif->gendev); | ||
1642 | wait_for_completion(&hwif->gendev_rel_comp); | ||
1643 | |||
1644 | /* | ||
1645 | * Remove us from the kernel's knowledge | ||
1646 | */ | ||
1647 | blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS); | ||
1648 | kfree(hwif->sg_table); | ||
1649 | unregister_blkdev(hwif->major, hwif->name); | ||
1650 | |||
1651 | ide_release_dma_engine(hwif); | ||
1652 | |||
1653 | mutex_unlock(&ide_cfg_mtx); | ||
1654 | } | ||
1655 | |||
1650 | void ide_host_free(struct ide_host *host) | 1656 | void ide_host_free(struct ide_host *host) |
1651 | { | 1657 | { |
1652 | ide_hwif_t *hwif; | 1658 | ide_hwif_t *hwif; |
1653 | int i; | 1659 | int i; |
1654 | 1660 | ||
1655 | for (i = 0; i < MAX_HOST_PORTS; i++) { | 1661 | ide_host_for_each_port(i, hwif, host) { |
1656 | hwif = host->ports[i]; | ||
1657 | |||
1658 | if (hwif == NULL) | 1662 | if (hwif == NULL) |
1659 | continue; | 1663 | continue; |
1660 | 1664 | ||
1665 | ide_port_free_devices(hwif); | ||
1661 | ide_free_port_slot(hwif->index); | 1666 | ide_free_port_slot(hwif->index); |
1662 | kfree(hwif); | 1667 | kfree(hwif); |
1663 | } | 1668 | } |
@@ -1668,11 +1673,12 @@ EXPORT_SYMBOL_GPL(ide_host_free); | |||
1668 | 1673 | ||
1669 | void ide_host_remove(struct ide_host *host) | 1674 | void ide_host_remove(struct ide_host *host) |
1670 | { | 1675 | { |
1676 | ide_hwif_t *hwif; | ||
1671 | int i; | 1677 | int i; |
1672 | 1678 | ||
1673 | for (i = 0; i < MAX_HOST_PORTS; i++) { | 1679 | ide_host_for_each_port(i, hwif, host) { |
1674 | if (host->ports[i]) | 1680 | if (hwif) |
1675 | ide_unregister(host->ports[i]); | 1681 | ide_unregister(hwif); |
1676 | } | 1682 | } |
1677 | 1683 | ||
1678 | ide_host_free(host); | 1684 | ide_host_free(host); |
@@ -1691,8 +1697,8 @@ void ide_port_scan(ide_hwif_t *hwif) | |||
1691 | hwif->present = 1; | 1697 | hwif->present = 1; |
1692 | 1698 | ||
1693 | ide_port_tune_devices(hwif); | 1699 | ide_port_tune_devices(hwif); |
1694 | ide_acpi_port_init_devices(hwif); | ||
1695 | ide_port_setup_devices(hwif); | 1700 | ide_port_setup_devices(hwif); |
1701 | ide_acpi_port_init_devices(hwif); | ||
1696 | hwif_register_devices(hwif); | 1702 | hwif_register_devices(hwif); |
1697 | ide_proc_port_register_devices(hwif); | 1703 | ide_proc_port_register_devices(hwif); |
1698 | } | 1704 | } |
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index a14e2938e4f3..1d8978b3314a 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
@@ -439,13 +439,13 @@ static int proc_ide_read_dmodel | |||
439 | static int proc_ide_read_driver | 439 | static int proc_ide_read_driver |
440 | (char *page, char **start, off_t off, int count, int *eof, void *data) | 440 | (char *page, char **start, off_t off, int count, int *eof, void *data) |
441 | { | 441 | { |
442 | ide_drive_t *drive = (ide_drive_t *) data; | 442 | ide_drive_t *drive = (ide_drive_t *)data; |
443 | struct device *dev = &drive->gendev; | 443 | struct device *dev = &drive->gendev; |
444 | ide_driver_t *ide_drv; | 444 | struct ide_driver *ide_drv; |
445 | int len; | 445 | int len; |
446 | 446 | ||
447 | if (dev->driver) { | 447 | if (dev->driver) { |
448 | ide_drv = container_of(dev->driver, ide_driver_t, gen_driver); | 448 | ide_drv = to_ide_driver(dev->driver); |
449 | len = sprintf(page, "%s version %s\n", | 449 | len = sprintf(page, "%s version %s\n", |
450 | dev->driver->name, ide_drv->version); | 450 | dev->driver->name, ide_drv->version); |
451 | } else | 451 | } else |
@@ -555,7 +555,7 @@ static void ide_remove_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t | |||
555 | } | 555 | } |
556 | } | 556 | } |
557 | 557 | ||
558 | void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) | 558 | void ide_proc_register_driver(ide_drive_t *drive, struct ide_driver *driver) |
559 | { | 559 | { |
560 | mutex_lock(&ide_setting_mtx); | 560 | mutex_lock(&ide_setting_mtx); |
561 | drive->settings = driver->proc_devsets(drive); | 561 | drive->settings = driver->proc_devsets(drive); |
@@ -577,7 +577,7 @@ EXPORT_SYMBOL(ide_proc_register_driver); | |||
577 | * Takes ide_setting_mtx. | 577 | * Takes ide_setting_mtx. |
578 | */ | 578 | */ |
579 | 579 | ||
580 | void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) | 580 | void ide_proc_unregister_driver(ide_drive_t *drive, struct ide_driver *driver) |
581 | { | 581 | { |
582 | ide_remove_proc_entries(drive->proc, driver->proc_entries(drive)); | 582 | ide_remove_proc_entries(drive->proc, driver->proc_entries(drive)); |
583 | 583 | ||
@@ -593,14 +593,13 @@ EXPORT_SYMBOL(ide_proc_unregister_driver); | |||
593 | 593 | ||
594 | void ide_proc_port_register_devices(ide_hwif_t *hwif) | 594 | void ide_proc_port_register_devices(ide_hwif_t *hwif) |
595 | { | 595 | { |
596 | int d; | ||
597 | struct proc_dir_entry *ent; | 596 | struct proc_dir_entry *ent; |
598 | struct proc_dir_entry *parent = hwif->proc; | 597 | struct proc_dir_entry *parent = hwif->proc; |
598 | ide_drive_t *drive; | ||
599 | char name[64]; | 599 | char name[64]; |
600 | int i; | ||
600 | 601 | ||
601 | for (d = 0; d < MAX_DRIVES; d++) { | 602 | ide_port_for_each_dev(i, drive, hwif) { |
602 | ide_drive_t *drive = &hwif->drives[d]; | ||
603 | |||
604 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0 || drive->proc) | 603 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0 || drive->proc) |
605 | continue; | 604 | continue; |
606 | 605 | ||
@@ -653,7 +652,7 @@ void ide_proc_unregister_port(ide_hwif_t *hwif) | |||
653 | 652 | ||
654 | static int proc_print_driver(struct device_driver *drv, void *data) | 653 | static int proc_print_driver(struct device_driver *drv, void *data) |
655 | { | 654 | { |
656 | ide_driver_t *ide_drv = container_of(drv, ide_driver_t, gen_driver); | 655 | struct ide_driver *ide_drv = to_ide_driver(drv); |
657 | struct seq_file *s = data; | 656 | struct seq_file *s = data; |
658 | 657 | ||
659 | seq_printf(s, "%s version %s\n", drv->name, ide_drv->version); | 658 | seq_printf(s, "%s version %s\n", drv->name, ide_drv->version); |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 5d2aa22cd6e4..d7ecd3c79757 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -166,10 +166,10 @@ struct idetape_bh { | |||
166 | * to an interrupt or a timer event is stored in the struct defined below. | 166 | * to an interrupt or a timer event is stored in the struct defined below. |
167 | */ | 167 | */ |
168 | typedef struct ide_tape_obj { | 168 | typedef struct ide_tape_obj { |
169 | ide_drive_t *drive; | 169 | ide_drive_t *drive; |
170 | ide_driver_t *driver; | 170 | struct ide_driver *driver; |
171 | struct gendisk *disk; | 171 | struct gendisk *disk; |
172 | struct kref kref; | 172 | struct kref kref; |
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 |
@@ -479,7 +479,7 @@ static void ide_tape_kfree_buffer(idetape_tape_t *tape) | |||
479 | 479 | ||
480 | static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | 480 | static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) |
481 | { | 481 | { |
482 | struct request *rq = HWGROUP(drive)->rq; | 482 | struct request *rq = drive->hwif->rq; |
483 | idetape_tape_t *tape = drive->driver_data; | 483 | idetape_tape_t *tape = drive->driver_data; |
484 | unsigned long flags; | 484 | unsigned long flags; |
485 | int error; | 485 | int error; |
@@ -531,7 +531,7 @@ static void ide_tape_callback(ide_drive_t *drive, int dsc) | |||
531 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " | 531 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " |
532 | "itself - Aborting request!\n"); | 532 | "itself - Aborting request!\n"); |
533 | } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { | 533 | } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { |
534 | struct request *rq = drive->hwif->hwgroup->rq; | 534 | struct request *rq = drive->hwif->rq; |
535 | int blocks = pc->xferred / tape->blk_size; | 535 | int blocks = pc->xferred / tape->blk_size; |
536 | 536 | ||
537 | tape->avg_size += blocks * tape->blk_size; | 537 | tape->avg_size += blocks * tape->blk_size; |
@@ -576,7 +576,7 @@ static void ide_tape_callback(ide_drive_t *drive, int dsc) | |||
576 | 576 | ||
577 | /* | 577 | /* |
578 | * Postpone the current request so that ide.c will be able to service requests | 578 | * Postpone the current request so that ide.c will be able to service requests |
579 | * from another device on the same hwgroup while we are polling for DSC. | 579 | * from another device on the same port while we are polling for DSC. |
580 | */ | 580 | */ |
581 | static void idetape_postpone_request(ide_drive_t *drive) | 581 | static void idetape_postpone_request(ide_drive_t *drive) |
582 | { | 582 | { |
@@ -584,7 +584,8 @@ static void idetape_postpone_request(ide_drive_t *drive) | |||
584 | 584 | ||
585 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 585 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
586 | 586 | ||
587 | tape->postponed_rq = HWGROUP(drive)->rq; | 587 | tape->postponed_rq = drive->hwif->rq; |
588 | |||
588 | ide_stall_queue(drive, tape->dsc_poll_freq); | 589 | ide_stall_queue(drive, tape->dsc_poll_freq); |
589 | } | 590 | } |
590 | 591 | ||
@@ -2312,7 +2313,7 @@ static const struct ide_proc_devset *ide_tape_proc_devsets(ide_drive_t *drive) | |||
2312 | 2313 | ||
2313 | static int ide_tape_probe(ide_drive_t *); | 2314 | static int ide_tape_probe(ide_drive_t *); |
2314 | 2315 | ||
2315 | static ide_driver_t idetape_driver = { | 2316 | static struct ide_driver idetape_driver = { |
2316 | .gen_driver = { | 2317 | .gen_driver = { |
2317 | .owner = THIS_MODULE, | 2318 | .owner = THIS_MODULE, |
2318 | .name = "ide-tape", | 2319 | .name = "ide-tape", |
@@ -2323,7 +2324,6 @@ static ide_driver_t idetape_driver = { | |||
2323 | .version = IDETAPE_VERSION, | 2324 | .version = IDETAPE_VERSION, |
2324 | .do_request = idetape_do_request, | 2325 | .do_request = idetape_do_request, |
2325 | .end_request = idetape_end_request, | 2326 | .end_request = idetape_end_request, |
2326 | .error = __ide_error, | ||
2327 | #ifdef CONFIG_IDE_PROC_FS | 2327 | #ifdef CONFIG_IDE_PROC_FS |
2328 | .proc_entries = ide_tape_proc_entries, | 2328 | .proc_entries = ide_tape_proc_entries, |
2329 | .proc_devsets = ide_tape_proc_devsets, | 2329 | .proc_devsets = ide_tape_proc_devsets, |
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index bf4fb9d8d176..16138bce84a7 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c | |||
@@ -58,7 +58,7 @@ static ide_startstop_t task_in_intr(ide_drive_t *); | |||
58 | 58 | ||
59 | ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) | 59 | ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) |
60 | { | 60 | { |
61 | ide_hwif_t *hwif = HWIF(drive); | 61 | ide_hwif_t *hwif = drive->hwif; |
62 | struct ide_taskfile *tf = &task->tf; | 62 | struct ide_taskfile *tf = &task->tf; |
63 | ide_handler_t *handler = NULL; | 63 | ide_handler_t *handler = NULL; |
64 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 64 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
@@ -309,9 +309,9 @@ static ide_startstop_t task_error(ide_drive_t *drive, struct request *rq, | |||
309 | } | 309 | } |
310 | 310 | ||
311 | if (sectors > 0) { | 311 | if (sectors > 0) { |
312 | ide_driver_t *drv; | 312 | struct ide_driver *drv; |
313 | 313 | ||
314 | drv = *(ide_driver_t **)rq->rq_disk->private_data; | 314 | drv = *(struct ide_driver **)rq->rq_disk->private_data; |
315 | drv->end_request(drive, 1, sectors); | 315 | drv->end_request(drive, 1, sectors); |
316 | } | 316 | } |
317 | } | 317 | } |
@@ -328,9 +328,9 @@ void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat) | |||
328 | } | 328 | } |
329 | 329 | ||
330 | if (rq->rq_disk) { | 330 | if (rq->rq_disk) { |
331 | ide_driver_t *drv; | 331 | struct ide_driver *drv; |
332 | 332 | ||
333 | drv = *(ide_driver_t **)rq->rq_disk->private_data;; | 333 | drv = *(struct ide_driver **)rq->rq_disk->private_data;; |
334 | drv->end_request(drive, 1, rq->nr_sectors); | 334 | drv->end_request(drive, 1, rq->nr_sectors); |
335 | } else | 335 | } else |
336 | ide_end_request(drive, 1, rq->nr_sectors); | 336 | ide_end_request(drive, 1, rq->nr_sectors); |
@@ -361,7 +361,7 @@ static ide_startstop_t task_in_unexpected(ide_drive_t *drive, struct request *rq | |||
361 | static ide_startstop_t task_in_intr(ide_drive_t *drive) | 361 | static ide_startstop_t task_in_intr(ide_drive_t *drive) |
362 | { | 362 | { |
363 | ide_hwif_t *hwif = drive->hwif; | 363 | ide_hwif_t *hwif = drive->hwif; |
364 | struct request *rq = hwif->hwgroup->rq; | 364 | struct request *rq = hwif->rq; |
365 | u8 stat = hwif->tp_ops->read_status(hwif); | 365 | u8 stat = hwif->tp_ops->read_status(hwif); |
366 | 366 | ||
367 | /* Error? */ | 367 | /* Error? */ |
@@ -395,7 +395,7 @@ static ide_startstop_t task_in_intr(ide_drive_t *drive) | |||
395 | static ide_startstop_t task_out_intr (ide_drive_t *drive) | 395 | static ide_startstop_t task_out_intr (ide_drive_t *drive) |
396 | { | 396 | { |
397 | ide_hwif_t *hwif = drive->hwif; | 397 | ide_hwif_t *hwif = drive->hwif; |
398 | struct request *rq = HWGROUP(drive)->rq; | 398 | struct request *rq = hwif->rq; |
399 | u8 stat = hwif->tp_ops->read_status(hwif); | 399 | u8 stat = hwif->tp_ops->read_status(hwif); |
400 | 400 | ||
401 | if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) | 401 | if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) |
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 46a2d4ca812b..258805da15c3 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -60,179 +60,8 @@ | |||
60 | #include <linux/completion.h> | 60 | #include <linux/completion.h> |
61 | #include <linux/device.h> | 61 | #include <linux/device.h> |
62 | 62 | ||
63 | |||
64 | /* default maximum number of failures */ | ||
65 | #define IDE_DEFAULT_MAX_FAILURES 1 | ||
66 | |||
67 | struct class *ide_port_class; | 63 | struct class *ide_port_class; |
68 | 64 | ||
69 | static const u8 ide_hwif_to_major[] = { IDE0_MAJOR, IDE1_MAJOR, | ||
70 | IDE2_MAJOR, IDE3_MAJOR, | ||
71 | IDE4_MAJOR, IDE5_MAJOR, | ||
72 | IDE6_MAJOR, IDE7_MAJOR, | ||
73 | IDE8_MAJOR, IDE9_MAJOR }; | ||
74 | |||
75 | DEFINE_MUTEX(ide_cfg_mtx); | ||
76 | |||
77 | static void ide_port_init_devices_data(ide_hwif_t *); | ||
78 | |||
79 | /* | ||
80 | * Do not even *think* about calling this! | ||
81 | */ | ||
82 | void ide_init_port_data(ide_hwif_t *hwif, unsigned int index) | ||
83 | { | ||
84 | /* bulk initialize hwif & drive info with zeros */ | ||
85 | memset(hwif, 0, sizeof(ide_hwif_t)); | ||
86 | |||
87 | /* fill in any non-zero initial values */ | ||
88 | hwif->index = index; | ||
89 | hwif->major = ide_hwif_to_major[index]; | ||
90 | |||
91 | hwif->name[0] = 'i'; | ||
92 | hwif->name[1] = 'd'; | ||
93 | hwif->name[2] = 'e'; | ||
94 | hwif->name[3] = '0' + index; | ||
95 | |||
96 | init_completion(&hwif->gendev_rel_comp); | ||
97 | |||
98 | hwif->tp_ops = &default_tp_ops; | ||
99 | |||
100 | ide_port_init_devices_data(hwif); | ||
101 | } | ||
102 | |||
103 | static void ide_port_init_devices_data(ide_hwif_t *hwif) | ||
104 | { | ||
105 | int unit; | ||
106 | |||
107 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | ||
108 | ide_drive_t *drive = &hwif->drives[unit]; | ||
109 | u8 j = (hwif->index * MAX_DRIVES) + unit; | ||
110 | |||
111 | memset(drive, 0, sizeof(*drive)); | ||
112 | |||
113 | drive->media = ide_disk; | ||
114 | drive->select = (unit << 4) | ATA_DEVICE_OBS; | ||
115 | drive->hwif = hwif; | ||
116 | drive->ready_stat = ATA_DRDY; | ||
117 | drive->bad_wstat = BAD_W_STAT; | ||
118 | drive->special.b.recalibrate = 1; | ||
119 | drive->special.b.set_geometry = 1; | ||
120 | drive->name[0] = 'h'; | ||
121 | drive->name[1] = 'd'; | ||
122 | drive->name[2] = 'a' + j; | ||
123 | drive->max_failures = IDE_DEFAULT_MAX_FAILURES; | ||
124 | |||
125 | INIT_LIST_HEAD(&drive->list); | ||
126 | init_completion(&drive->gendev_rel_comp); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | static void __ide_port_unregister_devices(ide_hwif_t *hwif) | ||
131 | { | ||
132 | int i; | ||
133 | |||
134 | for (i = 0; i < MAX_DRIVES; i++) { | ||
135 | ide_drive_t *drive = &hwif->drives[i]; | ||
136 | |||
137 | if (drive->dev_flags & IDE_DFLAG_PRESENT) { | ||
138 | device_unregister(&drive->gendev); | ||
139 | wait_for_completion(&drive->gendev_rel_comp); | ||
140 | } | ||
141 | } | ||
142 | } | ||
143 | |||
144 | void ide_port_unregister_devices(ide_hwif_t *hwif) | ||
145 | { | ||
146 | mutex_lock(&ide_cfg_mtx); | ||
147 | __ide_port_unregister_devices(hwif); | ||
148 | hwif->present = 0; | ||
149 | ide_port_init_devices_data(hwif); | ||
150 | mutex_unlock(&ide_cfg_mtx); | ||
151 | } | ||
152 | EXPORT_SYMBOL_GPL(ide_port_unregister_devices); | ||
153 | |||
154 | /** | ||
155 | * ide_unregister - free an IDE interface | ||
156 | * @hwif: IDE interface | ||
157 | * | ||
158 | * Perform the final unregister of an IDE interface. At the moment | ||
159 | * we don't refcount interfaces so this will also get split up. | ||
160 | * | ||
161 | * Locking: | ||
162 | * The caller must not hold the IDE locks | ||
163 | * The drive present/vanishing is not yet properly locked | ||
164 | * Take care with the callbacks. These have been split to avoid | ||
165 | * deadlocking the IDE layer. The shutdown callback is called | ||
166 | * before we take the lock and free resources. It is up to the | ||
167 | * caller to be sure there is no pending I/O here, and that | ||
168 | * the interface will not be reopened (present/vanishing locking | ||
169 | * isn't yet done BTW). After we commit to the final kill we | ||
170 | * call the cleanup callback with the ide locks held. | ||
171 | * | ||
172 | * Unregister restores the hwif structures to the default state. | ||
173 | * This is raving bonkers. | ||
174 | */ | ||
175 | |||
176 | void ide_unregister(ide_hwif_t *hwif) | ||
177 | { | ||
178 | ide_hwif_t *g; | ||
179 | ide_hwgroup_t *hwgroup; | ||
180 | int irq_count = 0; | ||
181 | |||
182 | BUG_ON(in_interrupt()); | ||
183 | BUG_ON(irqs_disabled()); | ||
184 | |||
185 | mutex_lock(&ide_cfg_mtx); | ||
186 | |||
187 | if (hwif->present) { | ||
188 | __ide_port_unregister_devices(hwif); | ||
189 | hwif->present = 0; | ||
190 | } | ||
191 | |||
192 | ide_proc_unregister_port(hwif); | ||
193 | |||
194 | hwgroup = hwif->hwgroup; | ||
195 | /* | ||
196 | * free the irq if we were the only hwif using it | ||
197 | */ | ||
198 | g = hwgroup->hwif; | ||
199 | do { | ||
200 | if (g->irq == hwif->irq) | ||
201 | ++irq_count; | ||
202 | g = g->next; | ||
203 | } while (g != hwgroup->hwif); | ||
204 | if (irq_count == 1) | ||
205 | free_irq(hwif->irq, hwgroup); | ||
206 | |||
207 | ide_remove_port_from_hwgroup(hwif); | ||
208 | |||
209 | device_unregister(hwif->portdev); | ||
210 | device_unregister(&hwif->gendev); | ||
211 | wait_for_completion(&hwif->gendev_rel_comp); | ||
212 | |||
213 | /* | ||
214 | * Remove us from the kernel's knowledge | ||
215 | */ | ||
216 | blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS); | ||
217 | kfree(hwif->sg_table); | ||
218 | unregister_blkdev(hwif->major, hwif->name); | ||
219 | |||
220 | ide_release_dma_engine(hwif); | ||
221 | |||
222 | mutex_unlock(&ide_cfg_mtx); | ||
223 | } | ||
224 | |||
225 | void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) | ||
226 | { | ||
227 | memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); | ||
228 | hwif->irq = hw->irq; | ||
229 | hwif->chipset = hw->chipset; | ||
230 | hwif->dev = hw->dev; | ||
231 | hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; | ||
232 | hwif->ack_intr = hw->ack_intr; | ||
233 | hwif->config_data = hw->config; | ||
234 | } | ||
235 | |||
236 | /* | 65 | /* |
237 | * Locks for IDE setting functionality | 66 | * Locks for IDE setting functionality |
238 | */ | 67 | */ |
@@ -330,7 +159,6 @@ static int set_pio_mode_abuse(ide_hwif_t *hwif, u8 req_pio) | |||
330 | static int set_pio_mode(ide_drive_t *drive, int arg) | 159 | static int set_pio_mode(ide_drive_t *drive, int arg) |
331 | { | 160 | { |
332 | ide_hwif_t *hwif = drive->hwif; | 161 | ide_hwif_t *hwif = drive->hwif; |
333 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | ||
334 | const struct ide_port_ops *port_ops = hwif->port_ops; | 162 | const struct ide_port_ops *port_ops = hwif->port_ops; |
335 | 163 | ||
336 | if (arg < 0 || arg > 255) | 164 | if (arg < 0 || arg > 255) |
@@ -345,9 +173,9 @@ static int set_pio_mode(ide_drive_t *drive, int arg) | |||
345 | unsigned long flags; | 173 | unsigned long flags; |
346 | 174 | ||
347 | /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */ | 175 | /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */ |
348 | spin_lock_irqsave(&hwgroup->lock, flags); | 176 | spin_lock_irqsave(&hwif->lock, flags); |
349 | port_ops->set_pio_mode(drive, arg); | 177 | port_ops->set_pio_mode(drive, arg); |
350 | spin_unlock_irqrestore(&hwgroup->lock, flags); | 178 | spin_unlock_irqrestore(&hwif->lock, flags); |
351 | } else | 179 | } else |
352 | port_ops->set_pio_mode(drive, arg); | 180 | port_ops->set_pio_mode(drive, arg); |
353 | } else { | 181 | } else { |
@@ -453,7 +281,7 @@ static int ide_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
453 | static int generic_ide_probe(struct device *dev) | 281 | static int generic_ide_probe(struct device *dev) |
454 | { | 282 | { |
455 | ide_drive_t *drive = to_ide_device(dev); | 283 | ide_drive_t *drive = to_ide_device(dev); |
456 | ide_driver_t *drv = to_ide_driver(dev->driver); | 284 | struct ide_driver *drv = to_ide_driver(dev->driver); |
457 | 285 | ||
458 | return drv->probe ? drv->probe(drive) : -ENODEV; | 286 | return drv->probe ? drv->probe(drive) : -ENODEV; |
459 | } | 287 | } |
@@ -461,7 +289,7 @@ static int generic_ide_probe(struct device *dev) | |||
461 | static int generic_ide_remove(struct device *dev) | 289 | static int generic_ide_remove(struct device *dev) |
462 | { | 290 | { |
463 | ide_drive_t *drive = to_ide_device(dev); | 291 | ide_drive_t *drive = to_ide_device(dev); |
464 | ide_driver_t *drv = to_ide_driver(dev->driver); | 292 | struct ide_driver *drv = to_ide_driver(dev->driver); |
465 | 293 | ||
466 | if (drv->remove) | 294 | if (drv->remove) |
467 | drv->remove(drive); | 295 | drv->remove(drive); |
@@ -472,7 +300,7 @@ static int generic_ide_remove(struct device *dev) | |||
472 | static void generic_ide_shutdown(struct device *dev) | 300 | static void generic_ide_shutdown(struct device *dev) |
473 | { | 301 | { |
474 | ide_drive_t *drive = to_ide_device(dev); | 302 | ide_drive_t *drive = to_ide_device(dev); |
475 | ide_driver_t *drv = to_ide_driver(dev->driver); | 303 | struct ide_driver *drv = to_ide_driver(dev->driver); |
476 | 304 | ||
477 | if (dev->driver && drv->shutdown) | 305 | if (dev->driver && drv->shutdown) |
478 | drv->shutdown(drive); | 306 | drv->shutdown(drive); |
@@ -660,6 +488,7 @@ MODULE_PARM_DESC(ignore_cable, "ignore cable detection"); | |||
660 | 488 | ||
661 | void ide_port_apply_params(ide_hwif_t *hwif) | 489 | void ide_port_apply_params(ide_hwif_t *hwif) |
662 | { | 490 | { |
491 | ide_drive_t *drive; | ||
663 | int i; | 492 | int i; |
664 | 493 | ||
665 | if (ide_ignore_cable & (1 << hwif->index)) { | 494 | if (ide_ignore_cable & (1 << hwif->index)) { |
@@ -668,8 +497,8 @@ void ide_port_apply_params(ide_hwif_t *hwif) | |||
668 | hwif->cbl = ATA_CBL_PATA40_SHORT; | 497 | hwif->cbl = ATA_CBL_PATA40_SHORT; |
669 | } | 498 | } |
670 | 499 | ||
671 | for (i = 0; i < MAX_DRIVES; i++) | 500 | ide_port_for_each_dev(i, drive, hwif) |
672 | ide_dev_apply_params(&hwif->drives[i], i); | 501 | ide_dev_apply_params(drive, i); |
673 | } | 502 | } |
674 | 503 | ||
675 | /* | 504 | /* |
diff --git a/drivers/ide/it8172.c b/drivers/ide/it8172.c new file mode 100644 index 000000000000..e021078cd06b --- /dev/null +++ b/drivers/ide/it8172.c | |||
@@ -0,0 +1,166 @@ | |||
1 | /* | ||
2 | * | ||
3 | * BRIEF MODULE DESCRIPTION | ||
4 | * IT8172 IDE controller support | ||
5 | * | ||
6 | * Copyright (C) 2000 MontaVista Software Inc. | ||
7 | * Copyright (C) 2008 Shane McDonald | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License as published by the | ||
11 | * Free Software Foundation; either version 2 of the License, or (at your | ||
12 | * option) any later version. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
15 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
16 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
17 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
20 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
24 | * | ||
25 | * You should have received a copy of the GNU General Public License along | ||
26 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
27 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
28 | */ | ||
29 | |||
30 | #include <linux/module.h> | ||
31 | #include <linux/types.h> | ||
32 | #include <linux/kernel.h> | ||
33 | #include <linux/ioport.h> | ||
34 | #include <linux/pci.h> | ||
35 | #include <linux/ide.h> | ||
36 | #include <linux/init.h> | ||
37 | |||
38 | #define DRV_NAME "IT8172" | ||
39 | |||
40 | static void it8172_set_pio_mode(ide_drive_t *drive, const u8 pio) | ||
41 | { | ||
42 | ide_hwif_t *hwif = drive->hwif; | ||
43 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
44 | u16 drive_enables; | ||
45 | u32 drive_timing; | ||
46 | |||
47 | /* | ||
48 | * The highest value of DIOR/DIOW pulse width and recovery time | ||
49 | * that can be set in the IT8172 is 8 PCI clock cycles. As a result, | ||
50 | * it cannot be configured for PIO mode 0. This table sets these | ||
51 | * parameters to the maximum supported by the IT8172. | ||
52 | */ | ||
53 | static const u8 timings[] = { 0x3f, 0x3c, 0x1b, 0x12, 0x0a }; | ||
54 | |||
55 | pci_read_config_word(dev, 0x40, &drive_enables); | ||
56 | pci_read_config_dword(dev, 0x44, &drive_timing); | ||
57 | |||
58 | /* | ||
59 | * Enable port 0x44. The IT8172 spec is confused; it calls | ||
60 | * this register the "Slave IDE Timing Register", but in fact, | ||
61 | * it controls timing for both master and slave drives. | ||
62 | */ | ||
63 | drive_enables |= 0x4000; | ||
64 | |||
65 | drive_enables &= drive->dn ? 0xc006 : 0xc060; | ||
66 | if (drive->media == ide_disk) | ||
67 | /* enable prefetch */ | ||
68 | drive_enables |= 0x0004 << (drive->dn * 4); | ||
69 | if (ata_id_has_iordy(drive->id)) | ||
70 | /* enable IORDY sample-point */ | ||
71 | drive_enables |= 0x0002 << (drive->dn * 4); | ||
72 | |||
73 | drive_timing &= drive->dn ? 0x00003f00 : 0x000fc000; | ||
74 | drive_timing |= timings[pio] << (drive->dn * 6 + 8); | ||
75 | |||
76 | pci_write_config_word(dev, 0x40, drive_enables); | ||
77 | pci_write_config_dword(dev, 0x44, drive_timing); | ||
78 | } | ||
79 | |||
80 | static void it8172_set_dma_mode(ide_drive_t *drive, const u8 speed) | ||
81 | { | ||
82 | ide_hwif_t *hwif = drive->hwif; | ||
83 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
84 | int a_speed = 3 << (drive->dn * 4); | ||
85 | int u_flag = 1 << drive->dn; | ||
86 | int u_speed = 0; | ||
87 | u8 reg48, reg4a; | ||
88 | |||
89 | pci_read_config_byte(dev, 0x48, ®48); | ||
90 | pci_read_config_byte(dev, 0x4a, ®4a); | ||
91 | |||
92 | if (speed >= XFER_UDMA_0) { | ||
93 | u8 udma = speed - XFER_UDMA_0; | ||
94 | u_speed = udma << (drive->dn * 4); | ||
95 | |||
96 | pci_write_config_byte(dev, 0x48, reg48 | u_flag); | ||
97 | reg4a &= ~a_speed; | ||
98 | pci_write_config_byte(dev, 0x4a, reg4a | u_speed); | ||
99 | } else { | ||
100 | const u8 mwdma_to_pio[] = { 0, 3, 4 }; | ||
101 | u8 pio; | ||
102 | |||
103 | pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); | ||
104 | pci_write_config_byte(dev, 0x4a, reg4a & ~a_speed); | ||
105 | |||
106 | pio = mwdma_to_pio[speed - XFER_MW_DMA_0]; | ||
107 | |||
108 | it8172_set_pio_mode(drive, pio); | ||
109 | } | ||
110 | } | ||
111 | |||
112 | |||
113 | static const struct ide_port_ops it8172_port_ops = { | ||
114 | .set_pio_mode = it8172_set_pio_mode, | ||
115 | .set_dma_mode = it8172_set_dma_mode, | ||
116 | }; | ||
117 | |||
118 | static const struct ide_port_info it8172_port_info __devinitdata = { | ||
119 | .name = DRV_NAME, | ||
120 | .port_ops = &it8172_port_ops, | ||
121 | .enablebits = { {0x41, 0x80, 0x80}, {0x00, 0x00, 0x00} }, | ||
122 | .host_flags = IDE_HFLAG_SINGLE, | ||
123 | .pio_mask = ATA_PIO4 & ~ATA_PIO0, | ||
124 | .mwdma_mask = ATA_MWDMA2, | ||
125 | .udma_mask = ATA_UDMA2, | ||
126 | }; | ||
127 | |||
128 | static int __devinit it8172_init_one(struct pci_dev *dev, | ||
129 | const struct pci_device_id *id) | ||
130 | { | ||
131 | if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) | ||
132 | return -ENODEV; /* IT8172 is more than an IDE controller */ | ||
133 | return ide_pci_init_one(dev, &it8172_port_info, NULL); | ||
134 | } | ||
135 | |||
136 | static struct pci_device_id it8172_pci_tbl[] = { | ||
137 | { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8172), 0 }, | ||
138 | { 0, }, | ||
139 | }; | ||
140 | MODULE_DEVICE_TABLE(pci, it8172_pci_tbl); | ||
141 | |||
142 | static struct pci_driver it8172_pci_driver = { | ||
143 | .name = "IT8172_IDE", | ||
144 | .id_table = it8172_pci_tbl, | ||
145 | .probe = it8172_init_one, | ||
146 | .remove = ide_pci_remove, | ||
147 | .suspend = ide_pci_suspend, | ||
148 | .resume = ide_pci_resume, | ||
149 | }; | ||
150 | |||
151 | static int __init it8172_ide_init(void) | ||
152 | { | ||
153 | return ide_pci_register_driver(&it8172_pci_driver); | ||
154 | } | ||
155 | |||
156 | static void __exit it8172_ide_exit(void) | ||
157 | { | ||
158 | pci_unregister_driver(&it8172_pci_driver); | ||
159 | } | ||
160 | |||
161 | module_init(it8172_ide_init); | ||
162 | module_exit(it8172_ide_exit); | ||
163 | |||
164 | MODULE_AUTHOR("Steve Longerbeam"); | ||
165 | MODULE_DESCRIPTION("PCI driver module for ITE 8172 IDE"); | ||
166 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/ide/it8213.c b/drivers/ide/it8213.c index 7c2feeb3c5ec..d7969b6d139e 100644 --- a/drivers/ide/it8213.c +++ b/drivers/ide/it8213.c | |||
@@ -25,7 +25,7 @@ | |||
25 | 25 | ||
26 | static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio) | 26 | static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio) |
27 | { | 27 | { |
28 | ide_hwif_t *hwif = HWIF(drive); | 28 | ide_hwif_t *hwif = drive->hwif; |
29 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 29 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
30 | int is_slave = drive->dn & 1; | 30 | int is_slave = drive->dn & 1; |
31 | int master_port = 0x40; | 31 | int master_port = 0x40; |
@@ -82,7 +82,7 @@ static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
82 | 82 | ||
83 | static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) | 83 | static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) |
84 | { | 84 | { |
85 | ide_hwif_t *hwif = HWIF(drive); | 85 | ide_hwif_t *hwif = drive->hwif; |
86 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 86 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
87 | u8 maslave = 0x40; | 87 | u8 maslave = 0x40; |
88 | int a_speed = 3 << (drive->dn * 4); | 88 | int a_speed = 3 << (drive->dn * 4); |
diff --git a/drivers/ide/it821x.c b/drivers/ide/it821x.c index ef004089761b..0be27ac1f077 100644 --- a/drivers/ide/it821x.c +++ b/drivers/ide/it821x.c | |||
@@ -167,12 +167,10 @@ static void it821x_clock_strategy(ide_drive_t *drive) | |||
167 | ide_hwif_t *hwif = drive->hwif; | 167 | ide_hwif_t *hwif = drive->hwif; |
168 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 168 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
169 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); | 169 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); |
170 | ide_drive_t *pair; | 170 | ide_drive_t *pair = ide_get_pair_dev(drive); |
171 | int clock, altclock, sel = 0; | 171 | int clock, altclock, sel = 0; |
172 | u8 unit = drive->dn & 1, v; | 172 | u8 unit = drive->dn & 1, v; |
173 | 173 | ||
174 | pair = &hwif->drives[1 - unit]; | ||
175 | |||
176 | if(itdev->want[0][0] > itdev->want[1][0]) { | 174 | if(itdev->want[0][0] > itdev->want[1][0]) { |
177 | clock = itdev->want[0][1]; | 175 | clock = itdev->want[0][1]; |
178 | altclock = itdev->want[1][1]; | 176 | altclock = itdev->want[1][1]; |
@@ -239,15 +237,13 @@ static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
239 | { | 237 | { |
240 | ide_hwif_t *hwif = drive->hwif; | 238 | ide_hwif_t *hwif = drive->hwif; |
241 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); | 239 | struct it821x_dev *itdev = ide_get_hwifdata(hwif); |
242 | ide_drive_t *pair; | 240 | ide_drive_t *pair = ide_get_pair_dev(drive); |
243 | u8 unit = drive->dn & 1, set_pio = pio; | 241 | u8 unit = drive->dn & 1, set_pio = pio; |
244 | 242 | ||
245 | /* Spec says 89 ref driver uses 88 */ | 243 | /* Spec says 89 ref driver uses 88 */ |
246 | static u16 pio_timings[]= { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 }; | 244 | static u16 pio_timings[]= { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 }; |
247 | static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY }; | 245 | static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY }; |
248 | 246 | ||
249 | pair = &hwif->drives[1 - unit]; | ||
250 | |||
251 | /* | 247 | /* |
252 | * Compute the best PIO mode we can for a given device. We must | 248 | * Compute the best PIO mode we can for a given device. We must |
253 | * pick a speed that does not cause problems with the other device | 249 | * pick a speed that does not cause problems with the other device |
@@ -279,7 +275,7 @@ static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
279 | * the shared MWDMA/PIO timing register. | 275 | * the shared MWDMA/PIO timing register. |
280 | */ | 276 | */ |
281 | 277 | ||
282 | static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted) | 278 | static void it821x_tune_mwdma(ide_drive_t *drive, u8 mode_wanted) |
283 | { | 279 | { |
284 | ide_hwif_t *hwif = drive->hwif; | 280 | ide_hwif_t *hwif = drive->hwif; |
285 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 281 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -316,7 +312,7 @@ static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted) | |||
316 | * controller when doing UDMA modes in pass through. | 312 | * controller when doing UDMA modes in pass through. |
317 | */ | 313 | */ |
318 | 314 | ||
319 | static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted) | 315 | static void it821x_tune_udma(ide_drive_t *drive, u8 mode_wanted) |
320 | { | 316 | { |
321 | ide_hwif_t *hwif = drive->hwif; | 317 | ide_hwif_t *hwif = drive->hwif; |
322 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 318 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -516,6 +512,7 @@ static struct ide_dma_ops it821x_pass_through_dma_ops = { | |||
516 | .dma_test_irq = ide_dma_test_irq, | 512 | .dma_test_irq = ide_dma_test_irq, |
517 | .dma_timeout = ide_dma_timeout, | 513 | .dma_timeout = ide_dma_timeout, |
518 | .dma_lost_irq = ide_dma_lost_irq, | 514 | .dma_lost_irq = ide_dma_lost_irq, |
515 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
519 | }; | 516 | }; |
520 | 517 | ||
521 | /** | 518 | /** |
diff --git a/drivers/ide/ns87415.c b/drivers/ide/ns87415.c index 13789060f407..83643ed9a426 100644 --- a/drivers/ide/ns87415.c +++ b/drivers/ide/ns87415.c | |||
@@ -56,7 +56,7 @@ static u8 superio_read_status(ide_hwif_t *hwif) | |||
56 | return superio_ide_inb(hwif->io_ports.status_addr); | 56 | return superio_ide_inb(hwif->io_ports.status_addr); |
57 | } | 57 | } |
58 | 58 | ||
59 | static u8 superio_read_sff_dma_status(ide_hwif_t *hwif) | 59 | static u8 superio_dma_sff_read_status(ide_hwif_t *hwif) |
60 | { | 60 | { |
61 | return superio_ide_inb(hwif->dma_base + ATA_DMA_STATUS); | 61 | return superio_ide_inb(hwif->dma_base + ATA_DMA_STATUS); |
62 | } | 62 | } |
@@ -109,7 +109,6 @@ static const struct ide_tp_ops superio_tp_ops = { | |||
109 | .exec_command = ide_exec_command, | 109 | .exec_command = ide_exec_command, |
110 | .read_status = superio_read_status, | 110 | .read_status = superio_read_status, |
111 | .read_altstatus = ide_read_altstatus, | 111 | .read_altstatus = ide_read_altstatus, |
112 | .read_sff_dma_status = superio_read_sff_dma_status, | ||
113 | 112 | ||
114 | .set_irq = ide_set_irq, | 113 | .set_irq = ide_set_irq, |
115 | 114 | ||
@@ -132,18 +131,20 @@ static void __devinit superio_init_iops(struct hwif_s *hwif) | |||
132 | tmp = superio_ide_inb(dma_stat); | 131 | tmp = superio_ide_inb(dma_stat); |
133 | outb(tmp | 0x66, dma_stat); | 132 | outb(tmp | 0x66, dma_stat); |
134 | } | 133 | } |
134 | #else | ||
135 | #define superio_dma_sff_read_status ide_dma_sff_read_status | ||
135 | #endif | 136 | #endif |
136 | 137 | ||
137 | static unsigned int ns87415_count = 0, ns87415_control[MAX_HWIFS] = { 0 }; | 138 | static unsigned int ns87415_count = 0, ns87415_control[MAX_HWIFS] = { 0 }; |
138 | 139 | ||
139 | /* | 140 | /* |
140 | * This routine either enables/disables (according to IDE_DFLAG_PRESENT) | 141 | * This routine either enables/disables (according to IDE_DFLAG_PRESENT) |
141 | * the IRQ associated with the port (HWIF(drive)), | 142 | * the IRQ associated with the port, |
142 | * and selects either PIO or DMA handshaking for the next I/O operation. | 143 | * and selects either PIO or DMA handshaking for the next I/O operation. |
143 | */ | 144 | */ |
144 | static void ns87415_prepare_drive (ide_drive_t *drive, unsigned int use_dma) | 145 | static void ns87415_prepare_drive (ide_drive_t *drive, unsigned int use_dma) |
145 | { | 146 | { |
146 | ide_hwif_t *hwif = HWIF(drive); | 147 | ide_hwif_t *hwif = drive->hwif; |
147 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 148 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
148 | unsigned int bit, other, new, *old = (unsigned int *) hwif->select_data; | 149 | unsigned int bit, other, new, *old = (unsigned int *) hwif->select_data; |
149 | unsigned long flags; | 150 | unsigned long flags; |
@@ -197,11 +198,11 @@ static void ns87415_selectproc (ide_drive_t *drive) | |||
197 | 198 | ||
198 | static int ns87415_dma_end(ide_drive_t *drive) | 199 | static int ns87415_dma_end(ide_drive_t *drive) |
199 | { | 200 | { |
200 | ide_hwif_t *hwif = HWIF(drive); | 201 | ide_hwif_t *hwif = drive->hwif; |
201 | u8 dma_stat = 0, dma_cmd = 0; | 202 | u8 dma_stat = 0, dma_cmd = 0; |
202 | 203 | ||
203 | drive->waiting_for_dma = 0; | 204 | drive->waiting_for_dma = 0; |
204 | dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); | 205 | dma_stat = hwif->dma_ops->dma_sff_read_status(hwif); |
205 | /* get DMA command mode */ | 206 | /* get DMA command mode */ |
206 | dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); | 207 | dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); |
207 | /* stop DMA */ | 208 | /* stop DMA */ |
@@ -308,6 +309,7 @@ static const struct ide_dma_ops ns87415_dma_ops = { | |||
308 | .dma_test_irq = ide_dma_test_irq, | 309 | .dma_test_irq = ide_dma_test_irq, |
309 | .dma_lost_irq = ide_dma_lost_irq, | 310 | .dma_lost_irq = ide_dma_lost_irq, |
310 | .dma_timeout = ide_dma_timeout, | 311 | .dma_timeout = ide_dma_timeout, |
312 | .dma_sff_read_status = superio_dma_sff_read_status, | ||
311 | }; | 313 | }; |
312 | 314 | ||
313 | static const struct ide_port_info ns87415_chipset __devinitdata = { | 315 | static const struct ide_port_info ns87415_chipset __devinitdata = { |
diff --git a/drivers/ide/palm_bk3710.c b/drivers/ide/palm_bk3710.c index 122ed3c072fd..a7ac490c9ae3 100644 --- a/drivers/ide/palm_bk3710.c +++ b/drivers/ide/palm_bk3710.c | |||
@@ -324,8 +324,6 @@ static int __devinit palm_bk3710_init_dma(ide_hwif_t *hwif, | |||
324 | 324 | ||
325 | hwif->dma_base = hwif->io_ports.data_addr - IDE_PALM_ATA_PRI_REG_OFFSET; | 325 | hwif->dma_base = hwif->io_ports.data_addr - IDE_PALM_ATA_PRI_REG_OFFSET; |
326 | 326 | ||
327 | hwif->dma_ops = &sff_dma_ops; | ||
328 | |||
329 | return 0; | 327 | return 0; |
330 | } | 328 | } |
331 | 329 | ||
@@ -338,6 +336,7 @@ static const struct ide_port_ops palm_bk3710_ports_ops = { | |||
338 | static struct ide_port_info __devinitdata palm_bk3710_port_info = { | 336 | static struct ide_port_info __devinitdata palm_bk3710_port_info = { |
339 | .init_dma = palm_bk3710_init_dma, | 337 | .init_dma = palm_bk3710_init_dma, |
340 | .port_ops = &palm_bk3710_ports_ops, | 338 | .port_ops = &palm_bk3710_ports_ops, |
339 | .dma_ops = &sff_dma_ops, | ||
341 | .host_flags = IDE_HFLAG_MMIO, | 340 | .host_flags = IDE_HFLAG_MMIO, |
342 | .pio_mask = ATA_PIO4, | 341 | .pio_mask = ATA_PIO4, |
343 | .mwdma_mask = ATA_MWDMA2, | 342 | .mwdma_mask = ATA_MWDMA2, |
diff --git a/drivers/ide/pdc202xx_new.c b/drivers/ide/pdc202xx_new.c index 211ae46e3e0c..f21290c4b447 100644 --- a/drivers/ide/pdc202xx_new.c +++ b/drivers/ide/pdc202xx_new.c | |||
@@ -143,7 +143,7 @@ static struct udma_timing { | |||
143 | 143 | ||
144 | static void pdcnew_set_dma_mode(ide_drive_t *drive, const u8 speed) | 144 | static void pdcnew_set_dma_mode(ide_drive_t *drive, const u8 speed) |
145 | { | 145 | { |
146 | ide_hwif_t *hwif = HWIF(drive); | 146 | ide_hwif_t *hwif = drive->hwif; |
147 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 147 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
148 | u8 adj = (drive->dn & 1) ? 0x08 : 0x00; | 148 | u8 adj = (drive->dn & 1) ? 0x08 : 0x00; |
149 | 149 | ||
@@ -219,7 +219,7 @@ static void pdcnew_reset(ide_drive_t *drive) | |||
219 | * Deleted this because it is redundant from the caller. | 219 | * Deleted this because it is redundant from the caller. |
220 | */ | 220 | */ |
221 | printk(KERN_WARNING "pdc202xx_new: %s channel reset.\n", | 221 | printk(KERN_WARNING "pdc202xx_new: %s channel reset.\n", |
222 | HWIF(drive)->channel ? "Secondary" : "Primary"); | 222 | drive->hwif->channel ? "Secondary" : "Primary"); |
223 | } | 223 | } |
224 | 224 | ||
225 | /** | 225 | /** |
diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c index 624e62e5cc9a..97193323aebf 100644 --- a/drivers/ide/pdc202xx_old.c +++ b/drivers/ide/pdc202xx_old.c | |||
@@ -39,7 +39,7 @@ static void pdc_old_disable_66MHz_clock(ide_hwif_t *); | |||
39 | 39 | ||
40 | static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed) | 40 | static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed) |
41 | { | 41 | { |
42 | ide_hwif_t *hwif = HWIF(drive); | 42 | ide_hwif_t *hwif = drive->hwif; |
43 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 43 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
44 | u8 drive_pci = 0x60 + (drive->dn << 2); | 44 | u8 drive_pci = 0x60 + (drive->dn << 2); |
45 | 45 | ||
@@ -169,8 +169,8 @@ static void pdc202xx_dma_start(ide_drive_t *drive) | |||
169 | if (drive->current_speed > XFER_UDMA_2) | 169 | if (drive->current_speed > XFER_UDMA_2) |
170 | pdc_old_enable_66MHz_clock(drive->hwif); | 170 | pdc_old_enable_66MHz_clock(drive->hwif); |
171 | if (drive->media != ide_disk || (drive->dev_flags & IDE_DFLAG_LBA48)) { | 171 | if (drive->media != ide_disk || (drive->dev_flags & IDE_DFLAG_LBA48)) { |
172 | struct request *rq = HWGROUP(drive)->rq; | 172 | ide_hwif_t *hwif = drive->hwif; |
173 | ide_hwif_t *hwif = HWIF(drive); | 173 | struct request *rq = hwif->rq; |
174 | unsigned long high_16 = hwif->extra_base - 16; | 174 | unsigned long high_16 = hwif->extra_base - 16; |
175 | unsigned long atapi_reg = high_16 + (hwif->channel ? 0x24 : 0x20); | 175 | unsigned long atapi_reg = high_16 + (hwif->channel ? 0x24 : 0x20); |
176 | u32 word_count = 0; | 176 | u32 word_count = 0; |
@@ -189,7 +189,7 @@ static void pdc202xx_dma_start(ide_drive_t *drive) | |||
189 | static int pdc202xx_dma_end(ide_drive_t *drive) | 189 | static int pdc202xx_dma_end(ide_drive_t *drive) |
190 | { | 190 | { |
191 | if (drive->media != ide_disk || (drive->dev_flags & IDE_DFLAG_LBA48)) { | 191 | if (drive->media != ide_disk || (drive->dev_flags & IDE_DFLAG_LBA48)) { |
192 | ide_hwif_t *hwif = HWIF(drive); | 192 | ide_hwif_t *hwif = drive->hwif; |
193 | unsigned long high_16 = hwif->extra_base - 16; | 193 | unsigned long high_16 = hwif->extra_base - 16; |
194 | unsigned long atapi_reg = high_16 + (hwif->channel ? 0x24 : 0x20); | 194 | unsigned long atapi_reg = high_16 + (hwif->channel ? 0x24 : 0x20); |
195 | u8 clock = 0; | 195 | u8 clock = 0; |
@@ -205,7 +205,7 @@ static int pdc202xx_dma_end(ide_drive_t *drive) | |||
205 | 205 | ||
206 | static int pdc202xx_dma_test_irq(ide_drive_t *drive) | 206 | static int pdc202xx_dma_test_irq(ide_drive_t *drive) |
207 | { | 207 | { |
208 | ide_hwif_t *hwif = HWIF(drive); | 208 | ide_hwif_t *hwif = drive->hwif; |
209 | unsigned long high_16 = hwif->extra_base - 16; | 209 | unsigned long high_16 = hwif->extra_base - 16; |
210 | u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); | 210 | u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); |
211 | u8 sc1d = inb(high_16 + 0x001d); | 211 | u8 sc1d = inb(high_16 + 0x001d); |
@@ -243,7 +243,7 @@ static void pdc202xx_reset_host (ide_hwif_t *hwif) | |||
243 | 243 | ||
244 | static void pdc202xx_reset (ide_drive_t *drive) | 244 | static void pdc202xx_reset (ide_drive_t *drive) |
245 | { | 245 | { |
246 | ide_hwif_t *hwif = HWIF(drive); | 246 | ide_hwif_t *hwif = drive->hwif; |
247 | ide_hwif_t *mate = hwif->mate; | 247 | ide_hwif_t *mate = hwif->mate; |
248 | 248 | ||
249 | pdc202xx_reset_host(hwif); | 249 | pdc202xx_reset_host(hwif); |
@@ -337,6 +337,7 @@ static const struct ide_dma_ops pdc20246_dma_ops = { | |||
337 | .dma_test_irq = pdc202xx_dma_test_irq, | 337 | .dma_test_irq = pdc202xx_dma_test_irq, |
338 | .dma_lost_irq = pdc202xx_dma_lost_irq, | 338 | .dma_lost_irq = pdc202xx_dma_lost_irq, |
339 | .dma_timeout = pdc202xx_dma_timeout, | 339 | .dma_timeout = pdc202xx_dma_timeout, |
340 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
340 | }; | 341 | }; |
341 | 342 | ||
342 | static const struct ide_dma_ops pdc2026x_dma_ops = { | 343 | static const struct ide_dma_ops pdc2026x_dma_ops = { |
@@ -348,6 +349,7 @@ static const struct ide_dma_ops pdc2026x_dma_ops = { | |||
348 | .dma_test_irq = pdc202xx_dma_test_irq, | 349 | .dma_test_irq = pdc202xx_dma_test_irq, |
349 | .dma_lost_irq = pdc202xx_dma_lost_irq, | 350 | .dma_lost_irq = pdc202xx_dma_lost_irq, |
350 | .dma_timeout = pdc202xx_dma_timeout, | 351 | .dma_timeout = pdc202xx_dma_timeout, |
352 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
351 | }; | 353 | }; |
352 | 354 | ||
353 | #define DECLARE_PDC2026X_DEV(udma, sectors) \ | 355 | #define DECLARE_PDC2026X_DEV(udma, sectors) \ |
diff --git a/drivers/ide/piix.c b/drivers/ide/piix.c index 61d2d920a5cd..f1e2e4ef0d71 100644 --- a/drivers/ide/piix.c +++ b/drivers/ide/piix.c | |||
@@ -67,7 +67,7 @@ static int no_piix_dma; | |||
67 | 67 | ||
68 | static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio) | 68 | static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio) |
69 | { | 69 | { |
70 | ide_hwif_t *hwif = HWIF(drive); | 70 | ide_hwif_t *hwif = drive->hwif; |
71 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 71 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
72 | int is_slave = drive->dn & 1; | 72 | int is_slave = drive->dn & 1; |
73 | int master_port = hwif->channel ? 0x42 : 0x40; | 73 | int master_port = hwif->channel ? 0x42 : 0x40; |
@@ -136,7 +136,7 @@ static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
136 | 136 | ||
137 | static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) | 137 | static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) |
138 | { | 138 | { |
139 | ide_hwif_t *hwif = HWIF(drive); | 139 | ide_hwif_t *hwif = drive->hwif; |
140 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 140 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
141 | u8 maslave = hwif->channel ? 0x42 : 0x40; | 141 | u8 maslave = hwif->channel ? 0x42 : 0x40; |
142 | int a_speed = 3 << (drive->dn * 4); | 142 | int a_speed = 3 << (drive->dn * 4); |
@@ -224,7 +224,7 @@ static unsigned int init_chipset_ich(struct pci_dev *dev) | |||
224 | */ | 224 | */ |
225 | static void ich_clear_irq(ide_drive_t *drive) | 225 | static void ich_clear_irq(ide_drive_t *drive) |
226 | { | 226 | { |
227 | ide_hwif_t *hwif = HWIF(drive); | 227 | ide_hwif_t *hwif = drive->hwif; |
228 | u8 dma_stat; | 228 | u8 dma_stat; |
229 | 229 | ||
230 | /* | 230 | /* |
@@ -260,6 +260,8 @@ static const struct ich_laptop ich_laptop[] = { | |||
260 | { 0x27DF, 0x103C, 0x30A1 }, /* ICH7 on HP Compaq nc2400 */ | 260 | { 0x27DF, 0x103C, 0x30A1 }, /* ICH7 on HP Compaq nc2400 */ |
261 | { 0x27DF, 0x1071, 0xD221 }, /* ICH7 on Hercules EC-900 */ | 261 | { 0x27DF, 0x1071, 0xD221 }, /* ICH7 on Hercules EC-900 */ |
262 | { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on Acer Aspire 2023WLMi */ | 262 | { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on Acer Aspire 2023WLMi */ |
263 | { 0x24CA, 0x1025, 0x003d }, /* ICH4 on ACER TM290 */ | ||
264 | { 0x266F, 0x1025, 0x0066 }, /* ICH6 on ACER Aspire 1694WLMi */ | ||
263 | { 0x2653, 0x1043, 0x82D8 }, /* ICH6M on Asus Eee 701 */ | 265 | { 0x2653, 0x1043, 0x82D8 }, /* ICH6M on Asus Eee 701 */ |
264 | /* end marker */ | 266 | /* end marker */ |
265 | { 0, } | 267 | { 0, } |
diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.c index 7c481bb56fab..74625e821a43 100644 --- a/drivers/ide/pmac.c +++ b/drivers/ide/pmac.c | |||
@@ -955,7 +955,6 @@ static const struct ide_tp_ops pmac_tp_ops = { | |||
955 | .exec_command = pmac_exec_command, | 955 | .exec_command = pmac_exec_command, |
956 | .read_status = ide_read_status, | 956 | .read_status = ide_read_status, |
957 | .read_altstatus = ide_read_altstatus, | 957 | .read_altstatus = ide_read_altstatus, |
958 | .read_sff_dma_status = ide_read_sff_dma_status, | ||
959 | 958 | ||
960 | .set_irq = pmac_set_irq, | 959 | .set_irq = pmac_set_irq, |
961 | 960 | ||
@@ -1513,10 +1512,10 @@ use_pio_instead: | |||
1513 | static int | 1512 | static int |
1514 | pmac_ide_dma_setup(ide_drive_t *drive) | 1513 | pmac_ide_dma_setup(ide_drive_t *drive) |
1515 | { | 1514 | { |
1516 | ide_hwif_t *hwif = HWIF(drive); | 1515 | ide_hwif_t *hwif = drive->hwif; |
1517 | pmac_ide_hwif_t *pmif = | 1516 | pmac_ide_hwif_t *pmif = |
1518 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); | 1517 | (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); |
1519 | struct request *rq = HWGROUP(drive)->rq; | 1518 | struct request *rq = hwif->rq; |
1520 | u8 unit = drive->dn & 1, ata4 = (pmif->kind == controller_kl_ata4); | 1519 | u8 unit = drive->dn & 1, ata4 = (pmif->kind == controller_kl_ata4); |
1521 | 1520 | ||
1522 | if (!pmac_ide_build_dmatable(drive, rq)) { | 1521 | if (!pmac_ide_build_dmatable(drive, rq)) { |
@@ -1637,7 +1636,7 @@ pmac_ide_dma_test_irq (ide_drive_t *drive) | |||
1637 | break; | 1636 | break; |
1638 | if (++timeout > 100) { | 1637 | if (++timeout > 100) { |
1639 | printk(KERN_WARNING "ide%d, ide_dma_test_irq \ | 1638 | printk(KERN_WARNING "ide%d, ide_dma_test_irq \ |
1640 | timeout flushing channel\n", HWIF(drive)->index); | 1639 | timeout flushing channel\n", hwif->index); |
1641 | break; | 1640 | break; |
1642 | } | 1641 | } |
1643 | } | 1642 | } |
diff --git a/drivers/ide/q40ide.c b/drivers/ide/q40ide.c index 4af4a8ce4cdf..9f9c0b3cc3a3 100644 --- a/drivers/ide/q40ide.c +++ b/drivers/ide/q40ide.c | |||
@@ -99,7 +99,6 @@ static const struct ide_tp_ops q40ide_tp_ops = { | |||
99 | .exec_command = ide_exec_command, | 99 | .exec_command = ide_exec_command, |
100 | .read_status = ide_read_status, | 100 | .read_status = ide_read_status, |
101 | .read_altstatus = ide_read_altstatus, | 101 | .read_altstatus = ide_read_altstatus, |
102 | .read_sff_dma_status = ide_read_sff_dma_status, | ||
103 | 102 | ||
104 | .set_irq = ide_set_irq, | 103 | .set_irq = ide_set_irq, |
105 | 104 | ||
diff --git a/drivers/ide/qd65xx.c b/drivers/ide/qd65xx.c index bc27c7aba936..5b2e3af43c4b 100644 --- a/drivers/ide/qd65xx.c +++ b/drivers/ide/qd65xx.c | |||
@@ -202,7 +202,8 @@ static void qd6500_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
202 | recovery_time = drive->id[ATA_ID_EIDE_PIO] - 120; | 202 | recovery_time = drive->id[ATA_ID_EIDE_PIO] - 120; |
203 | } | 203 | } |
204 | 204 | ||
205 | qd_set_timing(drive, qd6500_compute_timing(HWIF(drive), active_time, recovery_time)); | 205 | qd_set_timing(drive, qd6500_compute_timing(drive->hwif, |
206 | active_time, recovery_time)); | ||
206 | } | 207 | } |
207 | 208 | ||
208 | static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio) | 209 | static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio) |
@@ -245,11 +246,11 @@ static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
245 | printk(KERN_INFO "%s: PIO mode%d\n", drive->name,pio); | 246 | printk(KERN_INFO "%s: PIO mode%d\n", drive->name,pio); |
246 | } | 247 | } |
247 | 248 | ||
248 | if (!HWIF(drive)->channel && drive->media != ide_disk) { | 249 | if (!hwif->channel && drive->media != ide_disk) { |
249 | outb(0x5f, QD_CONTROL_PORT); | 250 | outb(0x5f, QD_CONTROL_PORT); |
250 | printk(KERN_WARNING "%s: ATAPI: disabled read-ahead FIFO " | 251 | printk(KERN_WARNING "%s: ATAPI: disabled read-ahead FIFO " |
251 | "and post-write buffer on %s.\n", | 252 | "and post-write buffer on %s.\n", |
252 | drive->name, HWIF(drive)->name); | 253 | drive->name, hwif->name); |
253 | } | 254 | } |
254 | 255 | ||
255 | qd_set_timing(drive, qd6580_compute_timing(active_time, recovery_time)); | 256 | qd_set_timing(drive, qd6580_compute_timing(active_time, recovery_time)); |
diff --git a/drivers/ide/qd65xx.h b/drivers/ide/qd65xx.h index c83dea85e621..6636f9665d16 100644 --- a/drivers/ide/qd65xx.h +++ b/drivers/ide/qd65xx.h | |||
@@ -31,8 +31,8 @@ | |||
31 | 31 | ||
32 | #define QD_CONFIG(hwif) ((hwif)->config_data & 0x00ff) | 32 | #define QD_CONFIG(hwif) ((hwif)->config_data & 0x00ff) |
33 | 33 | ||
34 | #define QD_TIMING(drive) (byte)(((drive)->drive_data) & 0x00ff) | 34 | #define QD_TIMING(drive) (u8)(((drive)->drive_data) & 0x00ff) |
35 | #define QD_TIMREG(drive) (byte)((((drive)->drive_data) & 0xff00) >> 8) | 35 | #define QD_TIMREG(drive) (u8)((((drive)->drive_data) & 0xff00) >> 8) |
36 | 36 | ||
37 | #define QD6500_DEF_DATA ((QD_TIM1_PORT<<8) | (QD_ID3 ? 0x0c : 0x08)) | 37 | #define QD6500_DEF_DATA ((QD_TIM1_PORT<<8) | (QD_ID3 ? 0x0c : 0x08)) |
38 | #define QD6580_DEF_DATA ((QD_TIM1_PORT<<8) | (QD_ID3 ? 0x0a : 0x00)) | 38 | #define QD6580_DEF_DATA ((QD_TIM1_PORT<<8) | (QD_ID3 ? 0x0a : 0x00)) |
diff --git a/drivers/ide/sc1200.c b/drivers/ide/sc1200.c index ec7f766ef5e4..dbdd2985a0d8 100644 --- a/drivers/ide/sc1200.c +++ b/drivers/ide/sc1200.c | |||
@@ -125,7 +125,7 @@ out: | |||
125 | 125 | ||
126 | static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode) | 126 | static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode) |
127 | { | 127 | { |
128 | ide_hwif_t *hwif = HWIF(drive); | 128 | ide_hwif_t *hwif = drive->hwif; |
129 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 129 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
130 | unsigned int reg, timings; | 130 | unsigned int reg, timings; |
131 | unsigned short pci_clock; | 131 | unsigned short pci_clock; |
@@ -170,9 +170,9 @@ static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
170 | */ | 170 | */ |
171 | static int sc1200_dma_end(ide_drive_t *drive) | 171 | static int sc1200_dma_end(ide_drive_t *drive) |
172 | { | 172 | { |
173 | ide_hwif_t *hwif = HWIF(drive); | 173 | ide_hwif_t *hwif = drive->hwif; |
174 | unsigned long dma_base = hwif->dma_base; | 174 | unsigned long dma_base = hwif->dma_base; |
175 | byte dma_stat; | 175 | u8 dma_stat; |
176 | 176 | ||
177 | dma_stat = inb(dma_base+2); /* get DMA status */ | 177 | dma_stat = inb(dma_base+2); /* get DMA status */ |
178 | 178 | ||
@@ -199,7 +199,7 @@ static int sc1200_dma_end(ide_drive_t *drive) | |||
199 | 199 | ||
200 | static void sc1200_set_pio_mode(ide_drive_t *drive, const u8 pio) | 200 | static void sc1200_set_pio_mode(ide_drive_t *drive, const u8 pio) |
201 | { | 201 | { |
202 | ide_hwif_t *hwif = HWIF(drive); | 202 | ide_hwif_t *hwif = drive->hwif; |
203 | int mode = -1; | 203 | int mode = -1; |
204 | 204 | ||
205 | /* | 205 | /* |
@@ -292,6 +292,7 @@ static const struct ide_dma_ops sc1200_dma_ops = { | |||
292 | .dma_test_irq = ide_dma_test_irq, | 292 | .dma_test_irq = ide_dma_test_irq, |
293 | .dma_lost_irq = ide_dma_lost_irq, | 293 | .dma_lost_irq = ide_dma_lost_irq, |
294 | .dma_timeout = ide_dma_timeout, | 294 | .dma_timeout = ide_dma_timeout, |
295 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
295 | }; | 296 | }; |
296 | 297 | ||
297 | static const struct ide_port_info sc1200_chipset __devinitdata = { | 298 | static const struct ide_port_info sc1200_chipset __devinitdata = { |
diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c index 0f48f9dacfa5..8d2314b6327c 100644 --- a/drivers/ide/scc_pata.c +++ b/drivers/ide/scc_pata.c | |||
@@ -143,7 +143,7 @@ static u8 scc_read_altstatus(ide_hwif_t *hwif) | |||
143 | return (u8)in_be32((void *)hwif->io_ports.ctl_addr); | 143 | return (u8)in_be32((void *)hwif->io_ports.ctl_addr); |
144 | } | 144 | } |
145 | 145 | ||
146 | static u8 scc_read_sff_dma_status(ide_hwif_t *hwif) | 146 | static u8 scc_dma_sff_read_status(ide_hwif_t *hwif) |
147 | { | 147 | { |
148 | return (u8)in_be32((void *)(hwif->dma_base + 4)); | 148 | return (u8)in_be32((void *)(hwif->dma_base + 4)); |
149 | } | 149 | } |
@@ -217,7 +217,7 @@ scc_ide_outsl(unsigned long port, void *addr, u32 count) | |||
217 | 217 | ||
218 | static void scc_set_pio_mode(ide_drive_t *drive, const u8 pio) | 218 | static void scc_set_pio_mode(ide_drive_t *drive, const u8 pio) |
219 | { | 219 | { |
220 | ide_hwif_t *hwif = HWIF(drive); | 220 | ide_hwif_t *hwif = drive->hwif; |
221 | struct scc_ports *ports = ide_get_hwifdata(hwif); | 221 | struct scc_ports *ports = ide_get_hwifdata(hwif); |
222 | unsigned long ctl_base = ports->ctl; | 222 | unsigned long ctl_base = ports->ctl; |
223 | unsigned long cckctrl_port = ctl_base + 0xff0; | 223 | unsigned long cckctrl_port = ctl_base + 0xff0; |
@@ -249,7 +249,7 @@ static void scc_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
249 | 249 | ||
250 | static void scc_set_dma_mode(ide_drive_t *drive, const u8 speed) | 250 | static void scc_set_dma_mode(ide_drive_t *drive, const u8 speed) |
251 | { | 251 | { |
252 | ide_hwif_t *hwif = HWIF(drive); | 252 | ide_hwif_t *hwif = drive->hwif; |
253 | struct scc_ports *ports = ide_get_hwifdata(hwif); | 253 | struct scc_ports *ports = ide_get_hwifdata(hwif); |
254 | unsigned long ctl_base = ports->ctl; | 254 | unsigned long ctl_base = ports->ctl; |
255 | unsigned long cckctrl_port = ctl_base + 0xff0; | 255 | unsigned long cckctrl_port = ctl_base + 0xff0; |
@@ -259,7 +259,7 @@ static void scc_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
259 | unsigned long scrcst_port = ctl_base + 0x014; | 259 | unsigned long scrcst_port = ctl_base + 0x014; |
260 | unsigned long udenvt_port = ctl_base + 0x018; | 260 | unsigned long udenvt_port = ctl_base + 0x018; |
261 | unsigned long tdvhsel_port = ctl_base + 0x020; | 261 | unsigned long tdvhsel_port = ctl_base + 0x020; |
262 | int is_slave = (&hwif->drives[1] == drive); | 262 | int is_slave = drive->dn & 1; |
263 | int offset, idx; | 263 | int offset, idx; |
264 | unsigned long reg; | 264 | unsigned long reg; |
265 | unsigned long jcactsel; | 265 | unsigned long jcactsel; |
@@ -292,7 +292,7 @@ static void scc_dma_host_set(ide_drive_t *drive, int on) | |||
292 | { | 292 | { |
293 | ide_hwif_t *hwif = drive->hwif; | 293 | ide_hwif_t *hwif = drive->hwif; |
294 | u8 unit = drive->dn & 1; | 294 | u8 unit = drive->dn & 1; |
295 | u8 dma_stat = scc_ide_inb(hwif->dma_base + 4); | 295 | u8 dma_stat = scc_dma_sff_read_status(hwif); |
296 | 296 | ||
297 | if (on) | 297 | if (on) |
298 | dma_stat |= (1 << (5 + unit)); | 298 | dma_stat |= (1 << (5 + unit)); |
@@ -316,7 +316,7 @@ static void scc_dma_host_set(ide_drive_t *drive, int on) | |||
316 | static int scc_dma_setup(ide_drive_t *drive) | 316 | static int scc_dma_setup(ide_drive_t *drive) |
317 | { | 317 | { |
318 | ide_hwif_t *hwif = drive->hwif; | 318 | ide_hwif_t *hwif = drive->hwif; |
319 | struct request *rq = HWGROUP(drive)->rq; | 319 | struct request *rq = hwif->rq; |
320 | unsigned int reading; | 320 | unsigned int reading; |
321 | u8 dma_stat; | 321 | u8 dma_stat; |
322 | 322 | ||
@@ -338,7 +338,7 @@ static int scc_dma_setup(ide_drive_t *drive) | |||
338 | out_be32((void __iomem *)hwif->dma_base, reading); | 338 | out_be32((void __iomem *)hwif->dma_base, reading); |
339 | 339 | ||
340 | /* read DMA status for INTR & ERROR flags */ | 340 | /* read DMA status for INTR & ERROR flags */ |
341 | dma_stat = in_be32((void __iomem *)(hwif->dma_base + 4)); | 341 | dma_stat = scc_dma_sff_read_status(hwif); |
342 | 342 | ||
343 | /* clear INTR & ERROR flags */ | 343 | /* clear INTR & ERROR flags */ |
344 | out_be32((void __iomem *)(hwif->dma_base + 4), dma_stat | 6); | 344 | out_be32((void __iomem *)(hwif->dma_base + 4), dma_stat | 6); |
@@ -367,7 +367,7 @@ static int __scc_dma_end(ide_drive_t *drive) | |||
367 | /* stop DMA */ | 367 | /* stop DMA */ |
368 | scc_ide_outb(dma_cmd & ~1, hwif->dma_base); | 368 | scc_ide_outb(dma_cmd & ~1, hwif->dma_base); |
369 | /* get DMA status */ | 369 | /* get DMA status */ |
370 | dma_stat = scc_ide_inb(hwif->dma_base + 4); | 370 | dma_stat = scc_dma_sff_read_status(hwif); |
371 | /* clear the INTR & ERROR bits */ | 371 | /* clear the INTR & ERROR bits */ |
372 | scc_ide_outb(dma_stat | 6, hwif->dma_base + 4); | 372 | scc_ide_outb(dma_stat | 6, hwif->dma_base + 4); |
373 | /* purge DMA mappings */ | 373 | /* purge DMA mappings */ |
@@ -387,7 +387,7 @@ static int __scc_dma_end(ide_drive_t *drive) | |||
387 | 387 | ||
388 | static int scc_dma_end(ide_drive_t *drive) | 388 | static int scc_dma_end(ide_drive_t *drive) |
389 | { | 389 | { |
390 | ide_hwif_t *hwif = HWIF(drive); | 390 | ide_hwif_t *hwif = drive->hwif; |
391 | void __iomem *dma_base = (void __iomem *)hwif->dma_base; | 391 | void __iomem *dma_base = (void __iomem *)hwif->dma_base; |
392 | unsigned long intsts_port = hwif->dma_base + 0x014; | 392 | unsigned long intsts_port = hwif->dma_base + 0x014; |
393 | u32 reg; | 393 | u32 reg; |
@@ -405,17 +405,18 @@ static int scc_dma_end(ide_drive_t *drive) | |||
405 | drive->name); | 405 | drive->name); |
406 | data_loss = 1; | 406 | data_loss = 1; |
407 | if (retry++) { | 407 | if (retry++) { |
408 | struct request *rq = HWGROUP(drive)->rq; | 408 | struct request *rq = hwif->rq; |
409 | int unit; | 409 | ide_drive_t *drive; |
410 | int i; | ||
411 | |||
410 | /* ERROR_RESET and drive->crc_count are needed | 412 | /* ERROR_RESET and drive->crc_count are needed |
411 | * to reduce DMA transfer mode in retry process. | 413 | * to reduce DMA transfer mode in retry process. |
412 | */ | 414 | */ |
413 | if (rq) | 415 | if (rq) |
414 | rq->errors |= ERROR_RESET; | 416 | rq->errors |= ERROR_RESET; |
415 | for (unit = 0; unit < MAX_DRIVES; unit++) { | 417 | |
416 | ide_drive_t *drive = &hwif->drives[unit]; | 418 | ide_port_for_each_dev(i, drive, hwif) |
417 | drive->crc_count++; | 419 | drive->crc_count++; |
418 | } | ||
419 | } | 420 | } |
420 | } | 421 | } |
421 | } | 422 | } |
@@ -496,7 +497,7 @@ static int scc_dma_end(ide_drive_t *drive) | |||
496 | /* returns 1 if dma irq issued, 0 otherwise */ | 497 | /* returns 1 if dma irq issued, 0 otherwise */ |
497 | static int scc_dma_test_irq(ide_drive_t *drive) | 498 | static int scc_dma_test_irq(ide_drive_t *drive) |
498 | { | 499 | { |
499 | ide_hwif_t *hwif = HWIF(drive); | 500 | ide_hwif_t *hwif = drive->hwif; |
500 | u32 int_stat = in_be32((void __iomem *)hwif->dma_base + 0x014); | 501 | u32 int_stat = in_be32((void __iomem *)hwif->dma_base + 0x014); |
501 | 502 | ||
502 | /* SCC errata A252,A308 workaround: Step4 */ | 503 | /* SCC errata A252,A308 workaround: Step4 */ |
@@ -852,7 +853,6 @@ static const struct ide_tp_ops scc_tp_ops = { | |||
852 | .exec_command = scc_exec_command, | 853 | .exec_command = scc_exec_command, |
853 | .read_status = scc_read_status, | 854 | .read_status = scc_read_status, |
854 | .read_altstatus = scc_read_altstatus, | 855 | .read_altstatus = scc_read_altstatus, |
855 | .read_sff_dma_status = scc_read_sff_dma_status, | ||
856 | 856 | ||
857 | .set_irq = scc_set_irq, | 857 | .set_irq = scc_set_irq, |
858 | 858 | ||
@@ -879,6 +879,7 @@ static const struct ide_dma_ops scc_dma_ops = { | |||
879 | .dma_test_irq = scc_dma_test_irq, | 879 | .dma_test_irq = scc_dma_test_irq, |
880 | .dma_lost_irq = ide_dma_lost_irq, | 880 | .dma_lost_irq = ide_dma_lost_irq, |
881 | .dma_timeout = ide_dma_timeout, | 881 | .dma_timeout = ide_dma_timeout, |
882 | .dma_sff_read_status = scc_dma_sff_read_status, | ||
882 | }; | 883 | }; |
883 | 884 | ||
884 | #define DECLARE_SCC_DEV(name_str) \ | 885 | #define DECLARE_SCC_DEV(name_str) \ |
diff --git a/drivers/ide/serverworks.c b/drivers/ide/serverworks.c index 437bc919dafd..382102ba467b 100644 --- a/drivers/ide/serverworks.c +++ b/drivers/ide/serverworks.c | |||
@@ -151,7 +151,7 @@ static void svwks_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
151 | static const u8 dma_modes[] = { 0x77, 0x21, 0x20 }; | 151 | static const u8 dma_modes[] = { 0x77, 0x21, 0x20 }; |
152 | static const u8 drive_pci2[] = { 0x45, 0x44, 0x47, 0x46 }; | 152 | static const u8 drive_pci2[] = { 0x45, 0x44, 0x47, 0x46 }; |
153 | 153 | ||
154 | ide_hwif_t *hwif = HWIF(drive); | 154 | ide_hwif_t *hwif = drive->hwif; |
155 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 155 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
156 | u8 unit = drive->dn & 1; | 156 | u8 unit = drive->dn & 1; |
157 | 157 | ||
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 9f1f9163a136..e85d1ed29c2a 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -130,7 +130,7 @@ int ide_pci_check_simplex(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
130 | * we tune the drive then try to grab DMA ownership if we want to be | 130 | * we tune the drive then try to grab DMA ownership if we want to be |
131 | * the DMA end. This has to be become dynamic to handle hot-plug. | 131 | * the DMA end. This has to be become dynamic to handle hot-plug. |
132 | */ | 132 | */ |
133 | dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); | 133 | dma_stat = hwif->dma_ops->dma_sff_read_status(hwif); |
134 | if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) { | 134 | if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) { |
135 | printk(KERN_INFO "%s %s: simplex device: DMA disabled\n", | 135 | printk(KERN_INFO "%s %s: simplex device: DMA disabled\n", |
136 | d->name, pci_name(dev)); | 136 | d->name, pci_name(dev)); |
@@ -377,6 +377,9 @@ int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
377 | 377 | ||
378 | hwif->dma_base = base; | 378 | hwif->dma_base = base; |
379 | 379 | ||
380 | if (hwif->dma_ops == NULL) | ||
381 | hwif->dma_ops = &sff_dma_ops; | ||
382 | |||
380 | if (ide_pci_check_simplex(hwif, d) < 0) | 383 | if (ide_pci_check_simplex(hwif, d) < 0) |
381 | return -1; | 384 | return -1; |
382 | 385 | ||
@@ -393,8 +396,6 @@ int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
393 | 396 | ||
394 | if (ide_allocate_dma_engine(hwif)) | 397 | if (ide_allocate_dma_engine(hwif)) |
395 | return -1; | 398 | return -1; |
396 | |||
397 | hwif->dma_ops = &sff_dma_ops; | ||
398 | } | 399 | } |
399 | 400 | ||
400 | return 0; | 401 | return 0; |
@@ -471,7 +472,7 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, | |||
471 | */ | 472 | */ |
472 | 473 | ||
473 | for (port = 0; port < channels; ++port) { | 474 | for (port = 0; port < channels; ++port) { |
474 | const ide_pci_enablebit_t *e = &(d->enablebits[port]); | 475 | const struct ide_pci_enablebit *e = &d->enablebits[port]; |
475 | 476 | ||
476 | if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) || | 477 | if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) || |
477 | (tmp & e->mask) != e->val)) { | 478 | (tmp & e->mask) != e->val)) { |
@@ -519,8 +520,7 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, | |||
519 | if (ret < 0) | 520 | if (ret < 0) |
520 | goto out; | 521 | goto out; |
521 | 522 | ||
522 | /* Is it an "IDE storage" device in non-PCI mode? */ | 523 | if (ide_pci_is_in_compatibility_mode(dev)) { |
523 | if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && (dev->class & 5) != 5) { | ||
524 | if (noisy) | 524 | if (noisy) |
525 | printk(KERN_INFO "%s %s: not 100%% native mode: will " | 525 | printk(KERN_INFO "%s %s: not 100%% native mode: will " |
526 | "probe irqs later\n", d->name, pci_name(dev)); | 526 | "probe irqs later\n", d->name, pci_name(dev)); |
diff --git a/drivers/ide/sgiioc4.c b/drivers/ide/sgiioc4.c index a687a7dfea6f..fdb9d7037694 100644 --- a/drivers/ide/sgiioc4.c +++ b/drivers/ide/sgiioc4.c | |||
@@ -123,7 +123,7 @@ static int | |||
123 | sgiioc4_clearirq(ide_drive_t * drive) | 123 | sgiioc4_clearirq(ide_drive_t * drive) |
124 | { | 124 | { |
125 | u32 intr_reg; | 125 | u32 intr_reg; |
126 | ide_hwif_t *hwif = HWIF(drive); | 126 | ide_hwif_t *hwif = drive->hwif; |
127 | struct ide_io_ports *io_ports = &hwif->io_ports; | 127 | struct ide_io_ports *io_ports = &hwif->io_ports; |
128 | unsigned long other_ir = io_ports->irq_addr + (IOC4_INTR_REG << 2); | 128 | unsigned long other_ir = io_ports->irq_addr + (IOC4_INTR_REG << 2); |
129 | 129 | ||
@@ -181,7 +181,7 @@ sgiioc4_clearirq(ide_drive_t * drive) | |||
181 | 181 | ||
182 | static void sgiioc4_dma_start(ide_drive_t *drive) | 182 | static void sgiioc4_dma_start(ide_drive_t *drive) |
183 | { | 183 | { |
184 | ide_hwif_t *hwif = HWIF(drive); | 184 | ide_hwif_t *hwif = drive->hwif; |
185 | unsigned long ioc4_dma_addr = hwif->dma_base + IOC4_DMA_CTRL * 4; | 185 | unsigned long ioc4_dma_addr = hwif->dma_base + IOC4_DMA_CTRL * 4; |
186 | unsigned int reg = readl((void __iomem *)ioc4_dma_addr); | 186 | unsigned int reg = readl((void __iomem *)ioc4_dma_addr); |
187 | unsigned int temp_reg = reg | IOC4_S_DMA_START; | 187 | unsigned int temp_reg = reg | IOC4_S_DMA_START; |
@@ -209,7 +209,7 @@ sgiioc4_ide_dma_stop(ide_hwif_t *hwif, u64 dma_base) | |||
209 | static int sgiioc4_dma_end(ide_drive_t *drive) | 209 | static int sgiioc4_dma_end(ide_drive_t *drive) |
210 | { | 210 | { |
211 | u32 ioc4_dma, bc_dev, bc_mem, num, valid = 0, cnt = 0; | 211 | u32 ioc4_dma, bc_dev, bc_mem, num, valid = 0, cnt = 0; |
212 | ide_hwif_t *hwif = HWIF(drive); | 212 | ide_hwif_t *hwif = drive->hwif; |
213 | unsigned long dma_base = hwif->dma_base; | 213 | unsigned long dma_base = hwif->dma_base; |
214 | int dma_stat = 0; | 214 | int dma_stat = 0; |
215 | unsigned long *ending_dma = ide_get_hwifdata(hwif); | 215 | unsigned long *ending_dma = ide_get_hwifdata(hwif); |
@@ -271,7 +271,7 @@ static void sgiioc4_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
271 | /* returns 1 if dma irq issued, 0 otherwise */ | 271 | /* returns 1 if dma irq issued, 0 otherwise */ |
272 | static int sgiioc4_dma_test_irq(ide_drive_t *drive) | 272 | static int sgiioc4_dma_test_irq(ide_drive_t *drive) |
273 | { | 273 | { |
274 | return sgiioc4_checkirq(HWIF(drive)); | 274 | return sgiioc4_checkirq(drive->hwif); |
275 | } | 275 | } |
276 | 276 | ||
277 | static void sgiioc4_dma_host_set(ide_drive_t *drive, int on) | 277 | static void sgiioc4_dma_host_set(ide_drive_t *drive, int on) |
@@ -367,7 +367,7 @@ static void | |||
367 | sgiioc4_configure_for_dma(int dma_direction, ide_drive_t * drive) | 367 | sgiioc4_configure_for_dma(int dma_direction, ide_drive_t * drive) |
368 | { | 368 | { |
369 | u32 ioc4_dma; | 369 | u32 ioc4_dma; |
370 | ide_hwif_t *hwif = HWIF(drive); | 370 | ide_hwif_t *hwif = drive->hwif; |
371 | unsigned long dma_base = hwif->dma_base; | 371 | unsigned long dma_base = hwif->dma_base; |
372 | unsigned long ioc4_dma_addr = dma_base + IOC4_DMA_CTRL * 4; | 372 | unsigned long ioc4_dma_addr = dma_base + IOC4_DMA_CTRL * 4; |
373 | u32 dma_addr, ending_dma_addr; | 373 | u32 dma_addr, ending_dma_addr; |
@@ -427,7 +427,7 @@ sgiioc4_configure_for_dma(int dma_direction, ide_drive_t * drive) | |||
427 | static unsigned int | 427 | static unsigned int |
428 | sgiioc4_build_dma_table(ide_drive_t * drive, struct request *rq, int ddir) | 428 | sgiioc4_build_dma_table(ide_drive_t * drive, struct request *rq, int ddir) |
429 | { | 429 | { |
430 | ide_hwif_t *hwif = HWIF(drive); | 430 | ide_hwif_t *hwif = drive->hwif; |
431 | unsigned int *table = hwif->dmatable_cpu; | 431 | unsigned int *table = hwif->dmatable_cpu; |
432 | unsigned int count = 0, i = 1; | 432 | unsigned int count = 0, i = 1; |
433 | struct scatterlist *sg; | 433 | struct scatterlist *sg; |
@@ -492,7 +492,7 @@ use_pio_instead: | |||
492 | 492 | ||
493 | static int sgiioc4_dma_setup(ide_drive_t *drive) | 493 | static int sgiioc4_dma_setup(ide_drive_t *drive) |
494 | { | 494 | { |
495 | struct request *rq = HWGROUP(drive)->rq; | 495 | struct request *rq = drive->hwif->rq; |
496 | unsigned int count = 0; | 496 | unsigned int count = 0; |
497 | int ddir; | 497 | int ddir; |
498 | 498 | ||
@@ -523,7 +523,6 @@ static const struct ide_tp_ops sgiioc4_tp_ops = { | |||
523 | .exec_command = ide_exec_command, | 523 | .exec_command = ide_exec_command, |
524 | .read_status = sgiioc4_read_status, | 524 | .read_status = sgiioc4_read_status, |
525 | .read_altstatus = ide_read_altstatus, | 525 | .read_altstatus = ide_read_altstatus, |
526 | .read_sff_dma_status = ide_read_sff_dma_status, | ||
527 | 526 | ||
528 | .set_irq = ide_set_irq, | 527 | .set_irq = ide_set_irq, |
529 | 528 | ||
diff --git a/drivers/ide/siimage.c b/drivers/ide/siimage.c index 7d622d20bc4c..cb2b352b876b 100644 --- a/drivers/ide/siimage.c +++ b/drivers/ide/siimage.c | |||
@@ -114,7 +114,7 @@ static unsigned long siimage_selreg(ide_hwif_t *hwif, int r) | |||
114 | 114 | ||
115 | static inline unsigned long siimage_seldev(ide_drive_t *drive, int r) | 115 | static inline unsigned long siimage_seldev(ide_drive_t *drive, int r) |
116 | { | 116 | { |
117 | ide_hwif_t *hwif = HWIF(drive); | 117 | ide_hwif_t *hwif = drive->hwif; |
118 | unsigned long base = (unsigned long)hwif->hwif_data; | 118 | unsigned long base = (unsigned long)hwif->hwif_data; |
119 | u8 unit = drive->dn & 1; | 119 | u8 unit = drive->dn & 1; |
120 | 120 | ||
@@ -243,7 +243,7 @@ static void sil_set_pio_mode(ide_drive_t *drive, u8 pio) | |||
243 | static const u16 tf_speed[] = { 0x328a, 0x2283, 0x1281, 0x10c3, 0x10c1 }; | 243 | static const u16 tf_speed[] = { 0x328a, 0x2283, 0x1281, 0x10c3, 0x10c1 }; |
244 | static const u16 data_speed[] = { 0x328a, 0x2283, 0x1104, 0x10c3, 0x10c1 }; | 244 | static const u16 data_speed[] = { 0x328a, 0x2283, 0x1104, 0x10c3, 0x10c1 }; |
245 | 245 | ||
246 | ide_hwif_t *hwif = HWIF(drive); | 246 | ide_hwif_t *hwif = drive->hwif; |
247 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 247 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
248 | ide_drive_t *pair = ide_get_pair_dev(drive); | 248 | ide_drive_t *pair = ide_get_pair_dev(drive); |
249 | u32 speedt = 0; | 249 | u32 speedt = 0; |
@@ -300,7 +300,7 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
300 | static const u8 ultra5[] = { 0x0C, 0x07, 0x05, 0x04, 0x02, 0x01 }; | 300 | static const u8 ultra5[] = { 0x0C, 0x07, 0x05, 0x04, 0x02, 0x01 }; |
301 | static const u16 dma[] = { 0x2208, 0x10C2, 0x10C1 }; | 301 | static const u16 dma[] = { 0x2208, 0x10C2, 0x10C1 }; |
302 | 302 | ||
303 | ide_hwif_t *hwif = HWIF(drive); | 303 | ide_hwif_t *hwif = drive->hwif; |
304 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 304 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
305 | unsigned long base = (unsigned long)hwif->hwif_data; | 305 | unsigned long base = (unsigned long)hwif->hwif_data; |
306 | u16 ultra = 0, multi = 0; | 306 | u16 ultra = 0, multi = 0; |
@@ -340,7 +340,7 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
340 | /* returns 1 if dma irq issued, 0 otherwise */ | 340 | /* returns 1 if dma irq issued, 0 otherwise */ |
341 | static int siimage_io_dma_test_irq(ide_drive_t *drive) | 341 | static int siimage_io_dma_test_irq(ide_drive_t *drive) |
342 | { | 342 | { |
343 | ide_hwif_t *hwif = HWIF(drive); | 343 | ide_hwif_t *hwif = drive->hwif; |
344 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 344 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
345 | u8 dma_altstat = 0; | 345 | u8 dma_altstat = 0; |
346 | unsigned long addr = siimage_selreg(hwif, 1); | 346 | unsigned long addr = siimage_selreg(hwif, 1); |
@@ -367,7 +367,7 @@ static int siimage_io_dma_test_irq(ide_drive_t *drive) | |||
367 | 367 | ||
368 | static int siimage_mmio_dma_test_irq(ide_drive_t *drive) | 368 | static int siimage_mmio_dma_test_irq(ide_drive_t *drive) |
369 | { | 369 | { |
370 | ide_hwif_t *hwif = HWIF(drive); | 370 | ide_hwif_t *hwif = drive->hwif; |
371 | unsigned long addr = siimage_selreg(hwif, 0x1); | 371 | unsigned long addr = siimage_selreg(hwif, 0x1); |
372 | void __iomem *sata_error_addr | 372 | void __iomem *sata_error_addr |
373 | = (void __iomem *)hwif->sata_scr[SATA_ERROR_OFFSET]; | 373 | = (void __iomem *)hwif->sata_scr[SATA_ERROR_OFFSET]; |
@@ -717,6 +717,7 @@ static const struct ide_dma_ops sil_dma_ops = { | |||
717 | .dma_test_irq = siimage_dma_test_irq, | 717 | .dma_test_irq = siimage_dma_test_irq, |
718 | .dma_timeout = ide_dma_timeout, | 718 | .dma_timeout = ide_dma_timeout, |
719 | .dma_lost_irq = ide_dma_lost_irq, | 719 | .dma_lost_irq = ide_dma_lost_irq, |
720 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
720 | }; | 721 | }; |
721 | 722 | ||
722 | #define DECLARE_SII_DEV(p_ops) \ | 723 | #define DECLARE_SII_DEV(p_ops) \ |
diff --git a/drivers/ide/sis5513.c b/drivers/ide/sis5513.c index ad32e18c5ba3..9ec1a4a4432c 100644 --- a/drivers/ide/sis5513.c +++ b/drivers/ide/sis5513.c | |||
@@ -274,7 +274,7 @@ static void sis_program_timings(ide_drive_t *drive, const u8 mode) | |||
274 | 274 | ||
275 | static void config_drive_art_rwp(ide_drive_t *drive) | 275 | static void config_drive_art_rwp(ide_drive_t *drive) |
276 | { | 276 | { |
277 | ide_hwif_t *hwif = HWIF(drive); | 277 | ide_hwif_t *hwif = drive->hwif; |
278 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 278 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
279 | u8 reg4bh = 0; | 279 | u8 reg4bh = 0; |
280 | u8 rw_prefetch = 0; | 280 | u8 rw_prefetch = 0; |
diff --git a/drivers/ide/sl82c105.c b/drivers/ide/sl82c105.c index 84dc33602ff8..48cc748c5043 100644 --- a/drivers/ide/sl82c105.c +++ b/drivers/ide/sl82c105.c | |||
@@ -140,7 +140,7 @@ static inline void sl82c105_reset_host(struct pci_dev *dev) | |||
140 | */ | 140 | */ |
141 | static void sl82c105_dma_lost_irq(ide_drive_t *drive) | 141 | static void sl82c105_dma_lost_irq(ide_drive_t *drive) |
142 | { | 142 | { |
143 | ide_hwif_t *hwif = HWIF(drive); | 143 | ide_hwif_t *hwif = drive->hwif; |
144 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 144 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
145 | u32 val, mask = hwif->channel ? CTRL_IDE_IRQB : CTRL_IDE_IRQA; | 145 | u32 val, mask = hwif->channel ? CTRL_IDE_IRQB : CTRL_IDE_IRQA; |
146 | u8 dma_cmd; | 146 | u8 dma_cmd; |
@@ -177,7 +177,7 @@ static void sl82c105_dma_lost_irq(ide_drive_t *drive) | |||
177 | */ | 177 | */ |
178 | static void sl82c105_dma_start(ide_drive_t *drive) | 178 | static void sl82c105_dma_start(ide_drive_t *drive) |
179 | { | 179 | { |
180 | ide_hwif_t *hwif = HWIF(drive); | 180 | ide_hwif_t *hwif = drive->hwif; |
181 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 181 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
182 | int reg = 0x44 + drive->dn * 4; | 182 | int reg = 0x44 + drive->dn * 4; |
183 | 183 | ||
@@ -299,6 +299,7 @@ static const struct ide_dma_ops sl82c105_dma_ops = { | |||
299 | .dma_test_irq = ide_dma_test_irq, | 299 | .dma_test_irq = ide_dma_test_irq, |
300 | .dma_lost_irq = sl82c105_dma_lost_irq, | 300 | .dma_lost_irq = sl82c105_dma_lost_irq, |
301 | .dma_timeout = sl82c105_dma_timeout, | 301 | .dma_timeout = sl82c105_dma_timeout, |
302 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
302 | }; | 303 | }; |
303 | 304 | ||
304 | static const struct ide_port_info sl82c105_chipset __devinitdata = { | 305 | static const struct ide_port_info sl82c105_chipset __devinitdata = { |
diff --git a/drivers/ide/slc90e66.c b/drivers/ide/slc90e66.c index 0f759e4ed779..40b4b94a4288 100644 --- a/drivers/ide/slc90e66.c +++ b/drivers/ide/slc90e66.c | |||
@@ -20,7 +20,7 @@ static DEFINE_SPINLOCK(slc90e66_lock); | |||
20 | 20 | ||
21 | static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) | 21 | static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) |
22 | { | 22 | { |
23 | ide_hwif_t *hwif = HWIF(drive); | 23 | ide_hwif_t *hwif = drive->hwif; |
24 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 24 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
25 | int is_slave = drive->dn & 1; | 25 | int is_slave = drive->dn & 1; |
26 | int master_port = hwif->channel ? 0x42 : 0x40; | 26 | int master_port = hwif->channel ? 0x42 : 0x40; |
@@ -73,7 +73,7 @@ static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
73 | 73 | ||
74 | static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed) | 74 | static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed) |
75 | { | 75 | { |
76 | ide_hwif_t *hwif = HWIF(drive); | 76 | ide_hwif_t *hwif = drive->hwif; |
77 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 77 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
78 | u8 maslave = hwif->channel ? 0x42 : 0x40; | 78 | u8 maslave = hwif->channel ? 0x42 : 0x40; |
79 | int sitre = 0, a_speed = 7 << (drive->dn * 4); | 79 | int sitre = 0, a_speed = 7 << (drive->dn * 4); |
diff --git a/drivers/ide/tc86c001.c b/drivers/ide/tc86c001.c index 93e2cce4b296..84109f5a1632 100644 --- a/drivers/ide/tc86c001.c +++ b/drivers/ide/tc86c001.c | |||
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | static void tc86c001_set_mode(ide_drive_t *drive, const u8 speed) | 16 | static void tc86c001_set_mode(ide_drive_t *drive, const u8 speed) |
17 | { | 17 | { |
18 | ide_hwif_t *hwif = HWIF(drive); | 18 | ide_hwif_t *hwif = drive->hwif; |
19 | unsigned long scr_port = hwif->config_data + (drive->dn ? 0x02 : 0x00); | 19 | unsigned long scr_port = hwif->config_data + (drive->dn ? 0x02 : 0x00); |
20 | u16 mode, scr = inw(scr_port); | 20 | u16 mode, scr = inw(scr_port); |
21 | 21 | ||
@@ -62,13 +62,12 @@ static void tc86c001_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
62 | */ | 62 | */ |
63 | static int tc86c001_timer_expiry(ide_drive_t *drive) | 63 | static int tc86c001_timer_expiry(ide_drive_t *drive) |
64 | { | 64 | { |
65 | ide_hwif_t *hwif = HWIF(drive); | 65 | ide_hwif_t *hwif = drive->hwif; |
66 | ide_expiry_t *expiry = ide_get_hwifdata(hwif); | 66 | ide_expiry_t *expiry = ide_get_hwifdata(hwif); |
67 | ide_hwgroup_t *hwgroup = HWGROUP(drive); | ||
68 | u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); | 67 | u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); |
69 | 68 | ||
70 | /* Restore a higher level driver's expiry handler first. */ | 69 | /* Restore a higher level driver's expiry handler first. */ |
71 | hwgroup->expiry = expiry; | 70 | hwif->expiry = expiry; |
72 | 71 | ||
73 | if ((dma_stat & 5) == 1) { /* DMA active and no interrupt */ | 72 | if ((dma_stat & 5) == 1) { /* DMA active and no interrupt */ |
74 | unsigned long sc_base = hwif->config_data; | 73 | unsigned long sc_base = hwif->config_data; |
@@ -110,11 +109,10 @@ static int tc86c001_timer_expiry(ide_drive_t *drive) | |||
110 | 109 | ||
111 | static void tc86c001_dma_start(ide_drive_t *drive) | 110 | static void tc86c001_dma_start(ide_drive_t *drive) |
112 | { | 111 | { |
113 | ide_hwif_t *hwif = HWIF(drive); | 112 | ide_hwif_t *hwif = drive->hwif; |
114 | ide_hwgroup_t *hwgroup = HWGROUP(drive); | ||
115 | unsigned long sc_base = hwif->config_data; | 113 | unsigned long sc_base = hwif->config_data; |
116 | unsigned long twcr_port = sc_base + (drive->dn ? 0x06 : 0x04); | 114 | unsigned long twcr_port = sc_base + (drive->dn ? 0x06 : 0x04); |
117 | unsigned long nsectors = hwgroup->rq->nr_sectors; | 115 | unsigned long nsectors = hwif->rq->nr_sectors; |
118 | 116 | ||
119 | /* | 117 | /* |
120 | * We have to manually load the sector count and size into | 118 | * We have to manually load the sector count and size into |
@@ -125,8 +123,8 @@ static void tc86c001_dma_start(ide_drive_t *drive) | |||
125 | outw(SECTOR_SIZE / 2, twcr_port); /* Transfer Word Count 1/2 */ | 123 | outw(SECTOR_SIZE / 2, twcr_port); /* Transfer Word Count 1/2 */ |
126 | 124 | ||
127 | /* Install our timeout expiry hook, saving the current handler... */ | 125 | /* Install our timeout expiry hook, saving the current handler... */ |
128 | ide_set_hwifdata(hwif, hwgroup->expiry); | 126 | ide_set_hwifdata(hwif, hwif->expiry); |
129 | hwgroup->expiry = &tc86c001_timer_expiry; | 127 | hwif->expiry = &tc86c001_timer_expiry; |
130 | 128 | ||
131 | ide_dma_start(drive); | 129 | ide_dma_start(drive); |
132 | } | 130 | } |
@@ -190,6 +188,7 @@ static const struct ide_dma_ops tc86c001_dma_ops = { | |||
190 | .dma_test_irq = ide_dma_test_irq, | 188 | .dma_test_irq = ide_dma_test_irq, |
191 | .dma_lost_irq = ide_dma_lost_irq, | 189 | .dma_lost_irq = ide_dma_lost_irq, |
192 | .dma_timeout = ide_dma_timeout, | 190 | .dma_timeout = ide_dma_timeout, |
191 | .dma_sff_read_status = ide_dma_sff_read_status, | ||
193 | }; | 192 | }; |
194 | 193 | ||
195 | static const struct ide_port_info tc86c001_chipset __devinitdata = { | 194 | static const struct ide_port_info tc86c001_chipset __devinitdata = { |
diff --git a/drivers/ide/triflex.c b/drivers/ide/triflex.c index b6ff40336aa9..8773c3ba7462 100644 --- a/drivers/ide/triflex.c +++ b/drivers/ide/triflex.c | |||
@@ -36,7 +36,7 @@ | |||
36 | 36 | ||
37 | static void triflex_set_mode(ide_drive_t *drive, const u8 speed) | 37 | static void triflex_set_mode(ide_drive_t *drive, const u8 speed) |
38 | { | 38 | { |
39 | ide_hwif_t *hwif = HWIF(drive); | 39 | ide_hwif_t *hwif = drive->hwif; |
40 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 40 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
41 | u32 triflex_timings = 0; | 41 | u32 triflex_timings = 0; |
42 | u16 timing = 0; | 42 | u16 timing = 0; |
diff --git a/drivers/ide/trm290.c b/drivers/ide/trm290.c index 2a5ea90cf8b8..b6a1285a4021 100644 --- a/drivers/ide/trm290.c +++ b/drivers/ide/trm290.c | |||
@@ -144,7 +144,7 @@ | |||
144 | 144 | ||
145 | static void trm290_prepare_drive (ide_drive_t *drive, unsigned int use_dma) | 145 | static void trm290_prepare_drive (ide_drive_t *drive, unsigned int use_dma) |
146 | { | 146 | { |
147 | ide_hwif_t *hwif = HWIF(drive); | 147 | ide_hwif_t *hwif = drive->hwif; |
148 | u16 reg = 0; | 148 | u16 reg = 0; |
149 | unsigned long flags; | 149 | unsigned long flags; |
150 | 150 | ||
@@ -184,7 +184,7 @@ static void trm290_dma_exec_cmd(ide_drive_t *drive, u8 command) | |||
184 | static int trm290_dma_setup(ide_drive_t *drive) | 184 | static int trm290_dma_setup(ide_drive_t *drive) |
185 | { | 185 | { |
186 | ide_hwif_t *hwif = drive->hwif; | 186 | ide_hwif_t *hwif = drive->hwif; |
187 | struct request *rq = hwif->hwgroup->rq; | 187 | struct request *rq = hwif->rq; |
188 | unsigned int count, rw; | 188 | unsigned int count, rw; |
189 | 189 | ||
190 | if (rq_data_dir(rq)) { | 190 | if (rq_data_dir(rq)) { |
@@ -222,15 +222,15 @@ static int trm290_dma_end(ide_drive_t *drive) | |||
222 | drive->waiting_for_dma = 0; | 222 | drive->waiting_for_dma = 0; |
223 | /* purge DMA mappings */ | 223 | /* purge DMA mappings */ |
224 | ide_destroy_dmatable(drive); | 224 | ide_destroy_dmatable(drive); |
225 | status = inw(HWIF(drive)->dma_base + 2); | 225 | status = inw(drive->hwif->dma_base + 2); |
226 | |||
226 | return status != 0x00ff; | 227 | return status != 0x00ff; |
227 | } | 228 | } |
228 | 229 | ||
229 | static int trm290_dma_test_irq(ide_drive_t *drive) | 230 | static int trm290_dma_test_irq(ide_drive_t *drive) |
230 | { | 231 | { |
231 | u16 status; | 232 | u16 status = inw(drive->hwif->dma_base + 2); |
232 | 233 | ||
233 | status = inw(HWIF(drive)->dma_base + 2); | ||
234 | return status == 0x00ff; | 234 | return status == 0x00ff; |
235 | } | 235 | } |
236 | 236 | ||
diff --git a/drivers/ide/tx4939ide.c b/drivers/ide/tx4939ide.c index 4a8c5a21bd4c..882f6f07c476 100644 --- a/drivers/ide/tx4939ide.c +++ b/drivers/ide/tx4939ide.c | |||
@@ -293,7 +293,7 @@ static int tx4939ide_dma_setup(ide_drive_t *drive) | |||
293 | { | 293 | { |
294 | ide_hwif_t *hwif = drive->hwif; | 294 | ide_hwif_t *hwif = drive->hwif; |
295 | void __iomem *base = TX4939IDE_BASE(hwif); | 295 | void __iomem *base = TX4939IDE_BASE(hwif); |
296 | struct request *rq = hwif->hwgroup->rq; | 296 | struct request *rq = hwif->rq; |
297 | u8 reading; | 297 | u8 reading; |
298 | int nent; | 298 | int nent; |
299 | 299 | ||
@@ -397,6 +397,17 @@ static int tx4939ide_dma_test_irq(ide_drive_t *drive) | |||
397 | return found; | 397 | return found; |
398 | } | 398 | } |
399 | 399 | ||
400 | #ifdef __BIG_ENDIAN | ||
401 | static u8 tx4939ide_dma_sff_read_status(ide_hwif_t *hwif) | ||
402 | { | ||
403 | void __iomem *base = TX4939IDE_BASE(hwif); | ||
404 | |||
405 | return tx4939ide_readb(base, TX4939IDE_DMA_Stat); | ||
406 | } | ||
407 | #else | ||
408 | #define tx4939ide_dma_sff_read_status ide_dma_sff_read_status | ||
409 | #endif | ||
410 | |||
400 | static void tx4939ide_init_hwif(ide_hwif_t *hwif) | 411 | static void tx4939ide_init_hwif(ide_hwif_t *hwif) |
401 | { | 412 | { |
402 | void __iomem *base = TX4939IDE_BASE(hwif); | 413 | void __iomem *base = TX4939IDE_BASE(hwif); |
@@ -443,13 +454,6 @@ static void tx4939ide_tf_load_fixup(ide_drive_t *drive, ide_task_t *task) | |||
443 | 454 | ||
444 | #ifdef __BIG_ENDIAN | 455 | #ifdef __BIG_ENDIAN |
445 | 456 | ||
446 | static u8 tx4939ide_read_sff_dma_status(ide_hwif_t *hwif) | ||
447 | { | ||
448 | void __iomem *base = TX4939IDE_BASE(hwif); | ||
449 | |||
450 | return tx4939ide_readb(base, TX4939IDE_DMA_Stat); | ||
451 | } | ||
452 | |||
453 | /* custom iops (independent from SWAP_IO_SPACE) */ | 457 | /* custom iops (independent from SWAP_IO_SPACE) */ |
454 | static u8 tx4939ide_inb(unsigned long port) | 458 | static u8 tx4939ide_inb(unsigned long port) |
455 | { | 459 | { |
@@ -585,7 +589,6 @@ static const struct ide_tp_ops tx4939ide_tp_ops = { | |||
585 | .exec_command = ide_exec_command, | 589 | .exec_command = ide_exec_command, |
586 | .read_status = ide_read_status, | 590 | .read_status = ide_read_status, |
587 | .read_altstatus = ide_read_altstatus, | 591 | .read_altstatus = ide_read_altstatus, |
588 | .read_sff_dma_status = tx4939ide_read_sff_dma_status, | ||
589 | 592 | ||
590 | .set_irq = ide_set_irq, | 593 | .set_irq = ide_set_irq, |
591 | 594 | ||
@@ -609,7 +612,6 @@ static const struct ide_tp_ops tx4939ide_tp_ops = { | |||
609 | .exec_command = ide_exec_command, | 612 | .exec_command = ide_exec_command, |
610 | .read_status = ide_read_status, | 613 | .read_status = ide_read_status, |
611 | .read_altstatus = ide_read_altstatus, | 614 | .read_altstatus = ide_read_altstatus, |
612 | .read_sff_dma_status = ide_read_sff_dma_status, | ||
613 | 615 | ||
614 | .set_irq = ide_set_irq, | 616 | .set_irq = ide_set_irq, |
615 | 617 | ||
@@ -638,6 +640,7 @@ static const struct ide_dma_ops tx4939ide_dma_ops = { | |||
638 | .dma_test_irq = tx4939ide_dma_test_irq, | 640 | .dma_test_irq = tx4939ide_dma_test_irq, |
639 | .dma_lost_irq = ide_dma_lost_irq, | 641 | .dma_lost_irq = ide_dma_lost_irq, |
640 | .dma_timeout = ide_dma_timeout, | 642 | .dma_timeout = ide_dma_timeout, |
643 | .dma_sff_read_status = tx4939ide_dma_sff_read_status, | ||
641 | }; | 644 | }; |
642 | 645 | ||
643 | static const struct ide_port_info tx4939ide_port_info __initdata = { | 646 | static const struct ide_port_info tx4939ide_port_info __initdata = { |
diff --git a/drivers/ide/umc8672.c b/drivers/ide/umc8672.c index e29978cf6197..0608d41fb6d0 100644 --- a/drivers/ide/umc8672.c +++ b/drivers/ide/umc8672.c | |||
@@ -106,22 +106,21 @@ static void umc_set_speeds(u8 speeds[]) | |||
106 | 106 | ||
107 | static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio) | 107 | static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio) |
108 | { | 108 | { |
109 | ide_hwif_t *hwif = drive->hwif; | 109 | ide_hwif_t *hwif = drive->hwif, *mate = hwif->mate; |
110 | ide_hwgroup_t *mate_hwgroup = hwif->mate ? hwif->mate->hwgroup : NULL; | ||
111 | unsigned long uninitialized_var(flags); | 110 | unsigned long uninitialized_var(flags); |
112 | 111 | ||
113 | printk("%s: setting umc8672 to PIO mode%d (speed %d)\n", | 112 | printk("%s: setting umc8672 to PIO mode%d (speed %d)\n", |
114 | drive->name, pio, pio_to_umc[pio]); | 113 | drive->name, pio, pio_to_umc[pio]); |
115 | if (mate_hwgroup) | 114 | if (mate) |
116 | spin_lock_irqsave(&mate_hwgroup->lock, flags); | 115 | spin_lock_irqsave(&mate->lock, flags); |
117 | if (mate_hwgroup && mate_hwgroup->handler) { | 116 | if (mate && mate->handler) { |
118 | printk(KERN_ERR "umc8672: other interface is busy: exiting tune_umc()\n"); | 117 | printk(KERN_ERR "umc8672: other interface is busy: exiting tune_umc()\n"); |
119 | } else { | 118 | } else { |
120 | current_speeds[drive->name[2] - 'a'] = pio_to_umc[pio]; | 119 | current_speeds[drive->name[2] - 'a'] = pio_to_umc[pio]; |
121 | umc_set_speeds(current_speeds); | 120 | umc_set_speeds(current_speeds); |
122 | } | 121 | } |
123 | if (mate_hwgroup) | 122 | if (mate) |
124 | spin_unlock_irqrestore(&mate_hwgroup->lock, flags); | 123 | spin_unlock_irqrestore(&mate->lock, flags); |
125 | } | 124 | } |
126 | 125 | ||
127 | static const struct ide_port_ops umc8672_port_ops = { | 126 | static const struct ide_port_ops umc8672_port_ops = { |
diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c index 2a812d3207e9..fecc0e03c3fc 100644 --- a/drivers/ide/via82cxxx.c +++ b/drivers/ide/via82cxxx.c | |||
@@ -178,7 +178,7 @@ static void via_set_drive(ide_drive_t *drive, const u8 speed) | |||
178 | ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); | 178 | ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); |
179 | } | 179 | } |
180 | 180 | ||
181 | via_set_speed(HWIF(drive), drive->dn, &t); | 181 | via_set_speed(hwif, drive->dn, &t); |
182 | } | 182 | } |
183 | 183 | ||
184 | /** | 184 | /** |
diff --git a/include/linux/ide.h b/include/linux/ide.h index db5ef8ae1ab9..3644f6323384 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
@@ -32,18 +32,14 @@ | |||
32 | # define SUPPORT_VLB_SYNC 1 | 32 | # define SUPPORT_VLB_SYNC 1 |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | typedef unsigned char byte; /* used everywhere */ | ||
36 | |||
37 | /* | 35 | /* |
38 | * Probably not wise to fiddle with these | 36 | * Probably not wise to fiddle with these |
39 | */ | 37 | */ |
38 | #define IDE_DEFAULT_MAX_FAILURES 1 | ||
40 | #define ERROR_MAX 8 /* Max read/write errors per sector */ | 39 | #define ERROR_MAX 8 /* Max read/write errors per sector */ |
41 | #define ERROR_RESET 3 /* Reset controller every 4th retry */ | 40 | #define ERROR_RESET 3 /* Reset controller every 4th retry */ |
42 | #define ERROR_RECAL 1 /* Recalibrate every 2nd retry */ | 41 | #define ERROR_RECAL 1 /* Recalibrate every 2nd retry */ |
43 | 42 | ||
44 | #define HWIF(drive) ((ide_hwif_t *)((drive)->hwif)) | ||
45 | #define HWGROUP(drive) ((ide_hwgroup_t *)(HWIF(drive)->hwgroup)) | ||
46 | |||
47 | /* | 43 | /* |
48 | * Definitions for accessing IDE controller registers | 44 | * Definitions for accessing IDE controller registers |
49 | */ | 45 | */ |
@@ -185,9 +181,6 @@ typedef struct hw_regs_s { | |||
185 | unsigned long config; | 181 | unsigned long config; |
186 | } hw_regs_t; | 182 | } hw_regs_t; |
187 | 183 | ||
188 | void ide_init_port_data(struct hwif_s *, unsigned int); | ||
189 | void ide_init_port_hw(struct hwif_s *, hw_regs_t *); | ||
190 | |||
191 | static inline void ide_std_init_ports(hw_regs_t *hw, | 184 | static inline void ide_std_init_ports(hw_regs_t *hw, |
192 | unsigned long io_addr, | 185 | unsigned long io_addr, |
193 | unsigned long ctl_addr) | 186 | unsigned long ctl_addr) |
@@ -433,18 +426,14 @@ struct ide_atapi_pc { | |||
433 | struct idetape_bh *bh; | 426 | struct idetape_bh *bh; |
434 | char *b_data; | 427 | char *b_data; |
435 | 428 | ||
436 | /* idescsi only for now */ | ||
437 | struct scatterlist *sg; | 429 | struct scatterlist *sg; |
438 | unsigned int sg_cnt; | 430 | unsigned int sg_cnt; |
439 | 431 | ||
440 | struct scsi_cmnd *scsi_cmd; | ||
441 | void (*done) (struct scsi_cmnd *); | ||
442 | |||
443 | unsigned long timeout; | 432 | unsigned long timeout; |
444 | }; | 433 | }; |
445 | 434 | ||
446 | struct ide_devset; | 435 | struct ide_devset; |
447 | struct ide_driver_s; | 436 | struct ide_driver; |
448 | 437 | ||
449 | #ifdef CONFIG_BLK_DEV_IDEACPI | 438 | #ifdef CONFIG_BLK_DEV_IDEACPI |
450 | struct ide_acpi_drive_link; | 439 | struct ide_acpi_drive_link; |
@@ -588,7 +577,6 @@ struct ide_drive_s { | |||
588 | struct request_queue *queue; /* request queue */ | 577 | struct request_queue *queue; /* request queue */ |
589 | 578 | ||
590 | struct request *rq; /* current request */ | 579 | struct request *rq; /* current request */ |
591 | struct ide_drive_s *next; /* circular list of hwgroup drives */ | ||
592 | void *driver_data; /* extra driver data */ | 580 | void *driver_data; /* extra driver data */ |
593 | u16 *id; /* identification info */ | 581 | u16 *id; /* identification info */ |
594 | #ifdef CONFIG_IDE_PROC_FS | 582 | #ifdef CONFIG_IDE_PROC_FS |
@@ -662,6 +650,8 @@ struct ide_drive_s { | |||
662 | int (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *, | 650 | int (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *, |
663 | unsigned int, int); | 651 | unsigned int, int); |
664 | 652 | ||
653 | ide_startstop_t (*irq_handler)(struct ide_drive_s *); | ||
654 | |||
665 | unsigned long atapi_flags; | 655 | unsigned long atapi_flags; |
666 | 656 | ||
667 | struct ide_atapi_pc request_sense_pc; | 657 | struct ide_atapi_pc request_sense_pc; |
@@ -684,7 +674,6 @@ struct ide_tp_ops { | |||
684 | void (*exec_command)(struct hwif_s *, u8); | 674 | void (*exec_command)(struct hwif_s *, u8); |
685 | u8 (*read_status)(struct hwif_s *); | 675 | u8 (*read_status)(struct hwif_s *); |
686 | u8 (*read_altstatus)(struct hwif_s *); | 676 | u8 (*read_altstatus)(struct hwif_s *); |
687 | u8 (*read_sff_dma_status)(struct hwif_s *); | ||
688 | 677 | ||
689 | void (*set_irq)(struct hwif_s *, int); | 678 | void (*set_irq)(struct hwif_s *, int); |
690 | 679 | ||
@@ -745,14 +734,17 @@ struct ide_dma_ops { | |||
745 | int (*dma_test_irq)(struct ide_drive_s *); | 734 | int (*dma_test_irq)(struct ide_drive_s *); |
746 | void (*dma_lost_irq)(struct ide_drive_s *); | 735 | void (*dma_lost_irq)(struct ide_drive_s *); |
747 | void (*dma_timeout)(struct ide_drive_s *); | 736 | void (*dma_timeout)(struct ide_drive_s *); |
737 | /* | ||
738 | * The following method is optional and only required to be | ||
739 | * implemented for the SFF-8038i compatible controllers. | ||
740 | */ | ||
741 | u8 (*dma_sff_read_status)(struct hwif_s *); | ||
748 | }; | 742 | }; |
749 | 743 | ||
750 | struct ide_host; | 744 | struct ide_host; |
751 | 745 | ||
752 | typedef struct hwif_s { | 746 | typedef struct hwif_s { |
753 | struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ | ||
754 | struct hwif_s *mate; /* other hwif from same PCI chip */ | 747 | struct hwif_s *mate; /* other hwif from same PCI chip */ |
755 | struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */ | ||
756 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ | 748 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ |
757 | 749 | ||
758 | struct ide_host *host; | 750 | struct ide_host *host; |
@@ -763,7 +755,7 @@ typedef struct hwif_s { | |||
763 | 755 | ||
764 | unsigned long sata_scr[SATA_NR_PORTS]; | 756 | unsigned long sata_scr[SATA_NR_PORTS]; |
765 | 757 | ||
766 | ide_drive_t drives[MAX_DRIVES]; /* drive info */ | 758 | ide_drive_t *devices[MAX_DRIVES + 1]; |
767 | 759 | ||
768 | u8 major; /* our major number */ | 760 | u8 major; /* our major number */ |
769 | u8 index; /* 0 for ide0; 1 for ide1; ... */ | 761 | u8 index; /* 0 for ide0; 1 for ide1; ... */ |
@@ -829,7 +821,7 @@ typedef struct hwif_s { | |||
829 | unsigned extra_ports; /* number of extra dma ports */ | 821 | unsigned extra_ports; /* number of extra dma ports */ |
830 | 822 | ||
831 | unsigned present : 1; /* this interface exists */ | 823 | unsigned present : 1; /* this interface exists */ |
832 | unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ | 824 | unsigned busy : 1; /* serializes devices on a port */ |
833 | 825 | ||
834 | struct device gendev; | 826 | struct device gendev; |
835 | struct device *portdev; | 827 | struct device *portdev; |
@@ -841,19 +833,49 @@ typedef struct hwif_s { | |||
841 | #ifdef CONFIG_BLK_DEV_IDEACPI | 833 | #ifdef CONFIG_BLK_DEV_IDEACPI |
842 | struct ide_acpi_hwif_link *acpidata; | 834 | struct ide_acpi_hwif_link *acpidata; |
843 | #endif | 835 | #endif |
836 | |||
837 | /* IRQ handler, if active */ | ||
838 | ide_startstop_t (*handler)(ide_drive_t *); | ||
839 | |||
840 | /* BOOL: polling active & poll_timeout field valid */ | ||
841 | unsigned int polling : 1; | ||
842 | |||
843 | /* current drive */ | ||
844 | ide_drive_t *cur_dev; | ||
845 | |||
846 | /* current request */ | ||
847 | struct request *rq; | ||
848 | |||
849 | /* failsafe timer */ | ||
850 | struct timer_list timer; | ||
851 | /* timeout value during long polls */ | ||
852 | unsigned long poll_timeout; | ||
853 | /* queried upon timeouts */ | ||
854 | int (*expiry)(ide_drive_t *); | ||
855 | |||
856 | int req_gen; | ||
857 | int req_gen_timer; | ||
858 | |||
859 | spinlock_t lock; | ||
844 | } ____cacheline_internodealigned_in_smp ide_hwif_t; | 860 | } ____cacheline_internodealigned_in_smp ide_hwif_t; |
845 | 861 | ||
846 | #define MAX_HOST_PORTS 4 | 862 | #define MAX_HOST_PORTS 4 |
847 | 863 | ||
848 | struct ide_host { | 864 | struct ide_host { |
849 | ide_hwif_t *ports[MAX_HOST_PORTS]; | 865 | ide_hwif_t *ports[MAX_HOST_PORTS + 1]; |
850 | unsigned int n_ports; | 866 | unsigned int n_ports; |
851 | struct device *dev[2]; | 867 | struct device *dev[2]; |
852 | unsigned int (*init_chipset)(struct pci_dev *); | 868 | unsigned int (*init_chipset)(struct pci_dev *); |
853 | unsigned long host_flags; | 869 | unsigned long host_flags; |
854 | void *host_priv; | 870 | void *host_priv; |
871 | ide_hwif_t *cur_port; /* for hosts requiring serialization */ | ||
872 | |||
873 | /* used for hosts requiring serialization */ | ||
874 | volatile long host_busy; | ||
855 | }; | 875 | }; |
856 | 876 | ||
877 | #define IDE_HOST_BUSY 0 | ||
878 | |||
857 | /* | 879 | /* |
858 | * internal ide interrupt handler type | 880 | * internal ide interrupt handler type |
859 | */ | 881 | */ |
@@ -863,38 +885,6 @@ typedef int (ide_expiry_t)(ide_drive_t *); | |||
863 | /* used by ide-cd, ide-floppy, etc. */ | 885 | /* used by ide-cd, ide-floppy, etc. */ |
864 | typedef void (xfer_func_t)(ide_drive_t *, struct request *rq, void *, unsigned); | 886 | typedef void (xfer_func_t)(ide_drive_t *, struct request *rq, void *, unsigned); |
865 | 887 | ||
866 | typedef struct hwgroup_s { | ||
867 | /* irq handler, if active */ | ||
868 | ide_startstop_t (*handler)(ide_drive_t *); | ||
869 | |||
870 | /* BOOL: protects all fields below */ | ||
871 | volatile int busy; | ||
872 | /* BOOL: polling active & poll_timeout field valid */ | ||
873 | unsigned int polling : 1; | ||
874 | |||
875 | /* current drive */ | ||
876 | ide_drive_t *drive; | ||
877 | /* ptr to current hwif in linked-list */ | ||
878 | ide_hwif_t *hwif; | ||
879 | |||
880 | /* current request */ | ||
881 | struct request *rq; | ||
882 | |||
883 | /* failsafe timer */ | ||
884 | struct timer_list timer; | ||
885 | /* timeout value during long polls */ | ||
886 | unsigned long poll_timeout; | ||
887 | /* queried upon timeouts */ | ||
888 | int (*expiry)(ide_drive_t *); | ||
889 | |||
890 | int req_gen; | ||
891 | int req_gen_timer; | ||
892 | |||
893 | spinlock_t lock; | ||
894 | } ide_hwgroup_t; | ||
895 | |||
896 | typedef struct ide_driver_s ide_driver_t; | ||
897 | |||
898 | extern struct mutex ide_setting_mtx; | 888 | extern struct mutex ide_setting_mtx; |
899 | 889 | ||
900 | /* | 890 | /* |
@@ -1020,8 +1010,8 @@ void ide_proc_register_port(ide_hwif_t *); | |||
1020 | void ide_proc_port_register_devices(ide_hwif_t *); | 1010 | void ide_proc_port_register_devices(ide_hwif_t *); |
1021 | void ide_proc_unregister_device(ide_drive_t *); | 1011 | void ide_proc_unregister_device(ide_drive_t *); |
1022 | void ide_proc_unregister_port(ide_hwif_t *); | 1012 | void ide_proc_unregister_port(ide_hwif_t *); |
1023 | void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); | 1013 | void ide_proc_register_driver(ide_drive_t *, struct ide_driver *); |
1024 | void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); | 1014 | void ide_proc_unregister_driver(ide_drive_t *, struct ide_driver *); |
1025 | 1015 | ||
1026 | read_proc_t proc_ide_read_capacity; | 1016 | read_proc_t proc_ide_read_capacity; |
1027 | read_proc_t proc_ide_read_geometry; | 1017 | read_proc_t proc_ide_read_geometry; |
@@ -1048,8 +1038,10 @@ static inline void ide_proc_register_port(ide_hwif_t *hwif) { ; } | |||
1048 | static inline void ide_proc_port_register_devices(ide_hwif_t *hwif) { ; } | 1038 | static inline void ide_proc_port_register_devices(ide_hwif_t *hwif) { ; } |
1049 | static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; } | 1039 | static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; } |
1050 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } | 1040 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } |
1051 | static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } | 1041 | static inline void ide_proc_register_driver(ide_drive_t *drive, |
1052 | static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } | 1042 | struct ide_driver *driver) { ; } |
1043 | static inline void ide_proc_unregister_driver(ide_drive_t *drive, | ||
1044 | struct ide_driver *driver) { ; } | ||
1053 | #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; | 1045 | #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; |
1054 | #endif | 1046 | #endif |
1055 | 1047 | ||
@@ -1118,11 +1110,10 @@ void ide_check_pm_state(ide_drive_t *, struct request *); | |||
1118 | * The gendriver.owner field should be set to the module owner of this driver. | 1110 | * The gendriver.owner field should be set to the module owner of this driver. |
1119 | * The gendriver.name field should be set to the name of this driver | 1111 | * The gendriver.name field should be set to the name of this driver |
1120 | */ | 1112 | */ |
1121 | struct ide_driver_s { | 1113 | struct ide_driver { |
1122 | const char *version; | 1114 | const char *version; |
1123 | ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); | 1115 | ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); |
1124 | int (*end_request)(ide_drive_t *, int, int); | 1116 | int (*end_request)(ide_drive_t *, int, int); |
1125 | ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); | ||
1126 | struct device_driver gen_driver; | 1117 | struct device_driver gen_driver; |
1127 | int (*probe)(ide_drive_t *); | 1118 | int (*probe)(ide_drive_t *); |
1128 | void (*remove)(ide_drive_t *); | 1119 | void (*remove)(ide_drive_t *); |
@@ -1134,7 +1125,7 @@ struct ide_driver_s { | |||
1134 | #endif | 1125 | #endif |
1135 | }; | 1126 | }; |
1136 | 1127 | ||
1137 | #define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver) | 1128 | #define to_ide_driver(drv) container_of(drv, struct ide_driver, gen_driver) |
1138 | 1129 | ||
1139 | int ide_device_get(ide_drive_t *); | 1130 | int ide_device_get(ide_drive_t *); |
1140 | void ide_device_put(ide_drive_t *); | 1131 | void ide_device_put(ide_drive_t *); |
@@ -1166,9 +1157,7 @@ void ide_execute_pkt_cmd(ide_drive_t *); | |||
1166 | 1157 | ||
1167 | void ide_pad_transfer(ide_drive_t *, int, int); | 1158 | void ide_pad_transfer(ide_drive_t *, int, int); |
1168 | 1159 | ||
1169 | ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8); | 1160 | ide_startstop_t ide_error(ide_drive_t *, const char *, u8); |
1170 | |||
1171 | ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); | ||
1172 | 1161 | ||
1173 | void ide_fix_driveid(u16 *); | 1162 | void ide_fix_driveid(u16 *); |
1174 | 1163 | ||
@@ -1192,7 +1181,6 @@ void ide_tf_dump(const char *, struct ide_taskfile *); | |||
1192 | void ide_exec_command(ide_hwif_t *, u8); | 1181 | void ide_exec_command(ide_hwif_t *, u8); |
1193 | u8 ide_read_status(ide_hwif_t *); | 1182 | u8 ide_read_status(ide_hwif_t *); |
1194 | u8 ide_read_altstatus(ide_hwif_t *); | 1183 | u8 ide_read_altstatus(ide_hwif_t *); |
1195 | u8 ide_read_sff_dma_status(ide_hwif_t *); | ||
1196 | 1184 | ||
1197 | void ide_set_irq(ide_hwif_t *, int); | 1185 | void ide_set_irq(ide_hwif_t *, int); |
1198 | 1186 | ||
@@ -1272,26 +1260,6 @@ extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout); | |||
1272 | 1260 | ||
1273 | extern void ide_timer_expiry(unsigned long); | 1261 | extern void ide_timer_expiry(unsigned long); |
1274 | extern irqreturn_t ide_intr(int irq, void *dev_id); | 1262 | extern irqreturn_t ide_intr(int irq, void *dev_id); |
1275 | |||
1276 | static inline int ide_lock_hwgroup(ide_hwgroup_t *hwgroup) | ||
1277 | { | ||
1278 | if (hwgroup->busy) | ||
1279 | return 1; | ||
1280 | |||
1281 | hwgroup->busy = 1; | ||
1282 | /* for atari only */ | ||
1283 | ide_get_lock(ide_intr, hwgroup); | ||
1284 | |||
1285 | return 0; | ||
1286 | } | ||
1287 | |||
1288 | static inline void ide_unlock_hwgroup(ide_hwgroup_t *hwgroup) | ||
1289 | { | ||
1290 | /* for atari only */ | ||
1291 | ide_release_lock(); | ||
1292 | hwgroup->busy = 0; | ||
1293 | } | ||
1294 | |||
1295 | extern void do_ide_request(struct request_queue *); | 1263 | extern void do_ide_request(struct request_queue *); |
1296 | 1264 | ||
1297 | void ide_init_disk(struct gendisk *, ide_drive_t *); | 1265 | void ide_init_disk(struct gendisk *, ide_drive_t *); |
@@ -1327,11 +1295,11 @@ static inline int ide_hwif_setup_dma(ide_hwif_t *hwif, | |||
1327 | } | 1295 | } |
1328 | #endif | 1296 | #endif |
1329 | 1297 | ||
1330 | typedef struct ide_pci_enablebit_s { | 1298 | struct ide_pci_enablebit { |
1331 | u8 reg; /* byte pci reg holding the enable-bit */ | 1299 | u8 reg; /* byte pci reg holding the enable-bit */ |
1332 | u8 mask; /* mask to isolate the enable-bit */ | 1300 | u8 mask; /* mask to isolate the enable-bit */ |
1333 | u8 val; /* value of masked reg when "enabled" */ | 1301 | u8 val; /* value of masked reg when "enabled" */ |
1334 | } ide_pci_enablebit_t; | 1302 | }; |
1335 | 1303 | ||
1336 | enum { | 1304 | enum { |
1337 | /* Uses ISA control ports not PCI ones. */ | 1305 | /* Uses ISA control ports not PCI ones. */ |
@@ -1420,7 +1388,8 @@ struct ide_port_info { | |||
1420 | const struct ide_port_ops *port_ops; | 1388 | const struct ide_port_ops *port_ops; |
1421 | const struct ide_dma_ops *dma_ops; | 1389 | const struct ide_dma_ops *dma_ops; |
1422 | 1390 | ||
1423 | ide_pci_enablebit_t enablebits[2]; | 1391 | struct ide_pci_enablebit enablebits[2]; |
1392 | |||
1424 | hwif_chipset_t chipset; | 1393 | hwif_chipset_t chipset; |
1425 | 1394 | ||
1426 | u16 max_sectors; /* if < than the default one */ | 1395 | u16 max_sectors; /* if < than the default one */ |
@@ -1492,6 +1461,7 @@ void ide_dma_exec_cmd(ide_drive_t *, u8); | |||
1492 | extern void ide_dma_start(ide_drive_t *); | 1461 | extern void ide_dma_start(ide_drive_t *); |
1493 | int ide_dma_end(ide_drive_t *); | 1462 | int ide_dma_end(ide_drive_t *); |
1494 | int ide_dma_test_irq(ide_drive_t *); | 1463 | int ide_dma_test_irq(ide_drive_t *); |
1464 | u8 ide_dma_sff_read_status(ide_hwif_t *); | ||
1495 | extern const struct ide_dma_ops sff_dma_ops; | 1465 | extern const struct ide_dma_ops sff_dma_ops; |
1496 | #else | 1466 | #else |
1497 | static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } | 1467 | static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } |
@@ -1529,9 +1499,6 @@ static inline void ide_acpi_port_init_devices(ide_hwif_t *hwif) { ; } | |||
1529 | static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {} | 1499 | static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {} |
1530 | #endif | 1500 | #endif |
1531 | 1501 | ||
1532 | void ide_remove_port_from_hwgroup(ide_hwif_t *); | ||
1533 | void ide_unregister(ide_hwif_t *); | ||
1534 | |||
1535 | void ide_register_region(struct gendisk *); | 1502 | void ide_register_region(struct gendisk *); |
1536 | void ide_unregister_region(struct gendisk *); | 1503 | void ide_unregister_region(struct gendisk *); |
1537 | 1504 | ||
@@ -1616,23 +1583,6 @@ static inline void ide_set_max_pio(ide_drive_t *drive) | |||
1616 | ide_set_pio(drive, 255); | 1583 | ide_set_pio(drive, 255); |
1617 | } | 1584 | } |
1618 | 1585 | ||
1619 | extern spinlock_t ide_lock; | ||
1620 | extern struct mutex ide_cfg_mtx; | ||
1621 | /* | ||
1622 | * Structure locking: | ||
1623 | * | ||
1624 | * ide_cfg_mtx and hwgroup->lock together protect changes to | ||
1625 | * ide_hwif_t->next | ||
1626 | * ide_drive_t->next | ||
1627 | * | ||
1628 | * ide_hwgroup_t->busy: hwgroup->lock | ||
1629 | * ide_hwgroup_t->hwif: hwgroup->lock | ||
1630 | * ide_hwif_t->{hwgroup,mate}: constant, no locking | ||
1631 | * ide_drive_t->hwif: constant, no locking | ||
1632 | */ | ||
1633 | |||
1634 | #define local_irq_set(flags) do { local_save_flags((flags)); local_irq_enable_in_hardirq(); } while (0) | ||
1635 | |||
1636 | char *ide_media_string(ide_drive_t *); | 1586 | char *ide_media_string(ide_drive_t *); |
1637 | 1587 | ||
1638 | extern struct device_attribute ide_dev_attrs[]; | 1588 | extern struct device_attribute ide_dev_attrs[]; |
@@ -1651,8 +1601,15 @@ static inline int hwif_to_node(ide_hwif_t *hwif) | |||
1651 | 1601 | ||
1652 | static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive) | 1602 | static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive) |
1653 | { | 1603 | { |
1654 | ide_drive_t *peer = &drive->hwif->drives[(drive->dn ^ 1) & 1]; | 1604 | ide_drive_t *peer = drive->hwif->devices[(drive->dn ^ 1) & 1]; |
1655 | 1605 | ||
1656 | return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL; | 1606 | return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL; |
1657 | } | 1607 | } |
1608 | |||
1609 | #define ide_port_for_each_dev(i, dev, port) \ | ||
1610 | for ((i) = 0; ((dev) = (port)->devices[i]) || (i) < MAX_DRIVES; (i)++) | ||
1611 | |||
1612 | #define ide_host_for_each_port(i, port, host) \ | ||
1613 | for ((i) = 0; ((port) = (host)->ports[i]) || (i) < MAX_HOST_PORTS; (i)++) | ||
1614 | |||
1658 | #endif /* _IDE_H */ | 1615 | #endif /* _IDE_H */ |
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 218c73b1e6d4..d543365518ab 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h | |||
@@ -1658,6 +1658,7 @@ | |||
1658 | #define PCI_VENDOR_ID_ROCKWELL 0x127A | 1658 | #define PCI_VENDOR_ID_ROCKWELL 0x127A |
1659 | 1659 | ||
1660 | #define PCI_VENDOR_ID_ITE 0x1283 | 1660 | #define PCI_VENDOR_ID_ITE 0x1283 |
1661 | #define PCI_DEVICE_ID_ITE_8172 0x8172 | ||
1661 | #define PCI_DEVICE_ID_ITE_8211 0x8211 | 1662 | #define PCI_DEVICE_ID_ITE_8211 0x8211 |
1662 | #define PCI_DEVICE_ID_ITE_8212 0x8212 | 1663 | #define PCI_DEVICE_ID_ITE_8212 0x8212 |
1663 | #define PCI_DEVICE_ID_ITE_8213 0x8213 | 1664 | #define PCI_DEVICE_ID_ITE_8213 0x8213 |