Commit ca388143 authored by's avatar Committed by Tom Rini

linux/compat.h: Properly implement ndelay fallback

Commit c68c62 ("i2c: mvtwsi: Make delay times frequency-dependent")
extensively used the ndelay function with a calculated parameter
which is dependant on the configured frequency of the I2C bus. If
standard speed is employed, the parameter is usually 10000 (10000ns
period length for 100kHz frequency).

But, since the arm architecture does not implement a proper version of
ndelay, the fallback default from include/linux/compat.h is used,
which defines every ndelay as udelay(1). This causes problems for
slower speeds on arm, since the delay time is now 9us too short for
the desired frequency, which leads to random failures of the I2C

To remedy this, we implement a proper, parameter-aware ndelay fallback
for architectures that don't implement a real ndelay function.
Reported-By: default avatarJason Brown <>
To: Tom Rini <>
To: Heiko Schocher <>
Signed-off-by: default avatarMario Six <>
parent 877ea607
......@@ -15,7 +15,7 @@ struct p_current{
extern struct p_current *current;
#define ndelay(x) udelay(1)
#define ndelay(x) udelay((x) < 1000 ? 1 : (x)/1000)
#define dev_dbg(dev, fmt, args...) \
debug(fmt, ##args)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment