aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-sff.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2008-04-07 09:47:19 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-04-17 15:44:22 -0400
commit9dadd45b24145d6aee2fabb28d7aef972301892b (patch)
treec97c323e2edd400bc94eaceddf20f84e9a6da005 /drivers/ata/libata-sff.c
parenta89611e8489ac24f371c9fd6fef6605b170b16ba (diff)
libata: move generic hardreset code from sata_sff_hardreset() to sata_link_hardreset()
sata_sff_hardreset() contains link readiness wait logic which isn't SFF specific. Move that part into sata_link_hardreset(), which now takes two more parameters - @online and @check_ready. Both are optional. The former is out parameter for link onlineness after reset. The latter is used to wait for link readiness after hardreset. Users of sata_link_hardreset() is updated to use new funtionality and ahci_hardreset() is updated to use sata_link_hardreset() instead of sata_sff_hardreset(). This doesn't really cause any behavior change. Signed-off-by: Tejun Heo <htejun@gmail.com>
Diffstat (limited to 'drivers/ata/libata-sff.c')
-rw-r--r--drivers/ata/libata-sff.c49
1 files changed, 9 insertions, 40 deletions
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 78912c5011ad..0b97e84d3af6 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -1921,50 +1921,19 @@ int ata_sff_softreset(struct ata_link *link, unsigned int *classes,
1921int sata_sff_hardreset(struct ata_link *link, unsigned int *class, 1921int sata_sff_hardreset(struct ata_link *link, unsigned int *class,
1922 unsigned long deadline) 1922 unsigned long deadline)
1923{ 1923{
1924 struct ata_port *ap = link->ap; 1924 struct ata_eh_context *ehc = &link->eh_context;
1925 const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context); 1925 const unsigned long *timing = sata_ehc_deb_timing(ehc);
1926 bool online;
1926 int rc; 1927 int rc;
1927 1928
1928 DPRINTK("ENTER\n"); 1929 rc = sata_link_hardreset(link, timing, deadline, &online,
1929 1930 ata_sff_check_ready);
1930 /* do hardreset */ 1931 *class = ATA_DEV_NONE;
1931 rc = sata_link_hardreset(link, timing, deadline); 1932 if (online)
1932 if (rc) { 1933 *class = ata_sff_dev_classify(link->device, 1, NULL);
1933 ata_link_printk(link, KERN_ERR,
1934 "COMRESET failed (errno=%d)\n", rc);
1935 return rc;
1936 }
1937
1938 /* TODO: phy layer with polling, timeouts, etc. */
1939 if (ata_link_offline(link)) {
1940 *class = ATA_DEV_NONE;
1941 DPRINTK("EXIT, link offline\n");
1942 return 0;
1943 }
1944
1945 /* If PMP is supported, we have to do follow-up SRST. Note
1946 * that some PMPs don't send D2H Reg FIS after hardreset at
1947 * all if the first port is empty. Wait for it just for a
1948 * second and request follow-up SRST.
1949 */
1950 if (ap->flags & ATA_FLAG_PMP) {
1951 ata_sff_wait_after_reset(link, 1, jiffies + HZ);
1952 return -EAGAIN;
1953 }
1954
1955 /* wait for the link to become online */
1956 rc = ata_sff_wait_after_reset(link, 1, deadline);
1957 /* link occupied, -ENODEV too is an error */
1958 if (rc) {
1959 ata_link_printk(link, KERN_ERR,
1960 "COMRESET failed (errno=%d)\n", rc);
1961 return rc;
1962 }
1963
1964 *class = ata_sff_dev_classify(link->device, 1, NULL);
1965 1934
1966 DPRINTK("EXIT, class=%u\n", *class); 1935 DPRINTK("EXIT, class=%u\n", *class);
1967 return 0; 1936 return rc;
1968} 1937}
1969 1938
1970/** 1939/**