summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2014-05-02 15:41:42 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2014-05-02 15:41:42 +0000
commitf80419c75a344b303275e380add3b8cb750bab9d (patch)
tree124a732dd0d8c171b28649986c716af0477ca746
parentb66ed84d193b8c0eddf5d946c6d2d94a8e8360ee (diff)
downloadast2050-flashrom-f80419c75a344b303275e380add3b8cb750bab9d.zip
ast2050-flashrom-f80419c75a344b303275e380add3b8cb750bab9d.tar.gz
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). Corresponding to flashrom svn r1782. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
-rw-r--r--flash.h2
-rw-r--r--flashrom.c2
-rw-r--r--jedec.c17
-rw-r--r--programmer.h10
-rw-r--r--serprog.c2
-rw-r--r--udelay.c10
6 files changed, 21 insertions, 22 deletions
diff --git a/flash.h b/flash.h
index e320ced..bfb0a49 100644
--- a/flash.h
+++ b/flash.h
@@ -56,7 +56,7 @@ typedef uint32_t chipsize_t; /* Able to store the number of bytes of any support
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]))
diff --git a/flashrom.c b/flashrom.c
index 092572e..23728f6 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -485,7 +485,7 @@ void chip_readn(const struct flashctx *flash, uint8_t *buf, chipaddr addr,
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);
diff --git a/jedec.c b/jedec.c
index 10f5db9..be4782a 100644
--- a/jedec.c
+++ b/jedec.c
@@ -37,8 +37,7 @@ uint8_t oddparity(uint8_t val)
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 @@ static int probe_jedec_common(struct flashctx *flash, unsigned int mask)
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 @@ static int erase_sector_jedec_common(struct flashctx *flash, unsigned int page,
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 @@ static int erase_block_jedec_common(struct flashctx *flash, unsigned int block,
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_block_jedec_common(struct flashctx *flash, unsigned int block,
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));
diff --git a/programmer.h b/programmer.h
index d4d1f90..4f4cc02 100644
--- a/programmer.h
+++ b/programmer.h
@@ -120,7 +120,7 @@ struct programmer_entry {
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 @@ extern const struct board_info laptops_known[];
#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 @@ int register_programmer(struct registered_programmer *pgm);
/* serprog.c */
#if CONFIG_SERPROG == 1
int serprog_init(void);
-void serprog_delay(int usecs);
+void serprog_delay(unsigned int usecs);
#endif
/* serial.c */
diff --git a/serprog.c b/serprog.c
index 35c4f32..5f26aea 100644
--- a/serprog.c
+++ b/serprog.c
@@ -870,7 +870,7 @@ static void serprog_chip_readn(const struct flashctx *flash, uint8_t * buf,
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);
diff --git a/udelay.c b/udelay.c
index e3cf3e3..ee858b8 100644
--- a/udelay.c
+++ b/udelay.c
@@ -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 @@ static unsigned long measure_os_delay_resolution(void)
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 @@ recalibrate:
}
/* 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 @@ void internal_sleep(int usecs)
}
/* 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 @@ void myusec_calibrate_delay(void)
get_cpu_speed();
}
-void internal_delay(int usecs)
+void internal_delay(unsigned int usecs)
{
udelay(usecs);
}
OpenPOWER on IntegriCloud