On 2021/08/03 0:58, Bart Van Assche wrote: > On 8/2/21 2:21 AM, Damien Le Moal wrote: >> diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h >> index 77b17e08b0da..27dc7fb0ba12 100644 >> --- a/include/uapi/linux/ioprio.h >> +++ b/include/uapi/linux/ioprio.h >> @@ -6,10 +6,12 @@ >> * Gives us 8 prio classes with 13-bits of data for each class >> */ >> #define IOPRIO_CLASS_SHIFT (13) >> +#define IOPRIO_CLASS_MASK (0x07) >> #define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1) >> >> -#define IOPRIO_PRIO_CLASS(mask) ((mask) >> IOPRIO_CLASS_SHIFT) >> -#define IOPRIO_PRIO_DATA(mask) ((mask) & IOPRIO_PRIO_MASK) >> +#define IOPRIO_PRIO_CLASS(val) \ >> + (((val) >> IOPRIO_CLASS_SHIFT) & IOPRIO_CLASS_MASK) >> +#define IOPRIO_PRIO_DATA(val) ((val) & IOPRIO_PRIO_MASK) >> #define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data) >> >> /* >> @@ -23,9 +25,16 @@ enum { >> IOPRIO_CLASS_RT, >> IOPRIO_CLASS_BE, >> IOPRIO_CLASS_IDLE, >> + >> + IOPRIO_CLASS_MAX, >> }; >> >> -#define ioprio_valid(mask) (IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE) >> +static inline bool ioprio_valid(unsigned short ioprio) >> +{ >> + unsigned short class = IOPRIO_PRIO_CLASS(ioprio); >> + >> + return class > IOPRIO_CLASS_NONE && class < IOPRIO_CLASS_MAX; >> +} >> >> /* >> * 8 best effort priority levels are supported > > Are there any plans to use ioprio_valid() in user space applications? If > not, should this function perhaps be defined in a kernel-only header? Good point. I wondered the same. I think it may be better to leave that one in include/linux/ioprio.h instead of moving it to the uapi header. Jens, Thoughts ? > > Thanks, > > Bart. > > > -- Damien Le Moal Western Digital Research