diff options
author | Tejun Heo <htejun@gmail.com> | 2007-08-06 05:36:23 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-10-12 14:55:30 -0400 |
commit | f58229f8060055b08b34008ea08f31de1e2f003c (patch) | |
tree | 6ca5ef546671cb975ef3632fb032c238eaf1bb4c /drivers/ata/ata_generic.c | |
parent | 9af5c9c97dc9d599281778864c72b385f0c63341 (diff) |
libata-link: implement and use link/device iterators
Multiple links and different number of devices per link should be
considered to iterate over links and devices. This patch implements
and uses link and device iterators - ata_port_for_each_link() and
ata_link_for_each_dev() - and ata_link_max_devices().
This change makes a lot of functions iterate over only possible
devices instead of from dev 0 to dev ATA_MAX_DEVICES. All such
changes have been examined and nothing should be broken.
While at it, add a separating comment before device helpers to
distinguish them better from link helpers and others.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/ata_generic.c')
-rw-r--r-- | drivers/ata/ata_generic.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c index b5e390ff5bd8..44328a16075c 100644 --- a/drivers/ata/ata_generic.c +++ b/drivers/ata/ata_generic.c | |||
@@ -46,21 +46,20 @@ | |||
46 | static int generic_set_mode(struct ata_port *ap, struct ata_device **unused) | 46 | static int generic_set_mode(struct ata_port *ap, struct ata_device **unused) |
47 | { | 47 | { |
48 | int dma_enabled = 0; | 48 | int dma_enabled = 0; |
49 | int i; | 49 | struct ata_device *dev; |
50 | 50 | ||
51 | /* Bits 5 and 6 indicate if DMA is active on master/slave */ | 51 | /* Bits 5 and 6 indicate if DMA is active on master/slave */ |
52 | if (ap->ioaddr.bmdma_addr) | 52 | if (ap->ioaddr.bmdma_addr) |
53 | dma_enabled = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); | 53 | dma_enabled = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); |
54 | 54 | ||
55 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 55 | ata_link_for_each_dev(dev, &ap->link) { |
56 | struct ata_device *dev = &ap->link.device[i]; | ||
57 | if (ata_dev_enabled(dev)) { | 56 | if (ata_dev_enabled(dev)) { |
58 | /* We don't really care */ | 57 | /* We don't really care */ |
59 | dev->pio_mode = XFER_PIO_0; | 58 | dev->pio_mode = XFER_PIO_0; |
60 | dev->dma_mode = XFER_MW_DMA_0; | 59 | dev->dma_mode = XFER_MW_DMA_0; |
61 | /* We do need the right mode information for DMA or PIO | 60 | /* We do need the right mode information for DMA or PIO |
62 | and this comes from the current configuration flags */ | 61 | and this comes from the current configuration flags */ |
63 | if (dma_enabled & (1 << (5 + i))) { | 62 | if (dma_enabled & (1 << (5 + dev->devno))) { |
64 | ata_id_to_dma_mode(dev, XFER_MW_DMA_0); | 63 | ata_id_to_dma_mode(dev, XFER_MW_DMA_0); |
65 | dev->flags &= ~ATA_DFLAG_PIO; | 64 | dev->flags &= ~ATA_DFLAG_PIO; |
66 | } else { | 65 | } else { |