Author: stefanct Date: Fri May 2 17:41:42 2014 New Revision: 1782 URL: http://flashrom.org/trac/flashrom/changeset/1782
Log: Make delay values unsigned.
There is no reason for negative delays in our use cases: - We don't need it (to work around any quirks). - sleep() (POSIX) uses an unsigned argument. - usleep() (POSIX) uses an unsigned argument. - Sleep() (Windows) uses an unsigned argument.
Change all callees as well (without any complications).
Signed-off-by: Stefan Tauner stefan.tauner@alumni.tuwien.ac.at Acked-by: Stefan Tauner stefan.tauner@alumni.tuwien.ac.at
Modified: trunk/flash.h trunk/flashrom.c trunk/jedec.c trunk/programmer.h trunk/serprog.c trunk/udelay.c
Modified: trunk/flash.h ============================================================================== --- trunk/flash.h Sun Apr 27 07:07:35 2014 (r1781) +++ trunk/flash.h Fri May 2 17:41:42 2014 (r1782) @@ -56,7 +56,7 @@ int register_shutdown(int (*function) (void *data), void *data); void *programmer_map_flash_region(const char *descr, uintptr_t phys_addr, size_t len); void programmer_unmap_flash_region(void *virt_addr, size_t len); -void programmer_delay(int usecs); +void programmer_delay(unsigned int usecs);
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
Modified: trunk/flashrom.c ============================================================================== --- trunk/flashrom.c Sun Apr 27 07:07:35 2014 (r1781) +++ trunk/flashrom.c Fri May 2 17:41:42 2014 (r1782) @@ -485,7 +485,7 @@ flash->pgm->par.chip_readn(flash, buf, addr, len); }
-void programmer_delay(int usecs) +void programmer_delay(unsigned int usecs) { if (usecs > 0) programmer_table[programmer].delay(usecs);
Modified: trunk/jedec.c ============================================================================== --- trunk/jedec.c Sun Apr 27 07:07:35 2014 (r1781) +++ trunk/jedec.c Fri May 2 17:41:42 2014 (r1782) @@ -37,8 +37,7 @@ return (val ^ (val >> 1)) & 0x1; }
-static void toggle_ready_jedec_common(const struct flashctx *flash, - chipaddr dst, int delay) +static void toggle_ready_jedec_common(const struct flashctx *flash, chipaddr dst, unsigned int delay) { unsigned int i = 0; uint8_t tmp1, tmp2; @@ -128,7 +127,7 @@ uint8_t id1, id2; uint32_t largeid1, largeid2; uint32_t flashcontent1, flashcontent2; - int probe_timing_enter, probe_timing_exit; + unsigned int probe_timing_enter, probe_timing_exit;
if (chip->probe_timing > 0) probe_timing_enter = probe_timing_exit = chip->probe_timing; @@ -245,9 +244,9 @@ unsigned int pagesize, unsigned int mask) { chipaddr bios = flash->virtual_memory; - int delay_us = 0; + unsigned int delay_us = 0; if(flash->chip->probe_timing != TIMING_ZERO) - delay_us = 10; + delay_us = 10;
/* Issue the Sector Erase command */ chip_writeb(flash, 0xAA, bios + (0x5555 & mask)); @@ -275,9 +274,9 @@ unsigned int blocksize, unsigned int mask) { chipaddr bios = flash->virtual_memory; - int delay_us = 0; + unsigned int delay_us = 0; if(flash->chip->probe_timing != TIMING_ZERO) - delay_us = 10; + delay_us = 10;
/* Issue the Sector Erase command */ chip_writeb(flash, 0xAA, bios + (0x5555 & mask)); @@ -304,9 +303,9 @@ static int erase_chip_jedec_common(struct flashctx *flash, unsigned int mask) { chipaddr bios = flash->virtual_memory; - int delay_us = 0; + unsigned int delay_us = 0; if(flash->chip->probe_timing != TIMING_ZERO) - delay_us = 10; + delay_us = 10;
/* Issue the JEDEC Chip Erase command */ chip_writeb(flash, 0xAA, bios + (0x5555 & mask));
Modified: trunk/programmer.h ============================================================================== --- trunk/programmer.h Sun Apr 27 07:07:35 2014 (r1781) +++ trunk/programmer.h Fri May 2 17:41:42 2014 (r1782) @@ -120,7 +120,7 @@ void *(*map_flash_region) (const char *descr, uintptr_t phys_addr, size_t len); void (*unmap_flash_region) (void *virt_addr, size_t len);
- void (*delay) (int usecs); + void (*delay) (unsigned int usecs); };
extern const struct programmer_entry programmer_table[]; @@ -248,10 +248,10 @@ #endif
/* udelay.c */ -void myusec_delay(int usecs); +void myusec_delay(unsigned int usecs); void myusec_calibrate_delay(void); -void internal_sleep(int usecs); -void internal_delay(int usecs); +void internal_sleep(unsigned int usecs); +void internal_delay(unsigned int usecs);
#if CONFIG_INTERNAL == 1 /* board_enable.c */ @@ -655,7 +655,7 @@ /* serprog.c */ #if CONFIG_SERPROG == 1 int serprog_init(void); -void serprog_delay(int usecs); +void serprog_delay(unsigned int usecs); #endif
/* serial.c */
Modified: trunk/serprog.c ============================================================================== --- trunk/serprog.c Sun Apr 27 07:07:35 2014 (r1781) +++ trunk/serprog.c Fri May 2 17:41:42 2014 (r1782) @@ -870,7 +870,7 @@ sp_do_read_n(&(buf[addrm-addr]), addrm, lenm); // FIXME: return error }
-void serprog_delay(int usecs) +void serprog_delay(unsigned int usecs) { unsigned char buf[4]; msg_pspew("%s usecs=%d\n", __func__, usecs);
Modified: trunk/udelay.c ============================================================================== --- trunk/udelay.c Sun Apr 27 07:07:35 2014 (r1781) +++ trunk/udelay.c Fri May 2 17:41:42 2014 (r1782) @@ -30,7 +30,7 @@ /* loops per microsecond */ static unsigned long micro = 1;
-__attribute__ ((noinline)) void myusec_delay(int usecs) +__attribute__ ((noinline)) void myusec_delay(unsigned int usecs) { unsigned long i; for (i = 0; i < usecs * micro; i++) { @@ -63,7 +63,7 @@ return timeusec; }
-static unsigned long measure_delay(int usecs) +static unsigned long measure_delay(unsigned int usecs) { unsigned long timeusec; struct timeval start, end; @@ -170,7 +170,7 @@ }
/* Not very precise sleep. */ -void internal_sleep(int usecs) +void internal_sleep(unsigned int usecs) { #ifdef _WIN32 Sleep((usecs + 999) / 1000); @@ -181,7 +181,7 @@ }
/* Precise delay. */ -void internal_delay(int usecs) +void internal_delay(unsigned int usecs) { /* If the delay is >1 s, use internal_sleep because timing does not need to be so precise. */ if (usecs > 1000000) { @@ -199,7 +199,7 @@ get_cpu_speed(); }
-void internal_delay(int usecs) +void internal_delay(unsigned int usecs) { udelay(usecs); }