aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-08-06 05:36:23 -0400
committerJeff Garzik <jeff@garzik.org>2007-10-12 14:55:31 -0400
commit0260731f0187840e272bfa10d3ba0f3e417976f5 (patch)
treed39219275e89ce782f3151b5ac47726957a81e24 /drivers
parentcc0680a580b5be81a1ca321b58f8e9b80b5c1052 (diff)
libata-link: linkify config/EH related functions
Make the following functions deal with ata_link instead of ata_port. * ata_set_mode() * ata_eh_autopsy() and related functions * ata_eh_report() and related functions * suspend/resume related functions * ata_eh_recover() and related functions Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/ata_generic.c7
-rw-r--r--drivers/ata/libata-core.c18
-rw-r--r--drivers/ata/libata-eh.c121
-rw-r--r--drivers/ata/libata.h2
-rw-r--r--drivers/ata/pata_it821x.c6
-rw-r--r--drivers/ata/pata_ixp4xx_cf.c4
-rw-r--r--drivers/ata/pata_legacy.c6
-rw-r--r--drivers/ata/pata_optidma.c11
-rw-r--r--drivers/ata/pata_pcmcia.c12
-rw-r--r--drivers/ata/pata_pdc2027x.c11
-rw-r--r--drivers/ata/pata_platform.c4
-rw-r--r--drivers/ata/pata_rz1000.c6
-rw-r--r--drivers/ata/pdc_adma.c5
-rw-r--r--drivers/ata/sata_sil.c16
14 files changed, 120 insertions, 109 deletions
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
index 44328a16075c..e390ad47c8ef 100644
--- a/drivers/ata/ata_generic.c
+++ b/drivers/ata/ata_generic.c
@@ -34,7 +34,7 @@
34 34
35/** 35/**
36 * generic_set_mode - mode setting 36 * generic_set_mode - mode setting
37 * @ap: interface to set up 37 * @link: link to set up
38 * @unused: returned device on error 38 * @unused: returned device on error
39 * 39 *
40 * Use a non standard set_mode function. We don't want to be tuned. 40 * Use a non standard set_mode function. We don't want to be tuned.
@@ -43,8 +43,9 @@
43 * and respect them. 43 * and respect them.
44 */ 44 */
45 45
46static int generic_set_mode(struct ata_port *ap, struct ata_device **unused) 46static int generic_set_mode(struct ata_link *link, struct ata_device **unused)
47{ 47{
48 struct ata_port *ap = link->ap;
48 int dma_enabled = 0; 49 int dma_enabled = 0;
49 struct ata_device *dev; 50 struct ata_device *dev;
50 51
@@ -52,7 +53,7 @@ static int generic_set_mode(struct ata_port *ap, struct ata_device **unused)
52 if (ap->ioaddr.bmdma_addr) 53 if (ap->ioaddr.bmdma_addr)
53 dma_enabled = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); 54 dma_enabled = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
54 55
55 ata_link_for_each_dev(dev, &ap->link) { 56 ata_link_for_each_dev(dev, link) {
56 if (ata_dev_enabled(dev)) { 57 if (ata_dev_enabled(dev)) {
57 /* We don't really care */ 58 /* We don't really care */
58 dev->pio_mode = XFER_PIO_0; 59 dev->pio_mode = XFER_PIO_0;
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 73f66f4e1eeb..944f54457c8f 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2171,7 +2171,7 @@ int ata_bus_probe(struct ata_port *ap)
2171 } 2171 }
2172 2172
2173 /* configure transfer mode */ 2173 /* configure transfer mode */
2174 rc = ata_set_mode(ap, &dev); 2174 rc = ata_set_mode(&ap->link, &dev);
2175 if (rc) 2175 if (rc)
2176 goto fail; 2176 goto fail;
2177 2177
@@ -2782,7 +2782,7 @@ static int ata_dev_set_mode(struct ata_device *dev)
2782 2782
2783/** 2783/**
2784 * ata_do_set_mode - Program timings and issue SET FEATURES - XFER 2784 * ata_do_set_mode - Program timings and issue SET FEATURES - XFER
2785 * @ap: port on which timings will be programmed 2785 * @link: link on which timings will be programmed
2786 * @r_failed_dev: out paramter for failed device 2786 * @r_failed_dev: out paramter for failed device
2787 * 2787 *
2788 * Standard implementation of the function used to tune and set 2788 * Standard implementation of the function used to tune and set
@@ -2797,9 +2797,9 @@ static int ata_dev_set_mode(struct ata_device *dev)
2797 * 0 on success, negative errno otherwise 2797 * 0 on success, negative errno otherwise
2798 */ 2798 */
2799 2799
2800int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) 2800int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
2801{ 2801{
2802 struct ata_link *link = &ap->link; 2802 struct ata_port *ap = link->ap;
2803 struct ata_device *dev; 2803 struct ata_device *dev;
2804 int rc = 0, used_dma = 0, found = 0; 2804 int rc = 0, used_dma = 0, found = 0;
2805 2805
@@ -2877,7 +2877,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
2877 2877
2878/** 2878/**
2879 * ata_set_mode - Program timings and issue SET FEATURES - XFER 2879 * ata_set_mode - Program timings and issue SET FEATURES - XFER
2880 * @ap: port on which timings will be programmed 2880 * @link: link on which timings will be programmed
2881 * @r_failed_dev: out paramter for failed device 2881 * @r_failed_dev: out paramter for failed device
2882 * 2882 *
2883 * Set ATA device disk transfer mode (PIO3, UDMA6, etc.). If 2883 * Set ATA device disk transfer mode (PIO3, UDMA6, etc.). If
@@ -2890,12 +2890,14 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
2890 * RETURNS: 2890 * RETURNS:
2891 * 0 on success, negative errno otherwise 2891 * 0 on success, negative errno otherwise
2892 */ 2892 */
2893int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) 2893int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
2894{ 2894{
2895 struct ata_port *ap = link->ap;
2896
2895 /* has private set_mode? */ 2897 /* has private set_mode? */
2896 if (ap->ops->set_mode) 2898 if (ap->ops->set_mode)
2897 return ap->ops->set_mode(ap, r_failed_dev); 2899 return ap->ops->set_mode(link, r_failed_dev);
2898 return ata_do_set_mode(ap, r_failed_dev); 2900 return ata_do_set_mode(link, r_failed_dev);
2899} 2901}
2900 2902
2901/** 2903/**
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 0a9ce34a0e64..733aa761f3ee 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -1201,7 +1201,7 @@ static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc)
1201 1201
1202/** 1202/**
1203 * ata_eh_analyze_serror - analyze SError for a failed port 1203 * ata_eh_analyze_serror - analyze SError for a failed port
1204 * @ap: ATA port to analyze SError for 1204 * @link: ATA link to analyze SError for
1205 * 1205 *
1206 * Analyze SError if available and further determine cause of 1206 * Analyze SError if available and further determine cause of
1207 * failure. 1207 * failure.
@@ -1209,9 +1209,9 @@ static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc)
1209 * LOCKING: 1209 * LOCKING:
1210 * None. 1210 * None.
1211 */ 1211 */
1212static void ata_eh_analyze_serror(struct ata_port *ap) 1212static void ata_eh_analyze_serror(struct ata_link *link)
1213{ 1213{
1214 struct ata_eh_context *ehc = &ap->link.eh_context; 1214 struct ata_eh_context *ehc = &link->eh_context;
1215 u32 serror = ehc->i.serror; 1215 u32 serror = ehc->i.serror;
1216 unsigned int err_mask = 0, action = 0; 1216 unsigned int err_mask = 0, action = 0;
1217 1217
@@ -1241,7 +1241,7 @@ static void ata_eh_analyze_serror(struct ata_port *ap)
1241 1241
1242/** 1242/**
1243 * ata_eh_analyze_ncq_error - analyze NCQ error 1243 * ata_eh_analyze_ncq_error - analyze NCQ error
1244 * @ap: ATA port to analyze NCQ error for 1244 * @link: ATA link to analyze NCQ error for
1245 * 1245 *
1246 * Read log page 10h, determine the offending qc and acquire 1246 * Read log page 10h, determine the offending qc and acquire
1247 * error status TF. For NCQ device errors, all LLDDs have to do 1247 * error status TF. For NCQ device errors, all LLDDs have to do
@@ -1251,10 +1251,11 @@ static void ata_eh_analyze_serror(struct ata_port *ap)
1251 * LOCKING: 1251 * LOCKING:
1252 * Kernel thread context (may sleep). 1252 * Kernel thread context (may sleep).
1253 */ 1253 */
1254static void ata_eh_analyze_ncq_error(struct ata_port *ap) 1254static void ata_eh_analyze_ncq_error(struct ata_link *link)
1255{ 1255{
1256 struct ata_eh_context *ehc = &ap->link.eh_context; 1256 struct ata_port *ap = link->ap;
1257 struct ata_device *dev = ap->link.device; 1257 struct ata_eh_context *ehc = &link->eh_context;
1258 struct ata_device *dev = link->device;
1258 struct ata_queued_cmd *qc; 1259 struct ata_queued_cmd *qc;
1259 struct ata_taskfile tf; 1260 struct ata_taskfile tf;
1260 int tag, rc; 1261 int tag, rc;
@@ -1264,7 +1265,7 @@ static void ata_eh_analyze_ncq_error(struct ata_port *ap)
1264 return; 1265 return;
1265 1266
1266 /* is it NCQ device error? */ 1267 /* is it NCQ device error? */
1267 if (!ap->link.sactive || !(ehc->i.err_mask & AC_ERR_DEV)) 1268 if (!link->sactive || !(ehc->i.err_mask & AC_ERR_DEV))
1268 return; 1269 return;
1269 1270
1270 /* has LLDD analyzed already? */ 1271 /* has LLDD analyzed already? */
@@ -1281,13 +1282,13 @@ static void ata_eh_analyze_ncq_error(struct ata_port *ap)
1281 /* okay, this error is ours */ 1282 /* okay, this error is ours */
1282 rc = ata_eh_read_log_10h(dev, &tag, &tf); 1283 rc = ata_eh_read_log_10h(dev, &tag, &tf);
1283 if (rc) { 1284 if (rc) {
1284 ata_port_printk(ap, KERN_ERR, "failed to read log page 10h " 1285 ata_link_printk(link, KERN_ERR, "failed to read log page 10h "
1285 "(errno=%d)\n", rc); 1286 "(errno=%d)\n", rc);
1286 return; 1287 return;
1287 } 1288 }
1288 1289
1289 if (!(ap->link.sactive & (1 << tag))) { 1290 if (!(link->sactive & (1 << tag))) {
1290 ata_port_printk(ap, KERN_ERR, "log page 10h reported " 1291 ata_link_printk(link, KERN_ERR, "log page 10h reported "
1291 "inactive tag %d\n", tag); 1292 "inactive tag %d\n", tag);
1292 return; 1293 return;
1293 } 1294 }
@@ -1551,18 +1552,18 @@ static unsigned int ata_eh_speed_down(struct ata_device *dev, int is_io,
1551 1552
1552/** 1553/**
1553 * ata_eh_autopsy - analyze error and determine recovery action 1554 * ata_eh_autopsy - analyze error and determine recovery action
1554 * @ap: ATA port to perform autopsy on 1555 * @link: ATA link to perform autopsy on
1555 * 1556 *
1556 * Analyze why @ap failed and determine which recovery action is 1557 * Analyze why @link failed and determine which recovery actions
1557 * needed. This function also sets more detailed AC_ERR_* values 1558 * are needed. This function also sets more detailed AC_ERR_*
1558 * and fills sense data for ATAPI CHECK SENSE. 1559 * values and fills sense data for ATAPI CHECK SENSE.
1559 * 1560 *
1560 * LOCKING: 1561 * LOCKING:
1561 * Kernel thread context (may sleep). 1562 * Kernel thread context (may sleep).
1562 */ 1563 */
1563static void ata_eh_autopsy(struct ata_port *ap) 1564static void ata_eh_autopsy(struct ata_link *link)
1564{ 1565{
1565 struct ata_link *link = &ap->link; 1566 struct ata_port *ap = link->ap;
1566 struct ata_eh_context *ehc = &link->eh_context; 1567 struct ata_eh_context *ehc = &link->eh_context;
1567 unsigned int all_err_mask = 0; 1568 unsigned int all_err_mask = 0;
1568 int tag, is_io = 0; 1569 int tag, is_io = 0;
@@ -1578,7 +1579,7 @@ static void ata_eh_autopsy(struct ata_port *ap)
1578 rc = sata_scr_read(link, SCR_ERROR, &serror); 1579 rc = sata_scr_read(link, SCR_ERROR, &serror);
1579 if (rc == 0) { 1580 if (rc == 0) {
1580 ehc->i.serror |= serror; 1581 ehc->i.serror |= serror;
1581 ata_eh_analyze_serror(ap); 1582 ata_eh_analyze_serror(link);
1582 } else if (rc != -EOPNOTSUPP) { 1583 } else if (rc != -EOPNOTSUPP) {
1583 /* SError read failed, force hardreset and probing */ 1584 /* SError read failed, force hardreset and probing */
1584 ata_ehi_schedule_probe(&ehc->i); 1585 ata_ehi_schedule_probe(&ehc->i);
@@ -1587,7 +1588,7 @@ static void ata_eh_autopsy(struct ata_port *ap)
1587 } 1588 }
1588 1589
1589 /* analyze NCQ failure */ 1590 /* analyze NCQ failure */
1590 ata_eh_analyze_ncq_error(ap); 1591 ata_eh_analyze_ncq_error(link);
1591 1592
1592 /* any real error trumps AC_ERR_OTHER */ 1593 /* any real error trumps AC_ERR_OTHER */
1593 if (ehc->i.err_mask & ~AC_ERR_OTHER) 1594 if (ehc->i.err_mask & ~AC_ERR_OTHER)
@@ -1598,7 +1599,7 @@ static void ata_eh_autopsy(struct ata_port *ap)
1598 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { 1599 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) {
1599 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); 1600 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
1600 1601
1601 if (!(qc->flags & ATA_QCFLAG_FAILED)) 1602 if (!(qc->flags & ATA_QCFLAG_FAILED) || qc->dev->link != link)
1602 continue; 1603 continue;
1603 1604
1604 /* inherit upper level err_mask */ 1605 /* inherit upper level err_mask */
@@ -1653,16 +1654,17 @@ static void ata_eh_autopsy(struct ata_port *ap)
1653 1654
1654/** 1655/**
1655 * ata_eh_report - report error handling to user 1656 * ata_eh_report - report error handling to user
1656 * @ap: ATA port EH is going on 1657 * @link: ATA link EH is going on
1657 * 1658 *
1658 * Report EH to user. 1659 * Report EH to user.
1659 * 1660 *
1660 * LOCKING: 1661 * LOCKING:
1661 * None. 1662 * None.
1662 */ 1663 */
1663static void ata_eh_report(struct ata_port *ap) 1664static void ata_eh_report(struct ata_link *link)
1664{ 1665{
1665 struct ata_eh_context *ehc = &ap->link.eh_context; 1666 struct ata_port *ap = link->ap;
1667 struct ata_eh_context *ehc = &link->eh_context;
1666 const char *frozen, *desc; 1668 const char *frozen, *desc;
1667 int tag, nr_failed = 0; 1669 int tag, nr_failed = 0;
1668 1670
@@ -1673,7 +1675,7 @@ static void ata_eh_report(struct ata_port *ap)
1673 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { 1675 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) {
1674 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); 1676 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
1675 1677
1676 if (!(qc->flags & ATA_QCFLAG_FAILED)) 1678 if (!(qc->flags & ATA_QCFLAG_FAILED) || qc->dev->link != link)
1677 continue; 1679 continue;
1678 if (qc->flags & ATA_QCFLAG_SENSE_VALID && !qc->err_mask) 1680 if (qc->flags & ATA_QCFLAG_SENSE_VALID && !qc->err_mask)
1679 continue; 1681 continue;
@@ -1691,17 +1693,17 @@ static void ata_eh_report(struct ata_port *ap)
1691 if (ehc->i.dev) { 1693 if (ehc->i.dev) {
1692 ata_dev_printk(ehc->i.dev, KERN_ERR, "exception Emask 0x%x " 1694 ata_dev_printk(ehc->i.dev, KERN_ERR, "exception Emask 0x%x "
1693 "SAct 0x%x SErr 0x%x action 0x%x%s\n", 1695 "SAct 0x%x SErr 0x%x action 0x%x%s\n",
1694 ehc->i.err_mask, ap->link.sactive, 1696 ehc->i.err_mask, link->sactive,
1695 ehc->i.serror, ehc->i.action, frozen); 1697 ehc->i.serror, ehc->i.action, frozen);
1696 if (desc) 1698 if (desc)
1697 ata_dev_printk(ehc->i.dev, KERN_ERR, "%s\n", desc); 1699 ata_dev_printk(ehc->i.dev, KERN_ERR, "%s\n", desc);
1698 } else { 1700 } else {
1699 ata_port_printk(ap, KERN_ERR, "exception Emask 0x%x " 1701 ata_link_printk(link, KERN_ERR, "exception Emask 0x%x "
1700 "SAct 0x%x SErr 0x%x action 0x%x%s\n", 1702 "SAct 0x%x SErr 0x%x action 0x%x%s\n",
1701 ehc->i.err_mask, ap->link.sactive, 1703 ehc->i.err_mask, link->sactive,
1702 ehc->i.serror, ehc->i.action, frozen); 1704 ehc->i.serror, ehc->i.action, frozen);
1703 if (desc) 1705 if (desc)
1704 ata_port_printk(ap, KERN_ERR, "%s\n", desc); 1706 ata_link_printk(link, KERN_ERR, "%s\n", desc);
1705 } 1707 }
1706 1708
1707 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { 1709 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) {
@@ -1714,7 +1716,8 @@ static void ata_eh_report(struct ata_port *ap)
1714 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); 1716 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
1715 struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf; 1717 struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf;
1716 1718
1717 if (!(qc->flags & ATA_QCFLAG_FAILED) || !qc->err_mask) 1719 if (!(qc->flags & ATA_QCFLAG_FAILED) ||
1720 qc->dev->link != link || !qc->err_mask)
1718 continue; 1721 continue;
1719 1722
1720 ata_dev_printk(qc->dev, KERN_ERR, 1723 ata_dev_printk(qc->dev, KERN_ERR,
@@ -1936,10 +1939,11 @@ static int ata_eh_reset(struct ata_link *link, int classify,
1936 return rc; 1939 return rc;
1937} 1940}
1938 1941
1939static int ata_eh_revalidate_and_attach(struct ata_port *ap, 1942static int ata_eh_revalidate_and_attach(struct ata_link *link,
1940 struct ata_device **r_failed_dev) 1943 struct ata_device **r_failed_dev)
1941{ 1944{
1942 struct ata_eh_context *ehc = &ap->link.eh_context; 1945 struct ata_port *ap = link->ap;
1946 struct ata_eh_context *ehc = &link->eh_context;
1943 struct ata_device *dev; 1947 struct ata_device *dev;
1944 unsigned int new_mask = 0; 1948 unsigned int new_mask = 0;
1945 unsigned long flags; 1949 unsigned long flags;
@@ -1951,7 +1955,7 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
1951 * be done backwards such that PDIAG- is released by the slave 1955 * be done backwards such that PDIAG- is released by the slave
1952 * device before the master device is identified. 1956 * device before the master device is identified.
1953 */ 1957 */
1954 ata_link_for_each_dev_reverse(dev, &ap->link) { 1958 ata_link_for_each_dev_reverse(dev, link) {
1955 unsigned int action = ata_eh_dev_action(dev); 1959 unsigned int action = ata_eh_dev_action(dev);
1956 unsigned int readid_flags = 0; 1960 unsigned int readid_flags = 0;
1957 1961
@@ -1959,17 +1963,17 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
1959 readid_flags |= ATA_READID_POSTRESET; 1963 readid_flags |= ATA_READID_POSTRESET;
1960 1964
1961 if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) { 1965 if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) {
1962 if (ata_link_offline(&ap->link)) { 1966 if (ata_link_offline(link)) {
1963 rc = -EIO; 1967 rc = -EIO;
1964 goto err; 1968 goto err;
1965 } 1969 }
1966 1970
1967 ata_eh_about_to_do(&ap->link, dev, ATA_EH_REVALIDATE); 1971 ata_eh_about_to_do(link, dev, ATA_EH_REVALIDATE);
1968 rc = ata_dev_revalidate(dev, readid_flags); 1972 rc = ata_dev_revalidate(dev, readid_flags);
1969 if (rc) 1973 if (rc)
1970 goto err; 1974 goto err;
1971 1975
1972 ata_eh_done(&ap->link, dev, ATA_EH_REVALIDATE); 1976 ata_eh_done(link, dev, ATA_EH_REVALIDATE);
1973 1977
1974 /* Configuration may have changed, reconfigure 1978 /* Configuration may have changed, reconfigure
1975 * transfer mode. 1979 * transfer mode.
@@ -2011,7 +2015,7 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
2011 /* Configure new devices forward such that user doesn't see 2015 /* Configure new devices forward such that user doesn't see
2012 * device detection messages backwards. 2016 * device detection messages backwards.
2013 */ 2017 */
2014 ata_link_for_each_dev(dev, &ap->link) { 2018 ata_link_for_each_dev(dev, link) {
2015 if (!(new_mask & (1 << dev->devno))) 2019 if (!(new_mask & (1 << dev->devno)))
2016 continue; 2020 continue;
2017 2021
@@ -2037,40 +2041,40 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
2037 return rc; 2041 return rc;
2038} 2042}
2039 2043
2040static int ata_port_nr_enabled(struct ata_port *ap) 2044static int ata_link_nr_enabled(struct ata_link *link)
2041{ 2045{
2042 struct ata_device *dev; 2046 struct ata_device *dev;
2043 int cnt = 0; 2047 int cnt = 0;
2044 2048
2045 ata_link_for_each_dev(dev, &ap->link) 2049 ata_link_for_each_dev(dev, link)
2046 if (ata_dev_enabled(dev)) 2050 if (ata_dev_enabled(dev))
2047 cnt++; 2051 cnt++;
2048 return cnt; 2052 return cnt;
2049} 2053}
2050 2054
2051static int ata_port_nr_vacant(struct ata_port *ap) 2055static int ata_link_nr_vacant(struct ata_link *link)
2052{ 2056{
2053 struct ata_device *dev; 2057 struct ata_device *dev;
2054 int cnt = 0; 2058 int cnt = 0;
2055 2059
2056 ata_link_for_each_dev(dev, &ap->link) 2060 ata_link_for_each_dev(dev, link)
2057 if (dev->class == ATA_DEV_UNKNOWN) 2061 if (dev->class == ATA_DEV_UNKNOWN)
2058 cnt++; 2062 cnt++;
2059 return cnt; 2063 return cnt;
2060} 2064}
2061 2065
2062static int ata_eh_skip_recovery(struct ata_port *ap) 2066static int ata_eh_skip_recovery(struct ata_link *link)
2063{ 2067{
2064 struct ata_eh_context *ehc = &ap->link.eh_context; 2068 struct ata_eh_context *ehc = &link->eh_context;
2065 struct ata_device *dev; 2069 struct ata_device *dev;
2066 2070
2067 /* thaw frozen port, resume link and recover failed devices */ 2071 /* thaw frozen port, resume link and recover failed devices */
2068 if ((ap->pflags & ATA_PFLAG_FROZEN) || 2072 if ((link->ap->pflags & ATA_PFLAG_FROZEN) ||
2069 (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_port_nr_enabled(ap)) 2073 (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_link_nr_enabled(link))
2070 return 0; 2074 return 0;
2071 2075
2072 /* skip if class codes for all vacant slots are ATA_DEV_NONE */ 2076 /* skip if class codes for all vacant slots are ATA_DEV_NONE */
2073 ata_link_for_each_dev(dev, &ap->link) { 2077 ata_link_for_each_dev(dev, link) {
2074 if (dev->class == ATA_DEV_UNKNOWN && 2078 if (dev->class == ATA_DEV_UNKNOWN &&
2075 ehc->classes[dev->devno] != ATA_DEV_NONE) 2079 ehc->classes[dev->devno] != ATA_DEV_NONE)
2076 return 0; 2080 return 0;
@@ -2154,14 +2158,15 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2154 ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 2158 ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
2155 ata_postreset_fn_t postreset) 2159 ata_postreset_fn_t postreset)
2156{ 2160{
2157 struct ata_eh_context *ehc = &ap->link.eh_context; 2161 struct ata_link *link = &ap->link;
2162 struct ata_eh_context *ehc = &link->eh_context;
2158 struct ata_device *dev; 2163 struct ata_device *dev;
2159 int rc; 2164 int rc;
2160 2165
2161 DPRINTK("ENTER\n"); 2166 DPRINTK("ENTER\n");
2162 2167
2163 /* prep for recovery */ 2168 /* prep for recovery */
2164 ata_link_for_each_dev(dev, &ap->link) { 2169 ata_link_for_each_dev(dev, link) {
2165 ehc->tries[dev->devno] = ATA_EH_DEV_TRIES; 2170 ehc->tries[dev->devno] = ATA_EH_DEV_TRIES;
2166 2171
2167 /* collect port action mask recorded in dev actions */ 2172 /* collect port action mask recorded in dev actions */
@@ -2191,20 +2196,20 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2191 goto out; 2196 goto out;
2192 2197
2193 /* skip EH if possible. */ 2198 /* skip EH if possible. */
2194 if (ata_eh_skip_recovery(ap)) 2199 if (ata_eh_skip_recovery(link))
2195 ehc->i.action = 0; 2200 ehc->i.action = 0;
2196 2201
2197 ata_link_for_each_dev(dev, &ap->link) 2202 ata_link_for_each_dev(dev, link)
2198 ehc->classes[dev->devno] = ATA_DEV_UNKNOWN; 2203 ehc->classes[dev->devno] = ATA_DEV_UNKNOWN;
2199 2204
2200 /* reset */ 2205 /* reset */
2201 if (ehc->i.action & ATA_EH_RESET_MASK) { 2206 if (ehc->i.action & ATA_EH_RESET_MASK) {
2202 ata_eh_freeze_port(ap); 2207 ata_eh_freeze_port(ap);
2203 2208
2204 rc = ata_eh_reset(&ap->link, ata_port_nr_vacant(ap), prereset, 2209 rc = ata_eh_reset(link, ata_link_nr_vacant(link), prereset,
2205 softreset, hardreset, postreset); 2210 softreset, hardreset, postreset);
2206 if (rc) { 2211 if (rc) {
2207 ata_port_printk(ap, KERN_ERR, 2212 ata_link_printk(link, KERN_ERR,
2208 "reset failed, giving up\n"); 2213 "reset failed, giving up\n");
2209 goto out; 2214 goto out;
2210 } 2215 }
@@ -2213,13 +2218,13 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2213 } 2218 }
2214 2219
2215 /* revalidate existing devices and attach new ones */ 2220 /* revalidate existing devices and attach new ones */
2216 rc = ata_eh_revalidate_and_attach(ap, &dev); 2221 rc = ata_eh_revalidate_and_attach(link, &dev);
2217 if (rc) 2222 if (rc)
2218 goto dev_fail; 2223 goto dev_fail;
2219 2224
2220 /* configure transfer mode if necessary */ 2225 /* configure transfer mode if necessary */
2221 if (ehc->i.flags & ATA_EHI_SETMODE) { 2226 if (ehc->i.flags & ATA_EHI_SETMODE) {
2222 rc = ata_set_mode(ap, &dev); 2227 rc = ata_set_mode(link, &dev);
2223 if (rc) 2228 if (rc)
2224 goto dev_fail; 2229 goto dev_fail;
2225 ehc->i.flags &= ~ATA_EHI_SETMODE; 2230 ehc->i.flags &= ~ATA_EHI_SETMODE;
@@ -2230,8 +2235,8 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2230 dev_fail: 2235 dev_fail:
2231 ata_eh_handle_dev_fail(dev, rc); 2236 ata_eh_handle_dev_fail(dev, rc);
2232 2237
2233 if (ata_port_nr_enabled(ap)) { 2238 if (ata_link_nr_enabled(link)) {
2234 ata_port_printk(ap, KERN_WARNING, "failed to recover some " 2239 ata_link_printk(link, KERN_WARNING, "failed to recover some "
2235 "devices, retrying in 5 secs\n"); 2240 "devices, retrying in 5 secs\n");
2236 ssleep(5); 2241 ssleep(5);
2237 } else { 2242 } else {
@@ -2243,7 +2248,7 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2243 2248
2244 out: 2249 out:
2245 if (rc) { 2250 if (rc) {
2246 ata_link_for_each_dev(dev, &ap->link); 2251 ata_link_for_each_dev(dev, link);
2247 ata_dev_disable(dev); 2252 ata_dev_disable(dev);
2248 } 2253 }
2249 2254
@@ -2310,8 +2315,8 @@ void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
2310 ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 2315 ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
2311 ata_postreset_fn_t postreset) 2316 ata_postreset_fn_t postreset)
2312{ 2317{
2313 ata_eh_autopsy(ap); 2318 ata_eh_autopsy(&ap->link);
2314 ata_eh_report(ap); 2319 ata_eh_report(&ap->link);
2315 ata_eh_recover(ap, prereset, softreset, hardreset, postreset); 2320 ata_eh_recover(ap, prereset, softreset, hardreset, postreset);
2316 ata_eh_finish(ap); 2321 ata_eh_finish(ap);
2317} 2322}
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 700843a9f30a..6d85edefa7c6 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -81,7 +81,7 @@ extern int ata_dev_configure(struct ata_device *dev);
81extern int sata_down_spd_limit(struct ata_link *link); 81extern int sata_down_spd_limit(struct ata_link *link);
82extern int sata_set_spd_needed(struct ata_link *link); 82extern int sata_set_spd_needed(struct ata_link *link);
83extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel); 83extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel);
84extern int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev); 84extern int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
85extern void ata_sg_clean(struct ata_queued_cmd *qc); 85extern void ata_sg_clean(struct ata_queued_cmd *qc);
86extern void ata_qc_free(struct ata_queued_cmd *qc); 86extern void ata_qc_free(struct ata_queued_cmd *qc);
87extern void ata_qc_issue(struct ata_queued_cmd *qc); 87extern void ata_qc_issue(struct ata_queued_cmd *qc);
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index 088eb1d23761..f32d9b7ab496 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -450,7 +450,7 @@ static unsigned int it821x_passthru_qc_issue_prot(struct ata_queued_cmd *qc)
450 450
451/** 451/**
452 * it821x_smart_set_mode - mode setting 452 * it821x_smart_set_mode - mode setting
453 * @ap: interface to set up 453 * @link: interface to set up
454 * @unused: device that failed (error only) 454 * @unused: device that failed (error only)
455 * 455 *
456 * Use a non standard set_mode function. We don't want to be tuned. 456 * Use a non standard set_mode function. We don't want to be tuned.
@@ -459,11 +459,11 @@ static unsigned int it821x_passthru_qc_issue_prot(struct ata_queued_cmd *qc)
459 * and respect them. 459 * and respect them.
460 */ 460 */
461 461
462static int it821x_smart_set_mode(struct ata_port *ap, struct ata_device **unused) 462static int it821x_smart_set_mode(struct ata_link *link, struct ata_device **unused)
463{ 463{
464 struct ata_device *dev; 464 struct ata_device *dev;
465 465
466 ata_link_for_each_dev(dev, &ap->link) { 466 ata_link_for_each_dev(dev, link) {
467 if (ata_dev_enabled(dev)) { 467 if (ata_dev_enabled(dev)) {
468 /* We don't really care */ 468 /* We don't really care */
469 dev->pio_mode = XFER_PIO_0; 469 dev->pio_mode = XFER_PIO_0;
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
index 7db315a9baad..6bf1709508ab 100644
--- a/drivers/ata/pata_ixp4xx_cf.c
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -26,11 +26,11 @@
26#define DRV_NAME "pata_ixp4xx_cf" 26#define DRV_NAME "pata_ixp4xx_cf"
27#define DRV_VERSION "0.2" 27#define DRV_VERSION "0.2"
28 28
29static int ixp4xx_set_mode(struct ata_port *ap, struct ata_device **error) 29static int ixp4xx_set_mode(struct ata_link *link, struct ata_device **error)
30{ 30{
31 struct ata_device *dev; 31 struct ata_device *dev;
32 32
33 ata_link_for_each_dev(dev, &ap->link) { 33 ata_link_for_each_dev(dev, link) {
34 if (ata_dev_enabled(dev)) { 34 if (ata_dev_enabled(dev)) {
35 ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n"); 35 ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n");
36 dev->pio_mode = XFER_PIO_0; 36 dev->pio_mode = XFER_PIO_0;
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c
index 9d92843b033d..cfb2bc86a1d1 100644
--- a/drivers/ata/pata_legacy.c
+++ b/drivers/ata/pata_legacy.c
@@ -96,7 +96,7 @@ static int iordy_mask = 0xFFFFFFFF; /* Use iordy if available */
96 96
97/** 97/**
98 * legacy_set_mode - mode setting 98 * legacy_set_mode - mode setting
99 * @ap: IDE interface 99 * @link: IDE link
100 * @unused: Device that failed when error is returned 100 * @unused: Device that failed when error is returned
101 * 101 *
102 * Use a non standard set_mode function. We don't want to be tuned. 102 * Use a non standard set_mode function. We don't want to be tuned.
@@ -107,11 +107,11 @@ static int iordy_mask = 0xFFFFFFFF; /* Use iordy if available */
107 * expand on this as per hdparm in the base kernel. 107 * expand on this as per hdparm in the base kernel.
108 */ 108 */
109 109
110static int legacy_set_mode(struct ata_port *ap, struct ata_device **unused) 110static int legacy_set_mode(struct ata_link *link, struct ata_device **unused)
111{ 111{
112 struct ata_device *dev; 112 struct ata_device *dev;
113 113
114 ata_link_for_each_dev(dev, &ap->link) { 114 ata_link_for_each_dev(dev, link) {
115 if (ata_dev_enabled(dev)) { 115 if (ata_dev_enabled(dev)) {
116 ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); 116 ata_dev_printk(dev, KERN_INFO, "configured for PIO\n");
117 dev->pio_mode = XFER_PIO_0; 117 dev->pio_mode = XFER_PIO_0;
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c
index 39fcba800077..09ef725afd90 100644
--- a/drivers/ata/pata_optidma.c
+++ b/drivers/ata/pata_optidma.c
@@ -324,25 +324,26 @@ static u8 optidma_make_bits43(struct ata_device *adev)
324 324
325/** 325/**
326 * optidma_set_mode - mode setup 326 * optidma_set_mode - mode setup
327 * @ap: port to set up 327 * @link: link to set up
328 * 328 *
329 * Use the standard setup to tune the chipset and then finalise the 329 * Use the standard setup to tune the chipset and then finalise the
330 * configuration by writing the nibble of extra bits of data into 330 * configuration by writing the nibble of extra bits of data into
331 * the chip. 331 * the chip.
332 */ 332 */
333 333
334static int optidma_set_mode(struct ata_port *ap, struct ata_device **r_failed) 334static int optidma_set_mode(struct ata_link *link, struct ata_device **r_failed)
335{ 335{
336 struct ata_port *ap = link->ap;
336 u8 r; 337 u8 r;
337 int nybble = 4 * ap->port_no; 338 int nybble = 4 * ap->port_no;
338 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 339 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
339 int rc = ata_do_set_mode(ap, r_failed); 340 int rc = ata_do_set_mode(link, r_failed);
340 if (rc == 0) { 341 if (rc == 0) {
341 pci_read_config_byte(pdev, 0x43, &r); 342 pci_read_config_byte(pdev, 0x43, &r);
342 343
343 r &= (0x0F << nybble); 344 r &= (0x0F << nybble);
344 r |= (optidma_make_bits43(&ap->link.device[0]) + 345 r |= (optidma_make_bits43(&link->device[0]) +
345 (optidma_make_bits43(&ap->link.device[0]) << 2)) << nybble; 346 (optidma_make_bits43(&link->device[0]) << 2)) << nybble;
346 pci_write_config_byte(pdev, 0x43, r); 347 pci_write_config_byte(pdev, 0x43, r);
347 } 348 }
348 return rc; 349 return rc;
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index 890f649ddcce..9bfe12ac851a 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -56,7 +56,7 @@ struct ata_pcmcia_info {
56 56
57/** 57/**
58 * pcmcia_set_mode - PCMCIA specific mode setup 58 * pcmcia_set_mode - PCMCIA specific mode setup
59 * @ap: Port 59 * @link: link
60 * @r_failed_dev: Return pointer for failed device 60 * @r_failed_dev: Return pointer for failed device
61 * 61 *
62 * Perform the tuning and setup of the devices and timings, which 62 * Perform the tuning and setup of the devices and timings, which
@@ -65,13 +65,13 @@ struct ata_pcmcia_info {
65 * decode, which alas is embarrassingly common in the PC world 65 * decode, which alas is embarrassingly common in the PC world
66 */ 66 */
67 67
68static int pcmcia_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) 68static int pcmcia_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
69{ 69{
70 struct ata_device *master = &ap->link.device[0]; 70 struct ata_device *master = &link->device[0];
71 struct ata_device *slave = &ap->link.device[1]; 71 struct ata_device *slave = &link->device[1];
72 72
73 if (!ata_dev_enabled(master) || !ata_dev_enabled(slave)) 73 if (!ata_dev_enabled(master) || !ata_dev_enabled(slave))
74 return ata_do_set_mode(ap, r_failed_dev); 74 return ata_do_set_mode(link, r_failed_dev);
75 75
76 if (memcmp(master->id + ATA_ID_FW_REV, slave->id + ATA_ID_FW_REV, 76 if (memcmp(master->id + ATA_ID_FW_REV, slave->id + ATA_ID_FW_REV,
77 ATA_ID_FW_REV_LEN + ATA_ID_PROD_LEN) == 0) 77 ATA_ID_FW_REV_LEN + ATA_ID_PROD_LEN) == 0)
@@ -84,7 +84,7 @@ static int pcmcia_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev
84 ata_dev_disable(slave); 84 ata_dev_disable(slave);
85 } 85 }
86 } 86 }
87 return ata_do_set_mode(ap, r_failed_dev); 87 return ata_do_set_mode(link, r_failed_dev);
88} 88}
89 89
90static struct scsi_host_template pcmcia_sht = { 90static struct scsi_host_template pcmcia_sht = {
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index ba39efbe5405..db069d7515bc 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -69,7 +69,7 @@ static void pdc2027x_set_dmamode(struct ata_port *ap, struct ata_device *adev);
69static int pdc2027x_check_atapi_dma(struct ata_queued_cmd *qc); 69static int pdc2027x_check_atapi_dma(struct ata_queued_cmd *qc);
70static unsigned long pdc2027x_mode_filter(struct ata_device *adev, unsigned long mask); 70static unsigned long pdc2027x_mode_filter(struct ata_device *adev, unsigned long mask);
71static int pdc2027x_cable_detect(struct ata_port *ap); 71static int pdc2027x_cable_detect(struct ata_port *ap);
72static int pdc2027x_set_mode(struct ata_port *ap, struct ata_device **r_failed); 72static int pdc2027x_set_mode(struct ata_link *link, struct ata_device **r_failed);
73 73
74/* 74/*
75 * ATA Timing Tables based on 133MHz controller clock. 75 * ATA Timing Tables based on 133MHz controller clock.
@@ -470,23 +470,24 @@ static void pdc2027x_set_dmamode(struct ata_port *ap, struct ata_device *adev)
470 470
471/** 471/**
472 * pdc2027x_set_mode - Set the timing registers back to correct values. 472 * pdc2027x_set_mode - Set the timing registers back to correct values.
473 * @ap: Port to configure 473 * @link: link to configure
474 * @r_failed: Returned device for failure 474 * @r_failed: Returned device for failure
475 * 475 *
476 * The pdc2027x hardware will look at "SET FEATURES" and change the timing registers 476 * The pdc2027x hardware will look at "SET FEATURES" and change the timing registers
477 * automatically. The values set by the hardware might be incorrect, under 133Mhz PLL. 477 * automatically. The values set by the hardware might be incorrect, under 133Mhz PLL.
478 * This function overwrites the possibly incorrect values set by the hardware to be correct. 478 * This function overwrites the possibly incorrect values set by the hardware to be correct.
479 */ 479 */
480static int pdc2027x_set_mode(struct ata_port *ap, struct ata_device **r_failed) 480static int pdc2027x_set_mode(struct ata_link *link, struct ata_device **r_failed)
481{ 481{
482 struct ata_port *ap = link->ap;
482 struct ata_device *dev; 483 struct ata_device *dev;
483 int rc; 484 int rc;
484 485
485 rc = ata_do_set_mode(ap, r_failed); 486 rc = ata_do_set_mode(link, r_failed);
486 if (rc < 0) 487 if (rc < 0)
487 return rc; 488 return rc;
488 489
489 ata_link_for_each_dev(dev, &ap->link) { 490 ata_link_for_each_dev(dev, link) {
490 if (ata_dev_enabled(dev)) { 491 if (ata_dev_enabled(dev)) {
491 492
492 pdc2027x_set_piomode(ap, dev); 493 pdc2027x_set_piomode(ap, dev);
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
index ee1605bfc29f..37e5158391da 100644
--- a/drivers/ata/pata_platform.c
+++ b/drivers/ata/pata_platform.c
@@ -30,11 +30,11 @@ static int pio_mask = 1;
30 * Provide our own set_mode() as we don't want to change anything that has 30 * Provide our own set_mode() as we don't want to change anything that has
31 * already been configured.. 31 * already been configured..
32 */ 32 */
33static int pata_platform_set_mode(struct ata_port *ap, struct ata_device **unused) 33static int pata_platform_set_mode(struct ata_link *link, struct ata_device **unused)
34{ 34{
35 struct ata_device *dev; 35 struct ata_device *dev;
36 36
37 ata_link_for_each_dev(dev, &ap->link) { 37 ata_link_for_each_dev(dev, link) {
38 if (ata_dev_enabled(dev)) { 38 if (ata_dev_enabled(dev)) {
39 /* We don't really care */ 39 /* We don't really care */
40 dev->pio_mode = dev->xfer_mode = XFER_PIO_0; 40 dev->pio_mode = dev->xfer_mode = XFER_PIO_0;
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c
index 300b3d5de81e..de3698cf3b8c 100644
--- a/drivers/ata/pata_rz1000.c
+++ b/drivers/ata/pata_rz1000.c
@@ -26,7 +26,7 @@
26 26
27/** 27/**
28 * rz1000_set_mode - mode setting function 28 * rz1000_set_mode - mode setting function
29 * @ap: ATA interface 29 * @link: ATA link
30 * @unused: returned device on set_mode failure 30 * @unused: returned device on set_mode failure
31 * 31 *
32 * Use a non standard set_mode function. We don't want to be tuned. We 32 * Use a non standard set_mode function. We don't want to be tuned. We
@@ -34,11 +34,11 @@
34 * whacked out. 34 * whacked out.
35 */ 35 */
36 36
37static int rz1000_set_mode(struct ata_port *ap, struct ata_device **unused) 37static int rz1000_set_mode(struct ata_link *link, struct ata_device **unused)
38{ 38{
39 struct ata_device *dev; 39 struct ata_device *dev;
40 40
41 ata_link_for_each_dev(dev, &ap->link) { 41 ata_link_for_each_dev(dev, link) {
42 if (ata_dev_enabled(dev)) { 42 if (ata_dev_enabled(dev)) {
43 /* We don't really care */ 43 /* We don't really care */
44 dev->pio_mode = XFER_PIO_0; 44 dev->pio_mode = XFER_PIO_0;
diff --git a/drivers/ata/pdc_adma.c b/drivers/ata/pdc_adma.c
index 064a3b505609..304c19b9b0f2 100644
--- a/drivers/ata/pdc_adma.c
+++ b/drivers/ata/pdc_adma.c
@@ -297,15 +297,16 @@ static void adma_thaw(struct ata_port *ap)
297 adma_reinit_engine(ap); 297 adma_reinit_engine(ap);
298} 298}
299 299
300static int adma_prereset(struct ata_port *ap, unsigned long deadline) 300static int adma_prereset(struct ata_link *link, unsigned long deadline)
301{ 301{
302 struct ata_port *ap = link->ap;
302 struct adma_port_priv *pp = ap->private_data; 303 struct adma_port_priv *pp = ap->private_data;
303 304
304 if (pp->state != adma_state_idle) /* healthy paranoia */ 305 if (pp->state != adma_state_idle) /* healthy paranoia */
305 pp->state = adma_state_mmio; 306 pp->state = adma_state_mmio;
306 adma_reinit_engine(ap); 307 adma_reinit_engine(ap);
307 308
308 return ata_std_prereset(ap, deadline); 309 return ata_std_prereset(link, deadline);
309} 310}
310 311
311static void adma_error_handler(struct ata_port *ap) 312static void adma_error_handler(struct ata_port *ap)
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index 4c9295a49a49..5cd3eb83e4ad 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -117,7 +117,7 @@ static int sil_pci_device_resume(struct pci_dev *pdev);
117static void sil_dev_config(struct ata_device *dev); 117static void sil_dev_config(struct ata_device *dev);
118static int sil_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); 118static int sil_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val);
119static int sil_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); 119static int sil_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val);
120static int sil_set_mode (struct ata_port *ap, struct ata_device **r_failed); 120static int sil_set_mode(struct ata_link *link, struct ata_device **r_failed);
121static void sil_freeze(struct ata_port *ap); 121static void sil_freeze(struct ata_port *ap);
122static void sil_thaw(struct ata_port *ap); 122static void sil_thaw(struct ata_port *ap);
123 123
@@ -290,27 +290,27 @@ static unsigned char sil_get_device_cache_line(struct pci_dev *pdev)
290 290
291/** 291/**
292 * sil_set_mode - wrap set_mode functions 292 * sil_set_mode - wrap set_mode functions
293 * @ap: port to set up 293 * @link: link to set up
294 * @r_failed: returned device when we fail 294 * @r_failed: returned device when we fail
295 * 295 *
296 * Wrap the libata method for device setup as after the setup we need 296 * Wrap the libata method for device setup as after the setup we need
297 * to inspect the results and do some configuration work 297 * to inspect the results and do some configuration work
298 */ 298 */
299 299
300static int sil_set_mode (struct ata_port *ap, struct ata_device **r_failed) 300static int sil_set_mode(struct ata_link *link, struct ata_device **r_failed)
301{ 301{
302 struct ata_host *host = ap->host; 302 struct ata_port *ap = link->ap;
303 struct ata_device *dev; 303 void __iomem *mmio_base = ap->host->iomap[SIL_MMIO_BAR];
304 void __iomem *mmio_base = host->iomap[SIL_MMIO_BAR];
305 void __iomem *addr = mmio_base + sil_port[ap->port_no].xfer_mode; 304 void __iomem *addr = mmio_base + sil_port[ap->port_no].xfer_mode;
305 struct ata_device *dev;
306 u32 tmp, dev_mode[2] = { }; 306 u32 tmp, dev_mode[2] = { };
307 int rc; 307 int rc;
308 308
309 rc = ata_do_set_mode(ap, r_failed); 309 rc = ata_do_set_mode(link, r_failed);
310 if (rc) 310 if (rc)
311 return rc; 311 return rc;
312 312
313 ata_link_for_each_dev(dev, &ap->link) { 313 ata_link_for_each_dev(dev, link) {
314 if (!ata_dev_enabled(dev)) 314 if (!ata_dev_enabled(dev))
315 dev_mode[dev->devno] = 0; /* PIO0/1/2 */ 315 dev_mode[dev->devno] = 0; /* PIO0/1/2 */
316 else if (dev->flags & ATA_DFLAG_PIO) 316 else if (dev->flags & ATA_DFLAG_PIO)