aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-core.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-01-29 06:31:31 -0500
committerJeff Garzik <jgarzik@redhat.com>2009-02-02 23:03:08 -0500
commit9913ff8abf1c70a8d52560dc931e1901d025ad27 (patch)
treed91ed8d73e9cb554d071e1d1449d5d0ef883e1a3 /drivers/ata/libata-core.c
parent678afac678061ee41bc3007885003c125912a8e2 (diff)
libata: check onlineness before using SPD in sata_down_spd_limit()
sata_down_spd_limit() should check whether the link is online before using the SPD value to determine how to limit the link speed. Factor out onlineness test and test it from sata_down_spd_limit(). Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r--drivers/ata/libata-core.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index af60d271582..d006e5c4768 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -164,6 +164,11 @@ MODULE_LICENSE("GPL");
164MODULE_VERSION(DRV_VERSION); 164MODULE_VERSION(DRV_VERSION);
165 165
166 166
167static bool ata_sstatus_online(u32 sstatus)
168{
169 return (sstatus & 0xf) == 0x3;
170}
171
167/** 172/**
168 * ata_link_next - link iteration helper 173 * ata_link_next - link iteration helper
169 * @link: the previous link, NULL to start 174 * @link: the previous link, NULL to start
@@ -2891,7 +2896,7 @@ int sata_down_spd_limit(struct ata_link *link)
2891 * If not, use cached value in link->sata_spd. 2896 * If not, use cached value in link->sata_spd.
2892 */ 2897 */
2893 rc = sata_scr_read(link, SCR_STATUS, &sstatus); 2898 rc = sata_scr_read(link, SCR_STATUS, &sstatus);
2894 if (rc == 0) 2899 if (rc == 0 && ata_sstatus_online(sstatus))
2895 spd = (sstatus >> 4) & 0xf; 2900 spd = (sstatus >> 4) & 0xf;
2896 else 2901 else
2897 spd = link->sata_spd; 2902 spd = link->sata_spd;
@@ -5162,7 +5167,7 @@ bool ata_phys_link_online(struct ata_link *link)
5162 u32 sstatus; 5167 u32 sstatus;
5163 5168
5164 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && 5169 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 &&
5165 (sstatus & 0xf) == 0x3) 5170 ata_sstatus_online(sstatus))
5166 return true; 5171 return true;
5167 return false; 5172 return false;
5168} 5173}
@@ -5186,7 +5191,7 @@ bool ata_phys_link_offline(struct ata_link *link)
5186 u32 sstatus; 5191 u32 sstatus;
5187 5192
5188 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && 5193 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 &&
5189 (sstatus & 0xf) != 0x3) 5194 !ata_sstatus_online(sstatus))
5190 return true; 5195 return true;
5191 return false; 5196 return false;
5192} 5197}