1 // SPDX-License-Identifier: LGPL-2.1+
2 /* Copyright (C) 2022 Kent Overstreet */
4 #include <linux/bitops.h>
5 #include <linux/kernel.h>
6 #include <linux/printbuf.h>
7 #include <linux/pretty-printers.h>
10 * prt_string_option - Given a list of strings, print out the list and indicate
11 * which option is selected, with square brackets (sysfs style)
13 * @out: The printbuf to output to
14 * @list: List of strings to choose from
15 * @selected: The option to highlight, with square brackets
17 void prt_string_option(struct printbuf *out,
18 const char * const list[],
23 for (i = 0; list[i]; i++) {
28 prt_str(out, list[i]);
33 EXPORT_SYMBOL(prt_string_option);
36 * prt_bitflags: Given a bitmap and a list of names for each bit, print out which
37 * bits are on, comma separated
39 * @out: The printbuf to output to
40 * @list: List of names for each bit
41 * @flags: Bits to print
43 void prt_bitflags(struct printbuf *out,
44 const char * const list[], u64 flags)
52 while (flags && (bit = __ffs(flags)) < nr) {
56 prt_str(out, list[bit]);
60 EXPORT_SYMBOL(prt_bitflags);