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>
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 */
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 */