On Mon, 21 Oct 2013 23:55:44 +0200
Stefan Tauner <stefan.tauner(a)student.tuwien.ac.at> wrote:
> 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.
>
> Signed-off-by: Stefan Tauner <stefan.tauner(a)student.tuwien.ac.at>
> ---
> flash.h | 2 +-
> flashrom.c | 2 +-
> programmer.h | 10 +++++-----
> serprog.c | 2 +-
> udelay.c | 10 +++++-----
> 5 files changed, 13 insertions(+), 13 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/programmer.h b/programmer.h
> index ef96c9e..b3df981 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 */
> @@ -654,7 +654,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 237db7d..8a952d4 100644
> --- a/serprog.c
> +++ b/serprog.c
> @@ -865,7 +865,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);
> }
I have also modified all callees which just required new local types
but no other changes.
Acked-by: Stefan Tauner <stefan.tauner(a)alumni.tuwien.ac.at>
and committed in r1782.
--
Kind regards/Mit freundlichen Grüßen, Stefan Tauner