Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/include/linux Make Linux usecs_to_jiff...
details: https://anonhg.NetBSD.org/src/rev/a2bddad8650d
branches: trunk
changeset: 330975:a2bddad8650d
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Jul 26 06:20:25 2014 +0000
description:
Make Linux usecs_to_jiffies work with hz up to 2000.
diffstat:
sys/external/bsd/drm2/include/linux/jiffies.h | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diffs (30 lines):
diff -r 226c2c6f1611 -r a2bddad8650d sys/external/bsd/drm2/include/linux/jiffies.h
--- a/sys/external/bsd/drm2/include/linux/jiffies.h Sat Jul 26 06:12:30 2014 +0000
+++ b/sys/external/bsd/drm2/include/linux/jiffies.h Sat Jul 26 06:20:25 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: jiffies.h,v 1.4 2014/07/16 20:59:58 riastradh Exp $ */
+/* $NetBSD: jiffies.h,v 1.5 2014/07/26 06:20:25 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -56,7 +56,19 @@
static inline unsigned int
usecs_to_jiffies(unsigned int usec)
{
- return mstohz((usec + (1000 / hz) - 1) / (1000 / hz));
+ if (hz <= 100)
+ return mstohz(roundup(usec, (1000 / hz)));
+
+ /*
+ * Avoid integer overflow on 32-bit platforms. The cutoff is
+ * kinda arbitrary; for hz <= 2000, 0x200000 is safe, but both
+ * values could wiggle around a little.
+ */
+ KASSERT(hz <= 2000);
+ if (usec <= 0x200000)
+ return ((usec * hz) / 1000000);
+ else
+ return ((usec / 1000000) * hz);
}
static inline unsigned int
Home |
Main Index |
Thread Index |
Old Index