]> git.sur5r.net Git - u-boot/commitdiff
st_smi: Fix smi read status
authorVipin Kumar <vipin.kumar@st.com>
Mon, 7 May 2012 07:30:25 +0000 (13:00 +0530)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Sat, 7 Jul 2012 12:07:39 +0000 (14:07 +0200)
smi_read_sr fails sometimes because of TFF not getting set within assumed time.
This condition may arise because of, for example, smi memory being in a erase
mode.

This fix is to enable reading the status register until timeout.

Signed-off-by: Vipin Kumar <vipin.kumar@st.com>
Signed-off-by: Amit Virdi <amit.virdi@st.com>
Signed-off-by: Stefan Roese <sr@denx.de>
drivers/mtd/st_smi.c

index 8c276036af78d714dcf59a6db470d63c79aef5bd..38f22b736e6e657e3ef8095f825280d958c7cd3d 100644 (file)
@@ -188,9 +188,7 @@ static int smi_wait_till_ready(int bank, int timeout)
           but potentially three seconds (!) after page erase. */
        do {
                sr = smi_read_sr(bank);
-               if (sr < 0)
-                       continue;       /* try until timeout */
-               else if (!(sr & WIP_BIT))
+               if ((sr >= 0) && (!(sr & WIP_BIT)))
                        return 0;
 
                /* Try again after 1m-sec */
@@ -231,9 +229,7 @@ static int smi_write_enable(int bank)
 
        do {
                sr = smi_read_sr(bank);
-               if (sr < 0)
-                       break;
-               else if (sr & (1 << (bank + WM_SHIFT)))
+               if ((sr >= 0) && (sr & (1 << (bank + WM_SHIFT))))
                        return 0;
 
                /* Try again after 1m-sec */