[PATCH 1/4] ata: libata-sata: Simplify sata_link_resume() interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When called directly outside of sata_link_hardreset(), the debounce
timing array passed to sata_link_resume() is always the array returned
by sata_ehc_deb_timing() for the target link. Based on this, the
interface of sata_link_resume() can be simplified by removing the
params argument. The timing array is infered locally using
sata_ehc_deb_timing().

To allow sata_link_hardreset() to specify a timing array, the helper
function __sata_link_resume() is introduced and sata_link_resume()
implemented using this helper.

Signed-off-by: Damien Le Moal <damien.lemoal@xxxxxxxxxxxxxxxxxx>
---
 drivers/ata/libata-core.c   |  3 +--
 drivers/ata/libata-sata.c   | 42 +++++++++++++++++++++----------------
 drivers/ata/sata_inic162x.c |  3 +--
 drivers/ata/sata_nv.c       |  3 +--
 include/linux/libata.h      |  4 +---
 5 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index cceedde51126..1bdb6e78f0ed 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3575,7 +3575,6 @@ int ata_std_prereset(struct ata_link *link, unsigned long deadline)
 {
 	struct ata_port *ap = link->ap;
 	struct ata_eh_context *ehc = &link->eh_context;
-	const unsigned long *timing = sata_ehc_deb_timing(ehc);
 	int rc;
 
 	/* if we're about to do hardreset, nothing more to do */
@@ -3584,7 +3583,7 @@ int ata_std_prereset(struct ata_link *link, unsigned long deadline)
 
 	/* if SATA, resume link */
 	if (ap->flags & ATA_FLAG_SATA) {
-		rc = sata_link_resume(link, timing, deadline);
+		rc = sata_link_resume(link, deadline);
 		/* whine about phy resume failure but proceed */
 		if (rc && rc != -EOPNOTSUPP)
 			ata_link_warn(link,
diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
index 044a16daa2d4..86f1475e5bca 100644
--- a/drivers/ata/libata-sata.c
+++ b/drivers/ata/libata-sata.c
@@ -279,22 +279,9 @@ int sata_link_debounce(struct ata_link *link, const unsigned long *params,
 }
 EXPORT_SYMBOL_GPL(sata_link_debounce);
 
-/**
- *	sata_link_resume - resume SATA link
- *	@link: ATA link to resume SATA
- *	@params: timing parameters { interval, duration, timeout } in msec
- *	@deadline: deadline jiffies for the operation
- *
- *	Resume SATA phy @link and debounce it.
- *
- *	LOCKING:
- *	Kernel thread context (may sleep)
- *
- *	RETURNS:
- *	0 on success, -errno on failure.
- */
-int sata_link_resume(struct ata_link *link, const unsigned long *params,
-		     unsigned long deadline)
+static int __sata_link_resume(struct ata_link *link,
+			      const unsigned long *timing,
+			      unsigned long deadline)
 {
 	int tries = ATA_LINK_RESUME_TRIES;
 	u32 scontrol, serror;
@@ -335,7 +322,7 @@ int sata_link_resume(struct ata_link *link, const unsigned long *params,
 		ata_link_warn(link, "link resume succeeded after %d retries\n",
 			      ATA_LINK_RESUME_TRIES - tries);
 
-	if ((rc = sata_link_debounce(link, params, deadline)))
+	if ((rc = sata_link_debounce(link, timing, deadline)))
 		return rc;
 
 	/* clear SError, some PHYs require this even for SRST to work */
@@ -344,6 +331,25 @@ int sata_link_resume(struct ata_link *link, const unsigned long *params,
 
 	return rc != -EINVAL ? rc : 0;
 }
+
+/**
+ *	sata_link_resume - resume SATA link
+ *	@link: ATA link to resume SATA
+ *	@deadline: deadline jiffies for the operation
+ *
+ *	Resume SATA phy @link and debounce it.
+ *
+ *	LOCKING:
+ *	Kernel thread context (may sleep)
+ *
+ *	RETURNS:
+ *	0 on success, -errno on failure.
+ */
+int sata_link_resume(struct ata_link *link, unsigned long deadline)
+{
+	return __sata_link_resume(link,
+			sata_ehc_deb_timing(&link->eh_context), deadline);
+}
 EXPORT_SYMBOL_GPL(sata_link_resume);
 
 /**
@@ -568,7 +574,7 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
 	ata_msleep(link->ap, 1);
 
 	/* bring link back */
-	rc = sata_link_resume(link, timing, deadline);
+	rc = __sata_link_resume(link, timing, deadline);
 	if (rc)
 		goto out;
 	/* if link is offline nothing more to do */
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index 11e518f0111c..8d4d041cc724 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -621,7 +621,6 @@ static int inic_hardreset(struct ata_link *link, unsigned int *class,
 	struct ata_port *ap = link->ap;
 	void __iomem *port_base = inic_port_base(ap);
 	void __iomem *idma_ctl = port_base + PORT_IDMA_CTL;
-	const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context);
 	int rc;
 
 	/* hammer it into sane state */
@@ -632,7 +631,7 @@ static int inic_hardreset(struct ata_link *link, unsigned int *class,
 	ata_msleep(ap, 1);
 	writew(0, idma_ctl);
 
-	rc = sata_link_resume(link, timing, deadline);
+	rc = sata_link_resume(link, deadline);
 	if (rc) {
 		ata_link_warn(link,
 			      "failed to resume link after reset (errno=%d)\n",
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 7f14d0d31057..b5f27eac86b1 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -1529,7 +1529,6 @@ static int nv_hardreset(struct ata_link *link, unsigned int *class,
 		sata_link_hardreset(link, sata_deb_timing_hotplug, deadline,
 				    NULL, NULL);
 	else {
-		const unsigned long *timing = sata_ehc_deb_timing(ehc);
 		int rc;
 
 		if (!(ehc->i.flags & ATA_EHI_QUIET))
@@ -1537,7 +1536,7 @@ static int nv_hardreset(struct ata_link *link, unsigned int *class,
 				      "nv: skipping hardreset on occupied port\n");
 
 		/* make sure the link is online */
-		rc = sata_link_resume(link, timing, deadline);
+		rc = sata_link_resume(link, deadline);
 		/* whine about phy resume failure but proceed */
 		if (rc && rc != -EOPNOTSUPP)
 			ata_link_warn(link, "failed to resume link (errno=%d)\n",
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 9b1d3d8b1252..e89d612326f6 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1171,8 +1171,7 @@ extern int sata_set_spd(struct ata_link *link);
 extern int sata_link_hardreset(struct ata_link *link,
 			const unsigned long *timing, unsigned long deadline,
 			bool *online, int (*check_ready)(struct ata_link *));
-extern int sata_link_resume(struct ata_link *link, const unsigned long *params,
-			    unsigned long deadline);
+extern int sata_link_resume(struct ata_link *link, unsigned long deadline);
 extern void ata_eh_analyze_ncq_error(struct ata_link *link);
 #else
 static inline const unsigned long *
@@ -1205,7 +1204,6 @@ static inline int sata_link_hardreset(struct ata_link *link,
 	return -EOPNOTSUPP;
 }
 static inline int sata_link_resume(struct ata_link *link,
-				   const unsigned long *params,
 				   unsigned long deadline)
 {
 	return -EOPNOTSUPP;
-- 
2.35.1




[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux