summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Le Moal <damien.lemoal@wdc.com>2021-08-11 12:36:59 +0900
committerJens Axboe <axboe@kernel.dk>2021-08-18 07:21:11 -0600
commita553a835ca57668b0d9907d8ec2507ec51292d9a (patch)
tree1d9f304bbc3e11244f921f46b5e88bf3e98c88c0
parent25bca50e523cbe96c0207fbb92f22ff2bc28e9aa (diff)
downloadlinux-a553a835ca57668b0d9907d8ec2507ec51292d9a.tar.gz
linux-a553a835ca57668b0d9907d8ec2507ec51292d9a.tar.bz2
linux-a553a835ca57668b0d9907d8ec2507ec51292d9a.zip
block: change ioprio_valid() to an inline function
Change the ioprio_valid() macro in include/usapi/linux/ioprio.h to an inline function declared on the kernel side in include/linux/ioprio.h. Also improve checks on the class value by checking the upper bound value. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Link: https://lore.kernel.org/r/20210811033702.368488-4-damien.lemoal@wdc.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--include/linux/ioprio.h10
-rw-r--r--include/uapi/linux/ioprio.h2
2 files changed, 10 insertions, 2 deletions
diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h
index ef9ad4fb245f..2ee3373684b1 100644
--- a/include/linux/ioprio.h
+++ b/include/linux/ioprio.h
@@ -9,6 +9,16 @@
#include <uapi/linux/ioprio.h>
/*
+ * Check that a priority value has a valid class.
+ */
+static inline bool ioprio_valid(unsigned short ioprio)
+{
+ unsigned short class = IOPRIO_PRIO_CLASS(ioprio);
+
+ return class > IOPRIO_CLASS_NONE && class <= IOPRIO_CLASS_IDLE;
+}
+
+/*
* if process has set io priority explicitly, use that. if not, convert
* the cpu scheduler nice value to an io priority
*/
diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h
index 6b735854aebd..5064e230374c 100644
--- a/include/uapi/linux/ioprio.h
+++ b/include/uapi/linux/ioprio.h
@@ -27,8 +27,6 @@ enum {
IOPRIO_CLASS_IDLE,
};
-#define ioprio_valid(mask) (IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE)
-
/*
* 8 best effort priority levels are supported
*/