From d8c330821aa3ae1d441cdf3aed64d457d0ed0cd9 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Thu, 5 May 2022 23:31:10 +0200 Subject: kernel/driver: clean up the ps2/serial drivers --- src/kernel/util.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/kernel/util.h') diff --git a/src/kernel/util.h b/src/kernel/util.h index 0e57d67..59af755 100644 --- a/src/kernel/util.h +++ b/src/kernel/util.h @@ -19,3 +19,9 @@ static inline int32_t capped_cast32(uint32_t u) { return (int32_t)min(u, (uint32_t)INT32_MAX); } + +static inline int clamp(int lo, int i, int hi) { + if (i < lo) return lo; + if (i > hi) return hi; + return i; +} -- cgit v1.2.3