diff options
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r-- | drivers/ata/libata-core.c | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index dd2de485124a..f30c4771b3af 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -2105,21 +2105,19 @@ int ata_bus_probe(struct ata_port *ap) | |||
2105 | { | 2105 | { |
2106 | unsigned int classes[ATA_MAX_DEVICES]; | 2106 | unsigned int classes[ATA_MAX_DEVICES]; |
2107 | int tries[ATA_MAX_DEVICES]; | 2107 | int tries[ATA_MAX_DEVICES]; |
2108 | int i, rc; | 2108 | int rc; |
2109 | struct ata_device *dev; | 2109 | struct ata_device *dev; |
2110 | 2110 | ||
2111 | ata_port_probe(ap); | 2111 | ata_port_probe(ap); |
2112 | 2112 | ||
2113 | for (i = 0; i < ATA_MAX_DEVICES; i++) | 2113 | ata_link_for_each_dev(dev, &ap->link) |
2114 | tries[i] = ATA_PROBE_MAX_TRIES; | 2114 | tries[dev->devno] = ATA_PROBE_MAX_TRIES; |
2115 | 2115 | ||
2116 | retry: | 2116 | retry: |
2117 | /* reset and determine device classes */ | 2117 | /* reset and determine device classes */ |
2118 | ap->ops->phy_reset(ap); | 2118 | ap->ops->phy_reset(ap); |
2119 | 2119 | ||
2120 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2120 | ata_link_for_each_dev(dev, &ap->link) { |
2121 | dev = &ap->link.device[i]; | ||
2122 | |||
2123 | if (!(ap->flags & ATA_FLAG_DISABLED) && | 2121 | if (!(ap->flags & ATA_FLAG_DISABLED) && |
2124 | dev->class != ATA_DEV_UNKNOWN) | 2122 | dev->class != ATA_DEV_UNKNOWN) |
2125 | classes[dev->devno] = dev->class; | 2123 | classes[dev->devno] = dev->class; |
@@ -2134,18 +2132,16 @@ int ata_bus_probe(struct ata_port *ap) | |||
2134 | /* after the reset the device state is PIO 0 and the controller | 2132 | /* after the reset the device state is PIO 0 and the controller |
2135 | state is undefined. Record the mode */ | 2133 | state is undefined. Record the mode */ |
2136 | 2134 | ||
2137 | for (i = 0; i < ATA_MAX_DEVICES; i++) | 2135 | ata_link_for_each_dev(dev, &ap->link) |
2138 | ap->link.device[i].pio_mode = XFER_PIO_0; | 2136 | dev->pio_mode = XFER_PIO_0; |
2139 | 2137 | ||
2140 | /* read IDENTIFY page and configure devices. We have to do the identify | 2138 | /* read IDENTIFY page and configure devices. We have to do the identify |
2141 | specific sequence bass-ackwards so that PDIAG- is released by | 2139 | specific sequence bass-ackwards so that PDIAG- is released by |
2142 | the slave device */ | 2140 | the slave device */ |
2143 | 2141 | ||
2144 | for (i = ATA_MAX_DEVICES - 1; i >= 0; i--) { | 2142 | ata_link_for_each_dev(dev, &ap->link) { |
2145 | dev = &ap->link.device[i]; | 2143 | if (tries[dev->devno]) |
2146 | 2144 | dev->class = classes[dev->devno]; | |
2147 | if (tries[i]) | ||
2148 | dev->class = classes[i]; | ||
2149 | 2145 | ||
2150 | if (!ata_dev_enabled(dev)) | 2146 | if (!ata_dev_enabled(dev)) |
2151 | continue; | 2147 | continue; |
@@ -2163,8 +2159,7 @@ int ata_bus_probe(struct ata_port *ap) | |||
2163 | /* After the identify sequence we can now set up the devices. We do | 2159 | /* After the identify sequence we can now set up the devices. We do |
2164 | this in the normal order so that the user doesn't get confused */ | 2160 | this in the normal order so that the user doesn't get confused */ |
2165 | 2161 | ||
2166 | for(i = 0; i < ATA_MAX_DEVICES; i++) { | 2162 | ata_link_for_each_dev(dev, &ap->link) { |
2167 | dev = &ap->link.device[i]; | ||
2168 | if (!ata_dev_enabled(dev)) | 2163 | if (!ata_dev_enabled(dev)) |
2169 | continue; | 2164 | continue; |
2170 | 2165 | ||
@@ -2180,8 +2175,8 @@ int ata_bus_probe(struct ata_port *ap) | |||
2180 | if (rc) | 2175 | if (rc) |
2181 | goto fail; | 2176 | goto fail; |
2182 | 2177 | ||
2183 | for (i = 0; i < ATA_MAX_DEVICES; i++) | 2178 | ata_link_for_each_dev(dev, &ap->link) |
2184 | if (ata_dev_enabled(&ap->link.device[i])) | 2179 | if (ata_dev_enabled(dev)) |
2185 | return 0; | 2180 | return 0; |
2186 | 2181 | ||
2187 | /* no device present, disable port */ | 2182 | /* no device present, disable port */ |
@@ -2803,16 +2798,14 @@ static int ata_dev_set_mode(struct ata_device *dev) | |||
2803 | 2798 | ||
2804 | int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) | 2799 | int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) |
2805 | { | 2800 | { |
2801 | struct ata_link *link = &ap->link; | ||
2806 | struct ata_device *dev; | 2802 | struct ata_device *dev; |
2807 | int i, rc = 0, used_dma = 0, found = 0; | 2803 | int rc = 0, used_dma = 0, found = 0; |
2808 | |||
2809 | 2804 | ||
2810 | /* step 1: calculate xfer_mask */ | 2805 | /* step 1: calculate xfer_mask */ |
2811 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2806 | ata_link_for_each_dev(dev, link) { |
2812 | unsigned int pio_mask, dma_mask; | 2807 | unsigned int pio_mask, dma_mask; |
2813 | 2808 | ||
2814 | dev = &ap->link.device[i]; | ||
2815 | |||
2816 | if (!ata_dev_enabled(dev)) | 2809 | if (!ata_dev_enabled(dev)) |
2817 | continue; | 2810 | continue; |
2818 | 2811 | ||
@@ -2831,8 +2824,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) | |||
2831 | goto out; | 2824 | goto out; |
2832 | 2825 | ||
2833 | /* step 2: always set host PIO timings */ | 2826 | /* step 2: always set host PIO timings */ |
2834 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2827 | ata_link_for_each_dev(dev, link) { |
2835 | dev = &ap->link.device[i]; | ||
2836 | if (!ata_dev_enabled(dev)) | 2828 | if (!ata_dev_enabled(dev)) |
2837 | continue; | 2829 | continue; |
2838 | 2830 | ||
@@ -2849,9 +2841,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) | |||
2849 | } | 2841 | } |
2850 | 2842 | ||
2851 | /* step 3: set host DMA timings */ | 2843 | /* step 3: set host DMA timings */ |
2852 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2844 | ata_link_for_each_dev(dev, link) { |
2853 | dev = &ap->link.device[i]; | ||
2854 | |||
2855 | if (!ata_dev_enabled(dev) || !dev->dma_mode) | 2845 | if (!ata_dev_enabled(dev) || !dev->dma_mode) |
2856 | continue; | 2846 | continue; |
2857 | 2847 | ||
@@ -2862,9 +2852,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) | |||
2862 | } | 2852 | } |
2863 | 2853 | ||
2864 | /* step 4: update devices' xfer mode */ | 2854 | /* step 4: update devices' xfer mode */ |
2865 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2855 | ata_link_for_each_dev(dev, link) { |
2866 | dev = &ap->link.device[i]; | ||
2867 | |||
2868 | /* don't update suspended devices' xfer mode */ | 2856 | /* don't update suspended devices' xfer mode */ |
2869 | if (!ata_dev_enabled(dev)) | 2857 | if (!ata_dev_enabled(dev)) |
2870 | continue; | 2858 | continue; |
@@ -6113,6 +6101,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host) | |||
6113 | 6101 | ||
6114 | ap->link.ap = ap; | 6102 | ap->link.ap = ap; |
6115 | 6103 | ||
6104 | /* can't use iterator, ap isn't initialized yet */ | ||
6116 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 6105 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
6117 | struct ata_device *dev = &ap->link.device[i]; | 6106 | struct ata_device *dev = &ap->link.device[i]; |
6118 | dev->link = &ap->link; | 6107 | dev->link = &ap->link; |
@@ -6453,7 +6442,8 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) | |||
6453 | /* kick EH for boot probing */ | 6442 | /* kick EH for boot probing */ |
6454 | spin_lock_irqsave(ap->lock, flags); | 6443 | spin_lock_irqsave(ap->lock, flags); |
6455 | 6444 | ||
6456 | ehi->probe_mask = (1 << ATA_MAX_DEVICES) - 1; | 6445 | ehi->probe_mask = |
6446 | (1 << ata_link_max_devices(&ap->link)) - 1; | ||
6457 | ehi->action |= ATA_EH_SOFTRESET; | 6447 | ehi->action |= ATA_EH_SOFTRESET; |
6458 | ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; | 6448 | ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; |
6459 | 6449 | ||
@@ -6551,7 +6541,7 @@ int ata_host_activate(struct ata_host *host, int irq, | |||
6551 | void ata_port_detach(struct ata_port *ap) | 6541 | void ata_port_detach(struct ata_port *ap) |
6552 | { | 6542 | { |
6553 | unsigned long flags; | 6543 | unsigned long flags; |
6554 | int i; | 6544 | struct ata_device *dev; |
6555 | 6545 | ||
6556 | if (!ap->ops->error_handler) | 6546 | if (!ap->ops->error_handler) |
6557 | goto skip_eh; | 6547 | goto skip_eh; |
@@ -6568,8 +6558,8 @@ void ata_port_detach(struct ata_port *ap) | |||
6568 | */ | 6558 | */ |
6569 | spin_lock_irqsave(ap->lock, flags); | 6559 | spin_lock_irqsave(ap->lock, flags); |
6570 | 6560 | ||
6571 | for (i = 0; i < ATA_MAX_DEVICES; i++) | 6561 | ata_link_for_each_dev(dev, &ap->link) |
6572 | ata_dev_disable(&ap->link.device[i]); | 6562 | ata_dev_disable(dev); |
6573 | 6563 | ||
6574 | spin_unlock_irqrestore(ap->lock, flags); | 6564 | spin_unlock_irqrestore(ap->lock, flags); |
6575 | 6565 | ||