aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/pci')
-rw-r--r--drivers/ide/pci/aec62xx.c8
-rw-r--r--drivers/ide/pci/alim15x3.c15
-rw-r--r--drivers/ide/pci/amd74xx.c8
-rw-r--r--drivers/ide/pci/atiixp.c6
-rw-r--r--drivers/ide/pci/cmd640.c18
-rw-r--r--drivers/ide/pci/cmd64x.c10
-rw-r--r--drivers/ide/pci/cs5520.c4
-rw-r--r--drivers/ide/pci/cs5530.c6
-rw-r--r--drivers/ide/pci/cs5535.c8
-rw-r--r--drivers/ide/pci/cy82c693.c124
-rw-r--r--drivers/ide/pci/delkin_cb.c6
-rw-r--r--drivers/ide/pci/generic.c6
-rw-r--r--drivers/ide/pci/hpt34x.c6
-rw-r--r--drivers/ide/pci/hpt366.c15
-rw-r--r--drivers/ide/pci/it8213.c6
-rw-r--r--drivers/ide/pci/it821x.c46
-rw-r--r--drivers/ide/pci/jmicron.c6
-rw-r--r--drivers/ide/pci/ns87415.c21
-rw-r--r--drivers/ide/pci/opti621.c8
-rw-r--r--drivers/ide/pci/pdc202xx_new.c6
-rw-r--r--drivers/ide/pci/pdc202xx_old.c14
-rw-r--r--drivers/ide/pci/piix.c46
-rw-r--r--drivers/ide/pci/rz1000.c6
-rw-r--r--drivers/ide/pci/sc1200.c12
-rw-r--r--drivers/ide/pci/scc_pata.c29
-rw-r--r--drivers/ide/pci/serverworks.c8
-rw-r--r--drivers/ide/pci/sgiioc4.c59
-rw-r--r--drivers/ide/pci/siimage.c17
-rw-r--r--drivers/ide/pci/sis5513.c6
-rw-r--r--drivers/ide/pci/sl82c105.c8
-rw-r--r--drivers/ide/pci/slc90e66.c6
-rw-r--r--drivers/ide/pci/tc86c001.c8
-rw-r--r--drivers/ide/pci/triflex.c15
-rw-r--r--drivers/ide/pci/trm290.c10
-rw-r--r--drivers/ide/pci/via82cxxx.c6
35 files changed, 232 insertions, 351 deletions
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index e7475ba559c7..4142c698e0d3 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -115,7 +115,7 @@ static void aec6260_set_mode(ide_drive_t *drive, const u8 speed)
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;
118 u8 unit = (drive->select.b.unit & 0x01); 118 u8 unit = drive->dn & 1;
119 u8 tmp1 = 0, tmp2 = 0; 119 u8 tmp1 = 0, tmp2 = 0;
120 u8 ultra = 0, drive_conf = 0, ultra_conf = 0; 120 u8 ultra = 0, drive_conf = 0, ultra_conf = 0;
121 unsigned long flags; 121 unsigned long flags;
@@ -302,7 +302,7 @@ static const struct pci_device_id aec62xx_pci_tbl[] = {
302}; 302};
303MODULE_DEVICE_TABLE(pci, aec62xx_pci_tbl); 303MODULE_DEVICE_TABLE(pci, aec62xx_pci_tbl);
304 304
305static struct pci_driver driver = { 305static struct pci_driver aec62xx_pci_driver = {
306 .name = "AEC62xx_IDE", 306 .name = "AEC62xx_IDE",
307 .id_table = aec62xx_pci_tbl, 307 .id_table = aec62xx_pci_tbl,
308 .probe = aec62xx_init_one, 308 .probe = aec62xx_init_one,
@@ -313,12 +313,12 @@ static struct pci_driver driver = {
313 313
314static int __init aec62xx_ide_init(void) 314static int __init aec62xx_ide_init(void)
315{ 315{
316 return ide_pci_register_driver(&driver); 316 return ide_pci_register_driver(&aec62xx_pci_driver);
317} 317}
318 318
319static void __exit aec62xx_ide_exit(void) 319static void __exit aec62xx_ide_exit(void)
320{ 320{
321 pci_unregister_driver(&driver); 321 pci_unregister_driver(&aec62xx_pci_driver);
322} 322}
323 323
324module_init(aec62xx_ide_init); 324module_init(aec62xx_ide_init);
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index 053c75263918..daf9dce39e52 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -77,8 +77,7 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
77 int bus_speed = ide_pci_clk ? ide_pci_clk : 33; 77 int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
78 int port = hwif->channel ? 0x5c : 0x58; 78 int port = hwif->channel ? 0x5c : 0x58;
79 int portFIFO = hwif->channel ? 0x55 : 0x54; 79 int portFIFO = hwif->channel ? 0x55 : 0x54;
80 u8 cd_dma_fifo = 0; 80 u8 cd_dma_fifo = 0, unit = drive->dn & 1;
81 int unit = drive->select.b.unit & 1;
82 81
83 if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8) 82 if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8)
84 s_clc = 0; 83 s_clc = 0;
@@ -112,7 +111,7 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
112 } 111 }
113 112
114 pci_write_config_byte(dev, port, s_clc); 113 pci_write_config_byte(dev, port, s_clc);
115 pci_write_config_byte(dev, port+drive->select.b.unit+2, (a_clc << 4) | r_clc); 114 pci_write_config_byte(dev, port + unit + 2, (a_clc << 4) | r_clc);
116 local_irq_restore(flags); 115 local_irq_restore(flags);
117} 116}
118 117
@@ -154,7 +153,7 @@ static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed)
154 ide_hwif_t *hwif = HWIF(drive); 153 ide_hwif_t *hwif = HWIF(drive);
155 struct pci_dev *dev = to_pci_dev(hwif->dev); 154 struct pci_dev *dev = to_pci_dev(hwif->dev);
156 u8 speed1 = speed; 155 u8 speed1 = speed;
157 u8 unit = (drive->select.b.unit & 0x01); 156 u8 unit = drive->dn & 1;
158 u8 tmpbyte = 0x00; 157 u8 tmpbyte = 0x00;
159 int m5229_udma = (hwif->channel) ? 0x57 : 0x56; 158 int m5229_udma = (hwif->channel) ? 0x57 : 0x56;
160 159
@@ -508,7 +507,7 @@ static const struct ide_dma_ops ali_dma_ops = {
508 .dma_setup = ali15x3_dma_setup, 507 .dma_setup = ali15x3_dma_setup,
509 .dma_exec_cmd = ide_dma_exec_cmd, 508 .dma_exec_cmd = ide_dma_exec_cmd,
510 .dma_start = ide_dma_start, 509 .dma_start = ide_dma_start,
511 .dma_end = __ide_dma_end, 510 .dma_end = ide_dma_end,
512 .dma_test_irq = ide_dma_test_irq, 511 .dma_test_irq = ide_dma_test_irq,
513 .dma_lost_irq = ide_dma_lost_irq, 512 .dma_lost_irq = ide_dma_lost_irq,
514 .dma_timeout = ide_dma_timeout, 513 .dma_timeout = ide_dma_timeout,
@@ -576,7 +575,7 @@ static const struct pci_device_id alim15x3_pci_tbl[] = {
576}; 575};
577MODULE_DEVICE_TABLE(pci, alim15x3_pci_tbl); 576MODULE_DEVICE_TABLE(pci, alim15x3_pci_tbl);
578 577
579static struct pci_driver driver = { 578static struct pci_driver alim15x3_pci_driver = {
580 .name = "ALI15x3_IDE", 579 .name = "ALI15x3_IDE",
581 .id_table = alim15x3_pci_tbl, 580 .id_table = alim15x3_pci_tbl,
582 .probe = alim15x3_init_one, 581 .probe = alim15x3_init_one,
@@ -587,12 +586,12 @@ static struct pci_driver driver = {
587 586
588static int __init ali15x3_ide_init(void) 587static int __init ali15x3_ide_init(void)
589{ 588{
590 return ide_pci_register_driver(&driver); 589 return ide_pci_register_driver(&alim15x3_pci_driver);
591} 590}
592 591
593static void __exit ali15x3_ide_exit(void) 592static void __exit ali15x3_ide_exit(void)
594{ 593{
595 return pci_unregister_driver(&driver); 594 return pci_unregister_driver(&alim15x3_pci_driver);
596} 595}
597 596
598module_init(ali15x3_ide_init); 597module_init(ali15x3_ide_init);
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index 824471f91bf5..81ec73134eda 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -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->present) { 95 if (peer->dev_flags & IDE_DFLAG_PRESENT) {
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 }
@@ -319,7 +319,7 @@ static const struct pci_device_id amd74xx_pci_tbl[] = {
319}; 319};
320MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); 320MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl);
321 321
322static struct pci_driver driver = { 322static struct pci_driver amd74xx_pci_driver = {
323 .name = "AMD_IDE", 323 .name = "AMD_IDE",
324 .id_table = amd74xx_pci_tbl, 324 .id_table = amd74xx_pci_tbl,
325 .probe = amd74xx_probe, 325 .probe = amd74xx_probe,
@@ -330,12 +330,12 @@ static struct pci_driver driver = {
330 330
331static int __init amd74xx_ide_init(void) 331static int __init amd74xx_ide_init(void)
332{ 332{
333 return ide_pci_register_driver(&driver); 333 return ide_pci_register_driver(&amd74xx_pci_driver);
334} 334}
335 335
336static void __exit amd74xx_ide_exit(void) 336static void __exit amd74xx_ide_exit(void)
337{ 337{
338 pci_unregister_driver(&driver); 338 pci_unregister_driver(&amd74xx_pci_driver);
339} 339}
340 340
341module_init(amd74xx_ide_init); 341module_init(amd74xx_ide_init);
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c
index e4437034dd08..b2735d28f5cc 100644
--- a/drivers/ide/pci/atiixp.c
+++ b/drivers/ide/pci/atiixp.c
@@ -182,7 +182,7 @@ static const struct pci_device_id atiixp_pci_tbl[] = {
182}; 182};
183MODULE_DEVICE_TABLE(pci, atiixp_pci_tbl); 183MODULE_DEVICE_TABLE(pci, atiixp_pci_tbl);
184 184
185static struct pci_driver driver = { 185static struct pci_driver atiixp_pci_driver = {
186 .name = "ATIIXP_IDE", 186 .name = "ATIIXP_IDE",
187 .id_table = atiixp_pci_tbl, 187 .id_table = atiixp_pci_tbl,
188 .probe = atiixp_init_one, 188 .probe = atiixp_init_one,
@@ -193,12 +193,12 @@ static struct pci_driver driver = {
193 193
194static int __init atiixp_ide_init(void) 194static int __init atiixp_ide_init(void)
195{ 195{
196 return ide_pci_register_driver(&driver); 196 return ide_pci_register_driver(&atiixp_pci_driver);
197} 197}
198 198
199static void __exit atiixp_ide_exit(void) 199static void __exit atiixp_ide_exit(void)
200{ 200{
201 pci_unregister_driver(&driver); 201 pci_unregister_driver(&atiixp_pci_driver);
202} 202}
203 203
204module_init(atiixp_ide_init); 204module_init(atiixp_ide_init);
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
index 7f39cdb41410..e4306647d00d 100644
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -378,13 +378,13 @@ static void __set_prefetch_mode(ide_drive_t *drive, int mode)
378{ 378{
379 if (mode) { /* want prefetch on? */ 379 if (mode) { /* want prefetch on? */
380#if CMD640_PREFETCH_MASKS 380#if CMD640_PREFETCH_MASKS
381 drive->no_unmask = 1; 381 drive->dev_flags |= IDE_DFLAG_NO_UNMASK;
382 drive->unmask = 0; 382 drive->dev_flags &= ~IDE_DFLAG_UNMASK;
383#endif 383#endif
384 drive->no_io_32bit = 0; 384 drive->dev_flags &= ~IDE_DFLAG_NO_IO_32BIT;
385 } else { 385 } else {
386 drive->no_unmask = 0; 386 drive->dev_flags &= ~IDE_DFLAG_NO_UNMASK;
387 drive->no_io_32bit = 1; 387 drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT;
388 drive->io_32bit = 0; 388 drive->io_32bit = 0;
389 } 389 }
390} 390}
@@ -468,10 +468,10 @@ static void program_drive_counts(ide_drive_t *drive, unsigned int index)
468 */ 468 */
469 if (index > 1) { 469 if (index > 1) {
470 ide_hwif_t *hwif = drive->hwif; 470 ide_hwif_t *hwif = drive->hwif;
471 ide_drive_t *peer = &hwif->drives[!drive->select.b.unit]; 471 ide_drive_t *peer = &hwif->drives[!(drive->dn & 1)];
472 unsigned int mate = index ^ 1; 472 unsigned int mate = index ^ 1;
473 473
474 if (peer->present) { 474 if (peer->dev_flags & IDE_DFLAG_PRESENT) {
475 if (setup_count < setup_counts[mate]) 475 if (setup_count < setup_counts[mate])
476 setup_count = setup_counts[mate]; 476 setup_count = setup_counts[mate];
477 if (active_count < active_counts[mate]) 477 if (active_count < active_counts[mate])
@@ -607,7 +607,7 @@ static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio)
607 607
608static void cmd640_init_dev(ide_drive_t *drive) 608static void cmd640_init_dev(ide_drive_t *drive)
609{ 609{
610 unsigned int i = drive->hwif->channel * 2 + drive->select.b.unit; 610 unsigned int i = drive->hwif->channel * 2 + (drive->dn & 1);
611 611
612#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED 612#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
613 /* 613 /*
@@ -626,7 +626,7 @@ static void cmd640_init_dev(ide_drive_t *drive)
626 */ 626 */
627 check_prefetch(drive, i); 627 check_prefetch(drive, i);
628 printk(KERN_INFO DRV_NAME ": drive%d timings/prefetch(%s) preserved\n", 628 printk(KERN_INFO DRV_NAME ": drive%d timings/prefetch(%s) preserved\n",
629 i, drive->no_io_32bit ? "off" : "on"); 629 i, (drive->dev_flags & IDE_DFLAG_NO_IO_32BIT) ? "off" : "on");
630#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ 630#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
631} 631}
632 632
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
index 456dee18b660..935385c77e06 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -228,7 +228,7 @@ static int cmd648_dma_end(ide_drive_t *drive)
228{ 228{
229 ide_hwif_t *hwif = HWIF(drive); 229 ide_hwif_t *hwif = HWIF(drive);
230 unsigned long base = hwif->dma_base - (hwif->channel * 8); 230 unsigned long base = hwif->dma_base - (hwif->channel * 8);
231 int err = __ide_dma_end(drive); 231 int err = ide_dma_end(drive);
232 u8 irq_mask = hwif->channel ? MRDMODE_INTR_CH1 : 232 u8 irq_mask = hwif->channel ? MRDMODE_INTR_CH1 :
233 MRDMODE_INTR_CH0; 233 MRDMODE_INTR_CH0;
234 u8 mrdmode = inb(base + 1); 234 u8 mrdmode = inb(base + 1);
@@ -248,7 +248,7 @@ static int cmd64x_dma_end(ide_drive_t *drive)
248 u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : 248 u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 :
249 CFR_INTR_CH0; 249 CFR_INTR_CH0;
250 u8 irq_stat = 0; 250 u8 irq_stat = 0;
251 int err = __ide_dma_end(drive); 251 int err = ide_dma_end(drive);
252 252
253 (void) pci_read_config_byte(dev, irq_reg, &irq_stat); 253 (void) pci_read_config_byte(dev, irq_reg, &irq_stat);
254 /* clear the interrupt bit */ 254 /* clear the interrupt bit */
@@ -505,7 +505,7 @@ static const struct pci_device_id cmd64x_pci_tbl[] = {
505}; 505};
506MODULE_DEVICE_TABLE(pci, cmd64x_pci_tbl); 506MODULE_DEVICE_TABLE(pci, cmd64x_pci_tbl);
507 507
508static struct pci_driver driver = { 508static struct pci_driver cmd64x_pci_driver = {
509 .name = "CMD64x_IDE", 509 .name = "CMD64x_IDE",
510 .id_table = cmd64x_pci_tbl, 510 .id_table = cmd64x_pci_tbl,
511 .probe = cmd64x_init_one, 511 .probe = cmd64x_init_one,
@@ -516,12 +516,12 @@ static struct pci_driver driver = {
516 516
517static int __init cmd64x_ide_init(void) 517static int __init cmd64x_ide_init(void)
518{ 518{
519 return ide_pci_register_driver(&driver); 519 return ide_pci_register_driver(&cmd64x_pci_driver);
520} 520}
521 521
522static void __exit cmd64x_ide_exit(void) 522static void __exit cmd64x_ide_exit(void)
523{ 523{
524 pci_unregister_driver(&driver); 524 pci_unregister_driver(&cmd64x_pci_driver);
525} 525}
526 526
527module_init(cmd64x_ide_init); 527module_init(cmd64x_ide_init);
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
index d6341f7c4144..5efb467f8fa0 100644
--- a/drivers/ide/pci/cs5520.c
+++ b/drivers/ide/pci/cs5520.c
@@ -145,7 +145,7 @@ static const struct pci_device_id cs5520_pci_tbl[] = {
145}; 145};
146MODULE_DEVICE_TABLE(pci, cs5520_pci_tbl); 146MODULE_DEVICE_TABLE(pci, cs5520_pci_tbl);
147 147
148static struct pci_driver driver = { 148static struct pci_driver cs5520_pci_driver = {
149 .name = "Cyrix_IDE", 149 .name = "Cyrix_IDE",
150 .id_table = cs5520_pci_tbl, 150 .id_table = cs5520_pci_tbl,
151 .probe = cs5520_init_one, 151 .probe = cs5520_init_one,
@@ -155,7 +155,7 @@ static struct pci_driver driver = {
155 155
156static int __init cs5520_ide_init(void) 156static int __init cs5520_ide_init(void)
157{ 157{
158 return ide_pci_register_driver(&driver); 158 return ide_pci_register_driver(&cs5520_pci_driver);
159} 159}
160 160
161module_init(cs5520_ide_init); 161module_init(cs5520_ide_init);
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c
index da42fa7e9f97..53f079cc00af 100644
--- a/drivers/ide/pci/cs5530.c
+++ b/drivers/ide/pci/cs5530.c
@@ -267,7 +267,7 @@ static const struct pci_device_id cs5530_pci_tbl[] = {
267}; 267};
268MODULE_DEVICE_TABLE(pci, cs5530_pci_tbl); 268MODULE_DEVICE_TABLE(pci, cs5530_pci_tbl);
269 269
270static struct pci_driver driver = { 270static struct pci_driver cs5530_pci_driver = {
271 .name = "CS5530 IDE", 271 .name = "CS5530 IDE",
272 .id_table = cs5530_pci_tbl, 272 .id_table = cs5530_pci_tbl,
273 .probe = cs5530_init_one, 273 .probe = cs5530_init_one,
@@ -278,12 +278,12 @@ static struct pci_driver driver = {
278 278
279static int __init cs5530_ide_init(void) 279static int __init cs5530_ide_init(void)
280{ 280{
281 return ide_pci_register_driver(&driver); 281 return ide_pci_register_driver(&cs5530_pci_driver);
282} 282}
283 283
284static void __exit cs5530_ide_exit(void) 284static void __exit cs5530_ide_exit(void)
285{ 285{
286 pci_unregister_driver(&driver); 286 pci_unregister_driver(&cs5530_pci_driver);
287} 287}
288 288
289module_init(cs5530_ide_init); 289module_init(cs5530_ide_init);
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c
index 1e5bc59ea2fb..983d957a0189 100644
--- a/drivers/ide/pci/cs5535.c
+++ b/drivers/ide/pci/cs5535.c
@@ -76,7 +76,7 @@ static unsigned int cs5535_udma_timings[5] =
76static void cs5535_set_speed(ide_drive_t *drive, const u8 speed) 76static void cs5535_set_speed(ide_drive_t *drive, const u8 speed)
77{ 77{
78 u32 reg = 0, dummy; 78 u32 reg = 0, dummy;
79 int unit = drive->select.b.unit; 79 u8 unit = drive->dn & 1;
80 80
81 /* Set the PIO timings */ 81 /* Set the PIO timings */
82 if (speed < XFER_SW_DMA_0) { 82 if (speed < XFER_SW_DMA_0) {
@@ -192,7 +192,7 @@ static const struct pci_device_id cs5535_pci_tbl[] = {
192 192
193MODULE_DEVICE_TABLE(pci, cs5535_pci_tbl); 193MODULE_DEVICE_TABLE(pci, cs5535_pci_tbl);
194 194
195static struct pci_driver driver = { 195static struct pci_driver cs5535_pci_driver = {
196 .name = "CS5535_IDE", 196 .name = "CS5535_IDE",
197 .id_table = cs5535_pci_tbl, 197 .id_table = cs5535_pci_tbl,
198 .probe = cs5535_init_one, 198 .probe = cs5535_init_one,
@@ -203,12 +203,12 @@ static struct pci_driver driver = {
203 203
204static int __init cs5535_ide_init(void) 204static int __init cs5535_ide_init(void)
205{ 205{
206 return ide_pci_register_driver(&driver); 206 return ide_pci_register_driver(&cs5535_pci_driver);
207} 207}
208 208
209static void __exit cs5535_ide_exit(void) 209static void __exit cs5535_ide_exit(void)
210{ 210{
211 pci_unregister_driver(&driver); 211 pci_unregister_driver(&cs5535_pci_driver);
212} 212}
213 213
214module_init(cs5535_ide_init); 214module_init(cs5535_ide_init);
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
index 69820e9224d1..5297f07d2933 100644
--- a/drivers/ide/pci/cy82c693.c
+++ b/drivers/ide/pci/cy82c693.c
@@ -50,18 +50,11 @@
50 50
51#define DRV_NAME "cy82c693" 51#define DRV_NAME "cy82c693"
52 52
53/* the current version */
54#define CY82_VERSION "CY82C693U driver v0.34 99-13-12 Andreas S. Krebs (akrebs@altavista.net)"
55
56/* 53/*
57 * The following are used to debug the driver. 54 * The following are used to debug the driver.
58 */ 55 */
59#define CY82C693_DEBUG_LOGS 0
60#define CY82C693_DEBUG_INFO 0 56#define CY82C693_DEBUG_INFO 0
61 57
62/* define CY82C693_SETDMA_CLOCK to set DMA Controller Clock Speed to ATCLK */
63#undef CY82C693_SETDMA_CLOCK
64
65/* 58/*
66 * NOTE: the value for busmaster timeout is tricky and I got it by 59 * NOTE: the value for busmaster timeout is tricky and I got it by
67 * trial and error! By using a to low value will cause DMA timeouts 60 * trial and error! By using a to low value will cause DMA timeouts
@@ -89,7 +82,6 @@
89#define CY82_INDEX_PORT 0x22 82#define CY82_INDEX_PORT 0x22
90#define CY82_DATA_PORT 0x23 83#define CY82_DATA_PORT 0x23
91 84
92#define CY82_INDEX_CTRLREG1 0x01
93#define CY82_INDEX_CHANNEL0 0x30 85#define CY82_INDEX_CHANNEL0 0x30
94#define CY82_INDEX_CHANNEL1 0x31 86#define CY82_INDEX_CHANNEL1 0x31
95#define CY82_INDEX_TIMEOUT 0x32 87#define CY82_INDEX_TIMEOUT 0x32
@@ -179,17 +171,6 @@ static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode)
179 171
180 index = hwif->channel ? CY82_INDEX_CHANNEL1 : CY82_INDEX_CHANNEL0; 172 index = hwif->channel ? CY82_INDEX_CHANNEL1 : CY82_INDEX_CHANNEL0;
181 173
182#if CY82C693_DEBUG_LOGS
183 /* for debug let's show the previous values */
184
185 outb(index, CY82_INDEX_PORT);
186 data = inb(CY82_DATA_PORT);
187
188 printk(KERN_INFO "%s (ch=%d, dev=%d): DMA mode is %d (single=%d)\n",
189 drive->name, HWIF(drive)->channel, drive->select.b.unit,
190 (data&0x3), ((data>>2)&1));
191#endif /* CY82C693_DEBUG_LOGS */
192
193 data = (mode & 3) | (single << 2); 174 data = (mode & 3) | (single << 2);
194 175
195 outb(index, CY82_INDEX_PORT); 176 outb(index, CY82_INDEX_PORT);
@@ -197,8 +178,7 @@ static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode)
197 178
198#if CY82C693_DEBUG_INFO 179#if CY82C693_DEBUG_INFO
199 printk(KERN_INFO "%s (ch=%d, dev=%d): set DMA mode to %d (single=%d)\n", 180 printk(KERN_INFO "%s (ch=%d, dev=%d): set DMA mode to %d (single=%d)\n",
200 drive->name, HWIF(drive)->channel, drive->select.b.unit, 181 drive->name, hwif->channel, drive->dn & 1, mode & 3, single);
201 mode & 3, single);
202#endif /* CY82C693_DEBUG_INFO */ 182#endif /* CY82C693_DEBUG_INFO */
203 183
204 /* 184 /*
@@ -239,50 +219,11 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio)
239 } 219 }
240 } 220 }
241 221
242#if CY82C693_DEBUG_LOGS
243 /* for debug let's show the register values */
244
245 if (drive->select.b.unit == 0) {
246 /*
247 * get master drive registers
248 * address setup control register
249 * is 32 bit !!!
250 */
251 pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl);
252 addrCtrl &= 0x0F;
253
254 /* now let's get the remaining registers */
255 pci_read_config_byte(dev, CY82_IDE_MASTER_IOR, &pclk.time_16r);
256 pci_read_config_byte(dev, CY82_IDE_MASTER_IOW, &pclk.time_16w);
257 pci_read_config_byte(dev, CY82_IDE_MASTER_8BIT, &pclk.time_8);
258 } else {
259 /*
260 * set slave drive registers
261 * address setup control register
262 * is 32 bit !!!
263 */
264 pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl);
265
266 addrCtrl &= 0xF0;
267 addrCtrl >>= 4;
268
269 /* now let's get the remaining registers */
270 pci_read_config_byte(dev, CY82_IDE_SLAVE_IOR, &pclk.time_16r);
271 pci_read_config_byte(dev, CY82_IDE_SLAVE_IOW, &pclk.time_16w);
272 pci_read_config_byte(dev, CY82_IDE_SLAVE_8BIT, &pclk.time_8);
273 }
274
275 printk(KERN_INFO "%s (ch=%d, dev=%d): PIO timing is "
276 "(addr=0x%X, ior=0x%X, iow=0x%X, 8bit=0x%X)\n",
277 drive->name, hwif->channel, drive->select.b.unit,
278 addrCtrl, pclk.time_16r, pclk.time_16w, pclk.time_8);
279#endif /* CY82C693_DEBUG_LOGS */
280
281 /* let's calc the values for this PIO mode */ 222 /* let's calc the values for this PIO mode */
282 compute_clocks(pio, &pclk); 223 compute_clocks(pio, &pclk);
283 224
284 /* now let's write the clocks registers */ 225 /* now let's write the clocks registers */
285 if (drive->select.b.unit == 0) { 226 if ((drive->dn & 1) == 0) {
286 /* 227 /*
287 * set master drive 228 * set master drive
288 * address setup control register 229 * address setup control register
@@ -324,63 +265,11 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio)
324#if CY82C693_DEBUG_INFO 265#if CY82C693_DEBUG_INFO
325 printk(KERN_INFO "%s (ch=%d, dev=%d): set PIO timing to " 266 printk(KERN_INFO "%s (ch=%d, dev=%d): set PIO timing to "
326 "(addr=0x%X, ior=0x%X, iow=0x%X, 8bit=0x%X)\n", 267 "(addr=0x%X, ior=0x%X, iow=0x%X, 8bit=0x%X)\n",
327 drive->name, hwif->channel, drive->select.b.unit, 268 drive->name, hwif->channel, drive->dn & 1,
328 addrCtrl, pclk.time_16r, pclk.time_16w, pclk.time_8); 269 addrCtrl, pclk.time_16r, pclk.time_16w, pclk.time_8);
329#endif /* CY82C693_DEBUG_INFO */ 270#endif /* CY82C693_DEBUG_INFO */
330} 271}
331 272
332/*
333 * this function is called during init and is used to setup the cy82c693 chip
334 */
335static unsigned int init_chipset_cy82c693(struct pci_dev *dev)
336{
337 if (PCI_FUNC(dev->devfn) != 1)
338 return 0;
339
340#ifdef CY82C693_SETDMA_CLOCK
341 u8 data = 0;
342#endif /* CY82C693_SETDMA_CLOCK */
343
344 /* write info about this verion of the driver */
345 printk(KERN_INFO CY82_VERSION "\n");
346
347#ifdef CY82C693_SETDMA_CLOCK
348 /* okay let's set the DMA clock speed */
349
350 outb(CY82_INDEX_CTRLREG1, CY82_INDEX_PORT);
351 data = inb(CY82_DATA_PORT);
352
353#if CY82C693_DEBUG_INFO
354 printk(KERN_INFO DRV_NAME ": Peripheral Configuration Register: 0x%X\n",
355 data);
356#endif /* CY82C693_DEBUG_INFO */
357
358 /*
359 * for some reason sometimes the DMA controller
360 * speed is set to ATCLK/2 ???? - we fix this here
361 *
362 * note: i don't know what causes this strange behaviour,
363 * but even changing the dma speed doesn't solve it :-(
364 * the ide performance is still only half the normal speed
365 *
366 * if anybody knows what goes wrong with my machine, please
367 * let me know - ASK
368 */
369
370 data |= 0x03;
371
372 outb(CY82_INDEX_CTRLREG1, CY82_INDEX_PORT);
373 outb(data, CY82_DATA_PORT);
374
375#if CY82C693_DEBUG_INFO
376 printk(KERN_INFO ": New Peripheral Configuration Register: 0x%X\n",
377 data);
378#endif /* CY82C693_DEBUG_INFO */
379
380#endif /* CY82C693_SETDMA_CLOCK */
381 return 0;
382}
383
384static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) 273static void __devinit init_iops_cy82c693(ide_hwif_t *hwif)
385{ 274{
386 static ide_hwif_t *primary; 275 static ide_hwif_t *primary;
@@ -401,7 +290,6 @@ static const struct ide_port_ops cy82c693_port_ops = {
401 290
402static const struct ide_port_info cy82c693_chipset __devinitdata = { 291static const struct ide_port_info cy82c693_chipset __devinitdata = {
403 .name = DRV_NAME, 292 .name = DRV_NAME,
404 .init_chipset = init_chipset_cy82c693,
405 .init_iops = init_iops_cy82c693, 293 .init_iops = init_iops_cy82c693,
406 .port_ops = &cy82c693_port_ops, 294 .port_ops = &cy82c693_port_ops,
407 .chipset = ide_cy82c693, 295 .chipset = ide_cy82c693,
@@ -443,7 +331,7 @@ static const struct pci_device_id cy82c693_pci_tbl[] = {
443}; 331};
444MODULE_DEVICE_TABLE(pci, cy82c693_pci_tbl); 332MODULE_DEVICE_TABLE(pci, cy82c693_pci_tbl);
445 333
446static struct pci_driver driver = { 334static struct pci_driver cy82c693_pci_driver = {
447 .name = "Cypress_IDE", 335 .name = "Cypress_IDE",
448 .id_table = cy82c693_pci_tbl, 336 .id_table = cy82c693_pci_tbl,
449 .probe = cy82c693_init_one, 337 .probe = cy82c693_init_one,
@@ -454,12 +342,12 @@ static struct pci_driver driver = {
454 342
455static int __init cy82c693_ide_init(void) 343static int __init cy82c693_ide_init(void)
456{ 344{
457 return ide_pci_register_driver(&driver); 345 return ide_pci_register_driver(&cy82c693_pci_driver);
458} 346}
459 347
460static void __exit cy82c693_ide_exit(void) 348static void __exit cy82c693_ide_exit(void)
461{ 349{
462 pci_unregister_driver(&driver); 350 pci_unregister_driver(&cy82c693_pci_driver);
463} 351}
464 352
465module_init(cy82c693_ide_init); 353module_init(cy82c693_ide_init);
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c
index 83b63b365e51..8689a706f537 100644
--- a/drivers/ide/pci/delkin_cb.c
+++ b/drivers/ide/pci/delkin_cb.c
@@ -117,7 +117,7 @@ static struct pci_device_id delkin_cb_pci_tbl[] __devinitdata = {
117}; 117};
118MODULE_DEVICE_TABLE(pci, delkin_cb_pci_tbl); 118MODULE_DEVICE_TABLE(pci, delkin_cb_pci_tbl);
119 119
120static struct pci_driver driver = { 120static struct pci_driver delkin_cb_pci_driver = {
121 .name = "Delkin-ASKA-Workbit Cardbus IDE", 121 .name = "Delkin-ASKA-Workbit Cardbus IDE",
122 .id_table = delkin_cb_pci_tbl, 122 .id_table = delkin_cb_pci_tbl,
123 .probe = delkin_cb_probe, 123 .probe = delkin_cb_probe,
@@ -126,12 +126,12 @@ static struct pci_driver driver = {
126 126
127static int __init delkin_cb_init(void) 127static int __init delkin_cb_init(void)
128{ 128{
129 return pci_register_driver(&driver); 129 return pci_register_driver(&delkin_cb_pci_driver);
130} 130}
131 131
132static void __exit delkin_cb_exit(void) 132static void __exit delkin_cb_exit(void)
133{ 133{
134 pci_unregister_driver(&driver); 134 pci_unregister_driver(&delkin_cb_pci_driver);
135} 135}
136 136
137module_init(delkin_cb_init); 137module_init(delkin_cb_init);
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c
index 092b238cb250..474f96a7c076 100644
--- a/drivers/ide/pci/generic.c
+++ b/drivers/ide/pci/generic.c
@@ -166,7 +166,7 @@ static const struct pci_device_id generic_pci_tbl[] = {
166}; 166};
167MODULE_DEVICE_TABLE(pci, generic_pci_tbl); 167MODULE_DEVICE_TABLE(pci, generic_pci_tbl);
168 168
169static struct pci_driver driver = { 169static struct pci_driver generic_pci_driver = {
170 .name = "PCI_IDE", 170 .name = "PCI_IDE",
171 .id_table = generic_pci_tbl, 171 .id_table = generic_pci_tbl,
172 .probe = generic_init_one, 172 .probe = generic_init_one,
@@ -177,12 +177,12 @@ static struct pci_driver driver = {
177 177
178static int __init generic_ide_init(void) 178static int __init generic_ide_init(void)
179{ 179{
180 return ide_pci_register_driver(&driver); 180 return ide_pci_register_driver(&generic_pci_driver);
181} 181}
182 182
183static void __exit generic_ide_exit(void) 183static void __exit generic_ide_exit(void)
184{ 184{
185 pci_unregister_driver(&driver); 185 pci_unregister_driver(&generic_pci_driver);
186} 186}
187 187
188module_init(generic_ide_init); 188module_init(generic_ide_init);
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
index 644de29f8fe4..fb1a3aa57f07 100644
--- a/drivers/ide/pci/hpt34x.c
+++ b/drivers/ide/pci/hpt34x.c
@@ -166,7 +166,7 @@ static const struct pci_device_id hpt34x_pci_tbl[] = {
166}; 166};
167MODULE_DEVICE_TABLE(pci, hpt34x_pci_tbl); 167MODULE_DEVICE_TABLE(pci, hpt34x_pci_tbl);
168 168
169static struct pci_driver driver = { 169static struct pci_driver hpt34x_pci_driver = {
170 .name = "HPT34x_IDE", 170 .name = "HPT34x_IDE",
171 .id_table = hpt34x_pci_tbl, 171 .id_table = hpt34x_pci_tbl,
172 .probe = hpt34x_init_one, 172 .probe = hpt34x_init_one,
@@ -177,12 +177,12 @@ static struct pci_driver driver = {
177 177
178static int __init hpt34x_ide_init(void) 178static int __init hpt34x_ide_init(void)
179{ 179{
180 return ide_pci_register_driver(&driver); 180 return ide_pci_register_driver(&hpt34x_pci_driver);
181} 181}
182 182
183static void __exit hpt34x_ide_exit(void) 183static void __exit hpt34x_ide_exit(void)
184{ 184{
185 pci_unregister_driver(&driver); 185 pci_unregister_driver(&hpt34x_pci_driver);
186} 186}
187 187
188module_init(hpt34x_ide_init); 188module_init(hpt34x_ide_init);
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index a194022b6a61..9cf171cb9376 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -835,7 +835,7 @@ static int hpt370_dma_end(ide_drive_t *drive)
835 if (dma_stat & 0x01) 835 if (dma_stat & 0x01)
836 hpt370_irq_timeout(drive); 836 hpt370_irq_timeout(drive);
837 } 837 }
838 return __ide_dma_end(drive); 838 return ide_dma_end(drive);
839} 839}
840 840
841static void hpt370_dma_timeout(ide_drive_t *drive) 841static void hpt370_dma_timeout(ide_drive_t *drive)
@@ -863,9 +863,6 @@ static int hpt374_dma_test_irq(ide_drive_t *drive)
863 if (dma_stat & 4) 863 if (dma_stat & 4)
864 return 1; 864 return 1;
865 865
866 if (!drive->waiting_for_dma)
867 printk(KERN_WARNING "%s: (%s) called while not waiting\n",
868 drive->name, __func__);
869 return 0; 866 return 0;
870} 867}
871 868
@@ -880,7 +877,7 @@ static int hpt374_dma_end(ide_drive_t *drive)
880 pci_read_config_byte(dev, mcr_addr, &mcr); 877 pci_read_config_byte(dev, mcr_addr, &mcr);
881 if (bwsr & mask) 878 if (bwsr & mask)
882 pci_write_config_byte(dev, mcr_addr, mcr | 0x30); 879 pci_write_config_byte(dev, mcr_addr, mcr | 0x30);
883 return __ide_dma_end(drive); 880 return ide_dma_end(drive);
884} 881}
885 882
886/** 883/**
@@ -1456,7 +1453,7 @@ static const struct ide_dma_ops hpt36x_dma_ops = {
1456 .dma_setup = ide_dma_setup, 1453 .dma_setup = ide_dma_setup,
1457 .dma_exec_cmd = ide_dma_exec_cmd, 1454 .dma_exec_cmd = ide_dma_exec_cmd,
1458 .dma_start = ide_dma_start, 1455 .dma_start = ide_dma_start,
1459 .dma_end = __ide_dma_end, 1456 .dma_end = ide_dma_end,
1460 .dma_test_irq = ide_dma_test_irq, 1457 .dma_test_irq = ide_dma_test_irq,
1461 .dma_lost_irq = hpt366_dma_lost_irq, 1458 .dma_lost_irq = hpt366_dma_lost_irq,
1462 .dma_timeout = ide_dma_timeout, 1459 .dma_timeout = ide_dma_timeout,
@@ -1622,7 +1619,7 @@ static const struct pci_device_id hpt366_pci_tbl[] __devinitconst = {
1622}; 1619};
1623MODULE_DEVICE_TABLE(pci, hpt366_pci_tbl); 1620MODULE_DEVICE_TABLE(pci, hpt366_pci_tbl);
1624 1621
1625static struct pci_driver driver = { 1622static struct pci_driver hpt366_pci_driver = {
1626 .name = "HPT366_IDE", 1623 .name = "HPT366_IDE",
1627 .id_table = hpt366_pci_tbl, 1624 .id_table = hpt366_pci_tbl,
1628 .probe = hpt366_init_one, 1625 .probe = hpt366_init_one,
@@ -1633,12 +1630,12 @@ static struct pci_driver driver = {
1633 1630
1634static int __init hpt366_ide_init(void) 1631static int __init hpt366_ide_init(void)
1635{ 1632{
1636 return ide_pci_register_driver(&driver); 1633 return ide_pci_register_driver(&hpt366_pci_driver);
1637} 1634}
1638 1635
1639static void __exit hpt366_ide_exit(void) 1636static void __exit hpt366_ide_exit(void)
1640{ 1637{
1641 pci_unregister_driver(&driver); 1638 pci_unregister_driver(&hpt366_pci_driver);
1642} 1639}
1643 1640
1644module_init(hpt366_ide_init); 1641module_init(hpt366_ide_init);
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c
index 0954ccd08d6f..7c2feeb3c5ec 100644
--- a/drivers/ide/pci/it8213.c
+++ b/drivers/ide/pci/it8213.c
@@ -189,7 +189,7 @@ static const struct pci_device_id it8213_pci_tbl[] = {
189 189
190MODULE_DEVICE_TABLE(pci, it8213_pci_tbl); 190MODULE_DEVICE_TABLE(pci, it8213_pci_tbl);
191 191
192static struct pci_driver driver = { 192static struct pci_driver it8213_pci_driver = {
193 .name = "ITE8213_IDE", 193 .name = "ITE8213_IDE",
194 .id_table = it8213_pci_tbl, 194 .id_table = it8213_pci_tbl,
195 .probe = it8213_init_one, 195 .probe = it8213_init_one,
@@ -200,12 +200,12 @@ static struct pci_driver driver = {
200 200
201static int __init it8213_ide_init(void) 201static int __init it8213_ide_init(void)
202{ 202{
203 return ide_pci_register_driver(&driver); 203 return ide_pci_register_driver(&it8213_pci_driver);
204} 204}
205 205
206static void __exit it8213_ide_exit(void) 206static void __exit it8213_ide_exit(void)
207{ 207{
208 pci_unregister_driver(&driver); 208 pci_unregister_driver(&it8213_pci_driver);
209} 209}
210 210
211module_init(it8213_ide_init); 211module_init(it8213_ide_init);
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index 46edd083b348..995e18bb3139 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -138,8 +138,7 @@ static void it821x_program_udma(ide_drive_t *drive, u16 timing)
138 struct pci_dev *dev = to_pci_dev(hwif->dev); 138 struct pci_dev *dev = to_pci_dev(hwif->dev);
139 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 139 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
140 int channel = hwif->channel; 140 int channel = hwif->channel;
141 int unit = drive->select.b.unit; 141 u8 unit = drive->dn & 1, conf;
142 u8 conf;
143 142
144 /* Program UDMA timing bits */ 143 /* Program UDMA timing bits */
145 if(itdev->clock_mode == ATA_66) 144 if(itdev->clock_mode == ATA_66)
@@ -168,13 +167,11 @@ static void it821x_clock_strategy(ide_drive_t *drive)
168 ide_hwif_t *hwif = drive->hwif; 167 ide_hwif_t *hwif = drive->hwif;
169 struct pci_dev *dev = to_pci_dev(hwif->dev); 168 struct pci_dev *dev = to_pci_dev(hwif->dev);
170 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 169 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
170 ide_drive_t *pair;
171 int clock, altclock, sel = 0;
172 u8 unit = drive->dn & 1, v;
171 173
172 u8 unit = drive->select.b.unit; 174 pair = &hwif->drives[1 - unit];
173 ide_drive_t *pair = &hwif->drives[1-unit];
174
175 int clock, altclock;
176 u8 v;
177 int sel = 0;
178 175
179 if(itdev->want[0][0] > itdev->want[1][0]) { 176 if(itdev->want[0][0] > itdev->want[1][0]) {
180 clock = itdev->want[0][1]; 177 clock = itdev->want[0][1];
@@ -240,16 +237,17 @@ static void it821x_clock_strategy(ide_drive_t *drive)
240 237
241static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio) 238static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio)
242{ 239{
243 ide_hwif_t *hwif = drive->hwif; 240 ide_hwif_t *hwif = drive->hwif;
244 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 241 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
245 int unit = drive->select.b.unit; 242 ide_drive_t *pair;
246 ide_drive_t *pair = &hwif->drives[1 - unit]; 243 u8 unit = drive->dn & 1, set_pio = pio;
247 u8 set_pio = pio;
248 244
249 /* Spec says 89 ref driver uses 88 */ 245 /* Spec says 89 ref driver uses 88 */
250 static u16 pio_timings[]= { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 }; 246 static u16 pio_timings[]= { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 };
251 static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY }; 247 static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY };
252 248
249 pair = &hwif->drives[1 - unit];
250
253 /* 251 /*
254 * Compute the best PIO mode we can for a given device. We must 252 * Compute the best PIO mode we can for a given device. We must
255 * pick a speed that does not cause problems with the other device 253 * pick a speed that does not cause problems with the other device
@@ -286,9 +284,7 @@ static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted)
286 ide_hwif_t *hwif = drive->hwif; 284 ide_hwif_t *hwif = drive->hwif;
287 struct pci_dev *dev = to_pci_dev(hwif->dev); 285 struct pci_dev *dev = to_pci_dev(hwif->dev);
288 struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif); 286 struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif);
289 int unit = drive->select.b.unit; 287 u8 unit = drive->dn & 1, channel = hwif->channel, conf;
290 int channel = hwif->channel;
291 u8 conf;
292 288
293 static u16 dma[] = { 0x8866, 0x3222, 0x3121 }; 289 static u16 dma[] = { 0x8866, 0x3222, 0x3121 };
294 static u8 mwdma_want[] = { ATA_ANY, ATA_66, ATA_ANY }; 290 static u8 mwdma_want[] = { ATA_ANY, ATA_66, ATA_ANY };
@@ -325,9 +321,7 @@ static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted)
325 ide_hwif_t *hwif = drive->hwif; 321 ide_hwif_t *hwif = drive->hwif;
326 struct pci_dev *dev = to_pci_dev(hwif->dev); 322 struct pci_dev *dev = to_pci_dev(hwif->dev);
327 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 323 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
328 int unit = drive->select.b.unit; 324 u8 unit = drive->dn & 1, channel = hwif->channel, conf;
329 int channel = hwif->channel;
330 u8 conf;
331 325
332 static u16 udma[] = { 0x4433, 0x4231, 0x3121, 0x2121, 0x1111, 0x2211, 0x1111 }; 326 static u16 udma[] = { 0x4433, 0x4231, 0x3121, 0x2121, 0x1111, 0x2211, 0x1111 };
333 static u8 udma_want[] = { ATA_ANY, ATA_50, ATA_ANY, ATA_66, ATA_66, ATA_50, ATA_66 }; 327 static u8 udma_want[] = { ATA_ANY, ATA_50, ATA_ANY, ATA_66, ATA_66, ATA_50, ATA_66 };
@@ -369,7 +363,8 @@ static void it821x_dma_start(ide_drive_t *drive)
369{ 363{
370 ide_hwif_t *hwif = drive->hwif; 364 ide_hwif_t *hwif = drive->hwif;
371 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 365 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
372 int unit = drive->select.b.unit; 366 u8 unit = drive->dn & 1;
367
373 if(itdev->mwdma[unit] != MWDMA_OFF) 368 if(itdev->mwdma[unit] != MWDMA_OFF)
374 it821x_program(drive, itdev->mwdma[unit]); 369 it821x_program(drive, itdev->mwdma[unit]);
375 else if(itdev->udma[unit] != UDMA_OFF && itdev->timing10) 370 else if(itdev->udma[unit] != UDMA_OFF && itdev->timing10)
@@ -389,9 +384,10 @@ static void it821x_dma_start(ide_drive_t *drive)
389static int it821x_dma_end(ide_drive_t *drive) 384static int it821x_dma_end(ide_drive_t *drive)
390{ 385{
391 ide_hwif_t *hwif = drive->hwif; 386 ide_hwif_t *hwif = drive->hwif;
392 int unit = drive->select.b.unit;
393 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 387 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
394 int ret = __ide_dma_end(drive); 388 int ret = ide_dma_end(drive);
389 u8 unit = drive->dn & 1;
390
395 if(itdev->mwdma[unit] != MWDMA_OFF) 391 if(itdev->mwdma[unit] != MWDMA_OFF)
396 it821x_program(drive, itdev->pio[unit]); 392 it821x_program(drive, itdev->pio[unit]);
397 return ret; 393 return ret;
@@ -454,7 +450,7 @@ static void it821x_quirkproc(ide_drive_t *drive)
454 * IRQ mask as we may well be in PIO (eg rev 0x10) 450 * IRQ mask as we may well be in PIO (eg rev 0x10)
455 * for now and we know unmasking is safe on this chipset. 451 * for now and we know unmasking is safe on this chipset.
456 */ 452 */
457 drive->unmask = 1; 453 drive->dev_flags |= IDE_DFLAG_UNMASK;
458 } else { 454 } else {
459 /* 455 /*
460 * Perform fixups on smart mode. We need to "lose" some 456 * Perform fixups on smart mode. We need to "lose" some
@@ -680,7 +676,7 @@ static const struct pci_device_id it821x_pci_tbl[] = {
680 676
681MODULE_DEVICE_TABLE(pci, it821x_pci_tbl); 677MODULE_DEVICE_TABLE(pci, it821x_pci_tbl);
682 678
683static struct pci_driver driver = { 679static struct pci_driver it821x_pci_driver = {
684 .name = "ITE821x IDE", 680 .name = "ITE821x IDE",
685 .id_table = it821x_pci_tbl, 681 .id_table = it821x_pci_tbl,
686 .probe = it821x_init_one, 682 .probe = it821x_init_one,
@@ -691,12 +687,12 @@ static struct pci_driver driver = {
691 687
692static int __init it821x_ide_init(void) 688static int __init it821x_ide_init(void)
693{ 689{
694 return ide_pci_register_driver(&driver); 690 return ide_pci_register_driver(&it821x_pci_driver);
695} 691}
696 692
697static void __exit it821x_ide_exit(void) 693static void __exit it821x_ide_exit(void)
698{ 694{
699 pci_unregister_driver(&driver); 695 pci_unregister_driver(&it821x_pci_driver);
700} 696}
701 697
702module_init(it821x_ide_init); 698module_init(it821x_ide_init);
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c
index acd647110648..9a68433cf46d 100644
--- a/drivers/ide/pci/jmicron.c
+++ b/drivers/ide/pci/jmicron.c
@@ -149,7 +149,7 @@ static struct pci_device_id jmicron_pci_tbl[] = {
149 149
150MODULE_DEVICE_TABLE(pci, jmicron_pci_tbl); 150MODULE_DEVICE_TABLE(pci, jmicron_pci_tbl);
151 151
152static struct pci_driver driver = { 152static struct pci_driver jmicron_pci_driver = {
153 .name = "JMicron IDE", 153 .name = "JMicron IDE",
154 .id_table = jmicron_pci_tbl, 154 .id_table = jmicron_pci_tbl,
155 .probe = jmicron_init_one, 155 .probe = jmicron_init_one,
@@ -160,12 +160,12 @@ static struct pci_driver driver = {
160 160
161static int __init jmicron_ide_init(void) 161static int __init jmicron_ide_init(void)
162{ 162{
163 return ide_pci_register_driver(&driver); 163 return ide_pci_register_driver(&jmicron_pci_driver);
164} 164}
165 165
166static void __exit jmicron_ide_exit(void) 166static void __exit jmicron_ide_exit(void)
167{ 167{
168 pci_unregister_driver(&driver); 168 pci_unregister_driver(&jmicron_pci_driver);
169} 169}
170 170
171module_init(jmicron_ide_init); 171module_init(jmicron_ide_init);
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
index 53bd645736d9..13789060f407 100644
--- a/drivers/ide/pci/ns87415.c
+++ b/drivers/ide/pci/ns87415.c
@@ -137,7 +137,7 @@ static void __devinit superio_init_iops(struct hwif_s *hwif)
137static unsigned int ns87415_count = 0, ns87415_control[MAX_HWIFS] = { 0 }; 137static unsigned int ns87415_count = 0, ns87415_control[MAX_HWIFS] = { 0 };
138 138
139/* 139/*
140 * This routine either enables/disables (according to drive->present) 140 * This routine either enables/disables (according to IDE_DFLAG_PRESENT)
141 * the IRQ associated with the port (HWIF(drive)), 141 * the IRQ associated with the port (HWIF(drive)),
142 * and selects either PIO or DMA handshaking for the next I/O operation. 142 * and selects either PIO or DMA handshaking for the next I/O operation.
143 */ 143 */
@@ -153,11 +153,15 @@ static void ns87415_prepare_drive (ide_drive_t *drive, unsigned int use_dma)
153 153
154 /* Adjust IRQ enable bit */ 154 /* Adjust IRQ enable bit */
155 bit = 1 << (8 + hwif->channel); 155 bit = 1 << (8 + hwif->channel);
156 new = drive->present ? (new & ~bit) : (new | bit); 156
157 if (drive->dev_flags & IDE_DFLAG_PRESENT)
158 new &= ~bit;
159 else
160 new |= bit;
157 161
158 /* Select PIO or DMA, DMA may only be selected for one drive/channel. */ 162 /* Select PIO or DMA, DMA may only be selected for one drive/channel. */
159 bit = 1 << (20 + drive->select.b.unit + (hwif->channel << 1)); 163 bit = 1 << (20 + (drive->dn & 1) + (hwif->channel << 1));
160 other = 1 << (20 + (1 - drive->select.b.unit) + (hwif->channel << 1)); 164 other = 1 << (20 + (1 - (drive->dn & 1)) + (hwif->channel << 1));
161 new = use_dma ? ((new & ~other) | bit) : (new & ~bit); 165 new = use_dma ? ((new & ~other) | bit) : (new & ~bit);
162 166
163 if (new != *old) { 167 if (new != *old) {
@@ -187,7 +191,8 @@ static void ns87415_prepare_drive (ide_drive_t *drive, unsigned int use_dma)
187 191
188static void ns87415_selectproc (ide_drive_t *drive) 192static void ns87415_selectproc (ide_drive_t *drive)
189{ 193{
190 ns87415_prepare_drive (drive, drive->using_dma); 194 ns87415_prepare_drive(drive,
195 !!(drive->dev_flags & IDE_DFLAG_USING_DMA));
191} 196}
192 197
193static int ns87415_dma_end(ide_drive_t *drive) 198static int ns87415_dma_end(ide_drive_t *drive)
@@ -334,7 +339,7 @@ static const struct pci_device_id ns87415_pci_tbl[] = {
334}; 339};
335MODULE_DEVICE_TABLE(pci, ns87415_pci_tbl); 340MODULE_DEVICE_TABLE(pci, ns87415_pci_tbl);
336 341
337static struct pci_driver driver = { 342static struct pci_driver ns87415_pci_driver = {
338 .name = "NS87415_IDE", 343 .name = "NS87415_IDE",
339 .id_table = ns87415_pci_tbl, 344 .id_table = ns87415_pci_tbl,
340 .probe = ns87415_init_one, 345 .probe = ns87415_init_one,
@@ -345,12 +350,12 @@ static struct pci_driver driver = {
345 350
346static int __init ns87415_ide_init(void) 351static int __init ns87415_ide_init(void)
347{ 352{
348 return ide_pci_register_driver(&driver); 353 return ide_pci_register_driver(&ns87415_pci_driver);
349} 354}
350 355
351static void __exit ns87415_ide_exit(void) 356static void __exit ns87415_ide_exit(void)
352{ 357{
353 pci_unregister_driver(&driver); 358 pci_unregister_driver(&ns87415_pci_driver);
354} 359}
355 360
356module_init(ns87415_ide_init); 361module_init(ns87415_ide_init);
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c
index 3de11ddcf863..6048eda3cd61 100644
--- a/drivers/ide/pci/opti621.c
+++ b/drivers/ide/pci/opti621.c
@@ -179,7 +179,7 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
179 misc = addr_timings[clk][addr_pio]; 179 misc = addr_timings[clk][addr_pio];
180 180
181 /* select Index-0/1 for Register-A/B */ 181 /* select Index-0/1 for Register-A/B */
182 write_reg(drive->select.b.unit, MISC_REG); 182 write_reg(drive->dn & 1, MISC_REG);
183 /* set read cycle timings */ 183 /* set read cycle timings */
184 write_reg(tim, READ_REG); 184 write_reg(tim, READ_REG);
185 /* set write cycle timings */ 185 /* set write cycle timings */
@@ -220,7 +220,7 @@ static const struct pci_device_id opti621_pci_tbl[] = {
220}; 220};
221MODULE_DEVICE_TABLE(pci, opti621_pci_tbl); 221MODULE_DEVICE_TABLE(pci, opti621_pci_tbl);
222 222
223static struct pci_driver driver = { 223static struct pci_driver opti621_pci_driver = {
224 .name = "Opti621_IDE", 224 .name = "Opti621_IDE",
225 .id_table = opti621_pci_tbl, 225 .id_table = opti621_pci_tbl,
226 .probe = opti621_init_one, 226 .probe = opti621_init_one,
@@ -231,12 +231,12 @@ static struct pci_driver driver = {
231 231
232static int __init opti621_ide_init(void) 232static int __init opti621_ide_init(void)
233{ 233{
234 return ide_pci_register_driver(&driver); 234 return ide_pci_register_driver(&opti621_pci_driver);
235} 235}
236 236
237static void __exit opti621_ide_exit(void) 237static void __exit opti621_ide_exit(void)
238{ 238{
239 pci_unregister_driver(&driver); 239 pci_unregister_driver(&opti621_pci_driver);
240} 240}
241 241
242module_init(opti621_ide_init); 242module_init(opti621_ide_init);
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index 9fc59962553b..211ae46e3e0c 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -561,7 +561,7 @@ static const struct pci_device_id pdc202new_pci_tbl[] = {
561}; 561};
562MODULE_DEVICE_TABLE(pci, pdc202new_pci_tbl); 562MODULE_DEVICE_TABLE(pci, pdc202new_pci_tbl);
563 563
564static struct pci_driver driver = { 564static struct pci_driver pdc202new_pci_driver = {
565 .name = "Promise_IDE", 565 .name = "Promise_IDE",
566 .id_table = pdc202new_pci_tbl, 566 .id_table = pdc202new_pci_tbl,
567 .probe = pdc202new_init_one, 567 .probe = pdc202new_init_one,
@@ -572,12 +572,12 @@ static struct pci_driver driver = {
572 572
573static int __init pdc202new_ide_init(void) 573static int __init pdc202new_ide_init(void)
574{ 574{
575 return ide_pci_register_driver(&driver); 575 return ide_pci_register_driver(&pdc202new_pci_driver);
576} 576}
577 577
578static void __exit pdc202new_ide_exit(void) 578static void __exit pdc202new_ide_exit(void)
579{ 579{
580 pci_unregister_driver(&driver); 580 pci_unregister_driver(&pdc202new_pci_driver);
581} 581}
582 582
583module_init(pdc202new_ide_init); 583module_init(pdc202new_ide_init);
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
index cb6d2a00c514..799557c25eef 100644
--- a/drivers/ide/pci/pdc202xx_old.c
+++ b/drivers/ide/pci/pdc202xx_old.c
@@ -168,7 +168,7 @@ static void pdc202xx_dma_start(ide_drive_t *drive)
168{ 168{
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->addressing == 1) { 171 if (drive->media != ide_disk || (drive->dev_flags & IDE_DFLAG_LBA48)) {
172 struct request *rq = HWGROUP(drive)->rq; 172 struct request *rq = HWGROUP(drive)->rq;
173 ide_hwif_t *hwif = HWIF(drive); 173 ide_hwif_t *hwif = HWIF(drive);
174 unsigned long high_16 = hwif->extra_base - 16; 174 unsigned long high_16 = hwif->extra_base - 16;
@@ -188,7 +188,7 @@ static void pdc202xx_dma_start(ide_drive_t *drive)
188 188
189static int pdc202xx_dma_end(ide_drive_t *drive) 189static int pdc202xx_dma_end(ide_drive_t *drive)
190{ 190{
191 if (drive->media != ide_disk || drive->addressing == 1) { 191 if (drive->media != ide_disk || (drive->dev_flags & IDE_DFLAG_LBA48)) {
192 ide_hwif_t *hwif = HWIF(drive); 192 ide_hwif_t *hwif = HWIF(drive);
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);
@@ -200,7 +200,7 @@ static int pdc202xx_dma_end(ide_drive_t *drive)
200 } 200 }
201 if (drive->current_speed > XFER_UDMA_2) 201 if (drive->current_speed > XFER_UDMA_2)
202 pdc_old_disable_66MHz_clock(drive->hwif); 202 pdc_old_disable_66MHz_clock(drive->hwif);
203 return __ide_dma_end(drive); 203 return ide_dma_end(drive);
204} 204}
205 205
206static int pdc202xx_dma_test_irq(ide_drive_t *drive) 206static int pdc202xx_dma_test_irq(ide_drive_t *drive)
@@ -333,7 +333,7 @@ static const struct ide_dma_ops pdc20246_dma_ops = {
333 .dma_setup = ide_dma_setup, 333 .dma_setup = ide_dma_setup,
334 .dma_exec_cmd = ide_dma_exec_cmd, 334 .dma_exec_cmd = ide_dma_exec_cmd,
335 .dma_start = ide_dma_start, 335 .dma_start = ide_dma_start,
336 .dma_end = __ide_dma_end, 336 .dma_end = ide_dma_end,
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,
@@ -426,7 +426,7 @@ static const struct pci_device_id pdc202xx_pci_tbl[] = {
426}; 426};
427MODULE_DEVICE_TABLE(pci, pdc202xx_pci_tbl); 427MODULE_DEVICE_TABLE(pci, pdc202xx_pci_tbl);
428 428
429static struct pci_driver driver = { 429static struct pci_driver pdc202xx_pci_driver = {
430 .name = "Promise_Old_IDE", 430 .name = "Promise_Old_IDE",
431 .id_table = pdc202xx_pci_tbl, 431 .id_table = pdc202xx_pci_tbl,
432 .probe = pdc202xx_init_one, 432 .probe = pdc202xx_init_one,
@@ -437,12 +437,12 @@ static struct pci_driver driver = {
437 437
438static int __init pdc202xx_ide_init(void) 438static int __init pdc202xx_ide_init(void)
439{ 439{
440 return ide_pci_register_driver(&driver); 440 return ide_pci_register_driver(&pdc202xx_pci_driver);
441} 441}
442 442
443static void __exit pdc202xx_ide_exit(void) 443static void __exit pdc202xx_ide_exit(void)
444{ 444{
445 pci_unregister_driver(&driver); 445 pci_unregister_driver(&pdc202xx_pci_driver);
446} 446}
447 447
448module_init(pdc202xx_ide_init); 448module_init(pdc202xx_ide_init);
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
index a06c03f8e295..d63f9fdca76b 100644
--- a/drivers/ide/pci/piix.c
+++ b/drivers/ide/pci/piix.c
@@ -215,17 +215,26 @@ static unsigned int init_chipset_ich(struct pci_dev *dev)
215} 215}
216 216
217/** 217/**
218 * piix_dma_clear_irq - clear BMDMA status 218 * ich_clear_irq - clear BMDMA status
219 * @drive: IDE drive to clear 219 * @drive: IDE drive
220 * 220 *
221 * Called from ide_intr() for PIO interrupts 221 * ICHx contollers set DMA INTR no matter DMA or PIO.
222 * to clear BMDMA status as needed by ICHx 222 * BMDMA status might need to be cleared even for
223 * PIO interrupts to prevent spurious/lost IRQ.
223 */ 224 */
224static void piix_dma_clear_irq(ide_drive_t *drive) 225static void ich_clear_irq(ide_drive_t *drive)
225{ 226{
226 ide_hwif_t *hwif = HWIF(drive); 227 ide_hwif_t *hwif = HWIF(drive);
227 u8 dma_stat; 228 u8 dma_stat;
228 229
230 /*
231 * ide_dma_end() needs BMDMA status for error checking.
232 * So, skip clearing BMDMA status here and leave it
233 * to ide_dma_end() if this is DMA interrupt.
234 */
235 if (drive->waiting_for_dma || hwif->dma_base == 0)
236 return;
237
229 /* clear the INTR & ERROR bits */ 238 /* clear the INTR & ERROR bits */
230 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); 239 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS);
231 /* Should we force the bit as well ? */ 240 /* Should we force the bit as well ? */
@@ -249,6 +258,7 @@ static const struct ich_laptop ich_laptop[] = {
249 { 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */ 258 { 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */
250 { 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */ 259 { 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */
251 { 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 */
252 { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on Acer Aspire 2023WLMi */ 262 { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on Acer Aspire 2023WLMi */
253 { 0x2653, 0x1043, 0x82D8 }, /* ICH6M on Asus Eee 701 */ 263 { 0x2653, 0x1043, 0x82D8 }, /* ICH6M on Asus Eee 701 */
254 /* end marker */ 264 /* end marker */
@@ -293,21 +303,19 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif)
293 hwif->ultra_mask = hwif->mwdma_mask = hwif->swdma_mask = 0; 303 hwif->ultra_mask = hwif->mwdma_mask = hwif->swdma_mask = 0;
294} 304}
295 305
296static void __devinit init_hwif_ich(ide_hwif_t *hwif)
297{
298 init_hwif_piix(hwif);
299
300 /* ICHx need to clear the BMDMA status for all interrupts */
301 if (hwif->dma_base)
302 hwif->ide_dma_clear_irq = &piix_dma_clear_irq;
303}
304
305static const struct ide_port_ops piix_port_ops = { 306static const struct ide_port_ops piix_port_ops = {
306 .set_pio_mode = piix_set_pio_mode, 307 .set_pio_mode = piix_set_pio_mode,
307 .set_dma_mode = piix_set_dma_mode, 308 .set_dma_mode = piix_set_dma_mode,
308 .cable_detect = piix_cable_detect, 309 .cable_detect = piix_cable_detect,
309}; 310};
310 311
312static const struct ide_port_ops ich_port_ops = {
313 .set_pio_mode = piix_set_pio_mode,
314 .set_dma_mode = piix_set_dma_mode,
315 .clear_irq = ich_clear_irq,
316 .cable_detect = piix_cable_detect,
317};
318
311#ifndef CONFIG_IA64 319#ifndef CONFIG_IA64
312 #define IDE_HFLAGS_PIIX IDE_HFLAG_LEGACY_IRQS 320 #define IDE_HFLAGS_PIIX IDE_HFLAG_LEGACY_IRQS
313#else 321#else
@@ -331,9 +339,9 @@ static const struct ide_port_ops piix_port_ops = {
331 { \ 339 { \
332 .name = DRV_NAME, \ 340 .name = DRV_NAME, \
333 .init_chipset = init_chipset_ich, \ 341 .init_chipset = init_chipset_ich, \
334 .init_hwif = init_hwif_ich, \ 342 .init_hwif = init_hwif_piix, \
335 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ 343 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \
336 .port_ops = &piix_port_ops, \ 344 .port_ops = &ich_port_ops, \
337 .host_flags = IDE_HFLAGS_PIIX, \ 345 .host_flags = IDE_HFLAGS_PIIX, \
338 .pio_mask = ATA_PIO4, \ 346 .pio_mask = ATA_PIO4, \
339 .swdma_mask = ATA_SWDMA2_ONLY, \ 347 .swdma_mask = ATA_SWDMA2_ONLY, \
@@ -444,7 +452,7 @@ static const struct pci_device_id piix_pci_tbl[] = {
444}; 452};
445MODULE_DEVICE_TABLE(pci, piix_pci_tbl); 453MODULE_DEVICE_TABLE(pci, piix_pci_tbl);
446 454
447static struct pci_driver driver = { 455static struct pci_driver piix_pci_driver = {
448 .name = "PIIX_IDE", 456 .name = "PIIX_IDE",
449 .id_table = piix_pci_tbl, 457 .id_table = piix_pci_tbl,
450 .probe = piix_init_one, 458 .probe = piix_init_one,
@@ -456,12 +464,12 @@ static struct pci_driver driver = {
456static int __init piix_ide_init(void) 464static int __init piix_ide_init(void)
457{ 465{
458 piix_check_450nx(); 466 piix_check_450nx();
459 return ide_pci_register_driver(&driver); 467 return ide_pci_register_driver(&piix_pci_driver);
460} 468}
461 469
462static void __exit piix_ide_exit(void) 470static void __exit piix_ide_exit(void)
463{ 471{
464 pci_unregister_driver(&driver); 472 pci_unregister_driver(&piix_pci_driver);
465} 473}
466 474
467module_init(piix_ide_init); 475module_init(piix_ide_init);
diff --git a/drivers/ide/pci/rz1000.c b/drivers/ide/pci/rz1000.c
index c117a068761b..7daf0135cbac 100644
--- a/drivers/ide/pci/rz1000.c
+++ b/drivers/ide/pci/rz1000.c
@@ -59,7 +59,7 @@ static const struct pci_device_id rz1000_pci_tbl[] = {
59}; 59};
60MODULE_DEVICE_TABLE(pci, rz1000_pci_tbl); 60MODULE_DEVICE_TABLE(pci, rz1000_pci_tbl);
61 61
62static struct pci_driver driver = { 62static struct pci_driver rz1000_pci_driver = {
63 .name = "RZ1000_IDE", 63 .name = "RZ1000_IDE",
64 .id_table = rz1000_pci_tbl, 64 .id_table = rz1000_pci_tbl,
65 .probe = rz1000_init_one, 65 .probe = rz1000_init_one,
@@ -68,12 +68,12 @@ static struct pci_driver driver = {
68 68
69static int __init rz1000_ide_init(void) 69static int __init rz1000_ide_init(void)
70{ 70{
71 return ide_pci_register_driver(&driver); 71 return ide_pci_register_driver(&rz1000_pci_driver);
72} 72}
73 73
74static void __exit rz1000_ide_exit(void) 74static void __exit rz1000_ide_exit(void)
75{ 75{
76 pci_unregister_driver(&driver); 76 pci_unregister_driver(&rz1000_pci_driver);
77} 77}
78 78
79module_init(rz1000_ide_init); 79module_init(rz1000_ide_init);
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
index bdc1fed41260..f1a8758e3a99 100644
--- a/drivers/ide/pci/sc1200.c
+++ b/drivers/ide/pci/sc1200.c
@@ -126,7 +126,6 @@ static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode)
126{ 126{
127 ide_hwif_t *hwif = HWIF(drive); 127 ide_hwif_t *hwif = HWIF(drive);
128 struct pci_dev *dev = to_pci_dev(hwif->dev); 128 struct pci_dev *dev = to_pci_dev(hwif->dev);
129 int unit = drive->select.b.unit;
130 unsigned int reg, timings; 129 unsigned int reg, timings;
131 unsigned short pci_clock; 130 unsigned short pci_clock;
132 unsigned int basereg = hwif->channel ? 0x50 : 0x40; 131 unsigned int basereg = hwif->channel ? 0x50 : 0x40;
@@ -155,7 +154,7 @@ static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode)
155 else 154 else
156 timings = mwdma_timing[pci_clock][mode - XFER_MW_DMA_0]; 155 timings = mwdma_timing[pci_clock][mode - XFER_MW_DMA_0];
157 156
158 if (unit == 0) { /* are we configuring drive0? */ 157 if ((drive->dn & 1) == 0) {
159 pci_read_config_dword(dev, basereg + 4, &reg); 158 pci_read_config_dword(dev, basereg + 4, &reg);
160 timings |= reg & 0x80000000; /* preserve PIO format bit */ 159 timings |= reg & 0x80000000; /* preserve PIO format bit */
161 pci_write_config_dword(dev, basereg + 4, timings); 160 pci_write_config_dword(dev, basereg + 4, timings);
@@ -216,7 +215,8 @@ static void sc1200_set_pio_mode(ide_drive_t *drive, const u8 pio)
216 if (mode != -1) { 215 if (mode != -1) {
217 printk("SC1200: %s: changing (U)DMA mode\n", drive->name); 216 printk("SC1200: %s: changing (U)DMA mode\n", drive->name);
218 ide_dma_off_quietly(drive); 217 ide_dma_off_quietly(drive);
219 if (ide_set_dma_mode(drive, mode) == 0 && drive->using_dma) 218 if (ide_set_dma_mode(drive, mode) == 0 &&
219 (drive->dev_flags & IDE_DFLAG_USING_DMA))
220 hwif->dma_ops->dma_host_set(drive, 1); 220 hwif->dma_ops->dma_host_set(drive, 1);
221 return; 221 return;
222 } 222 }
@@ -328,7 +328,7 @@ static const struct pci_device_id sc1200_pci_tbl[] = {
328}; 328};
329MODULE_DEVICE_TABLE(pci, sc1200_pci_tbl); 329MODULE_DEVICE_TABLE(pci, sc1200_pci_tbl);
330 330
331static struct pci_driver driver = { 331static struct pci_driver sc1200_pci_driver = {
332 .name = "SC1200_IDE", 332 .name = "SC1200_IDE",
333 .id_table = sc1200_pci_tbl, 333 .id_table = sc1200_pci_tbl,
334 .probe = sc1200_init_one, 334 .probe = sc1200_init_one,
@@ -341,12 +341,12 @@ static struct pci_driver driver = {
341 341
342static int __init sc1200_ide_init(void) 342static int __init sc1200_ide_init(void)
343{ 343{
344 return ide_pci_register_driver(&driver); 344 return ide_pci_register_driver(&sc1200_pci_driver);
345} 345}
346 346
347static void __exit sc1200_ide_exit(void) 347static void __exit sc1200_ide_exit(void)
348{ 348{
349 pci_unregister_driver(&driver); 349 pci_unregister_driver(&sc1200_pci_driver);
350} 350}
351 351
352module_init(sc1200_ide_init); 352module_init(sc1200_ide_init);
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index e92a874b31df..9ce1d8059921 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -291,7 +291,7 @@ static void scc_set_dma_mode(ide_drive_t *drive, const u8 speed)
291static void scc_dma_host_set(ide_drive_t *drive, int on) 291static 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->select.b.unit & 0x01); 294 u8 unit = drive->dn & 1;
295 u8 dma_stat = scc_ide_inb(hwif->dma_base + 4); 295 u8 dma_stat = scc_ide_inb(hwif->dma_base + 4);
296 296
297 if (on) 297 if (on)
@@ -353,7 +353,6 @@ static void scc_dma_start(ide_drive_t *drive)
353 353
354 /* start DMA */ 354 /* start DMA */
355 scc_ide_outb(dma_cmd | 1, hwif->dma_base); 355 scc_ide_outb(dma_cmd | 1, hwif->dma_base);
356 hwif->dma = 1;
357 wmb(); 356 wmb();
358} 357}
359 358
@@ -374,7 +373,6 @@ static int __scc_dma_end(ide_drive_t *drive)
374 /* purge DMA mappings */ 373 /* purge DMA mappings */
375 ide_destroy_dmatable(drive); 374 ide_destroy_dmatable(drive);
376 /* verify good DMA status */ 375 /* verify good DMA status */
377 hwif->dma = 0;
378 wmb(); 376 wmb();
379 return (dma_stat & 7) != 4 ? (0x10 | dma_stat) : 0; 377 return (dma_stat & 7) != 4 ? (0x10 | dma_stat) : 0;
380} 378}
@@ -511,9 +509,6 @@ static int scc_dma_test_irq(ide_drive_t *drive)
511 if (int_stat & INTSTS_IOIRQS) 509 if (int_stat & INTSTS_IOIRQS)
512 return 1; 510 return 1;
513 511
514 if (!drive->waiting_for_dma)
515 printk(KERN_WARNING "%s: (%s) called while not waiting\n",
516 drive->name, __func__);
517 return 0; 512 return 0;
518} 513}
519 514
@@ -710,7 +705,7 @@ static void scc_tf_load(ide_drive_t *drive, ide_task_t *task)
710 scc_ide_outb(tf->lbah, io_ports->lbah_addr); 705 scc_ide_outb(tf->lbah, io_ports->lbah_addr);
711 706
712 if (task->tf_flags & IDE_TFLAG_OUT_DEVICE) 707 if (task->tf_flags & IDE_TFLAG_OUT_DEVICE)
713 scc_ide_outb((tf->device & HIHI) | drive->select.all, 708 scc_ide_outb((tf->device & HIHI) | drive->select,
714 io_ports->device_addr); 709 io_ports->device_addr);
715} 710}
716 711
@@ -826,6 +821,12 @@ static void __devinit init_iops_scc(ide_hwif_t *hwif)
826 init_mmio_iops_scc(hwif); 821 init_mmio_iops_scc(hwif);
827} 822}
828 823
824static int __devinit scc_init_dma(ide_hwif_t *hwif,
825 const struct ide_port_info *d)
826{
827 return ide_allocate_dma_engine(hwif);
828}
829
829static u8 scc_cable_detect(ide_hwif_t *hwif) 830static u8 scc_cable_detect(ide_hwif_t *hwif)
830{ 831{
831 return ATA_CBL_PATA80; 832 return ATA_CBL_PATA80;
@@ -890,6 +891,7 @@ static const struct ide_dma_ops scc_dma_ops = {
890 { \ 891 { \
891 .name = name_str, \ 892 .name = name_str, \
892 .init_iops = init_iops_scc, \ 893 .init_iops = init_iops_scc, \
894 .init_dma = scc_init_dma, \
893 .init_hwif = init_hwif_scc, \ 895 .init_hwif = init_hwif_scc, \
894 .tp_ops = &scc_tp_ops, \ 896 .tp_ops = &scc_tp_ops, \
895 .port_ops = &scc_port_ops, \ 897 .port_ops = &scc_port_ops, \
@@ -927,13 +929,6 @@ static void __devexit scc_remove(struct pci_dev *dev)
927{ 929{
928 struct scc_ports *ports = pci_get_drvdata(dev); 930 struct scc_ports *ports = pci_get_drvdata(dev);
929 struct ide_host *host = ports->host; 931 struct ide_host *host = ports->host;
930 ide_hwif_t *hwif = host->ports[0];
931
932 if (hwif->dmatable_cpu) {
933 pci_free_consistent(dev, PRD_ENTRIES * PRD_BYTES,
934 hwif->dmatable_cpu, hwif->dmatable_dma);
935 hwif->dmatable_cpu = NULL;
936 }
937 932
938 ide_host_remove(host); 933 ide_host_remove(host);
939 934
@@ -949,7 +944,7 @@ static const struct pci_device_id scc_pci_tbl[] = {
949}; 944};
950MODULE_DEVICE_TABLE(pci, scc_pci_tbl); 945MODULE_DEVICE_TABLE(pci, scc_pci_tbl);
951 946
952static struct pci_driver driver = { 947static struct pci_driver scc_pci_driver = {
953 .name = "SCC IDE", 948 .name = "SCC IDE",
954 .id_table = scc_pci_tbl, 949 .id_table = scc_pci_tbl,
955 .probe = scc_init_one, 950 .probe = scc_init_one,
@@ -958,14 +953,14 @@ static struct pci_driver driver = {
958 953
959static int scc_ide_init(void) 954static int scc_ide_init(void)
960{ 955{
961 return ide_pci_register_driver(&driver); 956 return ide_pci_register_driver(&scc_pci_driver);
962} 957}
963 958
964module_init(scc_ide_init); 959module_init(scc_ide_init);
965/* -- No exit code? 960/* -- No exit code?
966static void scc_ide_exit(void) 961static void scc_ide_exit(void)
967{ 962{
968 ide_pci_unregister_driver(&driver); 963 ide_pci_unregister_driver(&scc_pci_driver);
969} 964}
970module_exit(scc_ide_exit); 965module_exit(scc_ide_exit);
971 */ 966 */
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
index 3dff2aea317e..437bc919dafd 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -153,7 +153,7 @@ static void svwks_set_dma_mode(ide_drive_t *drive, const u8 speed)
153 153
154 ide_hwif_t *hwif = HWIF(drive); 154 ide_hwif_t *hwif = HWIF(drive);
155 struct pci_dev *dev = to_pci_dev(hwif->dev); 155 struct pci_dev *dev = to_pci_dev(hwif->dev);
156 u8 unit = (drive->select.b.unit & 0x01); 156 u8 unit = drive->dn & 1;
157 157
158 u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0; 158 u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0;
159 159
@@ -443,7 +443,7 @@ static const struct pci_device_id svwks_pci_tbl[] = {
443}; 443};
444MODULE_DEVICE_TABLE(pci, svwks_pci_tbl); 444MODULE_DEVICE_TABLE(pci, svwks_pci_tbl);
445 445
446static struct pci_driver driver = { 446static struct pci_driver svwks_pci_driver = {
447 .name = "Serverworks_IDE", 447 .name = "Serverworks_IDE",
448 .id_table = svwks_pci_tbl, 448 .id_table = svwks_pci_tbl,
449 .probe = svwks_init_one, 449 .probe = svwks_init_one,
@@ -454,12 +454,12 @@ static struct pci_driver driver = {
454 454
455static int __init svwks_ide_init(void) 455static int __init svwks_ide_init(void)
456{ 456{
457 return ide_pci_register_driver(&driver); 457 return ide_pci_register_driver(&svwks_pci_driver);
458} 458}
459 459
460static void __exit svwks_ide_exit(void) 460static void __exit svwks_ide_exit(void)
461{ 461{
462 pci_unregister_driver(&driver); 462 pci_unregister_driver(&svwks_pci_driver);
463} 463}
464 464
465module_init(svwks_ide_init); 465module_init(svwks_ide_init);
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 1017fb4f6317..dd634541ce36 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2003-2006 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2003-2006 Silicon Graphics, Inc. All Rights Reserved.
3 * Copyright (C) 2008 MontaVista Software, Inc.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License 6 * under the terms of version 2 of the GNU General Public License
@@ -150,7 +151,7 @@ sgiioc4_clearirq(ide_drive_t * drive)
150 int count = 0; 151 int count = 0;
151 152
152 stat = sgiioc4_read_status(hwif); 153 stat = sgiioc4_read_status(hwif);
153 while ((stat & 0x80) && (count++ < 100)) { 154 while ((stat & ATA_BUSY) && (count++ < 100)) {
154 udelay(1); 155 udelay(1);
155 stat = sgiioc4_read_status(hwif); 156 stat = sgiioc4_read_status(hwif);
156 } 157 }
@@ -310,7 +311,7 @@ static u8 sgiioc4_read_status(ide_hwif_t *hwif)
310 u8 reg = (u8) readb((void __iomem *) port); 311 u8 reg = (u8) readb((void __iomem *) port);
311 312
312 if ((port & 0xFFF) == 0x11C) { /* Status register of IOC4 */ 313 if ((port & 0xFFF) == 0x11C) { /* Status register of IOC4 */
313 if (reg & 0x51) { /* Not busy...check for interrupt */ 314 if (!(reg & ATA_BUSY)) { /* Not busy... check for interrupt */
314 unsigned long other_ir = port - 0x110; 315 unsigned long other_ir = port - 0x110;
315 unsigned int intr_reg = (u32) readl((void __iomem *) other_ir); 316 unsigned int intr_reg = (u32) readl((void __iomem *) other_ir);
316 317
@@ -338,35 +339,31 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d)
338 if (dma_base == 0) 339 if (dma_base == 0)
339 return -1; 340 return -1;
340 341
341 printk(KERN_INFO "%s: BM-DMA at 0x%04lx-0x%04lx\n", hwif->name, 342 printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name);
342 dma_base, dma_base + num_ports - 1);
343 343
344 if (!request_mem_region(dma_base, num_ports, hwif->name)) { 344 if (request_mem_region(dma_base, num_ports, hwif->name) == NULL) {
345 printk(KERN_ERR 345 printk(KERN_ERR "%s(%s) -- ERROR: addresses 0x%08lx to 0x%08lx "
346 "%s(%s) -- ERROR, Addresses 0x%p to 0x%p " 346 "already in use\n", __func__, hwif->name,
347 "ALREADY in use\n", 347 dma_base, dma_base + num_ports - 1);
348 __func__, hwif->name, (void *) dma_base,
349 (void *) dma_base + num_ports - 1);
350 return -1; 348 return -1;
351 } 349 }
352 350
353 virt_dma_base = ioremap(dma_base, num_ports); 351 virt_dma_base = ioremap(dma_base, num_ports);
354 if (virt_dma_base == NULL) { 352 if (virt_dma_base == NULL) {
355 printk(KERN_ERR 353 printk(KERN_ERR "%s(%s) -- ERROR: unable to map addresses "
356 "%s(%s) -- ERROR, Unable to map addresses 0x%lx to 0x%lx\n", 354 "0x%lx to 0x%lx\n", __func__, hwif->name,
357 __func__, hwif->name, dma_base, dma_base + num_ports - 1); 355 dma_base, dma_base + num_ports - 1);
358 goto dma_remap_failure; 356 goto dma_remap_failure;
359 } 357 }
360 hwif->dma_base = (unsigned long) virt_dma_base; 358 hwif->dma_base = (unsigned long) virt_dma_base;
361 359
362 hwif->dmatable_cpu = pci_alloc_consistent(dev, 360 hwif->sg_max_nents = IOC4_PRD_ENTRIES;
363 IOC4_PRD_ENTRIES * IOC4_PRD_BYTES,
364 &hwif->dmatable_dma);
365 361
366 if (!hwif->dmatable_cpu) 362 hwif->prd_max_nents = IOC4_PRD_ENTRIES;
367 goto dma_pci_alloc_failure; 363 hwif->prd_ent_size = IOC4_PRD_BYTES;
368 364
369 hwif->sg_max_nents = IOC4_PRD_ENTRIES; 365 if (ide_allocate_dma_engine(hwif))
366 goto dma_pci_alloc_failure;
370 367
371 pad = pci_alloc_consistent(dev, IOC4_IDE_CACHELINE_SIZE, 368 pad = pci_alloc_consistent(dev, IOC4_IDE_CACHELINE_SIZE,
372 (dma_addr_t *)&hwif->extra_base); 369 (dma_addr_t *)&hwif->extra_base);
@@ -375,13 +372,11 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d)
375 return 0; 372 return 0;
376 } 373 }
377 374
378 pci_free_consistent(dev, IOC4_PRD_ENTRIES * IOC4_PRD_BYTES, 375 ide_release_dma_engine(hwif);
379 hwif->dmatable_cpu, hwif->dmatable_dma); 376
380 printk(KERN_INFO 377 printk(KERN_ERR "%s(%s) -- ERROR: Unable to allocate DMA maps\n",
381 "%s() -- Error! Unable to allocate DMA Maps for drive %s\n",
382 __func__, hwif->name); 378 __func__, hwif->name);
383 printk(KERN_INFO 379 printk(KERN_INFO "%s: changing from DMA to PIO mode", hwif->name);
384 "Changing from DMA to PIO mode for Drive %s\n", hwif->name);
385 380
386dma_pci_alloc_failure: 381dma_pci_alloc_failure:
387 iounmap(virt_dma_base); 382 iounmap(virt_dma_base);
@@ -617,14 +612,12 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
617 irqport = (unsigned long) virt_base + IOC4_INTR_OFFSET; 612 irqport = (unsigned long) virt_base + IOC4_INTR_OFFSET;
618 613
619 cmd_phys_base = bar0 + IOC4_CMD_OFFSET; 614 cmd_phys_base = bar0 + IOC4_CMD_OFFSET;
620 if (!request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE, 615 if (request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE,
621 DRV_NAME)) { 616 DRV_NAME) == NULL) {
622 printk(KERN_ERR 617 printk(KERN_ERR "%s %s -- ERROR: addresses 0x%08lx to 0x%08lx "
623 "%s %s: -- ERROR, Addresses " 618 "already in use\n", DRV_NAME, pci_name(dev),
624 "0x%p to 0x%p ALREADY in use\n", 619 cmd_phys_base, cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE);
625 DRV_NAME, pci_name(dev), (void *)cmd_phys_base, 620 return -EBUSY;
626 (void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE);
627 return -ENOMEM;
628 } 621 }
629 622
630 /* Initialize the IO registers */ 623 /* Initialize the IO registers */
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index 174a873b4c64..eb4faf92c571 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -116,13 +116,14 @@ 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 = HWIF(drive);
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 120
120 base += 0xA0 + r; 121 base += 0xA0 + r;
121 if (hwif->host_flags & IDE_HFLAG_MMIO) 122 if (hwif->host_flags & IDE_HFLAG_MMIO)
122 base += hwif->channel << 6; 123 base += hwif->channel << 6;
123 else 124 else
124 base += hwif->channel << 4; 125 base += hwif->channel << 4;
125 base |= drive->select.b.unit << drive->select.b.unit; 126 base |= unit << unit;
126 return base; 127 return base;
127} 128}
128 129
@@ -255,7 +256,7 @@ static void sil_set_pio_mode(ide_drive_t *drive, u8 pio)
255 u8 addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84) 256 u8 addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84)
256 : (mmio ? 0xB4 : 0x80); 257 : (mmio ? 0xB4 : 0x80);
257 u8 mode = 0; 258 u8 mode = 0;
258 u8 unit = drive->select.b.unit; 259 u8 unit = drive->dn & 1;
259 260
260 /* trim *taskfile* PIO to the slowest of the master/slave */ 261 /* trim *taskfile* PIO to the slowest of the master/slave */
261 if (pair) { 262 if (pair) {
@@ -301,9 +302,9 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed)
301 302
302 ide_hwif_t *hwif = HWIF(drive); 303 ide_hwif_t *hwif = HWIF(drive);
303 struct pci_dev *dev = to_pci_dev(hwif->dev); 304 struct pci_dev *dev = to_pci_dev(hwif->dev);
304 u16 ultra = 0, multi = 0;
305 u8 mode = 0, unit = drive->select.b.unit;
306 unsigned long base = (unsigned long)hwif->hwif_data; 305 unsigned long base = (unsigned long)hwif->hwif_data;
306 u16 ultra = 0, multi = 0;
307 u8 mode = 0, unit = drive->dn & 1;
307 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; 308 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
308 u8 scsc = 0, addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84) 309 u8 scsc = 0, addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84)
309 : (mmio ? 0xB4 : 0x80); 310 : (mmio ? 0xB4 : 0x80);
@@ -712,7 +713,7 @@ static const struct ide_dma_ops sil_dma_ops = {
712 .dma_setup = ide_dma_setup, 713 .dma_setup = ide_dma_setup,
713 .dma_exec_cmd = ide_dma_exec_cmd, 714 .dma_exec_cmd = ide_dma_exec_cmd,
714 .dma_start = ide_dma_start, 715 .dma_start = ide_dma_start,
715 .dma_end = __ide_dma_end, 716 .dma_end = ide_dma_end,
716 .dma_test_irq = siimage_dma_test_irq, 717 .dma_test_irq = siimage_dma_test_irq,
717 .dma_timeout = ide_dma_timeout, 718 .dma_timeout = ide_dma_timeout,
718 .dma_lost_irq = ide_dma_lost_irq, 719 .dma_lost_irq = ide_dma_lost_irq,
@@ -829,7 +830,7 @@ static const struct pci_device_id siimage_pci_tbl[] = {
829}; 830};
830MODULE_DEVICE_TABLE(pci, siimage_pci_tbl); 831MODULE_DEVICE_TABLE(pci, siimage_pci_tbl);
831 832
832static struct pci_driver driver = { 833static struct pci_driver siimage_pci_driver = {
833 .name = "SiI_IDE", 834 .name = "SiI_IDE",
834 .id_table = siimage_pci_tbl, 835 .id_table = siimage_pci_tbl,
835 .probe = siimage_init_one, 836 .probe = siimage_init_one,
@@ -840,12 +841,12 @@ static struct pci_driver driver = {
840 841
841static int __init siimage_ide_init(void) 842static int __init siimage_ide_init(void)
842{ 843{
843 return ide_pci_register_driver(&driver); 844 return ide_pci_register_driver(&siimage_pci_driver);
844} 845}
845 846
846static void __exit siimage_ide_exit(void) 847static void __exit siimage_ide_exit(void)
847{ 848{
848 pci_unregister_driver(&driver); 849 pci_unregister_driver(&siimage_pci_driver);
849} 850}
850 851
851module_init(siimage_ide_init); 852module_init(siimage_ide_init);
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
index 734dd41f1f67..ad32e18c5ba3 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -605,7 +605,7 @@ static const struct pci_device_id sis5513_pci_tbl[] = {
605}; 605};
606MODULE_DEVICE_TABLE(pci, sis5513_pci_tbl); 606MODULE_DEVICE_TABLE(pci, sis5513_pci_tbl);
607 607
608static struct pci_driver driver = { 608static struct pci_driver sis5513_pci_driver = {
609 .name = "SIS_IDE", 609 .name = "SIS_IDE",
610 .id_table = sis5513_pci_tbl, 610 .id_table = sis5513_pci_tbl,
611 .probe = sis5513_init_one, 611 .probe = sis5513_init_one,
@@ -616,12 +616,12 @@ static struct pci_driver driver = {
616 616
617static int __init sis5513_ide_init(void) 617static int __init sis5513_ide_init(void)
618{ 618{
619 return ide_pci_register_driver(&driver); 619 return ide_pci_register_driver(&sis5513_pci_driver);
620} 620}
621 621
622static void __exit sis5513_ide_exit(void) 622static void __exit sis5513_ide_exit(void)
623{ 623{
624 pci_unregister_driver(&driver); 624 pci_unregister_driver(&sis5513_pci_driver);
625} 625}
626 626
627module_init(sis5513_ide_init); 627module_init(sis5513_ide_init);
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
index 37a6b7bdc040..84dc33602ff8 100644
--- a/drivers/ide/pci/sl82c105.c
+++ b/drivers/ide/pci/sl82c105.c
@@ -207,7 +207,7 @@ static int sl82c105_dma_end(ide_drive_t *drive)
207 207
208 DBG(("%s(drive:%s)\n", __func__, drive->name)); 208 DBG(("%s(drive:%s)\n", __func__, drive->name));
209 209
210 ret = __ide_dma_end(drive); 210 ret = ide_dma_end(drive);
211 211
212 pci_write_config_word(dev, reg, drive->drive_data); 212 pci_write_config_word(dev, reg, drive->drive_data);
213 213
@@ -345,7 +345,7 @@ static const struct pci_device_id sl82c105_pci_tbl[] = {
345}; 345};
346MODULE_DEVICE_TABLE(pci, sl82c105_pci_tbl); 346MODULE_DEVICE_TABLE(pci, sl82c105_pci_tbl);
347 347
348static struct pci_driver driver = { 348static struct pci_driver sl82c105_pci_driver = {
349 .name = "W82C105_IDE", 349 .name = "W82C105_IDE",
350 .id_table = sl82c105_pci_tbl, 350 .id_table = sl82c105_pci_tbl,
351 .probe = sl82c105_init_one, 351 .probe = sl82c105_init_one,
@@ -356,12 +356,12 @@ static struct pci_driver driver = {
356 356
357static int __init sl82c105_ide_init(void) 357static int __init sl82c105_ide_init(void)
358{ 358{
359 return ide_pci_register_driver(&driver); 359 return ide_pci_register_driver(&sl82c105_pci_driver);
360} 360}
361 361
362static void __exit sl82c105_ide_exit(void) 362static void __exit sl82c105_ide_exit(void)
363{ 363{
364 pci_unregister_driver(&driver); 364 pci_unregister_driver(&sl82c105_pci_driver);
365} 365}
366 366
367module_init(sl82c105_ide_init); 367module_init(sl82c105_ide_init);
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c
index a9551a13ac57..0f759e4ed779 100644
--- a/drivers/ide/pci/slc90e66.c
+++ b/drivers/ide/pci/slc90e66.c
@@ -154,7 +154,7 @@ static const struct pci_device_id slc90e66_pci_tbl[] = {
154}; 154};
155MODULE_DEVICE_TABLE(pci, slc90e66_pci_tbl); 155MODULE_DEVICE_TABLE(pci, slc90e66_pci_tbl);
156 156
157static struct pci_driver driver = { 157static struct pci_driver slc90e66_pci_driver = {
158 .name = "SLC90e66_IDE", 158 .name = "SLC90e66_IDE",
159 .id_table = slc90e66_pci_tbl, 159 .id_table = slc90e66_pci_tbl,
160 .probe = slc90e66_init_one, 160 .probe = slc90e66_init_one,
@@ -165,12 +165,12 @@ static struct pci_driver driver = {
165 165
166static int __init slc90e66_ide_init(void) 166static int __init slc90e66_ide_init(void)
167{ 167{
168 return ide_pci_register_driver(&driver); 168 return ide_pci_register_driver(&slc90e66_pci_driver);
169} 169}
170 170
171static void __exit slc90e66_ide_exit(void) 171static void __exit slc90e66_ide_exit(void)
172{ 172{
173 pci_unregister_driver(&driver); 173 pci_unregister_driver(&slc90e66_pci_driver);
174} 174}
175 175
176module_init(slc90e66_ide_init); 176module_init(slc90e66_ide_init);
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c
index 927277c54ec9..93e2cce4b296 100644
--- a/drivers/ide/pci/tc86c001.c
+++ b/drivers/ide/pci/tc86c001.c
@@ -186,7 +186,7 @@ static const struct ide_dma_ops tc86c001_dma_ops = {
186 .dma_setup = ide_dma_setup, 186 .dma_setup = ide_dma_setup,
187 .dma_exec_cmd = ide_dma_exec_cmd, 187 .dma_exec_cmd = ide_dma_exec_cmd,
188 .dma_start = tc86c001_dma_start, 188 .dma_start = tc86c001_dma_start,
189 .dma_end = __ide_dma_end, 189 .dma_end = ide_dma_end,
190 .dma_test_irq = ide_dma_test_irq, 190 .dma_test_irq = ide_dma_test_irq,
191 .dma_lost_irq = ide_dma_lost_irq, 191 .dma_lost_irq = ide_dma_lost_irq,
192 .dma_timeout = ide_dma_timeout, 192 .dma_timeout = ide_dma_timeout,
@@ -245,7 +245,7 @@ static const struct pci_device_id tc86c001_pci_tbl[] = {
245}; 245};
246MODULE_DEVICE_TABLE(pci, tc86c001_pci_tbl); 246MODULE_DEVICE_TABLE(pci, tc86c001_pci_tbl);
247 247
248static struct pci_driver driver = { 248static struct pci_driver tc86c001_pci_driver = {
249 .name = "TC86C001", 249 .name = "TC86C001",
250 .id_table = tc86c001_pci_tbl, 250 .id_table = tc86c001_pci_tbl,
251 .probe = tc86c001_init_one, 251 .probe = tc86c001_init_one,
@@ -254,12 +254,12 @@ static struct pci_driver driver = {
254 254
255static int __init tc86c001_ide_init(void) 255static int __init tc86c001_ide_init(void)
256{ 256{
257 return ide_pci_register_driver(&driver); 257 return ide_pci_register_driver(&tc86c001_pci_driver);
258} 258}
259 259
260static void __exit tc86c001_ide_exit(void) 260static void __exit tc86c001_ide_exit(void)
261{ 261{
262 pci_unregister_driver(&driver); 262 pci_unregister_driver(&tc86c001_pci_driver);
263} 263}
264 264
265module_init(tc86c001_ide_init); 265module_init(tc86c001_ide_init);
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c
index be8715dcee05..b6ff40336aa9 100644
--- a/drivers/ide/pci/triflex.c
+++ b/drivers/ide/pci/triflex.c
@@ -38,13 +38,12 @@ 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 = HWIF(drive);
40 struct pci_dev *dev = to_pci_dev(hwif->dev); 40 struct pci_dev *dev = to_pci_dev(hwif->dev);
41 u8 channel_offset = hwif->channel ? 0x74 : 0x70;
42 u16 timing = 0;
43 u32 triflex_timings = 0; 41 u32 triflex_timings = 0;
44 u8 unit = (drive->select.b.unit & 0x01); 42 u16 timing = 0;
45 43 u8 channel_offset = hwif->channel ? 0x74 : 0x70, unit = drive->dn & 1;
44
46 pci_read_config_dword(dev, channel_offset, &triflex_timings); 45 pci_read_config_dword(dev, channel_offset, &triflex_timings);
47 46
48 switch(speed) { 47 switch(speed) {
49 case XFER_MW_DMA_2: 48 case XFER_MW_DMA_2:
50 timing = 0x0103; 49 timing = 0x0103;
@@ -114,7 +113,7 @@ static const struct pci_device_id triflex_pci_tbl[] = {
114}; 113};
115MODULE_DEVICE_TABLE(pci, triflex_pci_tbl); 114MODULE_DEVICE_TABLE(pci, triflex_pci_tbl);
116 115
117static struct pci_driver driver = { 116static struct pci_driver triflex_pci_driver = {
118 .name = "TRIFLEX_IDE", 117 .name = "TRIFLEX_IDE",
119 .id_table = triflex_pci_tbl, 118 .id_table = triflex_pci_tbl,
120 .probe = triflex_init_one, 119 .probe = triflex_init_one,
@@ -125,12 +124,12 @@ static struct pci_driver driver = {
125 124
126static int __init triflex_ide_init(void) 125static int __init triflex_ide_init(void)
127{ 126{
128 return ide_pci_register_driver(&driver); 127 return ide_pci_register_driver(&triflex_pci_driver);
129} 128}
130 129
131static void __exit triflex_ide_exit(void) 130static void __exit triflex_ide_exit(void)
132{ 131{
133 pci_unregister_driver(&driver); 132 pci_unregister_driver(&triflex_pci_driver);
134} 133}
135 134
136module_init(triflex_ide_init); 135module_init(triflex_ide_init);
diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c
index 4dfbc6a68b5b..75ea61526566 100644
--- a/drivers/ide/pci/trm290.c
+++ b/drivers/ide/pci/trm290.c
@@ -161,7 +161,7 @@ static void trm290_prepare_drive (ide_drive_t *drive, unsigned int use_dma)
161 } 161 }
162 162
163 /* enable IRQ if not probing */ 163 /* enable IRQ if not probing */
164 if (drive->present) { 164 if (drive->dev_flags & IDE_DFLAG_PRESENT) {
165 reg = inw(hwif->config_data + 3); 165 reg = inw(hwif->config_data + 3);
166 reg &= 0x13; 166 reg &= 0x13;
167 reg &= ~(1 << hwif->channel); 167 reg &= ~(1 << hwif->channel);
@@ -173,7 +173,7 @@ static void trm290_prepare_drive (ide_drive_t *drive, unsigned int use_dma)
173 173
174static void trm290_selectproc (ide_drive_t *drive) 174static void trm290_selectproc (ide_drive_t *drive)
175{ 175{
176 trm290_prepare_drive(drive, drive->using_dma); 176 trm290_prepare_drive(drive, !!(drive->dev_flags & IDE_DFLAG_USING_DMA));
177} 177}
178 178
179static void trm290_dma_exec_cmd(ide_drive_t *drive, u8 command) 179static void trm290_dma_exec_cmd(ide_drive_t *drive, u8 command)
@@ -350,7 +350,7 @@ static const struct pci_device_id trm290_pci_tbl[] = {
350}; 350};
351MODULE_DEVICE_TABLE(pci, trm290_pci_tbl); 351MODULE_DEVICE_TABLE(pci, trm290_pci_tbl);
352 352
353static struct pci_driver driver = { 353static struct pci_driver trm290_pci_driver = {
354 .name = "TRM290_IDE", 354 .name = "TRM290_IDE",
355 .id_table = trm290_pci_tbl, 355 .id_table = trm290_pci_tbl,
356 .probe = trm290_init_one, 356 .probe = trm290_init_one,
@@ -359,12 +359,12 @@ static struct pci_driver driver = {
359 359
360static int __init trm290_ide_init(void) 360static int __init trm290_ide_init(void)
361{ 361{
362 return ide_pci_register_driver(&driver); 362 return ide_pci_register_driver(&trm290_pci_driver);
363} 363}
364 364
365static void __exit trm290_ide_exit(void) 365static void __exit trm290_ide_exit(void)
366{ 366{
367 pci_unregister_driver(&driver); 367 pci_unregister_driver(&trm290_pci_driver);
368} 368}
369 369
370module_init(trm290_ide_init); 370module_init(trm290_ide_init);
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index acacdaab69c2..2a812d3207e9 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -487,7 +487,7 @@ static const struct pci_device_id via_pci_tbl[] = {
487}; 487};
488MODULE_DEVICE_TABLE(pci, via_pci_tbl); 488MODULE_DEVICE_TABLE(pci, via_pci_tbl);
489 489
490static struct pci_driver driver = { 490static struct pci_driver via_pci_driver = {
491 .name = "VIA_IDE", 491 .name = "VIA_IDE",
492 .id_table = via_pci_tbl, 492 .id_table = via_pci_tbl,
493 .probe = via_init_one, 493 .probe = via_init_one,
@@ -498,12 +498,12 @@ static struct pci_driver driver = {
498 498
499static int __init via_ide_init(void) 499static int __init via_ide_init(void)
500{ 500{
501 return ide_pci_register_driver(&driver); 501 return ide_pci_register_driver(&via_pci_driver);
502} 502}
503 503
504static void __exit via_ide_exit(void) 504static void __exit via_ide_exit(void)
505{ 505{
506 pci_unregister_driver(&driver); 506 pci_unregister_driver(&via_pci_driver);
507} 507}
508 508
509module_init(via_ide_init); 509module_init(via_ide_init);