Thread (34 messages) 34 messages, 7 authors, 2013-08-24
STALE4685d
Revisions (9)
  1. v1 [diff vs current]
  2. v1 [diff vs current]
  3. v1 [diff vs current]
  4. v1 [diff vs current]
  5. v1 [diff vs current]
  6. v1 current
  7. v1 [diff vs current]
  8. v2 [diff vs current]
  9. v3 [diff vs current]

[PATCH V1 4/5] spi: Add Freescale QuadSpi driver

From: computersforpeace@gmail.com (Brian Norris)
Date: 2013-08-24 07:11:08

On 08/23/2013 09:44 AM, Mark Brown wrote:
On Mon, Aug 19, 2013 at 12:10:02PM +0800, Huang Shijie wrote:
quoted
+static int fsl_qspi_wait_till_ready(struct fsl_qspi *q)
+{
+	unsigned long deadline;
+	u32 sr;
+
+	deadline = jiffies + msecs_to_jiffies(40000);
+
+	do {
+		if ((sr = fsl_qspi_read_sr(q)) < 0)
+			break;
+		else if (!(sr & SR_WIP))
+			return 0;
+
+		cond_resched();
+
+	} while (!time_after_eq(jiffies, deadline));
+
+	return 1;
+}
Return an error code if we time out?
You also need to check that you didn't complete between your last 
fsl_qspi_read_sr() and the time_arter_eq() check. Theoretically, there 
could be a lot of time between them (due to cond_resched(), for 
instance). 40000 milliseconds is also a lot of time, but still...

IOW, add a check before the "return -ESOMETHING", something like this:

if (!(fsl_qspi_read_sr(q) & SR_WIP))
	return 0;

Brian
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help