{
        int state;
        ulong result;
+       ulong start;
 
        volatile u16 *addr =
                                (volatile u16 *) (info->start[sector]);
 
        /* wait until flash is ready */
        state = 0;
-       set_timer (0);
+       start = get_timer(0);
 
        do {
                result = *addr;
 
                /* check timeout */
-               if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) {
+               if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) {
                        MEM_FLASH_ADDR1 = CMD_READ_ARRAY;
                        state = ERR_TIMOUT;
                }
        ulong result;
        int cflag, iflag;
        int state;
+       ulong start;
 
        /*
         * Check if Flash is (sufficiently) erased
        *addr = data;
 
        /* arm simple, non interrupt dependent timer */
-       set_timer (0);
+       start = get_timer(0);
 
        /* wait until flash is ready */
        state = 0;
                result = *addr;
 
                /* check timeout */
-               if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) {
+               if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) {
                                state = ERR_TIMOUT;
                }
                if (!state && ((result & BIT_RDY_MASK) == (data & BIT_RDY_MASK)))
 
        int iflag, cflag, prot, sect;
        int rc = ERR_OK;
        int chip1;
+       ulong start;
 
        /* first look for protection bits */
 
                printf ("Erasing sector %2d ... ", sect);
 
                /* arm simple, non interrupt dependent timer */
-               set_timer (0);
+               start = get_timer(0);
 
                if (info->protect[sect] == 0) { /* not protected */
                        volatile u16 *addr =
                                result = *addr;
 
                                /* check timeout */
-                               if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) {
+                               if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) {
                                        MEM_FLASH_ADDR1 = CMD_READ_ARRAY;
                                        chip1 = TMO;
                                        break;
        int rc = ERR_OK;
        int cflag, iflag;
        int chip1;
+       ulong start;
 
        /*
         * Check if Flash is (sufficiently) erased
        *addr = data;
 
        /* arm simple, non interrupt dependent timer */
-       set_timer (0);
+       start = get_timer(0);
 
        /* wait until flash is ready */
        chip1 = 0;
                result = *addr;
 
                /* check timeout */
-               if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) {
+               if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) {
                        chip1 = ERR | TMO;
                        break;
                }
 
        int iflag, prot, sect;
        int rc = ERR_OK;
        int chip1;
+       ulong start;
 
        /* first look for protection bits */
 
                printf ("Erasing sector %2d ... ", sect);
 
                /* arm simple, non interrupt dependent timer */
-               set_timer (0);
+               start = get_timer(0);
 
                if (info->protect[sect] == 0) { /* not protected */
                        volatile u16 *addr =
                                result = *addr;
 
                                /* check timeout */
-                               if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) {
+                               if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) {
                                        MEM_FLASH_ADDR1 = CMD_READ_ARRAY;
                                        chip1 = TMO;
                                        break;
        int rc = ERR_OK;
        int iflag;
        int chip1;
+       ulong start;
 
        /*
         * Check if Flash is (sufficiently) erased
        *addr = data;
 
        /* arm simple, non interrupt dependent timer */
-       set_timer (0);
+       start = get_timer(0);
 
        /* wait until flash is ready */
        chip1 = 0;
                result = *addr;
 
                /* check timeout */
-               if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) {
+               if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) {
                        chip1 = ERR | TMO;
                        break;
                }