diff options
author | Timur Tabi <timur@freescale.com> | 2009-05-26 10:21:42 -0500 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2009-06-23 08:09:41 -0500 |
commit | f49156ea1bf3bccf45a01351cf3db2b5f6a8597e (patch) | |
tree | 804ab76e9cdb81850249e6ca82f9c7331ba775a5 /arch/powerpc | |
parent | b71a107c66ad952c9d35ec046a803efc89a80556 (diff) | |
download | op-kernel-dev-f49156ea1bf3bccf45a01351cf3db2b5f6a8597e.zip op-kernel-dev-f49156ea1bf3bccf45a01351cf3db2b5f6a8597e.tar.gz |
powerpc/qe: add polling timeout to qe_issue_cmd()
The qe_issue_cmd() function (Freescale PowerPC QUICC Engine library) polls
on a register until a status bit changes, but does not include a timeout
to handle the situation if the bit never changes. Change the code to use
the new spin_event_timeout() macro, which simplifies polling on a register
without a timeout.
Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/sysdev/qe_lib/qe.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c index b28b0e5..237e365 100644 --- a/arch/powerpc/sysdev/qe_lib/qe.c +++ b/arch/powerpc/sysdev/qe_lib/qe.c @@ -112,6 +112,7 @@ int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input) { unsigned long flags; u8 mcn_shift = 0, dev_shift = 0; + u32 ret; spin_lock_irqsave(&qe_lock, flags); if (cmd == QE_RESET) { @@ -139,11 +140,13 @@ int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input) } /* wait for the QE_CR_FLG to clear */ - while(in_be32(&qe_immr->cp.cecr) & QE_CR_FLG) - cpu_relax(); + ret = spin_event_timeout((in_be32(&qe_immr->cp.cecr) & QE_CR_FLG) == 0, + 100, 0); + /* On timeout (e.g. failure), the expression will be false (ret == 0), + otherwise it will be true (ret == 1). */ spin_unlock_irqrestore(&qe_lock, flags); - return 0; + return ret == 1; } EXPORT_SYMBOL(qe_issue_cmd); |