diff options
Diffstat (limited to 'arch/tile/lib/cpumask.c')
-rw-r--r-- | arch/tile/lib/cpumask.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/arch/tile/lib/cpumask.c b/arch/tile/lib/cpumask.c new file mode 100644 index 000000000000..af745b3b2559 --- /dev/null +++ b/arch/tile/lib/cpumask.c | |||
@@ -0,0 +1,51 @@ | |||
1 | /* | ||
2 | * Copyright 2010 Tilera Corporation. All Rights Reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation, version 2. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, but | ||
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
11 | * NON INFRINGEMENT. See the GNU General Public License for | ||
12 | * more details. | ||
13 | */ | ||
14 | |||
15 | #include <linux/cpumask.h> | ||
16 | #include <linux/ctype.h> | ||
17 | #include <linux/errno.h> | ||
18 | |||
19 | /* | ||
20 | * Allow cropping out bits beyond the end of the array. | ||
21 | * Move to "lib" directory if more clients want to use this routine. | ||
22 | */ | ||
23 | int bitmap_parselist_crop(const char *bp, unsigned long *maskp, int nmaskbits) | ||
24 | { | ||
25 | unsigned a, b; | ||
26 | |||
27 | bitmap_zero(maskp, nmaskbits); | ||
28 | do { | ||
29 | if (!isdigit(*bp)) | ||
30 | return -EINVAL; | ||
31 | a = simple_strtoul(bp, (char **)&bp, 10); | ||
32 | b = a; | ||
33 | if (*bp == '-') { | ||
34 | bp++; | ||
35 | if (!isdigit(*bp)) | ||
36 | return -EINVAL; | ||
37 | b = simple_strtoul(bp, (char **)&bp, 10); | ||
38 | } | ||
39 | if (!(a <= b)) | ||
40 | return -EINVAL; | ||
41 | if (b >= nmaskbits) | ||
42 | b = nmaskbits-1; | ||
43 | while (a <= b) { | ||
44 | set_bit(a, maskp); | ||
45 | a++; | ||
46 | } | ||
47 | if (*bp == ',') | ||
48 | bp++; | ||
49 | } while (*bp != '\0' && *bp != '\n'); | ||
50 | return 0; | ||
51 | } | ||