From eb8b7bf49ccc32d335f2b934431aeb5fc24220c2 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 6 Mar 2009 17:43:12 +0100 Subject: v4l/compat.h: add clamp_val From: Hans Verkuil Priority: normal Signed-off-by: Hans Verkuil --- v4l/compat.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'v4l/compat.h') diff --git a/v4l/compat.h b/v4l/compat.h index 3df844c87..16ff90bc4 100644 --- a/v4l/compat.h +++ b/v4l/compat.h @@ -238,6 +238,12 @@ static inline int list_is_singular(const struct list_head *head) min_t( __typeof__( x ), \ ( h ), \ ( x ) ) ) +#define clamp_val(val, min, max) ({ \ + typeof(val) __val = (val); \ + typeof(val) __min = (min); \ + typeof(val) __max = (max); \ + __val = __val < __min ? __min : __val; \ + __val > __max ? __max : __val; }) #endif #ifdef NEED_ALGO_CONTROL -- cgit v1.2.3