aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-01-06 11:20:56 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-01-06 11:20:56 -0500
commit2bd24a1cfc99d242c2cff9a6b74ca49fcaac3fb6 (patch)
treed4797f56699e9da367e12b5e1d01b108241424f6 /drivers/ide
parent5e7f3a46690f7f6c9f2781c700ab4370874aa0e8 (diff)
ide: add port and host iterators
Add ide_port_for_each_dev() / ide_host_for_each_port() iterators and update IDE code to use them. While at it: - s/unit/i/ variable in ide_port_wait_ready(), ide_probe_port(), ide_port_tune_devices(), ide_port_init_devices_data(), do_reset1(), ide_acpi_set_state() and scc_dma_end() - s/d/i/ variable in ide_proc_port_register_devices() There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-acpi.c14
-rw-r--r--drivers/ide/ide-iops.c11
-rw-r--r--drivers/ide/ide-probe.c96
-rw-r--r--drivers/ide/ide-proc.c7
-rw-r--r--drivers/ide/ide.c5
-rw-r--r--drivers/ide/scc_pata.c8
6 files changed, 58 insertions, 83 deletions
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index fd155b8a256c..2f9e941968d6 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -641,7 +641,8 @@ void ide_acpi_push_timing(ide_hwif_t *hwif)
641 */ 641 */
642void ide_acpi_set_state(ide_hwif_t *hwif, int on) 642void 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->devices[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
@@ -717,9 +717,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
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->devices[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->devices[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-iops.c b/drivers/ide/ide-iops.c
index 26b58d15c4e6..1a22c31ce7ac 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -1081,8 +1081,9 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1081 struct ide_io_ports *io_ports = &hwif->io_ports; 1081 struct ide_io_ports *io_ports = &hwif->io_ports;
1082 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 1082 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
1083 const struct ide_port_ops *port_ops; 1083 const struct ide_port_ops *port_ops;
1084 ide_drive_t *tdrive;
1084 unsigned long flags, timeout; 1085 unsigned long flags, timeout;
1085 unsigned int unit; 1086 int i;
1086 DEFINE_WAIT(wait); 1087 DEFINE_WAIT(wait);
1087 1088
1088 spin_lock_irqsave(&hwif->lock, flags); 1089 spin_lock_irqsave(&hwif->lock, flags);
@@ -1110,9 +1111,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1110 1111
1111 prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE); 1112 prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE);
1112 timeout = jiffies; 1113 timeout = jiffies;
1113 for (unit = 0; unit < MAX_DRIVES; unit++) { 1114 ide_port_for_each_dev(i, tdrive, hwif) {
1114 ide_drive_t *tdrive = hwif->devices[unit];
1115
1116 if (tdrive->dev_flags & IDE_DFLAG_PRESENT && 1115 if (tdrive->dev_flags & IDE_DFLAG_PRESENT &&
1117 tdrive->dev_flags & IDE_DFLAG_PARKED && 1116 tdrive->dev_flags & IDE_DFLAG_PARKED &&
1118 time_after(tdrive->sleep, timeout)) 1117 time_after(tdrive->sleep, timeout))
@@ -1133,8 +1132,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1133 * First, reset any device state data we were maintaining 1132 * First, reset any device state data we were maintaining
1134 * for any of the drives on this interface. 1133 * for any of the drives on this interface.
1135 */ 1134 */
1136 for (unit = 0; unit < MAX_DRIVES; ++unit) 1135 ide_port_for_each_dev(i, tdrive, hwif)
1137 pre_reset(hwif->devices[unit]); 1136 pre_reset(tdrive);
1138 1137
1139 if (io_ports->ctl_addr == 0) { 1138 if (io_ports->ctl_addr == 0) {
1140 spin_unlock_irqrestore(&hwif->lock, flags); 1139 spin_unlock_irqrestore(&hwif->lock, flags);
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 006e601cafb8..e688ca1c967c 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -697,7 +697,8 @@ out:
697 697
698static int ide_port_wait_ready(ide_hwif_t *hwif) 698static 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->devices[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,7 +731,7 @@ static int ide_port_wait_ready(ide_hwif_t *hwif)
732 } 731 }
733out: 732out:
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->devices[0]); 735 SELECT_DRIVE(hwif->devices[0]);
737 736
738 return rc; 737 return rc;
@@ -778,9 +777,10 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave);
778 777
779static int ide_probe_port(ide_hwif_t *hwif) 778static 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
@@ -806,9 +806,7 @@ static int ide_probe_port(ide_hwif_t *hwif)
806 * Second drive should only exist if first drive was found, 806 * Second drive should only exist if first drive was found,
807 * but a lot of cdrom drives are configured as single slaves. 807 * but a lot of cdrom drives are configured as single slaves.
808 */ 808 */
809 for (unit = 0; unit < MAX_DRIVES; ++unit) { 809 ide_port_for_each_dev(i, drive, hwif) {
810 ide_drive_t *drive = hwif->devices[unit];
811
812 (void) probe_for_drive(drive); 810 (void) probe_for_drive(drive);
813 if (drive->dev_flags & IDE_DFLAG_PRESENT) 811 if (drive->dev_flags & IDE_DFLAG_PRESENT)
814 rc = 0; 812 rc = 0;
@@ -829,20 +827,17 @@ static int ide_probe_port(ide_hwif_t *hwif)
829static void ide_port_tune_devices(ide_hwif_t *hwif) 827static void ide_port_tune_devices(ide_hwif_t *hwif)
830{ 828{
831 const struct ide_port_ops *port_ops = hwif->port_ops; 829 const struct ide_port_ops *port_ops = hwif->port_ops;
832 int unit; 830 ide_drive_t *drive;
833 831 int i;
834 for (unit = 0; unit < MAX_DRIVES; unit++) {
835 ide_drive_t *drive = hwif->devices[unit];
836 832
833 ide_port_for_each_dev(i, drive, hwif) {
837 if (drive->dev_flags & IDE_DFLAG_PRESENT) { 834 if (drive->dev_flags & IDE_DFLAG_PRESENT) {
838 if (port_ops && port_ops->quirkproc) 835 if (port_ops && port_ops->quirkproc)
839 port_ops->quirkproc(drive); 836 port_ops->quirkproc(drive);
840 } 837 }
841 } 838 }
842 839
843 for (unit = 0; unit < MAX_DRIVES; ++unit) { 840 ide_port_for_each_dev(i, drive, hwif) {
844 ide_drive_t *drive = hwif->devices[unit];
845
846 if (drive->dev_flags & IDE_DFLAG_PRESENT) { 841 if (drive->dev_flags & IDE_DFLAG_PRESENT) {
847 ide_set_max_pio(drive); 842 ide_set_max_pio(drive);
848 843
@@ -853,9 +848,7 @@ static void ide_port_tune_devices(ide_hwif_t *hwif)
853 } 848 }
854 } 849 }
855 850
856 for (unit = 0; unit < MAX_DRIVES; ++unit) { 851 ide_port_for_each_dev(i, drive, hwif) {
857 ide_drive_t *drive = hwif->devices[unit];
858
859 if ((hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) || 852 if ((hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) ||
860 drive->id[ATA_ID_DWORD_IO]) 853 drive->id[ATA_ID_DWORD_IO])
861 drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT; 854 drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT;
@@ -927,12 +920,11 @@ static DEFINE_MUTEX(ide_cfg_mtx);
927 */ 920 */
928static int ide_port_setup_devices(ide_hwif_t *hwif) 921static int ide_port_setup_devices(ide_hwif_t *hwif)
929{ 922{
923 ide_drive_t *drive;
930 int i, j = 0; 924 int i, j = 0;
931 925
932 mutex_lock(&ide_cfg_mtx); 926 mutex_lock(&ide_cfg_mtx);
933 for (i = 0; i < MAX_DRIVES; i++) { 927 ide_port_for_each_dev(i, drive, hwif) {
934 ide_drive_t *drive = hwif->devices[i];
935
936 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 928 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
937 continue; 929 continue;
938 930
@@ -1161,10 +1153,10 @@ out:
1161 1153
1162static void hwif_register_devices(ide_hwif_t *hwif) 1154static void hwif_register_devices(ide_hwif_t *hwif)
1163{ 1155{
1156 ide_drive_t *drive;
1164 unsigned int i; 1157 unsigned int i;
1165 1158
1166 for (i = 0; i < MAX_DRIVES; i++) { 1159 ide_port_for_each_dev(i, drive, hwif) {
1167 ide_drive_t *drive = hwif->devices[i];
1168 struct device *dev = &drive->gendev; 1160 struct device *dev = &drive->gendev;
1169 int ret; 1161 int ret;
1170 1162
@@ -1187,11 +1179,10 @@ static void hwif_register_devices(ide_hwif_t *hwif)
1187static void ide_port_init_devices(ide_hwif_t *hwif) 1179static void ide_port_init_devices(ide_hwif_t *hwif)
1188{ 1180{
1189 const struct ide_port_ops *port_ops = hwif->port_ops; 1181 const struct ide_port_ops *port_ops = hwif->port_ops;
1182 ide_drive_t *drive;
1190 int i; 1183 int i;
1191 1184
1192 for (i = 0; i < MAX_DRIVES; i++) { 1185 ide_port_for_each_dev(i, drive, hwif) {
1193 ide_drive_t *drive = hwif->devices[i];
1194
1195 drive->dn = i + hwif->channel * 2; 1186 drive->dn = i + hwif->channel * 2;
1196 1187
1197 if (hwif->host_flags & IDE_HFLAG_IO_32BIT) 1188 if (hwif->host_flags & IDE_HFLAG_IO_32BIT)
@@ -1282,16 +1273,16 @@ static const u8 ide_hwif_to_major[] =
1282 1273
1283static void ide_port_init_devices_data(ide_hwif_t *hwif) 1274static void ide_port_init_devices_data(ide_hwif_t *hwif)
1284{ 1275{
1285 int unit; 1276 ide_drive_t *drive;
1277 int i;
1286 1278
1287 for (unit = 0; unit < MAX_DRIVES; ++unit) { 1279 ide_port_for_each_dev(i, drive, hwif) {
1288 ide_drive_t *drive = hwif->devices[unit]; 1280 u8 j = (hwif->index * MAX_DRIVES) + i;
1289 u8 j = (hwif->index * MAX_DRIVES) + unit;
1290 1281
1291 memset(drive, 0, sizeof(*drive)); 1282 memset(drive, 0, sizeof(*drive));
1292 1283
1293 drive->media = ide_disk; 1284 drive->media = ide_disk;
1294 drive->select = (unit << 4) | ATA_DEVICE_OBS; 1285 drive->select = (i << 4) | ATA_DEVICE_OBS;
1295 drive->hwif = hwif; 1286 drive->hwif = hwif;
1296 drive->ready_stat = ATA_DRDY; 1287 drive->ready_stat = ATA_DRDY;
1297 drive->bad_wstat = BAD_W_STAT; 1288 drive->bad_wstat = BAD_W_STAT;
@@ -1387,10 +1378,11 @@ static void ide_free_port_slot(int idx)
1387 1378
1388static void ide_port_free_devices(ide_hwif_t *hwif) 1379static void ide_port_free_devices(ide_hwif_t *hwif)
1389{ 1380{
1381 ide_drive_t *drive;
1390 int i; 1382 int i;
1391 1383
1392 for (i = 0; i < MAX_DRIVES; i++) 1384 ide_port_for_each_dev(i, drive, hwif)
1393 kfree(hwif->devices[i]); 1385 kfree(drive);
1394} 1386}
1395 1387
1396static int ide_port_alloc_devices(ide_hwif_t *hwif, int node) 1388static int ide_port_alloc_devices(ide_hwif_t *hwif, int node)
@@ -1478,9 +1470,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1478 ide_hwif_t *hwif, *mate = NULL; 1470 ide_hwif_t *hwif, *mate = NULL;
1479 int i, j = 0; 1471 int i, j = 0;
1480 1472
1481 for (i = 0; i < MAX_HOST_PORTS; i++) { 1473 ide_host_for_each_port(i, hwif, host) {
1482 hwif = host->ports[i];
1483
1484 if (hwif == NULL) { 1474 if (hwif == NULL) {
1485 mate = NULL; 1475 mate = NULL;
1486 continue; 1476 continue;
@@ -1506,9 +1496,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1506 ide_port_init_devices(hwif); 1496 ide_port_init_devices(hwif);
1507 } 1497 }
1508 1498
1509 for (i = 0; i < MAX_HOST_PORTS; i++) { 1499 ide_host_for_each_port(i, hwif, host) {
1510 hwif = host->ports[i];
1511
1512 if (hwif == NULL) 1500 if (hwif == NULL)
1513 continue; 1501 continue;
1514 1502
@@ -1523,9 +1511,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1523 ide_port_tune_devices(hwif); 1511 ide_port_tune_devices(hwif);
1524 } 1512 }
1525 1513
1526 for (i = 0; i < MAX_HOST_PORTS; i++) { 1514 ide_host_for_each_port(i, hwif, host) {
1527 hwif = host->ports[i];
1528
1529 if (hwif == NULL) 1515 if (hwif == NULL)
1530 continue; 1516 continue;
1531 1517
@@ -1550,9 +1536,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1550 ide_acpi_port_init_devices(hwif); 1536 ide_acpi_port_init_devices(hwif);
1551 } 1537 }
1552 1538
1553 for (i = 0; i < MAX_HOST_PORTS; i++) { 1539 ide_host_for_each_port(i, hwif, host) {
1554 hwif = host->ports[i];
1555
1556 if (hwif == NULL) 1540 if (hwif == NULL)
1557 continue; 1541 continue;
1558 1542
@@ -1560,9 +1544,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1560 hwif_register_devices(hwif); 1544 hwif_register_devices(hwif);
1561 } 1545 }
1562 1546
1563 for (i = 0; i < MAX_HOST_PORTS; i++) { 1547 ide_host_for_each_port(i, hwif, host) {
1564 hwif = host->ports[i];
1565
1566 if (hwif == NULL) 1548 if (hwif == NULL)
1567 continue; 1549 continue;
1568 1550
@@ -1602,11 +1584,10 @@ EXPORT_SYMBOL_GPL(ide_host_add);
1602 1584
1603static void __ide_port_unregister_devices(ide_hwif_t *hwif) 1585static void __ide_port_unregister_devices(ide_hwif_t *hwif)
1604{ 1586{
1587 ide_drive_t *drive;
1605 int i; 1588 int i;
1606 1589
1607 for (i = 0; i < MAX_DRIVES; i++) { 1590 ide_port_for_each_dev(i, drive, hwif) {
1608 ide_drive_t *drive = hwif->devices[i];
1609
1610 if (drive->dev_flags & IDE_DFLAG_PRESENT) { 1591 if (drive->dev_flags & IDE_DFLAG_PRESENT) {
1611 device_unregister(&drive->gendev); 1592 device_unregister(&drive->gendev);
1612 wait_for_completion(&drive->gendev_rel_comp); 1593 wait_for_completion(&drive->gendev_rel_comp);
@@ -1675,9 +1656,7 @@ void ide_host_free(struct ide_host *host)
1675 ide_hwif_t *hwif; 1656 ide_hwif_t *hwif;
1676 int i; 1657 int i;
1677 1658
1678 for (i = 0; i < MAX_HOST_PORTS; i++) { 1659 ide_host_for_each_port(i, hwif, host) {
1679 hwif = host->ports[i];
1680
1681 if (hwif == NULL) 1660 if (hwif == NULL)
1682 continue; 1661 continue;
1683 1662
@@ -1692,11 +1671,12 @@ EXPORT_SYMBOL_GPL(ide_host_free);
1692 1671
1693void ide_host_remove(struct ide_host *host) 1672void ide_host_remove(struct ide_host *host)
1694{ 1673{
1674 ide_hwif_t *hwif;
1695 int i; 1675 int i;
1696 1676
1697 for (i = 0; i < MAX_HOST_PORTS; i++) { 1677 ide_host_for_each_port(i, hwif, host) {
1698 if (host->ports[i]) 1678 if (hwif)
1699 ide_unregister(host->ports[i]); 1679 ide_unregister(hwif);
1700 } 1680 }
1701 1681
1702 ide_host_free(host); 1682 ide_host_free(host);
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index 1dc827fa7061..1d8978b3314a 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -593,14 +593,13 @@ EXPORT_SYMBOL(ide_proc_unregister_driver);
593 593
594void ide_proc_port_register_devices(ide_hwif_t *hwif) 594void 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->devices[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
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 8a6f893d127e..258805da15c3 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -488,6 +488,7 @@ MODULE_PARM_DESC(ignore_cable, "ignore cable detection");
488 488
489void ide_port_apply_params(ide_hwif_t *hwif) 489void ide_port_apply_params(ide_hwif_t *hwif)
490{ 490{
491 ide_drive_t *drive;
491 int i; 492 int i;
492 493
493 if (ide_ignore_cable & (1 << hwif->index)) { 494 if (ide_ignore_cable & (1 << hwif->index)) {
@@ -496,8 +497,8 @@ void ide_port_apply_params(ide_hwif_t *hwif)
496 hwif->cbl = ATA_CBL_PATA40_SHORT; 497 hwif->cbl = ATA_CBL_PATA40_SHORT;
497 } 498 }
498 499
499 for (i = 0; i < MAX_DRIVES; i++) 500 ide_port_for_each_dev(i, drive, hwif)
500 ide_dev_apply_params(hwif->devices[i], i); 501 ide_dev_apply_params(drive, i);
501} 502}
502 503
503/* 504/*
diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c
index 841164d7d3b9..5d53850c79d7 100644
--- a/drivers/ide/scc_pata.c
+++ b/drivers/ide/scc_pata.c
@@ -406,17 +406,17 @@ static int scc_dma_end(ide_drive_t *drive)
406 data_loss = 1; 406 data_loss = 1;
407 if (retry++) { 407 if (retry++) {
408 struct request *rq = hwif->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++) {
416 ide_drive_t *drive = hwif->devices[unit];
417 417
418 ide_port_for_each_dev(i, drive, hwif)
418 drive->crc_count++; 419 drive->crc_count++;
419 }
420 } 420 }
421 } 421 }
422 } 422 }