Skip to content

Commit aae06fc

Browse files
committed
lib/bitmap: split-out string-related operations to a separate files
lib/bitmap.c and corresponding include/linux/bitmap.h are intended to hold functions related to operations on bitmaps, like bitmap_shift or bitmap_set. Historically, some string-related operations like bitmap_parse are also reside in lib/bitmap.c. Now that the subsystem evolves, string-related bitmap operations became a significant part of the file. Because they are quite different from the other bitmap functions by nature, it's worth to split them to a separate source/header files. CC: Andrew Morton <akpm@linux-foundation.org> CC: Andy Shevchenko <andriy.shevchenko@linux.intel.com> CC: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Yury Norov <yury.norov@gmail.com>
1 parent 7733aa8 commit aae06fc

File tree

6 files changed

+530
-530
lines changed

6 files changed

+530
-530
lines changed

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3506,12 +3506,14 @@ R: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
35063506
R: Rasmus Villemoes <linux@rasmusvillemoes.dk>
35073507
S: Maintained
35083508
F: include/linux/bitfield.h
3509+
F: include/linux/bitmap-str.h
35093510
F: include/linux/bitmap.h
35103511
F: include/linux/bits.h
35113512
F: include/linux/cpumask.h
35123513
F: include/linux/find.h
35133514
F: include/linux/nodemask.h
35143515
F: include/vdso/bits.h
3516+
F: lib/bitmap-str.c
35153517
F: lib/bitmap.c
35163518
F: lib/cpumask.c
35173519
F: lib/cpumask_kunit.c

include/linux/bitmap-str.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef __LINUX_BITMAP_STR_H
3+
#define __LINUX_BITMAP_STR_H
4+
5+
int bitmap_parse_user(const char __user *ubuf, unsigned int ulen, unsigned long *dst, int nbits);
6+
int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp, int nmaskbits);
7+
extern int bitmap_print_bitmask_to_buf(char *buf, const unsigned long *maskp,
8+
int nmaskbits, loff_t off, size_t count);
9+
extern int bitmap_print_list_to_buf(char *buf, const unsigned long *maskp,
10+
int nmaskbits, loff_t off, size_t count);
11+
int bitmap_parse(const char *buf, unsigned int buflen, unsigned long *dst, int nbits);
12+
int bitmap_parselist(const char *buf, unsigned long *maskp, int nmaskbits);
13+
int bitmap_parselist_user(const char __user *ubuf, unsigned int ulen,
14+
unsigned long *dst, int nbits);
15+
16+
#endif /* __LINUX_BITMAP_STR_H */

include/linux/bitmap.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/limits.h>
1111
#include <linux/string.h>
1212
#include <linux/types.h>
13+
#include <linux/bitmap-str.h>
1314

1415
struct device;
1516

@@ -200,14 +201,6 @@ bitmap_find_next_zero_area(unsigned long *map,
200201
align_mask, 0);
201202
}
202203

203-
int bitmap_parse(const char *buf, unsigned int buflen,
204-
unsigned long *dst, int nbits);
205-
int bitmap_parse_user(const char __user *ubuf, unsigned int ulen,
206-
unsigned long *dst, int nbits);
207-
int bitmap_parselist(const char *buf, unsigned long *maskp,
208-
int nmaskbits);
209-
int bitmap_parselist_user(const char __user *ubuf, unsigned int ulen,
210-
unsigned long *dst, int nbits);
211204
void bitmap_remap(unsigned long *dst, const unsigned long *src,
212205
const unsigned long *old, const unsigned long *new, unsigned int nbits);
213206
int bitmap_bitremap(int oldbit,
@@ -220,15 +213,6 @@ int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order)
220213
void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int order);
221214
int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order);
222215

223-
int bitmap_print_to_pagebuf(bool list, char *buf,
224-
const unsigned long *maskp, int nmaskbits);
225-
226-
extern int bitmap_print_bitmask_to_buf(char *buf, const unsigned long *maskp,
227-
int nmaskbits, loff_t off, size_t count);
228-
229-
extern int bitmap_print_list_to_buf(char *buf, const unsigned long *maskp,
230-
int nmaskbits, loff_t off, size_t count);
231-
232216
#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
233217
#define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
234218

lib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ obj-y += bcd.o sort.o parser.o debug_locks.o random32.o \
4848
bsearch.o find_bit.o llist.o memweight.o kfifo.o \
4949
percpu-refcount.o rhashtable.o base64.o \
5050
once.o refcount.o rcuref.o usercopy.o errseq.o bucket_locks.o \
51-
generic-radix-tree.o
51+
generic-radix-tree.o bitmap-str.o
5252
obj-$(CONFIG_STRING_SELFTEST) += test_string.o
5353
obj-y += string_helpers.o
5454
obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o

0 commit comments

Comments
 (0)