diff options
author | Tejun Heo <tj@kernel.org> | 2008-10-27 06:59:23 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-10-27 23:55:12 -0400 |
commit | 4a9c7b3359889399aacb94019bbdfc9f38d4cff7 (patch) | |
tree | a791790f02f2a0a5b3ea66c1526ae79f1711dca8 /drivers | |
parent | c77a036beceabbfd85b366193685cb49f38292bd (diff) |
libata: fix device iteration bugs
There were several places where only enabled devices should be
iterated over but device enabledness wasn't checked.
* IDENTIFY data 40 wire check in cable_is_40wire()
* xfer_mode/ncq_enabled saving in ata_scsi_error()
* DUBIOUS_XFER handling in ata_set_mode()
While at it, reformat comments in cable_is_40wire().
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ata/libata-core.c | 34 | ||||
-rw-r--r-- | drivers/ata/libata-eh.c | 9 |
2 files changed, 28 insertions, 15 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 8cb0b360bfd8..97df4807a088 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -4156,29 +4156,33 @@ static int cable_is_40wire(struct ata_port *ap) | |||
4156 | struct ata_link *link; | 4156 | struct ata_link *link; |
4157 | struct ata_device *dev; | 4157 | struct ata_device *dev; |
4158 | 4158 | ||
4159 | /* If the controller thinks we are 40 wire, we are */ | 4159 | /* If the controller thinks we are 40 wire, we are. */ |
4160 | if (ap->cbl == ATA_CBL_PATA40) | 4160 | if (ap->cbl == ATA_CBL_PATA40) |
4161 | return 1; | 4161 | return 1; |
4162 | /* If the controller thinks we are 80 wire, we are */ | 4162 | |
4163 | /* If the controller thinks we are 80 wire, we are. */ | ||
4163 | if (ap->cbl == ATA_CBL_PATA80 || ap->cbl == ATA_CBL_SATA) | 4164 | if (ap->cbl == ATA_CBL_PATA80 || ap->cbl == ATA_CBL_SATA) |
4164 | return 0; | 4165 | return 0; |
4165 | /* If the system is known to be 40 wire short cable (eg laptop), | 4166 | |
4166 | then we allow 80 wire modes even if the drive isn't sure */ | 4167 | /* If the system is known to be 40 wire short cable (eg |
4168 | * laptop), then we allow 80 wire modes even if the drive | ||
4169 | * isn't sure. | ||
4170 | */ | ||
4167 | if (ap->cbl == ATA_CBL_PATA40_SHORT) | 4171 | if (ap->cbl == ATA_CBL_PATA40_SHORT) |
4168 | return 0; | 4172 | return 0; |
4169 | /* If the controller doesn't know we scan | 4173 | |
4170 | 4174 | /* If the controller doesn't know, we scan. | |
4171 | - Note: We look for all 40 wire detects at this point. | 4175 | * |
4172 | Any 80 wire detect is taken to be 80 wire cable | 4176 | * Note: We look for all 40 wire detects at this point. Any |
4173 | because | 4177 | * 80 wire detect is taken to be 80 wire cable because |
4174 | - In many setups only the one drive (slave if present) | 4178 | * - in many setups only the one drive (slave if present) will |
4175 | will give a valid detect | 4179 | * give a valid detect |
4176 | - If you have a non detect capable drive you don't | 4180 | * - if you have a non detect capable drive you don't want it |
4177 | want it to colour the choice | 4181 | * to colour the choice |
4178 | */ | 4182 | */ |
4179 | ata_port_for_each_link(link, ap) { | 4183 | ata_port_for_each_link(link, ap) { |
4180 | ata_link_for_each_dev(dev, link) { | 4184 | ata_link_for_each_dev(dev, link) { |
4181 | if (!ata_is_40wire(dev)) | 4185 | if (ata_dev_enabled(dev) && !ata_is_40wire(dev)) |
4182 | return 0; | 4186 | return 0; |
4183 | } | 4187 | } |
4184 | } | 4188 | } |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 5d687d7cffae..a6a3b1554c45 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -603,6 +603,9 @@ void ata_scsi_error(struct Scsi_Host *host) | |||
603 | ata_link_for_each_dev(dev, link) { | 603 | ata_link_for_each_dev(dev, link) { |
604 | int devno = dev->devno; | 604 | int devno = dev->devno; |
605 | 605 | ||
606 | if (!ata_dev_enabled(dev)) | ||
607 | continue; | ||
608 | |||
606 | ehc->saved_xfer_mode[devno] = dev->xfer_mode; | 609 | ehc->saved_xfer_mode[devno] = dev->xfer_mode; |
607 | if (ata_ncq_enabled(dev)) | 610 | if (ata_ncq_enabled(dev)) |
608 | ehc->saved_ncq_enabled |= 1 << devno; | 611 | ehc->saved_ncq_enabled |= 1 << devno; |
@@ -2787,6 +2790,9 @@ int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev) | |||
2787 | 2790 | ||
2788 | /* if data transfer is verified, clear DUBIOUS_XFER on ering top */ | 2791 | /* if data transfer is verified, clear DUBIOUS_XFER on ering top */ |
2789 | ata_link_for_each_dev(dev, link) { | 2792 | ata_link_for_each_dev(dev, link) { |
2793 | if (!ata_dev_enabled(dev)) | ||
2794 | continue; | ||
2795 | |||
2790 | if (!(dev->flags & ATA_DFLAG_DUBIOUS_XFER)) { | 2796 | if (!(dev->flags & ATA_DFLAG_DUBIOUS_XFER)) { |
2791 | struct ata_ering_entry *ent; | 2797 | struct ata_ering_entry *ent; |
2792 | 2798 | ||
@@ -2808,6 +2814,9 @@ int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev) | |||
2808 | u8 saved_xfer_mode = ehc->saved_xfer_mode[dev->devno]; | 2814 | u8 saved_xfer_mode = ehc->saved_xfer_mode[dev->devno]; |
2809 | u8 saved_ncq = !!(ehc->saved_ncq_enabled & (1 << dev->devno)); | 2815 | u8 saved_ncq = !!(ehc->saved_ncq_enabled & (1 << dev->devno)); |
2810 | 2816 | ||
2817 | if (!ata_dev_enabled(dev)) | ||
2818 | continue; | ||
2819 | |||
2811 | if (dev->xfer_mode != saved_xfer_mode || | 2820 | if (dev->xfer_mode != saved_xfer_mode || |
2812 | ata_ncq_enabled(dev) != saved_ncq) | 2821 | ata_ncq_enabled(dev) != saved_ncq) |
2813 | dev->flags |= ATA_DFLAG_DUBIOUS_XFER; | 2822 | dev->flags |= ATA_DFLAG_DUBIOUS_XFER; |