[PATCH V1 4/5] spi: Add Freescale QuadSpi driver
Brian Norris
computersforpeace at gmail.com
Sat Aug 24 03:11:08 EDT 2013
On 08/23/2013 09:44 AM, Mark Brown wrote:
> On Mon, Aug 19, 2013 at 12:10:02PM +0800, Huang Shijie wrote:
>> +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
More information about the linux-arm-kernel
mailing list