summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-02-11 22:40:21 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2019-02-18 14:25:51 +0100
commit4798a032abd6329519038bacbf308a2a9cb65311 (patch)
tree38ee9c5e5667e0cb2ed1627add55d7c321863527
parent97430d9c47a57f22d2d051334f15233f49155f70 (diff)
downloadbarebox-4798a032abd6329519038bacbf308a2a9cb65311.tar.gz
barebox-4798a032abd6329519038bacbf308a2a9cb65311.tar.xz
include: Import min_not_zero() macro from Linux
Import min_not_zero() macro from Linux used by some kernel code. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--include/linux/kernel.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index ee0b48e089..849c079d0c 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -136,6 +136,16 @@ extern long long simple_strtoll(const char *,char **,unsigned int);
(_max2 > _max3 ? _max2 : _max3); })
/**
+ * min_not_zero - return the minimum that is _not_ zero, unless both are zero
+ * @x: value1
+ * @y: value2
+ */
+#define min_not_zero(x, y) ({ \
+ typeof(x) __x = (x); \
+ typeof(y) __y = (y); \
+ __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
+
+/**
* clamp - return a value clamped to a given range with strict typechecking
* @val: current value
* @min: minimum allowable value