mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-09 15:51:13 -04:00
Several selftests subdirectories duplicated the define __maybe_unused, leading to redundant code. Move to kselftest.h header and remove other definitions. This addresses the duplication noted in the proc-pid-vm warning fix Link: https://lkml.kernel.org/r/20250821101159.2238-1-reddybalavignesh9979@gmail.com Signed-off-by: Bala-Vignesh-Reddy <reddybalavignesh9979@gmail.com> Suggested-by: Andrew Morton <akpm@linux-foundation.org> Link:https://lore.kernel.org/lkml/20250820143954.33d95635e504e94df01930d0@linux-foundation.org/ Reviewed-by: Wei Yang <richard.weiyang@gmail.com> Acked-by: SeongJae Park <sj@kernel.org> Reviewed-by: Ming Lei <ming.lei@redhat.com> Acked-by: Mickal Salan <mic@digikod.net> [landlock] Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
69 lines
1.4 KiB
C
69 lines
1.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef KUBLK_UTILS_H
|
|
#define KUBLK_UTILS_H
|
|
|
|
#ifndef min
|
|
#define min(a, b) ((a) < (b) ? (a) : (b))
|
|
#endif
|
|
|
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
|
|
|
#ifndef offsetof
|
|
#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER)
|
|
#endif
|
|
|
|
#ifndef container_of
|
|
#define container_of(ptr, type, member) ({ \
|
|
unsigned long __mptr = (unsigned long)(ptr); \
|
|
((type *)(__mptr - offsetof(type, member))); })
|
|
#endif
|
|
|
|
#define round_up(val, rnd) \
|
|
(((val) + ((rnd) - 1)) & ~((rnd) - 1))
|
|
|
|
static inline unsigned int ilog2(unsigned int x)
|
|
{
|
|
if (x == 0)
|
|
return 0;
|
|
return (sizeof(x) * 8 - 1) - __builtin_clz(x);
|
|
}
|
|
|
|
#define UBLK_DBG_DEV (1U << 0)
|
|
#define UBLK_DBG_THREAD (1U << 1)
|
|
#define UBLK_DBG_IO_CMD (1U << 2)
|
|
#define UBLK_DBG_IO (1U << 3)
|
|
#define UBLK_DBG_CTRL_CMD (1U << 4)
|
|
#define UBLK_LOG (1U << 5)
|
|
|
|
extern unsigned int ublk_dbg_mask;
|
|
|
|
static inline void ublk_err(const char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
vfprintf(stderr, fmt, ap);
|
|
}
|
|
|
|
static inline void ublk_log(const char *fmt, ...)
|
|
{
|
|
if (ublk_dbg_mask & UBLK_LOG) {
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
vfprintf(stdout, fmt, ap);
|
|
}
|
|
}
|
|
|
|
static inline void ublk_dbg(int level, const char *fmt, ...)
|
|
{
|
|
if (level & ublk_dbg_mask) {
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
vfprintf(stdout, fmt, ap);
|
|
}
|
|
}
|
|
|
|
#endif
|