I make a function like this
trace_printk(\"111111\");
udelay(4000);
trace_printk(\"222222\");
and the log shows it\'s 4.01 ms , it\'OK
As you've already noticed, the nanosecond delay implementation is quite a coarse approximation compared to the millisecond delay, because of the 0x5
constant factor used. 0x10c7 / 0x5
is approximately 859. Using 0x4
would be closer to 1000 (approximately 1073).
However, using 0x4 would cause the ndelay
to be less than the number of nanoseconds requested. In general, delay functions aim to provide a delay at least as long as requested by the user (see here: http://practicepeople.blogspot.jp/2013/08/kernel-programming-busy-waiting-delay.html).