Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1351776
| From | Boris Brezillon <boris.brezillon@free-electrons.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 15/16] mtd: nand: sunxi: make use of readl_poll_timeout() |
| Date | 2016-03-07 17:30 +0100 |
| Message-ID | <ra6cI-5dM-55@gated-at.bofh.it> (permalink) |
| References | <ra630-57L-7@gated-at.bofh.it> <ra6cH-5dM-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Replace open coded polling loops by readl_poll_timeout() calls.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
drivers/mtd/nand/sunxi_nand.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index 79c90fd..002194b 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -39,7 +39,7 @@
#include <linux/dmaengine.h>
#include <linux/gpio.h>
#include <linux/interrupt.h>
-#include <linux/io.h>
+#include <linux/iopoll.h>
#define NFC_REG_CTL 0x0000
#define NFC_REG_ST 0x0004
@@ -323,33 +323,33 @@ static int sunxi_nfc_wait_int(struct sunxi_nfc *nfc, u32 flags,
static int sunxi_nfc_wait_cmd_fifo_empty(struct sunxi_nfc *nfc)
{
- unsigned long timeout = jiffies +
- msecs_to_jiffies(NFC_DEFAULT_TIMEOUT_MS);
+ u32 status;
+ int ret;
- do {
- if (!(readl(nfc->regs + NFC_REG_ST) & NFC_CMD_FIFO_STATUS))
- return 0;
- } while (time_before(jiffies, timeout));
+ ret = readl_poll_timeout(nfc->regs + NFC_REG_ST, status,
+ !(status & NFC_CMD_FIFO_STATUS), 1,
+ NFC_DEFAULT_TIMEOUT_MS * 1000);
+ if (ret)
+ dev_err(nfc->dev, "wait for empty cmd FIFO timedout\n");
- dev_err(nfc->dev, "wait for empty cmd FIFO timedout\n");
- return -ETIMEDOUT;
+ return ret;
}
static int sunxi_nfc_rst(struct sunxi_nfc *nfc)
{
- unsigned long timeout = jiffies +
- msecs_to_jiffies(NFC_DEFAULT_TIMEOUT_MS);
+ u32 ctl;
+ int ret;
writel(0, nfc->regs + NFC_REG_ECC_CTL);
writel(NFC_RESET, nfc->regs + NFC_REG_CTL);
- do {
- if (!(readl(nfc->regs + NFC_REG_CTL) & NFC_RESET))
- return 0;
- } while (time_before(jiffies, timeout));
+ ret = readl_poll_timeout(nfc->regs + NFC_REG_CTL, ctl,
+ !(ctl & NFC_RESET), 1,
+ NFC_DEFAULT_TIMEOUT_MS * 1000);
+ if (ret)
+ dev_err(nfc->dev, "wait for NAND controller reset timedout\n");
- dev_err(nfc->dev, "wait for NAND controller reset timedout\n");
- return -ETIMEDOUT;
+ return ret;
}
static int sunxi_nfc_dev_ready(struct mtd_info *mtd)
--
2.1.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/16] mtd: nand: sunxi: various improvements/fixes Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:20 +0100
[PATCH 03/16] mtd: nand: sunxi: fix EDO mode selection Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:20 +0100
[PATCH 12/16] mtd: nand: sunxi: disable clks on device removal Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
[PATCH 14/16] mtd: nand: sunxi: fix ->dev_ready() implementation Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
[PATCH 09/16] mtd: nand: sunxi: let the NAND controller control the CE line Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
[PATCH 16/16] mtd: nand: sunxi: poll for events instead of using interrupts Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
[PATCH 07/16] mtd: nand: sunxi: implement ->read_subpage() Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
[PATCH 10/16] mtd: nand: sunxi: fix the NFC_ECC_ERR_CNT() macro Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
[PATCH 13/16] mtd: nand: enable ECC pipelining Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
[PATCH 11/16] mtd: nand: sunxi: fix NFC_CTL setting Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
[PATCH 15/16] mtd: nand: sunxi: make use of readl_poll_timeout() Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
[PATCH 05/16] mtd: nand: export default read/write oob functions Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
[PATCH 08/16] mtd: nand: sunxi: improve ->cmd_ctrl() function Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
csiph-web