]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mtd: sh_flctl: Switch from tick-based to time-based timeout
authorBastian Hecht <hechtb@googlemail.com>
Wed, 4 Jul 2012 14:05:26 +0000 (16:05 +0200)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Fri, 24 Aug 2012 08:03:34 +0000 (11:03 +0300)
Instead of counting down a compile-time value, we use a value based on
jiffies.

Signed-off-by: Bastian Hecht <hechtb@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
drivers/mtd/nand/sh_flctl.c
include/linux/mtd/sh_flctl.h

index ed03ed2355de2e60b5d1eb87234e3b62591c9ca4..0d9cce71de37cf212dee166f9dadeadd82b36247 100644 (file)
@@ -73,6 +73,8 @@ static struct nand_bbt_descr flctl_4secc_largepage = {
        .pattern = scan_ff_pattern,
 };
 
+static int loop_timeout_max;
+
 static void empty_fifo(struct sh_flctl *flctl)
 {
        writel(flctl->flintdmacr_base | AC1CLR | AC0CLR, FLINTDMACR(flctl));
@@ -91,7 +93,7 @@ static void timeout_error(struct sh_flctl *flctl, const char *str)
 
 static void wait_completion(struct sh_flctl *flctl)
 {
-       uint32_t timeout = LOOP_TIMEOUT_MAX;
+       uint32_t timeout = loop_timeout_max;
 
        while (timeout--) {
                if (readb(FLTRCR(flctl)) & TREND) {
@@ -138,7 +140,7 @@ static void set_addr(struct mtd_info *mtd, int column, int page_addr)
 
 static void wait_rfifo_ready(struct sh_flctl *flctl)
 {
-       uint32_t timeout = LOOP_TIMEOUT_MAX;
+       uint32_t timeout = loop_timeout_max;
 
        while (timeout--) {
                uint32_t val;
@@ -153,7 +155,7 @@ static void wait_rfifo_ready(struct sh_flctl *flctl)
 
 static void wait_wfifo_ready(struct sh_flctl *flctl)
 {
-       uint32_t len, timeout = LOOP_TIMEOUT_MAX;
+       uint32_t len, timeout = loop_timeout_max;
 
        while (timeout--) {
                /* check FIFO */
@@ -168,7 +170,7 @@ static void wait_wfifo_ready(struct sh_flctl *flctl)
 static enum flctl_ecc_res_t wait_recfifo_ready
                (struct sh_flctl *flctl, int sector_number)
 {
-       uint32_t timeout = LOOP_TIMEOUT_MAX;
+       uint32_t timeout = loop_timeout_max;
        void __iomem *ecc_reg[4];
        int i;
        int state = FL_SUCCESS;
@@ -247,7 +249,7 @@ static enum flctl_ecc_res_t wait_recfifo_ready
 
 static void wait_wecfifo_ready(struct sh_flctl *flctl)
 {
-       uint32_t timeout = LOOP_TIMEOUT_MAX;
+       uint32_t timeout = loop_timeout_max;
        uint32_t len;
 
        while (timeout--) {
@@ -939,6 +941,8 @@ static int __devinit flctl_probe(struct platform_device *pdev)
        pm_runtime_enable(&pdev->dev);
        pm_runtime_resume(&pdev->dev);
 
+       loop_timeout_max = loops_per_jiffy * msecs_to_jiffies(LOOP_TIMEOUT_MS);
+
        ret = nand_scan_ident(flctl_mtd, 1, NULL);
        if (ret)
                goto err_chip;
index 01e4b15b280ec2ca6ae135248eb1817c30d1efac..ade44c1f4027b30dad2084dc3d2bfd91311ec927 100644 (file)
 #define        _4ECCEND        (0x1 << 1)      /* 4 symbols end */
 #define        _4ECCEXST       (0x1 << 0)      /* 4 symbols exist */
 
-#define LOOP_TIMEOUT_MAX       0x00010000
+#define LOOP_TIMEOUT_MS        100
 
 enum flctl_ecc_res_t {
        FL_SUCCESS,