From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 7/8] include: Import min_not_zero() macro from Linux
Date: Mon, 11 Feb 2019 22:40:21 -0800 [thread overview]
Message-ID: <20190212064022.26154-8-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20190212064022.26154-1-andrew.smirnov@gmail.com>
Import min_not_zero() macro from Linux used by some kernel code.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-02-12 6:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-12 6:40 [PATCH 0/8] NVME support Andrey Smirnov
2019-02-12 6:40 ` [PATCH 1/8] PCI: Fix to_pci_dev() macro Andrey Smirnov
2019-02-12 6:40 ` [PATCH 2/8] PCI: Introduce device_pci_driver() Andrey Smirnov
2019-02-12 6:40 ` [PATCH 3/8] drivers: Make use of device_pci_driver() Andrey Smirnov
2019-02-12 6:40 ` [PATCH 4/8] include: Sync up pci_ids.h with 4.20-rc1 Andrey Smirnov
2019-02-12 6:40 ` [PATCH 5/8] include: Add definitnion for HZ Andrey Smirnov
2019-02-12 6:40 ` [PATCH 6/8] include: Import uuid.h for Linux Andrey Smirnov
2019-02-12 6:40 ` Andrey Smirnov [this message]
2019-02-12 6:40 ` [PATCH 8/8] drivers: Import a very basic NVME implementation from Linux Andrey Smirnov
2019-02-18 8:24 ` [PATCH 0/8] NVME support Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190212064022.26154-8-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox