aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-24 18:22:41 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-24 18:22:41 -0400
commit7ed5b157d9dff55bf477b4c8b4708d5d45476677 (patch)
treecbfd113108efd3b4d0b634f02ca8f09e99b7fdc7 /drivers/ide
parent8cd3c605624035b7f57deb8894e17c5ba6d05b2e (diff)
ide: add ide_for_each_present_dev() iterator
* Add ide_for_each_present_dev() iterator and convert IDE code to use it. * Do some drive-by CodingStyle fixups in ide-acpi.c while at it. 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.c30
-rw-r--r--drivers/ide/ide-iops.c5
-rw-r--r--drivers/ide/ide-probe.c38
3 files changed, 25 insertions, 48 deletions
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index a3bebba18425..8d6d31fcbfba 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -608,17 +608,17 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on)
608 DEBPRINT("no ACPI data for %s\n", hwif->name); 608 DEBPRINT("no ACPI data for %s\n", hwif->name);
609 return; 609 return;
610 } 610 }
611
611 /* channel first and then drives for power on and verse versa for power off */ 612 /* channel first and then drives for power on and verse versa for power off */
612 if (on) 613 if (on)
613 acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0); 614 acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0);
614 615
615 ide_port_for_each_dev(i, drive, hwif) { 616 ide_port_for_each_present_dev(i, drive, hwif) {
616 if (drive->acpidata->obj_handle && 617 if (drive->acpidata->obj_handle)
617 (drive->dev_flags & IDE_DFLAG_PRESENT)) {
618 acpi_bus_set_power(drive->acpidata->obj_handle, 618 acpi_bus_set_power(drive->acpidata->obj_handle,
619 on? ACPI_STATE_D0: ACPI_STATE_D3); 619 on ? ACPI_STATE_D0 : ACPI_STATE_D3);
620 }
621 } 620 }
621
622 if (!on) 622 if (!on)
623 acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D3); 623 acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D3);
624} 624}
@@ -667,12 +667,9 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
667 hwif->devices[1]->acpidata = &hwif->acpidata->slave; 667 hwif->devices[1]->acpidata = &hwif->acpidata->slave;
668 668
669 /* get _ADR info for each device */ 669 /* get _ADR info for each device */
670 ide_port_for_each_dev(i, drive, hwif) { 670 ide_port_for_each_present_dev(i, drive, hwif) {
671 acpi_handle dev_handle; 671 acpi_handle dev_handle;
672 672
673 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
674 continue;
675
676 DEBPRINT("ENTER: %s at channel#: %d port#: %d\n", 673 DEBPRINT("ENTER: %s at channel#: %d port#: %d\n",
677 drive->name, hwif->channel, drive->dn & 1); 674 drive->name, hwif->channel, drive->dn & 1);
678 675
@@ -685,13 +682,8 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
685 drive->acpidata->obj_handle = dev_handle; 682 drive->acpidata->obj_handle = dev_handle;
686 } 683 }
687 684
688 /* 685 /* send IDENTIFY for each device */
689 * Send IDENTIFY for each drive 686 ide_port_for_each_present_dev(i, drive, hwif) {
690 */
691 ide_port_for_each_dev(i, drive, hwif) {
692 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
693 continue;
694
695 err = taskfile_lib_get_identify(drive, drive->acpidata->idbuff); 687 err = taskfile_lib_get_identify(drive, drive->acpidata->idbuff);
696 if (err) 688 if (err)
697 DEBPRINT("identify device %s failed (%d)\n", 689 DEBPRINT("identify device %s failed (%d)\n",
@@ -711,9 +703,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
711 ide_acpi_get_timing(hwif); 703 ide_acpi_get_timing(hwif);
712 ide_acpi_push_timing(hwif); 704 ide_acpi_push_timing(hwif);
713 705
714 ide_port_for_each_dev(i, drive, hwif) { 706 ide_port_for_each_present_dev(i, drive, hwif) {
715 if (drive->dev_flags & IDE_DFLAG_PRESENT) 707 ide_acpi_exec_tfs(drive);
716 /* Execute ACPI startup code */
717 ide_acpi_exec_tfs(drive);
718 } 708 }
719} 709}
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index b1892bd95c6f..02fed32a4047 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -1103,9 +1103,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1103 1103
1104 prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE); 1104 prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE);
1105 timeout = jiffies; 1105 timeout = jiffies;
1106 ide_port_for_each_dev(i, tdrive, hwif) { 1106 ide_port_for_each_present_dev(i, tdrive, hwif) {
1107 if (tdrive->dev_flags & IDE_DFLAG_PRESENT && 1107 if ((tdrive->dev_flags & IDE_DFLAG_PARKED) &&
1108 tdrive->dev_flags & IDE_DFLAG_PARKED &&
1109 time_after(tdrive->sleep, timeout)) 1108 time_after(tdrive->sleep, timeout))
1110 timeout = tdrive->sleep; 1109 timeout = tdrive->sleep;
1111 } 1110 }
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 5deb7e717333..eb0a38cd83ce 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -825,22 +825,18 @@ static void ide_port_tune_devices(ide_hwif_t *hwif)
825 ide_drive_t *drive; 825 ide_drive_t *drive;
826 int i; 826 int i;
827 827
828 ide_port_for_each_dev(i, drive, hwif) { 828 ide_port_for_each_present_dev(i, drive, hwif) {
829 if (drive->dev_flags & IDE_DFLAG_PRESENT) { 829 if (port_ops && port_ops->quirkproc)
830 if (port_ops && port_ops->quirkproc) 830 port_ops->quirkproc(drive);
831 port_ops->quirkproc(drive);
832 }
833 } 831 }
834 832
835 ide_port_for_each_dev(i, drive, hwif) { 833 ide_port_for_each_present_dev(i, drive, hwif) {
836 if (drive->dev_flags & IDE_DFLAG_PRESENT) { 834 ide_set_max_pio(drive);
837 ide_set_max_pio(drive);
838 835
839 drive->dev_flags |= IDE_DFLAG_NICE1; 836 drive->dev_flags |= IDE_DFLAG_NICE1;
840 837
841 if (hwif->dma_ops) 838 if (hwif->dma_ops)
842 ide_set_dma(drive); 839 ide_set_dma(drive);
843 }
844 } 840 }
845} 841}
846 842
@@ -911,10 +907,7 @@ static int ide_port_setup_devices(ide_hwif_t *hwif)
911 int i, j = 0; 907 int i, j = 0;
912 908
913 mutex_lock(&ide_cfg_mtx); 909 mutex_lock(&ide_cfg_mtx);
914 ide_port_for_each_dev(i, drive, hwif) { 910 ide_port_for_each_present_dev(i, drive, hwif) {
915 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
916 continue;
917
918 if (ide_init_queue(drive)) { 911 if (ide_init_queue(drive)) {
919 printk(KERN_ERR "ide: failed to init %s\n", 912 printk(KERN_ERR "ide: failed to init %s\n",
920 drive->name); 913 drive->name);
@@ -1139,13 +1132,10 @@ static void hwif_register_devices(ide_hwif_t *hwif)
1139 ide_drive_t *drive; 1132 ide_drive_t *drive;
1140 unsigned int i; 1133 unsigned int i;
1141 1134
1142 ide_port_for_each_dev(i, drive, hwif) { 1135 ide_port_for_each_present_dev(i, drive, hwif) {
1143 struct device *dev = &drive->gendev; 1136 struct device *dev = &drive->gendev;
1144 int ret; 1137 int ret;
1145 1138
1146 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
1147 continue;
1148
1149 dev_set_name(dev, "%u.%u", hwif->index, i); 1139 dev_set_name(dev, "%u.%u", hwif->index, i);
1150 dev->parent = &hwif->gendev; 1140 dev->parent = &hwif->gendev;
1151 dev->bus = &ide_bus_type; 1141 dev->bus = &ide_bus_type;
@@ -1610,11 +1600,9 @@ static void __ide_port_unregister_devices(ide_hwif_t *hwif)
1610 ide_drive_t *drive; 1600 ide_drive_t *drive;
1611 int i; 1601 int i;
1612 1602
1613 ide_port_for_each_dev(i, drive, hwif) { 1603 ide_port_for_each_present_dev(i, drive, hwif) {
1614 if (drive->dev_flags & IDE_DFLAG_PRESENT) { 1604 device_unregister(&drive->gendev);
1615 device_unregister(&drive->gendev); 1605 wait_for_completion(&drive->gendev_rel_comp);
1616 wait_for_completion(&drive->gendev_rel_comp);
1617 }
1618 } 1606 }
1619} 1607}
1620 1608