In os/os-linux.h, define the ioprio() macro using the already defined IOPRIO_MAX_PRIO macro instead of hard coding the maximum priority value again. Also move the definitions of the ioprio_class() and ioprio() macros before the ioprio_value() function and use ioprio_class() inside ioprio_value_is_class_rt() instead of re-coding the iopriority class extraction again in that function. Signed-off-by: Damien Le Moal <dlemoal@xxxxxxxxxx> Reviewed-by: Niklas Cassel <niklas.cassel@xxxxxxx> --- os/os-linux.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/os/os-linux.h b/os/os-linux.h index 2f9f7e79..72727ac3 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -131,6 +131,9 @@ enum { #define IOPRIO_MIN_PRIO_CLASS 0 #define IOPRIO_MAX_PRIO_CLASS 3 +#define ioprio_class(ioprio) ((ioprio) >> IOPRIO_CLASS_SHIFT) +#define ioprio(ioprio) ((ioprio) & IOPRIO_MAX_PRIO) + static inline int ioprio_value(int ioprio_class, int ioprio) { /* @@ -144,7 +147,7 @@ static inline int ioprio_value(int ioprio_class, int ioprio) static inline bool ioprio_value_is_class_rt(unsigned int priority) { - return (priority >> IOPRIO_CLASS_SHIFT) == IOPRIO_CLASS_RT; + return ioprio_class(priority) == IOPRIO_CLASS_RT; } static inline int ioprio_set(int which, int who, int ioprio_class, int ioprio) @@ -153,9 +156,6 @@ static inline int ioprio_set(int which, int who, int ioprio_class, int ioprio) ioprio_value(ioprio_class, ioprio)); } -#define ioprio_class(ioprio) ((ioprio) >> IOPRIO_CLASS_SHIFT) -#define ioprio(ioprio) ((ioprio) & 7) - #ifndef CONFIG_HAVE_GETTID static inline int gettid(void) { -- 2.41.0