Skip to content

Commit

Permalink
Define MAX_UDELAY_MS
Browse files Browse the repository at this point in the history
    
If HZ was 1000, mdelay(2) cause overflow on multiplication in
__udelay.  We should define MAX_UDELAY_MS properly to prevent this.
    
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
Atsushi Nemoto authored and Ralf Baechle committed Nov 7, 2005
1 parent 53c2df2 commit a0f0820
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/asm-mips/delay.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,13 @@ static inline void __udelay(unsigned long usecs, unsigned long lpj)

#define udelay(usecs) __udelay((usecs),__udelay_val)

/* make sure "usecs *= ..." in udelay do not overflow. */
#if HZ >= 1000
#define MAX_UDELAY_MS 1
#elif HZ <= 200
#define MAX_UDELAY_MS 5
#else
#define MAX_UDELAY_MS (1000 / HZ)
#endif

#endif /* _ASM_DELAY_H */

0 comments on commit a0f0820

Please sign in to comment.