1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#include <linux/cpumask.h>
16#include <linux/ctype.h>
17#include <linux/errno.h>
18#include <linux/smp.h>
19#include <linux/export.h>
20
21
22
23
24
25int bitmap_parselist_crop(const char *bp, unsigned long *maskp, int nmaskbits)
26{
27 unsigned a, b;
28
29 bitmap_zero(maskp, nmaskbits);
30 do {
31 if (!isdigit(*bp))
32 return -EINVAL;
33 a = simple_strtoul(bp, (char **)&bp, 10);
34 b = a;
35 if (*bp == '-') {
36 bp++;
37 if (!isdigit(*bp))
38 return -EINVAL;
39 b = simple_strtoul(bp, (char **)&bp, 10);
40 }
41 if (!(a <= b))
42 return -EINVAL;
43 if (b >= nmaskbits)
44 b = nmaskbits-1;
45 while (a <= b) {
46 set_bit(a, maskp);
47 a++;
48 }
49 if (*bp == ',')
50 bp++;
51 } while (*bp != '\0' && *bp != '\n');
52 return 0;
53}
54EXPORT_SYMBOL(bitmap_parselist_crop);
55