File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 1
1
// SPDX-License-Identifier: LGPL-2.1+
2
2
/* Copyright (C) 2022 Kent Overstreet */
3
3
4
+ #include <linux/bitmap.h>
4
5
#include <linux/err.h>
5
6
#include <linux/export.h>
6
7
#include <linux/kernel.h>
@@ -423,3 +424,24 @@ void bch2_prt_bitflags(struct printbuf *out,
423
424
flags ^= BIT_ULL (bit );
424
425
}
425
426
}
427
+
428
+ void bch2_prt_bitflags_vector (struct printbuf * out ,
429
+ const char * const list [],
430
+ unsigned long * v , unsigned nr )
431
+ {
432
+ bool first = true;
433
+ unsigned i ;
434
+
435
+ for (i = 0 ; i < nr ; i ++ )
436
+ if (!list [i ]) {
437
+ nr = i - 1 ;
438
+ break ;
439
+ }
440
+
441
+ for_each_set_bit (i , v , nr ) {
442
+ if (!first )
443
+ bch2_prt_printf (out , "," );
444
+ first = false;
445
+ bch2_prt_printf (out , "%s" , list [i ]);
446
+ }
447
+ }
Original file line number Diff line number Diff line change @@ -124,6 +124,8 @@ void bch2_prt_units_u64(struct printbuf *, u64);
124
124
void bch2_prt_units_s64 (struct printbuf * , s64 );
125
125
void bch2_prt_string_option (struct printbuf * , const char * const [], size_t );
126
126
void bch2_prt_bitflags (struct printbuf * , const char * const [], u64 );
127
+ void bch2_prt_bitflags_vector (struct printbuf * , const char * const [],
128
+ unsigned long * , unsigned );
127
129
128
130
/* Initializer for a heap allocated printbuf: */
129
131
#define PRINTBUF ((struct printbuf) { .heap_allocated = true })
Original file line number Diff line number Diff line change @@ -243,6 +243,7 @@ do { \
243
243
#define prt_units_s64 (...) bch2_prt_units_s64(__VA_ARGS__)
244
244
#define prt_string_option (...) bch2_prt_string_option(__VA_ARGS__)
245
245
#define prt_bitflags (...) bch2_prt_bitflags(__VA_ARGS__)
246
+ #define prt_bitflags_vector (...) bch2_prt_bitflags_vector(__VA_ARGS__)
246
247
247
248
void bch2_pr_time_units (struct printbuf *, u64 );
248
249
void bch2_prt_datetime (struct printbuf *, time64_t );
You can’t perform that action at this time.
0 commit comments