Import min_not_zero() macro from Linux used by some kernel code.

Signed-off-by: Andrey Smirnov <[email protected]>
---
 include/linux/kernel.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index ee0b48e08..849c079d0 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -135,6 +135,16 @@ extern long long simple_strtoll(const char *,char 
**,unsigned int);
        _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) :       \
                (_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
-- 
2.20.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to