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
commitcc0680a580b5be81a1ca321b58f8e9b80b5c1052 (patch)
tree57454cdfdc9890f4e8d9f532e9cd240c7361951f /drivers
parent955e57dfde4ff75e4d7329ac7a3d645b16015309 (diff)
libata-link: linkify reset
Make reset methods and related functions deal with ata_link instead of ata_port. * ata_do_reset() * ata_eh_reset() * all prereset/reset/postreset methods and related functions This patch introduces no behavior change. 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/ahci.c34
-rw-r--r--drivers/ata/ata_piix.c7
-rw-r--r--drivers/ata/libata-core.c49
-rw-r--r--drivers/ata/libata-eh.c35
-rw-r--r--drivers/ata/pata_amd.c16
-rw-r--r--drivers/ata/pata_artop.c12
-rw-r--r--drivers/ata/pata_atiixp.c5
-rw-r--r--drivers/ata/pata_efar.c7
-rw-r--r--drivers/ata/pata_hpt37x.c12
-rw-r--r--drivers/ata/pata_hpt3x2n.c7
-rw-r--r--drivers/ata/pata_it8213.c7
-rw-r--r--drivers/ata/pata_jmicron.c8
-rw-r--r--drivers/ata/pata_marvell.c7
-rw-r--r--drivers/ata/pata_mpiix.c5
-rw-r--r--drivers/ata/pata_ns87410.c7
-rw-r--r--drivers/ata/pata_oldpiix.c7
-rw-r--r--drivers/ata/pata_opti.c7
-rw-r--r--drivers/ata/pata_optidma.c7
-rw-r--r--drivers/ata/pata_pdc2027x.c8
-rw-r--r--drivers/ata/pata_sil680.c7
-rw-r--r--drivers/ata/pata_sis.c7
-rw-r--r--drivers/ata/pata_sl82c105.c7
-rw-r--r--drivers/ata/pata_triflex.c7
-rw-r--r--drivers/ata/pata_via.c5
-rw-r--r--drivers/ata/sata_inic162x.c13
-rw-r--r--drivers/ata/sata_mv.c19
-rw-r--r--drivers/ata/sata_nv.c4
-rw-r--r--drivers/ata/sata_sil24.c26
-rw-r--r--drivers/ata/sata_via.c5
-rw-r--r--drivers/scsi/ipr.c8
30 files changed, 193 insertions, 162 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 6e5f69a3a0c2..e38ae12d0148 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1042,9 +1042,10 @@ static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
1042 return 0; 1042 return 0;
1043} 1043}
1044 1044
1045static int ahci_do_softreset(struct ata_port *ap, unsigned int *class, 1045static int ahci_do_softreset(struct ata_link *link, unsigned int *class,
1046 int pmp, unsigned long deadline) 1046 int pmp, unsigned long deadline)
1047{ 1047{
1048 struct ata_port *ap = link->ap;
1048 const char *reason = NULL; 1049 const char *reason = NULL;
1049 unsigned long now, msecs; 1050 unsigned long now, msecs;
1050 struct ata_taskfile tf; 1051 struct ata_taskfile tf;
@@ -1052,7 +1053,7 @@ static int ahci_do_softreset(struct ata_port *ap, unsigned int *class,
1052 1053
1053 DPRINTK("ENTER\n"); 1054 DPRINTK("ENTER\n");
1054 1055
1055 if (ata_link_offline(&ap->link)) { 1056 if (ata_link_offline(link)) {
1056 DPRINTK("PHY reports no device\n"); 1057 DPRINTK("PHY reports no device\n");
1057 *class = ATA_DEV_NONE; 1058 *class = ATA_DEV_NONE;
1058 return 0; 1059 return 0;
@@ -1061,10 +1062,10 @@ static int ahci_do_softreset(struct ata_port *ap, unsigned int *class,
1061 /* prepare for SRST (AHCI-1.1 10.4.1) */ 1062 /* prepare for SRST (AHCI-1.1 10.4.1) */
1062 rc = ahci_kick_engine(ap, 1); 1063 rc = ahci_kick_engine(ap, 1);
1063 if (rc) 1064 if (rc)
1064 ata_port_printk(ap, KERN_WARNING, 1065 ata_link_printk(link, KERN_WARNING,
1065 "failed to reset engine (errno=%d)", rc); 1066 "failed to reset engine (errno=%d)", rc);
1066 1067
1067 ata_tf_init(ap->link.device, &tf); 1068 ata_tf_init(link->device, &tf);
1068 1069
1069 /* issue the first D2H Register FIS */ 1070 /* issue the first D2H Register FIS */
1070 msecs = 0; 1071 msecs = 0;
@@ -1109,19 +1110,20 @@ static int ahci_do_softreset(struct ata_port *ap, unsigned int *class,
1109 return 0; 1110 return 0;
1110 1111
1111 fail: 1112 fail:
1112 ata_port_printk(ap, KERN_ERR, "softreset failed (%s)\n", reason); 1113 ata_link_printk(link, KERN_ERR, "softreset failed (%s)\n", reason);
1113 return rc; 1114 return rc;
1114} 1115}
1115 1116
1116static int ahci_softreset(struct ata_port *ap, unsigned int *class, 1117static int ahci_softreset(struct ata_link *link, unsigned int *class,
1117 unsigned long deadline) 1118 unsigned long deadline)
1118{ 1119{
1119 return ahci_do_softreset(ap, class, 0, deadline); 1120 return ahci_do_softreset(link, class, 0, deadline);
1120} 1121}
1121 1122
1122static int ahci_hardreset(struct ata_port *ap, unsigned int *class, 1123static int ahci_hardreset(struct ata_link *link, unsigned int *class,
1123 unsigned long deadline) 1124 unsigned long deadline)
1124{ 1125{
1126 struct ata_port *ap = link->ap;
1125 struct ahci_port_priv *pp = ap->private_data; 1127 struct ahci_port_priv *pp = ap->private_data;
1126 u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG; 1128 u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
1127 struct ata_taskfile tf; 1129 struct ata_taskfile tf;
@@ -1132,15 +1134,15 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class,
1132 ahci_stop_engine(ap); 1134 ahci_stop_engine(ap);
1133 1135
1134 /* clear D2H reception area to properly wait for D2H FIS */ 1136 /* clear D2H reception area to properly wait for D2H FIS */
1135 ata_tf_init(ap->link.device, &tf); 1137 ata_tf_init(link->device, &tf);
1136 tf.command = 0x80; 1138 tf.command = 0x80;
1137 ata_tf_to_fis(&tf, 0, 0, d2h_fis); 1139 ata_tf_to_fis(&tf, 0, 0, d2h_fis);
1138 1140
1139 rc = sata_std_hardreset(ap, class, deadline); 1141 rc = sata_std_hardreset(link, class, deadline);
1140 1142
1141 ahci_start_engine(ap); 1143 ahci_start_engine(ap);
1142 1144
1143 if (rc == 0 && ata_link_online(&ap->link)) 1145 if (rc == 0 && ata_link_online(link))
1144 *class = ahci_dev_classify(ap); 1146 *class = ahci_dev_classify(ap);
1145 if (*class == ATA_DEV_UNKNOWN) 1147 if (*class == ATA_DEV_UNKNOWN)
1146 *class = ATA_DEV_NONE; 1148 *class = ATA_DEV_NONE;
@@ -1149,9 +1151,10 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class,
1149 return rc; 1151 return rc;
1150} 1152}
1151 1153
1152static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class, 1154static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
1153 unsigned long deadline) 1155 unsigned long deadline)
1154{ 1156{
1157 struct ata_port *ap = link->ap;
1155 u32 serror; 1158 u32 serror;
1156 int rc; 1159 int rc;
1157 1160
@@ -1159,7 +1162,7 @@ static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class,
1159 1162
1160 ahci_stop_engine(ap); 1163 ahci_stop_engine(ap);
1161 1164
1162 rc = sata_port_hardreset(ap, sata_ehc_deb_timing(&ap->link.eh_context), 1165 rc = sata_link_hardreset(link, sata_ehc_deb_timing(&link->eh_context),
1163 deadline); 1166 deadline);
1164 1167
1165 /* vt8251 needs SError cleared for the port to operate */ 1168 /* vt8251 needs SError cleared for the port to operate */
@@ -1176,12 +1179,13 @@ static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class,
1176 return rc ?: -EAGAIN; 1179 return rc ?: -EAGAIN;
1177} 1180}
1178 1181
1179static void ahci_postreset(struct ata_port *ap, unsigned int *class) 1182static void ahci_postreset(struct ata_link *link, unsigned int *class)
1180{ 1183{
1184 struct ata_port *ap = link->ap;
1181 void __iomem *port_mmio = ahci_port_base(ap); 1185 void __iomem *port_mmio = ahci_port_base(ap);
1182 u32 new_tmp, tmp; 1186 u32 new_tmp, tmp;
1183 1187
1184 ata_std_postreset(ap, class); 1188 ata_std_postreset(link, class);
1185 1189
1186 /* Make sure port's ATAPI bit is set appropriately */ 1190 /* Make sure port's ATAPI bit is set appropriately */
1187 new_tmp = tmp = readl(port_mmio + PORT_CMD); 1191 new_tmp = tmp = readl(port_mmio + PORT_CMD);
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 92c2d5082bef..03fe493026eb 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -657,19 +657,20 @@ static int ich_pata_cable_detect(struct ata_port *ap)
657 657
658/** 658/**
659 * piix_pata_prereset - prereset for PATA host controller 659 * piix_pata_prereset - prereset for PATA host controller
660 * @ap: Target port 660 * @link: Target link
661 * @deadline: deadline jiffies for the operation 661 * @deadline: deadline jiffies for the operation
662 * 662 *
663 * LOCKING: 663 * LOCKING:
664 * None (inherited from caller). 664 * None (inherited from caller).
665 */ 665 */
666static int piix_pata_prereset(struct ata_port *ap, unsigned long deadline) 666static int piix_pata_prereset(struct ata_link *link, unsigned long deadline)
667{ 667{
668 struct ata_port *ap = link->ap;
668 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 669 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
669 670
670 if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no])) 671 if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no]))
671 return -ENOENT; 672 return -ENOENT;
672 return ata_std_prereset(ap, deadline); 673 return ata_std_prereset(link, deadline);
673} 674}
674 675
675static void piix_pata_error_handler(struct ata_port *ap) 676static void piix_pata_error_handler(struct ata_port *ap)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 6f99dee6b6d2..73f66f4e1eeb 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3306,10 +3306,10 @@ int sata_link_resume(struct ata_link *link, const unsigned long *params,
3306 3306
3307/** 3307/**
3308 * ata_std_prereset - prepare for reset 3308 * ata_std_prereset - prepare for reset
3309 * @ap: ATA port to be reset 3309 * @link: ATA link to be reset
3310 * @deadline: deadline jiffies for the operation 3310 * @deadline: deadline jiffies for the operation
3311 * 3311 *
3312 * @ap is about to be reset. Initialize it. Failure from 3312 * @link is about to be reset. Initialize it. Failure from
3313 * prereset makes libata abort whole reset sequence and give up 3313 * prereset makes libata abort whole reset sequence and give up
3314 * that port, so prereset should be best-effort. It does its 3314 * that port, so prereset should be best-effort. It does its
3315 * best to prepare for reset sequence but if things go wrong, it 3315 * best to prepare for reset sequence but if things go wrong, it
@@ -3321,9 +3321,9 @@ int sata_link_resume(struct ata_link *link, const unsigned long *params,
3321 * RETURNS: 3321 * RETURNS:
3322 * 0 on success, -errno otherwise. 3322 * 0 on success, -errno otherwise.
3323 */ 3323 */
3324int ata_std_prereset(struct ata_port *ap, unsigned long deadline) 3324int ata_std_prereset(struct ata_link *link, unsigned long deadline)
3325{ 3325{
3326 struct ata_link *link = &ap->link; 3326 struct ata_port *ap = link->ap;
3327 struct ata_eh_context *ehc = &link->eh_context; 3327 struct ata_eh_context *ehc = &link->eh_context;
3328 const unsigned long *timing = sata_ehc_deb_timing(ehc); 3328 const unsigned long *timing = sata_ehc_deb_timing(ehc);
3329 int rc; 3329 int rc;
@@ -3342,7 +3342,7 @@ int ata_std_prereset(struct ata_port *ap, unsigned long deadline)
3342 rc = sata_link_resume(link, timing, deadline); 3342 rc = sata_link_resume(link, timing, deadline);
3343 /* whine about phy resume failure but proceed */ 3343 /* whine about phy resume failure but proceed */
3344 if (rc && rc != -EOPNOTSUPP) 3344 if (rc && rc != -EOPNOTSUPP)
3345 ata_port_printk(ap, KERN_WARNING, "failed to resume " 3345 ata_link_printk(link, KERN_WARNING, "failed to resume "
3346 "link for reset (errno=%d)\n", rc); 3346 "link for reset (errno=%d)\n", rc);
3347 } 3347 }
3348 3348
@@ -3352,7 +3352,7 @@ int ata_std_prereset(struct ata_port *ap, unsigned long deadline)
3352 if (!(ap->flags & ATA_FLAG_SKIP_D2H_BSY) && !ata_link_offline(link)) { 3352 if (!(ap->flags & ATA_FLAG_SKIP_D2H_BSY) && !ata_link_offline(link)) {
3353 rc = ata_wait_ready(ap, deadline); 3353 rc = ata_wait_ready(ap, deadline);
3354 if (rc && rc != -ENODEV) { 3354 if (rc && rc != -ENODEV) {
3355 ata_port_printk(ap, KERN_WARNING, "device not ready " 3355 ata_link_printk(link, KERN_WARNING, "device not ready "
3356 "(errno=%d), forcing hardreset\n", rc); 3356 "(errno=%d), forcing hardreset\n", rc);
3357 ehc->i.action |= ATA_EH_HARDRESET; 3357 ehc->i.action |= ATA_EH_HARDRESET;
3358 } 3358 }
@@ -3363,7 +3363,7 @@ int ata_std_prereset(struct ata_port *ap, unsigned long deadline)
3363 3363
3364/** 3364/**
3365 * ata_std_softreset - reset host port via ATA SRST 3365 * ata_std_softreset - reset host port via ATA SRST
3366 * @ap: port to reset 3366 * @link: ATA link to reset
3367 * @classes: resulting classes of attached devices 3367 * @classes: resulting classes of attached devices
3368 * @deadline: deadline jiffies for the operation 3368 * @deadline: deadline jiffies for the operation
3369 * 3369 *
@@ -3375,10 +3375,10 @@ int ata_std_prereset(struct ata_port *ap, unsigned long deadline)
3375 * RETURNS: 3375 * RETURNS:
3376 * 0 on success, -errno otherwise. 3376 * 0 on success, -errno otherwise.
3377 */ 3377 */
3378int ata_std_softreset(struct ata_port *ap, unsigned int *classes, 3378int ata_std_softreset(struct ata_link *link, unsigned int *classes,
3379 unsigned long deadline) 3379 unsigned long deadline)
3380{ 3380{
3381 struct ata_link *link = &ap->link; 3381 struct ata_port *ap = link->ap;
3382 unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; 3382 unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS;
3383 unsigned int devmask = 0; 3383 unsigned int devmask = 0;
3384 int rc; 3384 int rc;
@@ -3405,7 +3405,7 @@ int ata_std_softreset(struct ata_port *ap, unsigned int *classes,
3405 rc = ata_bus_softreset(ap, devmask, deadline); 3405 rc = ata_bus_softreset(ap, devmask, deadline);
3406 /* if link is occupied, -ENODEV too is an error */ 3406 /* if link is occupied, -ENODEV too is an error */
3407 if (rc && (rc != -ENODEV || sata_scr_valid(link))) { 3407 if (rc && (rc != -ENODEV || sata_scr_valid(link))) {
3408 ata_port_printk(ap, KERN_ERR, "SRST failed (errno=%d)\n", rc); 3408 ata_link_printk(link, KERN_ERR, "SRST failed (errno=%d)\n", rc);
3409 return rc; 3409 return rc;
3410 } 3410 }
3411 3411
@@ -3420,12 +3420,12 @@ int ata_std_softreset(struct ata_port *ap, unsigned int *classes,
3420} 3420}
3421 3421
3422/** 3422/**
3423 * sata_port_hardreset - reset port via SATA phy reset 3423 * sata_link_hardreset - reset link via SATA phy reset
3424 * @ap: port to reset 3424 * @link: link to reset
3425 * @timing: timing parameters { interval, duratinon, timeout } in msec 3425 * @timing: timing parameters { interval, duratinon, timeout } in msec
3426 * @deadline: deadline jiffies for the operation 3426 * @deadline: deadline jiffies for the operation
3427 * 3427 *
3428 * SATA phy-reset host port using DET bits of SControl register. 3428 * SATA phy-reset @link using DET bits of SControl register.
3429 * 3429 *
3430 * LOCKING: 3430 * LOCKING:
3431 * Kernel thread context (may sleep) 3431 * Kernel thread context (may sleep)
@@ -3433,10 +3433,9 @@ int ata_std_softreset(struct ata_port *ap, unsigned int *classes,
3433 * RETURNS: 3433 * RETURNS:
3434 * 0 on success, -errno otherwise. 3434 * 0 on success, -errno otherwise.
3435 */ 3435 */
3436int sata_port_hardreset(struct ata_port *ap, const unsigned long *timing, 3436int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
3437 unsigned long deadline) 3437 unsigned long deadline)
3438{ 3438{
3439 struct ata_link *link = &ap->link;
3440 u32 scontrol; 3439 u32 scontrol;
3441 int rc; 3440 int rc;
3442 3441
@@ -3482,7 +3481,7 @@ int sata_port_hardreset(struct ata_port *ap, const unsigned long *timing,
3482 3481
3483/** 3482/**
3484 * sata_std_hardreset - reset host port via SATA phy reset 3483 * sata_std_hardreset - reset host port via SATA phy reset
3485 * @ap: port to reset 3484 * @link: link to reset
3486 * @class: resulting class of attached device 3485 * @class: resulting class of attached device
3487 * @deadline: deadline jiffies for the operation 3486 * @deadline: deadline jiffies for the operation
3488 * 3487 *
@@ -3495,19 +3494,19 @@ int sata_port_hardreset(struct ata_port *ap, const unsigned long *timing,
3495 * RETURNS: 3494 * RETURNS:
3496 * 0 on success, -errno otherwise. 3495 * 0 on success, -errno otherwise.
3497 */ 3496 */
3498int sata_std_hardreset(struct ata_port *ap, unsigned int *class, 3497int sata_std_hardreset(struct ata_link *link, unsigned int *class,
3499 unsigned long deadline) 3498 unsigned long deadline)
3500{ 3499{
3501 struct ata_link *link = &ap->link; 3500 struct ata_port *ap = link->ap;
3502 const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context); 3501 const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context);
3503 int rc; 3502 int rc;
3504 3503
3505 DPRINTK("ENTER\n"); 3504 DPRINTK("ENTER\n");
3506 3505
3507 /* do hardreset */ 3506 /* do hardreset */
3508 rc = sata_port_hardreset(ap, timing, deadline); 3507 rc = sata_link_hardreset(link, timing, deadline);
3509 if (rc) { 3508 if (rc) {
3510 ata_port_printk(ap, KERN_ERR, 3509 ata_link_printk(link, KERN_ERR,
3511 "COMRESET failed (errno=%d)\n", rc); 3510 "COMRESET failed (errno=%d)\n", rc);
3512 return rc; 3511 return rc;
3513 } 3512 }
@@ -3525,7 +3524,7 @@ int sata_std_hardreset(struct ata_port *ap, unsigned int *class,
3525 rc = ata_wait_ready(ap, deadline); 3524 rc = ata_wait_ready(ap, deadline);
3526 /* link occupied, -ENODEV too is an error */ 3525 /* link occupied, -ENODEV too is an error */
3527 if (rc) { 3526 if (rc) {
3528 ata_port_printk(ap, KERN_ERR, 3527 ata_link_printk(link, KERN_ERR,
3529 "COMRESET failed (errno=%d)\n", rc); 3528 "COMRESET failed (errno=%d)\n", rc);
3530 return rc; 3529 return rc;
3531 } 3530 }
@@ -3540,7 +3539,7 @@ int sata_std_hardreset(struct ata_port *ap, unsigned int *class,
3540 3539
3541/** 3540/**
3542 * ata_std_postreset - standard postreset callback 3541 * ata_std_postreset - standard postreset callback
3543 * @ap: the target ata_port 3542 * @link: the target ata_link
3544 * @classes: classes of attached devices 3543 * @classes: classes of attached devices
3545 * 3544 *
3546 * This function is invoked after a successful reset. Note that 3545 * This function is invoked after a successful reset. Note that
@@ -3550,9 +3549,9 @@ int sata_std_hardreset(struct ata_port *ap, unsigned int *class,
3550 * LOCKING: 3549 * LOCKING:
3551 * Kernel thread context (may sleep) 3550 * Kernel thread context (may sleep)
3552 */ 3551 */
3553void ata_std_postreset(struct ata_port *ap, unsigned int *classes) 3552void ata_std_postreset(struct ata_link *link, unsigned int *classes)
3554{ 3553{
3555 struct ata_link *link = &ap->link; 3554 struct ata_port *ap = link->ap;
3556 u32 serror; 3555 u32 serror;
3557 3556
3558 DPRINTK("ENTER\n"); 3557 DPRINTK("ENTER\n");
@@ -6946,7 +6945,7 @@ EXPORT_SYMBOL_GPL(__sata_phy_reset);
6946EXPORT_SYMBOL_GPL(ata_bus_reset); 6945EXPORT_SYMBOL_GPL(ata_bus_reset);
6947EXPORT_SYMBOL_GPL(ata_std_prereset); 6946EXPORT_SYMBOL_GPL(ata_std_prereset);
6948EXPORT_SYMBOL_GPL(ata_std_softreset); 6947EXPORT_SYMBOL_GPL(ata_std_softreset);
6949EXPORT_SYMBOL_GPL(sata_port_hardreset); 6948EXPORT_SYMBOL_GPL(sata_link_hardreset);
6950EXPORT_SYMBOL_GPL(sata_std_hardreset); 6949EXPORT_SYMBOL_GPL(sata_std_hardreset);
6951EXPORT_SYMBOL_GPL(ata_std_postreset); 6950EXPORT_SYMBOL_GPL(ata_std_postreset);
6952EXPORT_SYMBOL_GPL(ata_dev_classify); 6951EXPORT_SYMBOL_GPL(ata_dev_classify);
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index fc4b6413b192..0a9ce34a0e64 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -1737,16 +1737,16 @@ static void ata_eh_report(struct ata_port *ap)
1737 } 1737 }
1738} 1738}
1739 1739
1740static int ata_do_reset(struct ata_port *ap, ata_reset_fn_t reset, 1740static int ata_do_reset(struct ata_link *link, ata_reset_fn_t reset,
1741 unsigned int *classes, unsigned long deadline) 1741 unsigned int *classes, unsigned long deadline)
1742{ 1742{
1743 struct ata_device *dev; 1743 struct ata_device *dev;
1744 int rc; 1744 int rc;
1745 1745
1746 ata_link_for_each_dev(dev, &ap->link) 1746 ata_link_for_each_dev(dev, link)
1747 classes[dev->devno] = ATA_DEV_UNKNOWN; 1747 classes[dev->devno] = ATA_DEV_UNKNOWN;
1748 1748
1749 rc = reset(ap, classes, deadline); 1749 rc = reset(link, classes, deadline);
1750 if (rc) 1750 if (rc)
1751 return rc; 1751 return rc;
1752 1752
@@ -1754,12 +1754,12 @@ static int ata_do_reset(struct ata_port *ap, ata_reset_fn_t reset,
1754 * is complete and convert all ATA_DEV_UNKNOWN to 1754 * is complete and convert all ATA_DEV_UNKNOWN to
1755 * ATA_DEV_NONE. 1755 * ATA_DEV_NONE.
1756 */ 1756 */
1757 ata_link_for_each_dev(dev, &ap->link) 1757 ata_link_for_each_dev(dev, link)
1758 if (classes[dev->devno] != ATA_DEV_UNKNOWN) 1758 if (classes[dev->devno] != ATA_DEV_UNKNOWN)
1759 break; 1759 break;
1760 1760
1761 if (dev) { 1761 if (dev) {
1762 ata_link_for_each_dev(dev, &ap->link) { 1762 ata_link_for_each_dev(dev, link) {
1763 if (classes[dev->devno] == ATA_DEV_UNKNOWN) 1763 if (classes[dev->devno] == ATA_DEV_UNKNOWN)
1764 classes[dev->devno] = ATA_DEV_NONE; 1764 classes[dev->devno] = ATA_DEV_NONE;
1765 } 1765 }
@@ -1780,11 +1780,10 @@ static int ata_eh_followup_srst_needed(int rc, int classify,
1780 return 0; 1780 return 0;
1781} 1781}
1782 1782
1783static int ata_eh_reset(struct ata_port *ap, int classify, 1783static int ata_eh_reset(struct ata_link *link, int classify,
1784 ata_prereset_fn_t prereset, ata_reset_fn_t softreset, 1784 ata_prereset_fn_t prereset, ata_reset_fn_t softreset,
1785 ata_reset_fn_t hardreset, ata_postreset_fn_t postreset) 1785 ata_reset_fn_t hardreset, ata_postreset_fn_t postreset)
1786{ 1786{
1787 struct ata_link *link = &ap->link;
1788 struct ata_eh_context *ehc = &link->eh_context; 1787 struct ata_eh_context *ehc = &link->eh_context;
1789 unsigned int *classes = ehc->classes; 1788 unsigned int *classes = ehc->classes;
1790 int verbose = !(ehc->i.flags & ATA_EHI_QUIET); 1789 int verbose = !(ehc->i.flags & ATA_EHI_QUIET);
@@ -1810,10 +1809,10 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
1810 ehc->i.action |= ATA_EH_HARDRESET; 1809 ehc->i.action |= ATA_EH_HARDRESET;
1811 1810
1812 if (prereset) { 1811 if (prereset) {
1813 rc = prereset(ap, jiffies + ATA_EH_PRERESET_TIMEOUT); 1812 rc = prereset(link, jiffies + ATA_EH_PRERESET_TIMEOUT);
1814 if (rc) { 1813 if (rc) {
1815 if (rc == -ENOENT) { 1814 if (rc == -ENOENT) {
1816 ata_port_printk(ap, KERN_DEBUG, 1815 ata_link_printk(link, KERN_DEBUG,
1817 "port disabled. ignoring.\n"); 1816 "port disabled. ignoring.\n");
1818 ehc->i.action &= ~ATA_EH_RESET_MASK; 1817 ehc->i.action &= ~ATA_EH_RESET_MASK;
1819 1818
@@ -1822,7 +1821,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
1822 1821
1823 rc = 0; 1822 rc = 0;
1824 } else 1823 } else
1825 ata_port_printk(ap, KERN_ERR, 1824 ata_link_printk(link, KERN_ERR,
1826 "prereset failed (errno=%d)\n", rc); 1825 "prereset failed (errno=%d)\n", rc);
1827 goto out; 1826 goto out;
1828 } 1827 }
@@ -1854,7 +1853,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
1854 1853
1855 /* shut up during boot probing */ 1854 /* shut up during boot probing */
1856 if (verbose) 1855 if (verbose)
1857 ata_port_printk(ap, KERN_INFO, "%s resetting port\n", 1856 ata_link_printk(link, KERN_INFO, "%s resetting link\n",
1858 reset == softreset ? "soft" : "hard"); 1857 reset == softreset ? "soft" : "hard");
1859 1858
1860 /* mark that this EH session started with reset */ 1859 /* mark that this EH session started with reset */
@@ -1863,7 +1862,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
1863 else 1862 else
1864 ehc->i.flags |= ATA_EHI_DID_SOFTRESET; 1863 ehc->i.flags |= ATA_EHI_DID_SOFTRESET;
1865 1864
1866 rc = ata_do_reset(ap, reset, classes, deadline); 1865 rc = ata_do_reset(link, reset, classes, deadline);
1867 1866
1868 if (reset == hardreset && 1867 if (reset == hardreset &&
1869 ata_eh_followup_srst_needed(rc, classify, classes)) { 1868 ata_eh_followup_srst_needed(rc, classify, classes)) {
@@ -1871,7 +1870,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
1871 reset = softreset; 1870 reset = softreset;
1872 1871
1873 if (!reset) { 1872 if (!reset) {
1874 ata_port_printk(ap, KERN_ERR, 1873 ata_link_printk(link, KERN_ERR,
1875 "follow-up softreset required " 1874 "follow-up softreset required "
1876 "but no softreset avaliable\n"); 1875 "but no softreset avaliable\n");
1877 rc = -EINVAL; 1876 rc = -EINVAL;
@@ -1879,11 +1878,11 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
1879 } 1878 }
1880 1879
1881 ata_eh_about_to_do(link, NULL, ATA_EH_RESET_MASK); 1880 ata_eh_about_to_do(link, NULL, ATA_EH_RESET_MASK);
1882 rc = ata_do_reset(ap, reset, classes, deadline); 1881 rc = ata_do_reset(link, reset, classes, deadline);
1883 1882
1884 if (rc == 0 && classify && 1883 if (rc == 0 && classify &&
1885 classes[0] == ATA_DEV_UNKNOWN) { 1884 classes[0] == ATA_DEV_UNKNOWN) {
1886 ata_port_printk(ap, KERN_ERR, 1885 ata_link_printk(link, KERN_ERR,
1887 "classification failed\n"); 1886 "classification failed\n");
1888 rc = -EINVAL; 1887 rc = -EINVAL;
1889 goto out; 1888 goto out;
@@ -1896,7 +1895,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
1896 if (time_before(now, deadline)) { 1895 if (time_before(now, deadline)) {
1897 unsigned long delta = deadline - jiffies; 1896 unsigned long delta = deadline - jiffies;
1898 1897
1899 ata_port_printk(ap, KERN_WARNING, "reset failed " 1898 ata_link_printk(link, KERN_WARNING, "reset failed "
1900 "(errno=%d), retrying in %u secs\n", 1899 "(errno=%d), retrying in %u secs\n",
1901 rc, (jiffies_to_msecs(delta) + 999) / 1000); 1900 rc, (jiffies_to_msecs(delta) + 999) / 1000);
1902 1901
@@ -1925,7 +1924,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
1925 link->sata_spd = (sstatus >> 4) & 0xf; 1924 link->sata_spd = (sstatus >> 4) & 0xf;
1926 1925
1927 if (postreset) 1926 if (postreset)
1928 postreset(ap, classes); 1927 postreset(link, classes);
1929 1928
1930 /* reset successful, schedule revalidation */ 1929 /* reset successful, schedule revalidation */
1931 ata_eh_done(link, NULL, ehc->i.action & ATA_EH_RESET_MASK); 1930 ata_eh_done(link, NULL, ehc->i.action & ATA_EH_RESET_MASK);
@@ -2202,7 +2201,7 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2202 if (ehc->i.action & ATA_EH_RESET_MASK) { 2201 if (ehc->i.action & ATA_EH_RESET_MASK) {
2203 ata_eh_freeze_port(ap); 2202 ata_eh_freeze_port(ap);
2204 2203
2205 rc = ata_eh_reset(ap, ata_port_nr_vacant(ap), prereset, 2204 rc = ata_eh_reset(&ap->link, ata_port_nr_vacant(ap), prereset,
2206 softreset, hardreset, postreset); 2205 softreset, hardreset, postreset);
2207 if (rc) { 2206 if (rc) {
2208 ata_port_printk(ap, KERN_ERR, 2207 ata_port_printk(ap, KERN_ERR,
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index 04048fcf6305..d0cebe16a8ee 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -119,27 +119,28 @@ static void timing_setup(struct ata_port *ap, struct ata_device *adev, int offse
119} 119}
120 120
121/** 121/**
122 * amd_probe_init - perform reset handling 122 * amd_pre_reset - perform reset handling
123 * @ap: ATA port 123 * @link: ATA link
124 * @deadline: deadline jiffies for the operation 124 * @deadline: deadline jiffies for the operation
125 * 125 *
126 * Reset sequence checking enable bits to see which ports are 126 * Reset sequence checking enable bits to see which ports are
127 * active. 127 * active.
128 */ 128 */
129 129
130static int amd_pre_reset(struct ata_port *ap, unsigned long deadline) 130static int amd_pre_reset(struct ata_link *link, unsigned long deadline)
131{ 131{
132 static const struct pci_bits amd_enable_bits[] = { 132 static const struct pci_bits amd_enable_bits[] = {
133 { 0x40, 1, 0x02, 0x02 }, 133 { 0x40, 1, 0x02, 0x02 },
134 { 0x40, 1, 0x01, 0x01 } 134 { 0x40, 1, 0x01, 0x01 }
135 }; 135 };
136 136
137 struct ata_port *ap = link->ap;
137 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 138 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
138 139
139 if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no])) 140 if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no]))
140 return -ENOENT; 141 return -ENOENT;
141 142
142 return ata_std_prereset(ap, deadline); 143 return ata_std_prereset(link, deadline);
143} 144}
144 145
145static void amd_error_handler(struct ata_port *ap) 146static void amd_error_handler(struct ata_port *ap)
@@ -221,25 +222,26 @@ static void amd133_set_dmamode(struct ata_port *ap, struct ata_device *adev)
221 222
222/** 223/**
223 * nv_probe_init - cable detection 224 * nv_probe_init - cable detection
224 * @ap: ATA port 225 * @lin: ATA link
225 * 226 *
226 * Perform cable detection. The BIOS stores this in PCI config 227 * Perform cable detection. The BIOS stores this in PCI config
227 * space for us. 228 * space for us.
228 */ 229 */
229 230
230static int nv_pre_reset(struct ata_port *ap, unsigned long deadline) 231static int nv_pre_reset(struct ata_link *link, unsigned long deadline)
231{ 232{
232 static const struct pci_bits nv_enable_bits[] = { 233 static const struct pci_bits nv_enable_bits[] = {
233 { 0x50, 1, 0x02, 0x02 }, 234 { 0x50, 1, 0x02, 0x02 },
234 { 0x50, 1, 0x01, 0x01 } 235 { 0x50, 1, 0x01, 0x01 }
235 }; 236 };
236 237
238 struct ata_port *ap = link->ap;
237 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 239 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
238 240
239 if (!pci_test_config_bits(pdev, &nv_enable_bits[ap->port_no])) 241 if (!pci_test_config_bits(pdev, &nv_enable_bits[ap->port_no]))
240 return -ENOENT; 242 return -ENOENT;
241 243
242 return ata_std_prereset(ap, deadline); 244 return ata_std_prereset(link, deadline);
243} 245}
244 246
245static void nv_error_handler(struct ata_port *ap) 247static void nv_error_handler(struct ata_port *ap)
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index b5352ebecef9..361f2fca7e54 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -40,8 +40,9 @@
40 40
41static int clock = 0; 41static int clock = 0;
42 42
43static int artop6210_pre_reset(struct ata_port *ap, unsigned long deadline) 43static int artop6210_pre_reset(struct ata_link *link, unsigned long deadline)
44{ 44{
45 struct ata_port *ap = link->ap;
45 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 46 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
46 const struct pci_bits artop_enable_bits[] = { 47 const struct pci_bits artop_enable_bits[] = {
47 { 0x4AU, 1U, 0x02UL, 0x02UL }, /* port 0 */ 48 { 0x4AU, 1U, 0x02UL, 0x02UL }, /* port 0 */
@@ -51,7 +52,7 @@ static int artop6210_pre_reset(struct ata_port *ap, unsigned long deadline)
51 if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no])) 52 if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no]))
52 return -ENOENT; 53 return -ENOENT;
53 54
54 return ata_std_prereset(ap, deadline); 55 return ata_std_prereset(link, deadline);
55} 56}
56 57
57/** 58/**
@@ -71,27 +72,28 @@ static void artop6210_error_handler(struct ata_port *ap)
71 72
72/** 73/**
73 * artop6260_pre_reset - check for 40/80 pin 74 * artop6260_pre_reset - check for 40/80 pin
74 * @ap: Port 75 * @link: link
75 * @deadline: deadline jiffies for the operation 76 * @deadline: deadline jiffies for the operation
76 * 77 *
77 * The ARTOP hardware reports the cable detect bits in register 0x49. 78 * The ARTOP hardware reports the cable detect bits in register 0x49.
78 * Nothing complicated needed here. 79 * Nothing complicated needed here.
79 */ 80 */
80 81
81static int artop6260_pre_reset(struct ata_port *ap, unsigned long deadline) 82static int artop6260_pre_reset(struct ata_link *link, unsigned long deadline)
82{ 83{
83 static const struct pci_bits artop_enable_bits[] = { 84 static const struct pci_bits artop_enable_bits[] = {
84 { 0x4AU, 1U, 0x02UL, 0x02UL }, /* port 0 */ 85 { 0x4AU, 1U, 0x02UL, 0x02UL }, /* port 0 */
85 { 0x4AU, 1U, 0x04UL, 0x04UL }, /* port 1 */ 86 { 0x4AU, 1U, 0x04UL, 0x04UL }, /* port 1 */
86 }; 87 };
87 88
89 struct ata_port *ap = link->ap;
88 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 90 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
89 91
90 /* Odd numbered device ids are the units with enable bits (the -R cards) */ 92 /* Odd numbered device ids are the units with enable bits (the -R cards) */
91 if (pdev->device % 1 && !pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no])) 93 if (pdev->device % 1 && !pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no]))
92 return -ENOENT; 94 return -ENOENT;
93 95
94 return ata_std_prereset(ap, deadline); 96 return ata_std_prereset(link, deadline);
95} 97}
96 98
97/** 99/**
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index 86f85a2cab7e..656f4d0a5728 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -33,8 +33,9 @@ enum {
33 ATIIXP_IDE_UDMA_MODE = 0x56 33 ATIIXP_IDE_UDMA_MODE = 0x56
34}; 34};
35 35
36static int atiixp_pre_reset(struct ata_port *ap, unsigned long deadline) 36static int atiixp_pre_reset(struct ata_link *link, unsigned long deadline)
37{ 37{
38 struct ata_port *ap = link->ap;
38 static const struct pci_bits atiixp_enable_bits[] = { 39 static const struct pci_bits atiixp_enable_bits[] = {
39 { 0x48, 1, 0x01, 0x00 }, 40 { 0x48, 1, 0x01, 0x00 },
40 { 0x48, 1, 0x08, 0x00 } 41 { 0x48, 1, 0x08, 0x00 }
@@ -44,7 +45,7 @@ static int atiixp_pre_reset(struct ata_port *ap, unsigned long deadline)
44 if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no])) 45 if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no]))
45 return -ENOENT; 46 return -ENOENT;
46 47
47 return ata_std_prereset(ap, deadline); 48 return ata_std_prereset(link, deadline);
48} 49}
49 50
50static void atiixp_error_handler(struct ata_port *ap) 51static void atiixp_error_handler(struct ata_port *ap)
diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c
index c8ba59c56114..9f6fae6e38bf 100644
--- a/drivers/ata/pata_efar.c
+++ b/drivers/ata/pata_efar.c
@@ -26,25 +26,26 @@
26 26
27/** 27/**
28 * efar_pre_reset - Enable bits 28 * efar_pre_reset - Enable bits
29 * @ap: Port 29 * @link: ATA link
30 * @deadline: deadline jiffies for the operation 30 * @deadline: deadline jiffies for the operation
31 * 31 *
32 * Perform cable detection for the EFAR ATA interface. This is 32 * Perform cable detection for the EFAR ATA interface. This is
33 * different to the PIIX arrangement 33 * different to the PIIX arrangement
34 */ 34 */
35 35
36static int efar_pre_reset(struct ata_port *ap, unsigned long deadline) 36static int efar_pre_reset(struct ata_link *link, unsigned long deadline)
37{ 37{
38 static const struct pci_bits efar_enable_bits[] = { 38 static const struct pci_bits efar_enable_bits[] = {
39 { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */ 39 { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */
40 { 0x43U, 1U, 0x80UL, 0x80UL }, /* port 1 */ 40 { 0x43U, 1U, 0x80UL, 0x80UL }, /* port 1 */
41 }; 41 };
42 struct ata_port *ap = link->ap;
42 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 43 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
43 44
44 if (!pci_test_config_bits(pdev, &efar_enable_bits[ap->port_no])) 45 if (!pci_test_config_bits(pdev, &efar_enable_bits[ap->port_no]))
45 return -ENOENT; 46 return -ENOENT;
46 47
47 return ata_std_prereset(ap, deadline); 48 return ata_std_prereset(link, deadline);
48} 49}
49 50
50/** 51/**
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index c5ddd937dbf2..1a4d0ad68d18 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -304,15 +304,16 @@ static unsigned long hpt370a_filter(struct ata_device *adev, unsigned long mask)
304 304
305/** 305/**
306 * hpt37x_pre_reset - reset the hpt37x bus 306 * hpt37x_pre_reset - reset the hpt37x bus
307 * @ap: ATA port to reset 307 * @link: ATA link to reset
308 * @deadline: deadline jiffies for the operation 308 * @deadline: deadline jiffies for the operation
309 * 309 *
310 * Perform the initial reset handling for the 370/372 and 374 func 0 310 * Perform the initial reset handling for the 370/372 and 374 func 0
311 */ 311 */
312 312
313static int hpt37x_pre_reset(struct ata_port *ap, unsigned long deadline) 313static int hpt37x_pre_reset(struct ata_link *link, unsigned long deadline)
314{ 314{
315 u8 scr2, ata66; 315 u8 scr2, ata66;
316 struct ata_port *ap = link->ap;
316 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 317 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
317 static const struct pci_bits hpt37x_enable_bits[] = { 318 static const struct pci_bits hpt37x_enable_bits[] = {
318 { 0x50, 1, 0x04, 0x04 }, 319 { 0x50, 1, 0x04, 0x04 },
@@ -337,7 +338,7 @@ static int hpt37x_pre_reset(struct ata_port *ap, unsigned long deadline)
337 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); 338 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
338 udelay(100); 339 udelay(100);
339 340
340 return ata_std_prereset(ap, deadline); 341 return ata_std_prereset(link, deadline);
341} 342}
342 343
343/** 344/**
@@ -352,7 +353,7 @@ static void hpt37x_error_handler(struct ata_port *ap)
352 ata_bmdma_drive_eh(ap, hpt37x_pre_reset, ata_std_softreset, NULL, ata_std_postreset); 353 ata_bmdma_drive_eh(ap, hpt37x_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
353} 354}
354 355
355static int hpt374_pre_reset(struct ata_port *ap, unsigned long deadline) 356static int hpt374_pre_reset(struct ata_link *link, unsigned long deadline)
356{ 357{
357 static const struct pci_bits hpt37x_enable_bits[] = { 358 static const struct pci_bits hpt37x_enable_bits[] = {
358 { 0x50, 1, 0x04, 0x04 }, 359 { 0x50, 1, 0x04, 0x04 },
@@ -360,6 +361,7 @@ static int hpt374_pre_reset(struct ata_port *ap, unsigned long deadline)
360 }; 361 };
361 u16 mcr3, mcr6; 362 u16 mcr3, mcr6;
362 u8 ata66; 363 u8 ata66;
364 struct ata_port *ap = link->ap;
363 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 365 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
364 366
365 if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no])) 367 if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no]))
@@ -387,7 +389,7 @@ static int hpt374_pre_reset(struct ata_port *ap, unsigned long deadline)
387 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); 389 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
388 udelay(100); 390 udelay(100);
389 391
390 return ata_std_prereset(ap, deadline); 392 return ata_std_prereset(link, deadline);
391} 393}
392 394
393/** 395/**
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index f8f234bfc8ce..739a89180eb9 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -141,21 +141,22 @@ static int hpt3x2n_cable_detect(struct ata_port *ap)
141 141
142/** 142/**
143 * hpt3x2n_pre_reset - reset the hpt3x2n bus 143 * hpt3x2n_pre_reset - reset the hpt3x2n bus
144 * @ap: ATA port to reset 144 * @link: ATA link to reset
145 * @deadline: deadline jiffies for the operation 145 * @deadline: deadline jiffies for the operation
146 * 146 *
147 * Perform the initial reset handling for the 3x2n series controllers. 147 * Perform the initial reset handling for the 3x2n series controllers.
148 * Reset the hardware and state machine, 148 * Reset the hardware and state machine,
149 */ 149 */
150 150
151static int hpt3xn_pre_reset(struct ata_port *ap, unsigned long deadline) 151static int hpt3xn_pre_reset(struct ata_link *link, unsigned long deadline)
152{ 152{
153 struct ata_port *ap = link->ap;
153 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 154 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
154 /* Reset the state machine */ 155 /* Reset the state machine */
155 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); 156 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
156 udelay(100); 157 udelay(100);
157 158
158 return ata_std_prereset(ap, deadline); 159 return ata_std_prereset(link, deadline);
159} 160}
160 161
161/** 162/**
diff --git a/drivers/ata/pata_it8213.c b/drivers/ata/pata_it8213.c
index b8af55e89156..1daf1e19bdfc 100644
--- a/drivers/ata/pata_it8213.c
+++ b/drivers/ata/pata_it8213.c
@@ -23,23 +23,24 @@
23 23
24/** 24/**
25 * it8213_pre_reset - check for 40/80 pin 25 * it8213_pre_reset - check for 40/80 pin
26 * @ap: Port 26 * @link: link
27 * @deadline: deadline jiffies for the operation 27 * @deadline: deadline jiffies for the operation
28 * 28 *
29 * Filter out ports by the enable bits before doing the normal reset 29 * Filter out ports by the enable bits before doing the normal reset
30 * and probe. 30 * and probe.
31 */ 31 */
32 32
33static int it8213_pre_reset(struct ata_port *ap, unsigned long deadline) 33static int it8213_pre_reset(struct ata_link *link, unsigned long deadline)
34{ 34{
35 static const struct pci_bits it8213_enable_bits[] = { 35 static const struct pci_bits it8213_enable_bits[] = {
36 { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */ 36 { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */
37 }; 37 };
38 struct ata_port *ap = link->ap;
38 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 39 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
39 if (!pci_test_config_bits(pdev, &it8213_enable_bits[ap->port_no])) 40 if (!pci_test_config_bits(pdev, &it8213_enable_bits[ap->port_no]))
40 return -ENOENT; 41 return -ENOENT;
41 42
42 return ata_std_prereset(ap, deadline); 43 return ata_std_prereset(link, deadline);
43} 44}
44 45
45/** 46/**
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c
index 4d67f238eee2..1619b86b74af 100644
--- a/drivers/ata/pata_jmicron.c
+++ b/drivers/ata/pata_jmicron.c
@@ -29,7 +29,7 @@ typedef enum {
29 29
30/** 30/**
31 * jmicron_pre_reset - check for 40/80 pin 31 * jmicron_pre_reset - check for 40/80 pin
32 * @ap: Port 32 * @link: ATA link
33 * @deadline: deadline jiffies for the operation 33 * @deadline: deadline jiffies for the operation
34 * 34 *
35 * Perform the PATA port setup we need. 35 * Perform the PATA port setup we need.
@@ -39,9 +39,9 @@ typedef enum {
39 * and setup here. We assume that has been done by init_one and the 39 * and setup here. We assume that has been done by init_one and the
40 * BIOS. 40 * BIOS.
41 */ 41 */
42 42static int jmicron_pre_reset(struct ata_link *link, unsigned long deadline)
43static int jmicron_pre_reset(struct ata_port *ap, unsigned long deadline)
44{ 43{
44 struct ata_port *ap = link->ap;
45 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 45 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
46 u32 control; 46 u32 control;
47 u32 control5; 47 u32 control5;
@@ -103,7 +103,7 @@ static int jmicron_pre_reset(struct ata_port *ap, unsigned long deadline)
103 ap->cbl = ATA_CBL_SATA; 103 ap->cbl = ATA_CBL_SATA;
104 break; 104 break;
105 } 105 }
106 return ata_std_prereset(ap, deadline); 106 return ata_std_prereset(link, deadline);
107} 107}
108 108
109/** 109/**
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c
index b45506f1ef73..b4dd18f3fa5d 100644
--- a/drivers/ata/pata_marvell.c
+++ b/drivers/ata/pata_marvell.c
@@ -24,14 +24,15 @@
24 24
25/** 25/**
26 * marvell_pre_reset - check for 40/80 pin 26 * marvell_pre_reset - check for 40/80 pin
27 * @ap: Port 27 * @link: link
28 * @deadline: deadline jiffies for the operation 28 * @deadline: deadline jiffies for the operation
29 * 29 *
30 * Perform the PATA port setup we need. 30 * Perform the PATA port setup we need.
31 */ 31 */
32 32
33static int marvell_pre_reset(struct ata_port *ap, unsigned long deadline) 33static int marvell_pre_reset(struct ata_link *link, unsigned long deadline)
34{ 34{
35 struct ata_port *ap = link->ap;
35 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 36 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
36 u32 devices; 37 u32 devices;
37 void __iomem *barp; 38 void __iomem *barp;
@@ -54,7 +55,7 @@ static int marvell_pre_reset(struct ata_port *ap, unsigned long deadline)
54 (!(devices & 0x10))) /* PATA enable ? */ 55 (!(devices & 0x10))) /* PATA enable ? */
55 return -ENOENT; 56 return -ENOENT;
56 57
57 return ata_std_prereset(ap, deadline); 58 return ata_std_prereset(link, deadline);
58} 59}
59 60
60static int marvell_cable_detect(struct ata_port *ap) 61static int marvell_cable_detect(struct ata_port *ap)
diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c
index 4ea42838297e..36c964b9e7da 100644
--- a/drivers/ata/pata_mpiix.c
+++ b/drivers/ata/pata_mpiix.c
@@ -46,15 +46,16 @@ enum {
46 SECONDARY = (1 << 14) 46 SECONDARY = (1 << 14)
47}; 47};
48 48
49static int mpiix_pre_reset(struct ata_port *ap, unsigned long deadline) 49static int mpiix_pre_reset(struct ata_link *link, unsigned long deadline)
50{ 50{
51 struct ata_port *ap = link->ap;
51 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 52 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
52 static const struct pci_bits mpiix_enable_bits = { 0x6D, 1, 0x80, 0x80 }; 53 static const struct pci_bits mpiix_enable_bits = { 0x6D, 1, 0x80, 0x80 };
53 54
54 if (!pci_test_config_bits(pdev, &mpiix_enable_bits)) 55 if (!pci_test_config_bits(pdev, &mpiix_enable_bits))
55 return -ENOENT; 56 return -ENOENT;
56 57
57 return ata_std_prereset(ap, deadline); 58 return ata_std_prereset(link, deadline);
58} 59}
59 60
60/** 61/**
diff --git a/drivers/ata/pata_ns87410.c b/drivers/ata/pata_ns87410.c
index 2f5d714ebfc4..65a217727718 100644
--- a/drivers/ata/pata_ns87410.c
+++ b/drivers/ata/pata_ns87410.c
@@ -32,14 +32,15 @@
32 32
33/** 33/**
34 * ns87410_pre_reset - probe begin 34 * ns87410_pre_reset - probe begin
35 * @ap: ATA port 35 * @link: ATA link
36 * @deadline: deadline jiffies for the operation 36 * @deadline: deadline jiffies for the operation
37 * 37 *
38 * Check enabled ports 38 * Check enabled ports
39 */ 39 */
40 40
41static int ns87410_pre_reset(struct ata_port *ap, unsigned long deadline) 41static int ns87410_pre_reset(struct ata_link *link, unsigned long deadline)
42{ 42{
43 struct ata_port *ap = link->ap;
43 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 44 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
44 static const struct pci_bits ns87410_enable_bits[] = { 45 static const struct pci_bits ns87410_enable_bits[] = {
45 { 0x43, 1, 0x08, 0x08 }, 46 { 0x43, 1, 0x08, 0x08 },
@@ -49,7 +50,7 @@ static int ns87410_pre_reset(struct ata_port *ap, unsigned long deadline)
49 if (!pci_test_config_bits(pdev, &ns87410_enable_bits[ap->port_no])) 50 if (!pci_test_config_bits(pdev, &ns87410_enable_bits[ap->port_no]))
50 return -ENOENT; 51 return -ENOENT;
51 52
52 return ata_std_prereset(ap, deadline); 53 return ata_std_prereset(link, deadline);
53} 54}
54 55
55/** 56/**
diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c
index 091a70a0ef1c..5b2c86fe9fc2 100644
--- a/drivers/ata/pata_oldpiix.c
+++ b/drivers/ata/pata_oldpiix.c
@@ -29,14 +29,15 @@
29 29
30/** 30/**
31 * oldpiix_pre_reset - probe begin 31 * oldpiix_pre_reset - probe begin
32 * @ap: ATA port 32 * @link: ATA link
33 * @deadline: deadline jiffies for the operation 33 * @deadline: deadline jiffies for the operation
34 * 34 *
35 * Set up cable type and use generic probe init 35 * Set up cable type and use generic probe init
36 */ 36 */
37 37
38static int oldpiix_pre_reset(struct ata_port *ap, unsigned long deadline) 38static int oldpiix_pre_reset(struct ata_link *link, unsigned long deadline)
39{ 39{
40 struct ata_port *ap = link->ap;
40 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 41 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
41 static const struct pci_bits oldpiix_enable_bits[] = { 42 static const struct pci_bits oldpiix_enable_bits[] = {
42 { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */ 43 { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */
@@ -46,7 +47,7 @@ static int oldpiix_pre_reset(struct ata_port *ap, unsigned long deadline)
46 if (!pci_test_config_bits(pdev, &oldpiix_enable_bits[ap->port_no])) 47 if (!pci_test_config_bits(pdev, &oldpiix_enable_bits[ap->port_no]))
47 return -ENOENT; 48 return -ENOENT;
48 49
49 return ata_std_prereset(ap, deadline); 50 return ata_std_prereset(link, deadline);
50} 51}
51 52
52/** 53/**
diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c
index 458bf67f766f..5770c7755a62 100644
--- a/drivers/ata/pata_opti.c
+++ b/drivers/ata/pata_opti.c
@@ -46,14 +46,15 @@ enum {
46 46
47/** 47/**
48 * opti_pre_reset - probe begin 48 * opti_pre_reset - probe begin
49 * @ap: ATA port 49 * @link: ATA link
50 * @deadline: deadline jiffies for the operation 50 * @deadline: deadline jiffies for the operation
51 * 51 *
52 * Set up cable type and use generic probe init 52 * Set up cable type and use generic probe init
53 */ 53 */
54 54
55static int opti_pre_reset(struct ata_port *ap, unsigned long deadline) 55static int opti_pre_reset(struct ata_link *link, unsigned long deadline)
56{ 56{
57 struct ata_port *ap = link->ap;
57 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 58 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
58 static const struct pci_bits opti_enable_bits[] = { 59 static const struct pci_bits opti_enable_bits[] = {
59 { 0x45, 1, 0x80, 0x00 }, 60 { 0x45, 1, 0x80, 0x00 },
@@ -63,7 +64,7 @@ static int opti_pre_reset(struct ata_port *ap, unsigned long deadline)
63 if (!pci_test_config_bits(pdev, &opti_enable_bits[ap->port_no])) 64 if (!pci_test_config_bits(pdev, &opti_enable_bits[ap->port_no]))
64 return -ENOENT; 65 return -ENOENT;
65 66
66 return ata_std_prereset(ap, deadline); 67 return ata_std_prereset(link, deadline);
67} 68}
68 69
69/** 70/**
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c
index f8234d7fd825..39fcba800077 100644
--- a/drivers/ata/pata_optidma.c
+++ b/drivers/ata/pata_optidma.c
@@ -47,14 +47,15 @@ static int pci_clock; /* 0 = 33 1 = 25 */
47 47
48/** 48/**
49 * optidma_pre_reset - probe begin 49 * optidma_pre_reset - probe begin
50 * @ap: ATA port 50 * @link: ATA link
51 * @deadline: deadline jiffies for the operation 51 * @deadline: deadline jiffies for the operation
52 * 52 *
53 * Set up cable type and use generic probe init 53 * Set up cable type and use generic probe init
54 */ 54 */
55 55
56static int optidma_pre_reset(struct ata_port *ap, unsigned long deadline) 56static int optidma_pre_reset(struct ata_link *link, unsigned long deadline)
57{ 57{
58 struct ata_port *ap = link->ap;
58 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 59 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
59 static const struct pci_bits optidma_enable_bits = { 60 static const struct pci_bits optidma_enable_bits = {
60 0x40, 1, 0x08, 0x00 61 0x40, 1, 0x08, 0x00
@@ -63,7 +64,7 @@ static int optidma_pre_reset(struct ata_port *ap, unsigned long deadline)
63 if (ap->port_no && !pci_test_config_bits(pdev, &optidma_enable_bits)) 64 if (ap->port_no && !pci_test_config_bits(pdev, &optidma_enable_bits))
64 return -ENOENT; 65 return -ENOENT;
65 66
66 return ata_std_prereset(ap, deadline); 67 return ata_std_prereset(link, deadline);
67} 68}
68 69
69/** 70/**
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index 83c90cabc7ff..ba39efbe5405 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -300,7 +300,7 @@ static inline int pdc2027x_port_enabled(struct ata_port *ap)
300 300
301/** 301/**
302 * pdc2027x_prereset - prereset for PATA host controller 302 * pdc2027x_prereset - prereset for PATA host controller
303 * @ap: Target port 303 * @link: Target link
304 * @deadline: deadline jiffies for the operation 304 * @deadline: deadline jiffies for the operation
305 * 305 *
306 * Probeinit including cable detection. 306 * Probeinit including cable detection.
@@ -309,12 +309,12 @@ static inline int pdc2027x_port_enabled(struct ata_port *ap)
309 * None (inherited from caller). 309 * None (inherited from caller).
310 */ 310 */
311 311
312static int pdc2027x_prereset(struct ata_port *ap, unsigned long deadline) 312static int pdc2027x_prereset(struct ata_link *link, unsigned long deadline)
313{ 313{
314 /* Check whether port enabled */ 314 /* Check whether port enabled */
315 if (!pdc2027x_port_enabled(ap)) 315 if (!pdc2027x_port_enabled(link->ap))
316 return -ENOENT; 316 return -ENOENT;
317 return ata_std_prereset(ap, deadline); 317 return ata_std_prereset(link, deadline);
318} 318}
319 319
320/** 320/**
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index 40395804a66f..45515a22d856 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -95,15 +95,16 @@ static int sil680_cable_detect(struct ata_port *ap) {
95 95
96/** 96/**
97 * sil680_bus_reset - reset the SIL680 bus 97 * sil680_bus_reset - reset the SIL680 bus
98 * @ap: ATA port to reset 98 * @link: ATA link to reset
99 * @deadline: deadline jiffies for the operation 99 * @deadline: deadline jiffies for the operation
100 * 100 *
101 * Perform the SIL680 housekeeping when doing an ATA bus reset 101 * Perform the SIL680 housekeeping when doing an ATA bus reset
102 */ 102 */
103 103
104static int sil680_bus_reset(struct ata_port *ap,unsigned int *classes, 104static int sil680_bus_reset(struct ata_link *link, unsigned int *classes,
105 unsigned long deadline) 105 unsigned long deadline)
106{ 106{
107 struct ata_port *ap = link->ap;
107 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 108 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
108 unsigned long addr = sil680_selreg(ap, 0); 109 unsigned long addr = sil680_selreg(ap, 0);
109 u8 reset; 110 u8 reset;
@@ -112,7 +113,7 @@ static int sil680_bus_reset(struct ata_port *ap,unsigned int *classes,
112 pci_write_config_byte(pdev, addr, reset | 0x03); 113 pci_write_config_byte(pdev, addr, reset | 0x03);
113 udelay(25); 114 udelay(25);
114 pci_write_config_byte(pdev, addr, reset); 115 pci_write_config_byte(pdev, addr, reset);
115 return ata_std_softreset(ap, classes, deadline); 116 return ata_std_softreset(link, classes, deadline);
116} 117}
117 118
118static void sil680_error_handler(struct ata_port *ap) 119static void sil680_error_handler(struct ata_port *ap)
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index 9d6f81d52e18..b72227676f00 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -133,19 +133,20 @@ static int sis_66_cable_detect(struct ata_port *ap)
133 133
134/** 134/**
135 * sis_pre_reset - probe begin 135 * sis_pre_reset - probe begin
136 * @ap: ATA port 136 * @link: ATA link
137 * @deadline: deadline jiffies for the operation 137 * @deadline: deadline jiffies for the operation
138 * 138 *
139 * Set up cable type and use generic probe init 139 * Set up cable type and use generic probe init
140 */ 140 */
141 141
142static int sis_pre_reset(struct ata_port *ap, unsigned long deadline) 142static int sis_pre_reset(struct ata_link *link, unsigned long deadline)
143{ 143{
144 static const struct pci_bits sis_enable_bits[] = { 144 static const struct pci_bits sis_enable_bits[] = {
145 { 0x4aU, 1U, 0x02UL, 0x02UL }, /* port 0 */ 145 { 0x4aU, 1U, 0x02UL, 0x02UL }, /* port 0 */
146 { 0x4aU, 1U, 0x04UL, 0x04UL }, /* port 1 */ 146 { 0x4aU, 1U, 0x04UL, 0x04UL }, /* port 1 */
147 }; 147 };
148 148
149 struct ata_port *ap = link->ap;
149 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 150 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
150 151
151 if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) 152 if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no]))
@@ -154,7 +155,7 @@ static int sis_pre_reset(struct ata_port *ap, unsigned long deadline)
154 /* Clear the FIFO settings. We can't enable the FIFO until 155 /* Clear the FIFO settings. We can't enable the FIFO until
155 we know we are poking at a disk */ 156 we know we are poking at a disk */
156 pci_write_config_byte(pdev, 0x4B, 0); 157 pci_write_config_byte(pdev, 0x4B, 0);
157 return ata_std_prereset(ap, deadline); 158 return ata_std_prereset(link, deadline);
158} 159}
159 160
160 161
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c
index c0f43bb25956..375c3705dc43 100644
--- a/drivers/ata/pata_sl82c105.c
+++ b/drivers/ata/pata_sl82c105.c
@@ -43,23 +43,24 @@ enum {
43 43
44/** 44/**
45 * sl82c105_pre_reset - probe begin 45 * sl82c105_pre_reset - probe begin
46 * @ap: ATA port 46 * @link: ATA link
47 * @deadline: deadline jiffies for the operation 47 * @deadline: deadline jiffies for the operation
48 * 48 *
49 * Set up cable type and use generic probe init 49 * Set up cable type and use generic probe init
50 */ 50 */
51 51
52static int sl82c105_pre_reset(struct ata_port *ap, unsigned long deadline) 52static int sl82c105_pre_reset(struct ata_link *link, unsigned long deadline)
53{ 53{
54 static const struct pci_bits sl82c105_enable_bits[] = { 54 static const struct pci_bits sl82c105_enable_bits[] = {
55 { 0x40, 1, 0x01, 0x01 }, 55 { 0x40, 1, 0x01, 0x01 },
56 { 0x40, 1, 0x10, 0x10 } 56 { 0x40, 1, 0x10, 0x10 }
57 }; 57 };
58 struct ata_port *ap = link->ap;
58 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 59 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
59 60
60 if (ap->port_no && !pci_test_config_bits(pdev, &sl82c105_enable_bits[ap->port_no])) 61 if (ap->port_no && !pci_test_config_bits(pdev, &sl82c105_enable_bits[ap->port_no]))
61 return -ENOENT; 62 return -ENOENT;
62 return ata_std_prereset(ap, deadline); 63 return ata_std_prereset(link, deadline);
63} 64}
64 65
65 66
diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c
index af21f443db6e..bc4b6f6be963 100644
--- a/drivers/ata/pata_triflex.c
+++ b/drivers/ata/pata_triflex.c
@@ -47,25 +47,26 @@
47 47
48/** 48/**
49 * triflex_prereset - probe begin 49 * triflex_prereset - probe begin
50 * @ap: ATA port 50 * @link: ATA link
51 * @deadline: deadline jiffies for the operation 51 * @deadline: deadline jiffies for the operation
52 * 52 *
53 * Set up cable type and use generic probe init 53 * Set up cable type and use generic probe init
54 */ 54 */
55 55
56static int triflex_prereset(struct ata_port *ap, unsigned long deadline) 56static int triflex_prereset(struct ata_link *link, unsigned long deadline)
57{ 57{
58 static const struct pci_bits triflex_enable_bits[] = { 58 static const struct pci_bits triflex_enable_bits[] = {
59 { 0x80, 1, 0x01, 0x01 }, 59 { 0x80, 1, 0x01, 0x01 },
60 { 0x80, 1, 0x02, 0x02 } 60 { 0x80, 1, 0x02, 0x02 }
61 }; 61 };
62 62
63 struct ata_port *ap = link->ap;
63 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 64 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
64 65
65 if (!pci_test_config_bits(pdev, &triflex_enable_bits[ap->port_no])) 66 if (!pci_test_config_bits(pdev, &triflex_enable_bits[ap->port_no]))
66 return -ENOENT; 67 return -ENOENT;
67 68
68 return ata_std_prereset(ap, deadline); 69 return ata_std_prereset(link, deadline);
69} 70}
70 71
71 72
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index f143db4559e0..b612808a319e 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -187,8 +187,9 @@ static int via_cable_detect(struct ata_port *ap) {
187 return ATA_CBL_PATA40; 187 return ATA_CBL_PATA40;
188} 188}
189 189
190static int via_pre_reset(struct ata_port *ap, unsigned long deadline) 190static int via_pre_reset(struct ata_link *link, unsigned long deadline)
191{ 191{
192 struct ata_port *ap = link->ap;
192 const struct via_isa_bridge *config = ap->host->private_data; 193 const struct via_isa_bridge *config = ap->host->private_data;
193 194
194 if (!(config->flags & VIA_NO_ENABLES)) { 195 if (!(config->flags & VIA_NO_ENABLES)) {
@@ -201,7 +202,7 @@ static int via_pre_reset(struct ata_port *ap, unsigned long deadline)
201 return -ENOENT; 202 return -ENOENT;
202 } 203 }
203 204
204 return ata_std_prereset(ap, deadline); 205 return ata_std_prereset(link, deadline);
205} 206}
206 207
207 208
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index f2b1bea934bc..95caba0f910e 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -417,12 +417,13 @@ static void inic_thaw(struct ata_port *ap)
417 * SRST and SControl hardreset don't give valid signature on this 417 * SRST and SControl hardreset don't give valid signature on this
418 * controller. Only controller specific hardreset mechanism works. 418 * controller. Only controller specific hardreset mechanism works.
419 */ 419 */
420static int inic_hardreset(struct ata_port *ap, unsigned int *class, 420static int inic_hardreset(struct ata_link *link, unsigned int *class,
421 unsigned long deadline) 421 unsigned long deadline)
422{ 422{
423 struct ata_port *ap = link->ap;
423 void __iomem *port_base = inic_port_base(ap); 424 void __iomem *port_base = inic_port_base(ap);
424 void __iomem *idma_ctl = port_base + PORT_IDMA_CTL; 425 void __iomem *idma_ctl = port_base + PORT_IDMA_CTL;
425 const unsigned long *timing = sata_ehc_deb_timing(&ap->link.eh_context); 426 const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context);
426 u16 val; 427 u16 val;
427 int rc; 428 int rc;
428 429
@@ -435,15 +436,15 @@ static int inic_hardreset(struct ata_port *ap, unsigned int *class,
435 msleep(1); 436 msleep(1);
436 writew(val & ~IDMA_CTL_RST_ATA, idma_ctl); 437 writew(val & ~IDMA_CTL_RST_ATA, idma_ctl);
437 438
438 rc = sata_link_resume(&ap->link, timing, deadline); 439 rc = sata_link_resume(link, timing, deadline);
439 if (rc) { 440 if (rc) {
440 ata_port_printk(ap, KERN_WARNING, "failed to resume " 441 ata_link_printk(link, KERN_WARNING, "failed to resume "
441 "link after reset (errno=%d)\n", rc); 442 "link after reset (errno=%d)\n", rc);
442 return rc; 443 return rc;
443 } 444 }
444 445
445 *class = ATA_DEV_NONE; 446 *class = ATA_DEV_NONE;
446 if (ata_link_online(&ap->link)) { 447 if (ata_link_online(link)) {
447 struct ata_taskfile tf; 448 struct ata_taskfile tf;
448 449
449 /* wait a while before checking status */ 450 /* wait a while before checking status */
@@ -452,7 +453,7 @@ static int inic_hardreset(struct ata_port *ap, unsigned int *class,
452 rc = ata_wait_ready(ap, deadline); 453 rc = ata_wait_ready(ap, deadline);
453 /* link occupied, -ENODEV too is an error */ 454 /* link occupied, -ENODEV too is an error */
454 if (rc) { 455 if (rc) {
455 ata_port_printk(ap, KERN_WARNING, "device not ready " 456 ata_link_printk(link, KERN_WARNING, "device not ready "
456 "after hardreset (errno=%d)\n", rc); 457 "after hardreset (errno=%d)\n", rc);
457 return rc; 458 return rc;
458 } 459 }
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 8e63c60adaff..56784ce10544 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -2266,10 +2266,11 @@ comreset_retry:
2266 VPRINTK("EXIT\n"); 2266 VPRINTK("EXIT\n");
2267} 2267}
2268 2268
2269static int mv_prereset(struct ata_port *ap, unsigned long deadline) 2269static int mv_prereset(struct ata_link *link, unsigned long deadline)
2270{ 2270{
2271 struct ata_port *ap = link->ap;
2271 struct mv_port_priv *pp = ap->private_data; 2272 struct mv_port_priv *pp = ap->private_data;
2272 struct ata_eh_context *ehc = &ap->link.eh_context; 2273 struct ata_eh_context *ehc = &link->eh_context;
2273 int rc; 2274 int rc;
2274 2275
2275 rc = mv_stop_dma(ap); 2276 rc = mv_stop_dma(ap);
@@ -2285,7 +2286,7 @@ static int mv_prereset(struct ata_port *ap, unsigned long deadline)
2285 if (ehc->i.action & ATA_EH_HARDRESET) 2286 if (ehc->i.action & ATA_EH_HARDRESET)
2286 return 0; 2287 return 0;
2287 2288
2288 if (ata_link_online(&ap->link)) 2289 if (ata_link_online(link))
2289 rc = ata_wait_ready(ap, deadline); 2290 rc = ata_wait_ready(ap, deadline);
2290 else 2291 else
2291 rc = -ENODEV; 2292 rc = -ENODEV;
@@ -2293,9 +2294,10 @@ static int mv_prereset(struct ata_port *ap, unsigned long deadline)
2293 return rc; 2294 return rc;
2294} 2295}
2295 2296
2296static int mv_hardreset(struct ata_port *ap, unsigned int *class, 2297static int mv_hardreset(struct ata_link *link, unsigned int *class,
2297 unsigned long deadline) 2298 unsigned long deadline)
2298{ 2299{
2300 struct ata_port *ap = link->ap;
2299 struct mv_host_priv *hpriv = ap->host->private_data; 2301 struct mv_host_priv *hpriv = ap->host->private_data;
2300 void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR]; 2302 void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR];
2301 2303
@@ -2308,16 +2310,17 @@ static int mv_hardreset(struct ata_port *ap, unsigned int *class,
2308 return 0; 2310 return 0;
2309} 2311}
2310 2312
2311static void mv_postreset(struct ata_port *ap, unsigned int *classes) 2313static void mv_postreset(struct ata_link *link, unsigned int *classes)
2312{ 2314{
2315 struct ata_port *ap = link->ap;
2313 u32 serr; 2316 u32 serr;
2314 2317
2315 /* print link status */ 2318 /* print link status */
2316 sata_print_link_status(&ap->link); 2319 sata_print_link_status(link);
2317 2320
2318 /* clear SError */ 2321 /* clear SError */
2319 sata_scr_read(&ap->link, SCR_ERROR, &serr); 2322 sata_scr_read(link, SCR_ERROR, &serr);
2320 sata_scr_write_flush(&ap->link, SCR_ERROR, serr); 2323 sata_scr_write_flush(link, SCR_ERROR, serr);
2321 2324
2322 /* bail out if no device is present */ 2325 /* bail out if no device is present */
2323 if (classes[0] == ATA_DEV_NONE && classes[1] == ATA_DEV_NONE) { 2326 if (classes[0] == ATA_DEV_NONE && classes[1] == ATA_DEV_NONE) {
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index df4d50dcffbc..67ba0f75f1e9 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -1459,7 +1459,7 @@ static void nv_ck804_thaw(struct ata_port *ap)
1459 writeb(mask, mmio_base + NV_INT_ENABLE_CK804); 1459 writeb(mask, mmio_base + NV_INT_ENABLE_CK804);
1460} 1460}
1461 1461
1462static int nv_hardreset(struct ata_port *ap, unsigned int *class, 1462static int nv_hardreset(struct ata_link *link, unsigned int *class,
1463 unsigned long deadline) 1463 unsigned long deadline)
1464{ 1464{
1465 unsigned int dummy; 1465 unsigned int dummy;
@@ -1468,7 +1468,7 @@ static int nv_hardreset(struct ata_port *ap, unsigned int *class,
1468 * some controllers. Don't classify on hardreset. For more 1468 * some controllers. Don't classify on hardreset. For more
1469 * info, see http://bugme.osdl.org/show_bug.cgi?id=3352 1469 * info, see http://bugme.osdl.org/show_bug.cgi?id=3352
1470 */ 1470 */
1471 return sata_std_hardreset(ap, &dummy, deadline); 1471 return sata_std_hardreset(link, &dummy, deadline);
1472} 1472}
1473 1473
1474static void nv_error_handler(struct ata_port *ap) 1474static void nv_error_handler(struct ata_port *ap)
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index 0cd40d5215fe..869e414d7ed3 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -583,9 +583,10 @@ static int sil24_exec_polled_cmd(struct ata_port *ap, int pmp,
583 return rc; 583 return rc;
584} 584}
585 585
586static int sil24_do_softreset(struct ata_port *ap, unsigned int *class, 586static int sil24_do_softreset(struct ata_link *link, unsigned int *class,
587 int pmp, unsigned long deadline) 587 int pmp, unsigned long deadline)
588{ 588{
589 struct ata_port *ap = link->ap;
589 unsigned long timeout_msec = 0; 590 unsigned long timeout_msec = 0;
590 struct ata_taskfile tf; 591 struct ata_taskfile tf;
591 const char *reason; 592 const char *reason;
@@ -593,7 +594,7 @@ static int sil24_do_softreset(struct ata_port *ap, unsigned int *class,
593 594
594 DPRINTK("ENTER\n"); 595 DPRINTK("ENTER\n");
595 596
596 if (ata_link_offline(&ap->link)) { 597 if (ata_link_offline(link)) {
597 DPRINTK("PHY reports no device\n"); 598 DPRINTK("PHY reports no device\n");
598 *class = ATA_DEV_NONE; 599 *class = ATA_DEV_NONE;
599 goto out; 600 goto out;
@@ -609,7 +610,7 @@ static int sil24_do_softreset(struct ata_port *ap, unsigned int *class,
609 if (time_after(deadline, jiffies)) 610 if (time_after(deadline, jiffies))
610 timeout_msec = jiffies_to_msecs(deadline - jiffies); 611 timeout_msec = jiffies_to_msecs(deadline - jiffies);
611 612
612 ata_tf_init(ap->link.device, &tf); /* doesn't really matter */ 613 ata_tf_init(link->device, &tf); /* doesn't really matter */
613 rc = sil24_exec_polled_cmd(ap, pmp, &tf, 0, PRB_CTRL_SRST, 614 rc = sil24_exec_polled_cmd(ap, pmp, &tf, 0, PRB_CTRL_SRST,
614 timeout_msec); 615 timeout_msec);
615 if (rc == -EBUSY) { 616 if (rc == -EBUSY) {
@@ -631,29 +632,30 @@ static int sil24_do_softreset(struct ata_port *ap, unsigned int *class,
631 return 0; 632 return 0;
632 633
633 err: 634 err:
634 ata_port_printk(ap, KERN_ERR, "softreset failed (%s)\n", reason); 635 ata_link_printk(link, KERN_ERR, "softreset failed (%s)\n", reason);
635 return -EIO; 636 return -EIO;
636} 637}
637 638
638static int sil24_softreset(struct ata_port *ap, unsigned int *class, 639static int sil24_softreset(struct ata_link *link, unsigned int *class,
639 unsigned long deadline) 640 unsigned long deadline)
640{ 641{
641 return sil24_do_softreset(ap, class, 0, deadline); 642 return sil24_do_softreset(link, class, 0, deadline);
642} 643}
643 644
644static int sil24_hardreset(struct ata_port *ap, unsigned int *class, 645static int sil24_hardreset(struct ata_link *link, unsigned int *class,
645 unsigned long deadline) 646 unsigned long deadline)
646{ 647{
648 struct ata_port *ap = link->ap;
647 void __iomem *port = ap->ioaddr.cmd_addr; 649 void __iomem *port = ap->ioaddr.cmd_addr;
648 const char *reason; 650 const char *reason;
649 int tout_msec, rc; 651 int tout_msec, rc;
650 u32 tmp; 652 u32 tmp;
651 653
652 /* sil24 does the right thing(tm) without any protection */ 654 /* sil24 does the right thing(tm) without any protection */
653 sata_set_spd(&ap->link); 655 sata_set_spd(link);
654 656
655 tout_msec = 100; 657 tout_msec = 100;
656 if (ata_link_online(&ap->link)) 658 if (ata_link_online(link))
657 tout_msec = 5000; 659 tout_msec = 5000;
658 660
659 writel(PORT_CS_DEV_RST, port + PORT_CTRL_STAT); 661 writel(PORT_CS_DEV_RST, port + PORT_CTRL_STAT);
@@ -663,14 +665,14 @@ static int sil24_hardreset(struct ata_port *ap, unsigned int *class,
663 /* SStatus oscillates between zero and valid status after 665 /* SStatus oscillates between zero and valid status after
664 * DEV_RST, debounce it. 666 * DEV_RST, debounce it.
665 */ 667 */
666 rc = sata_link_debounce(&ap->link, sata_deb_timing_long, deadline); 668 rc = sata_link_debounce(link, sata_deb_timing_long, deadline);
667 if (rc) { 669 if (rc) {
668 reason = "PHY debouncing failed"; 670 reason = "PHY debouncing failed";
669 goto err; 671 goto err;
670 } 672 }
671 673
672 if (tmp & PORT_CS_DEV_RST) { 674 if (tmp & PORT_CS_DEV_RST) {
673 if (ata_link_offline(&ap->link)) 675 if (ata_link_offline(link))
674 return 0; 676 return 0;
675 reason = "link not ready"; 677 reason = "link not ready";
676 goto err; 678 goto err;
@@ -685,7 +687,7 @@ static int sil24_hardreset(struct ata_port *ap, unsigned int *class,
685 return -EAGAIN; 687 return -EAGAIN;
686 688
687 err: 689 err:
688 ata_port_printk(ap, KERN_ERR, "hardreset failed (%s)\n", reason); 690 ata_link_printk(link, KERN_ERR, "hardreset failed (%s)\n", reason);
689 return -EIO; 691 return -EIO;
690} 692}
691 693
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index 78a6833af713..690280660b81 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -276,7 +276,7 @@ static void svia_noop_freeze(struct ata_port *ap)
276 276
277/** 277/**
278 * vt6420_prereset - prereset for vt6420 278 * vt6420_prereset - prereset for vt6420
279 * @ap: target ATA port 279 * @link: target ATA link
280 * @deadline: deadline jiffies for the operation 280 * @deadline: deadline jiffies for the operation
281 * 281 *
282 * SCR registers on vt6420 are pieces of shit and may hang the 282 * SCR registers on vt6420 are pieces of shit and may hang the
@@ -294,8 +294,9 @@ static void svia_noop_freeze(struct ata_port *ap)
294 * RETURNS: 294 * RETURNS:
295 * 0 on success, -errno otherwise. 295 * 0 on success, -errno otherwise.
296 */ 296 */
297static int vt6420_prereset(struct ata_port *ap, unsigned long deadline) 297static int vt6420_prereset(struct ata_link *link, unsigned long deadline)
298{ 298{
299 struct ata_port *ap = link->ap;
299 struct ata_eh_context *ehc = &ap->link.eh_context; 300 struct ata_eh_context *ehc = &ap->link.eh_context;
300 unsigned long timeout = jiffies + (HZ * 5); 301 unsigned long timeout = jiffies + (HZ * 5);
301 u32 sstatus, scontrol; 302 u32 sstatus, scontrol;
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index affd77aafb23..9350fbf39f77 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -3829,18 +3829,18 @@ static int ipr_device_reset(struct ipr_ioa_cfg *ioa_cfg,
3829 3829
3830/** 3830/**
3831 * ipr_sata_reset - Reset the SATA port 3831 * ipr_sata_reset - Reset the SATA port
3832 * @ap: SATA port to reset 3832 * @link: SATA link to reset
3833 * @classes: class of the attached device 3833 * @classes: class of the attached device
3834 * 3834 *
3835 * This function issues a SATA phy reset to the affected ATA port. 3835 * This function issues a SATA phy reset to the affected ATA link.
3836 * 3836 *
3837 * Return value: 3837 * Return value:
3838 * 0 on success / non-zero on failure 3838 * 0 on success / non-zero on failure
3839 **/ 3839 **/
3840static int ipr_sata_reset(struct ata_port *ap, unsigned int *classes, 3840static int ipr_sata_reset(struct ata_link *link, unsigned int *classes,
3841 unsigned long deadline) 3841 unsigned long deadline)
3842{ 3842{
3843 struct ipr_sata_port *sata_port = ap->private_data; 3843 struct ipr_sata_port *sata_port = link->ap->private_data;
3844 struct ipr_ioa_cfg *ioa_cfg = sata_port->ioa_cfg; 3844 struct ipr_ioa_cfg *ioa_cfg = sata_port->ioa_cfg;
3845 struct ipr_resource_entry *res; 3845 struct ipr_resource_entry *res;
3846 unsigned long lock_flags = 0; 3846 unsigned long lock_flags = 0;