scale=0 define gcd(a,b) { auto t; while (b) { t = b; b = a % b; a = t; } return a; } /* Division by reciprocal multiplication. */ define fmul(b,n,d) { return (2^b*n+d-1)/d; } /* Adjustment factor when a ceiling value is used. Use as: (imul * n) + (fmulxx * n + fadjxx) >> xx) */ define fadj(b,n,d) { auto v; d = d/gcd(n,d); v = 2^b*(d-1)/d; return v; } /* Compute the appropriate mul/adj values as well as a shift count, which brings the mul value into the range 2^b-1 <= x < 2^b. Such a shift value will be correct in the signed integer range and off by at most one in the upper half of the unsigned range. */ define fmuls(b,n,d) { auto s, m; for (s = 0; 1; s++) { m = fmul(s,n,d); if (m >= 2^(b-1)) return s; } return 0; } define timeconst(hz) { print "/* Automatically generated by kernel/time/timeconst.bc */\n" print "/* Time conversion constants for HZ == ", hz, " */\n" print "\n" print "#ifndef KERNEL_TIMECONST_H\n" print "#define KERNEL_TIMECONST_H\n\n" print "#include \n" print "#include \n\n" print "#if HZ != ", hz, "\n" print "#error \qinclude/generated/timeconst.h has the wrong HZ value!\q\n" print "#endif\n\n" if (hz < 2) { print "#error Totally bogus HZ value!\n" } else { s=fmuls(32,1000,hz) obase=16 print "#define HZ_TO_MSEC_MUL32\tU64_C(0x", fmul(s,1000,hz), ")\n" print "#define HZ_TO_MSEC_ADJ32\tU64_C(0x", fadj(s,1000,hz), ")\n" obase=10 print "#define HZ_TO_MSEC_SHR32\t", s, "\n" s=fmuls(32,hz,1000) obase=16 print "#define MSEC_TO_HZ_MUL32\tU64_C(0x", fmul(s,hz,1000), ")\n" print "#define MSEC_TO_HZ_ADJ32\tU64_C(0x", fadj(s,hz,1000), ")\n" obase=10 print "#define MSEC_TO_HZ_SHR32\t", s, "\n" obase=10 cd=gcd(hz,1000) print "#define HZ_TO_MSEC_NUM\t\t", 1000/cd, "\n" print "#define HZ_TO_MSEC_DEN\t\t", hz/cd, "\n" print "#define MSEC_TO_HZ_NUM\t\t", hz/cd, "\n" print "#define MSEC_TO_HZ_DEN\t\t", 1000/cd, "\n" print "\n" s=fmuls(32,1000000,hz) obase=16 print "#define HZ_TO_USEC_MUL32\tU64_C(0x", fmul(s,1000000,hz), ")\n" print "#define HZ_TO_USEC_ADJ32\tU64_C(0x", fadj(s,1000000,hz), ")\n" obase=10 print "#define HZ_TO_USEC_SHR32\t", s, "\n" s=fmuls(32,hz,1000000) obase=16 print "#define USEC_TO_HZ_MUL32\tU64_C(0x", fmul(s,hz,1000000), ")\n" print "#define USEC_TO_HZ_ADJ32\tU64_C(0x", fadj(s,hz,1000000), ")\n" obase=10 print "#define USEC_TO_HZ_SHR32\t", s, "\n" obase=10 cd=gcd(hz,1000000) print "#define HZ_TO_USEC_NUM\t\t", 1000000/cd, "\n" print "#define HZ_TO_USEC_DEN\t\t", hz/cd, "\n" print "#define USEC_TO_HZ_NUM\t\t", hz/cd, "\n" print "#define USEC_TO_HZ_DEN\t\t", 1000000/cd, "\n" print "\n" print "#endif /* KERNEL_TIMECONST_H */\n" } halt } hz = read(); timeconst(hz) th: root/include/dt-bindings/gpio/meson8-gpio.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-12-25 14:30:04 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-25 14:30:04 -0800
commit3ddc76dfc786cc6f87852693227fb0b1f124f807 (patch)
tree8192b4721e05cf6823087f9696db8c0c8f144b02 /include/dt-bindings/gpio/meson8-gpio.h
parentb272f732f888d4cf43c943a40c9aaa836f9b7431 (diff)
parent1f3a8e49d8f28f498b8694464623ac20aebfe62a (diff)
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer type cleanups from Thomas Gleixner: "This series does a tree wide cleanup of types related to timers/timekeeping. - Get rid of cycles_t and use a plain u64. The type is not really helpful and caused more confusion than clarity - Get rid of the ktime union. The union has become useless as we use the scalar nanoseconds storage unconditionally now. The 32bit timespec alike storage got removed due to the Y2038 limitations some time ago. That leaves the odd union access around for no reason. Clean it up. Both changes have been done with coccinelle and a small amount of manual mopping up" * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: ktime: Get rid of ktime_equal() ktime: Cleanup ktime_set() usage ktime: Get rid of the union clocksource: Use a plain u64 instead of cycle_t
Diffstat (limited to 'include/dt-bindings/gpio/meson8-gpio.h')