diff options
author | Tejun Heo <tj@kernel.org> | 2013-03-12 14:30:04 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-03-12 14:30:04 -0400 |
commit | ba630e4940924ad1962883c207a62890778ced63 (patch) | |
tree | 5542e7ac7cec8c6d20851374c140805db387f10c | |
parent | 8719dceae2f98a578507c0f6b49c93f320bd729c (diff) |
cpumask: implement cpumask_parse()
We have cpulist_parse() but not cpumask_parse(). Implement it using
bitmap_parse().
bitmap_parse() is weird in that it takes @len for a string in
kernel-memory which also is inconsistent with bitmap_parselist().
Make cpumask_parse() calculate the length and don't expose the
inconsistency to cpumask users. Maybe we can fix up bitmap_parse()
later.
This will be used to expose workqueue cpumask knobs to userland via
sysfs.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r-- | include/linux/cpumask.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 032560295fcb..d08e4d2a9b92 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h | |||
@@ -591,6 +591,21 @@ static inline int cpulist_scnprintf(char *buf, int len, | |||
591 | } | 591 | } |
592 | 592 | ||
593 | /** | 593 | /** |
594 | * cpumask_parse - extract a cpumask from from a string | ||
595 | * @buf: the buffer to extract from | ||
596 | * @dstp: the cpumask to set. | ||
597 | * | ||
598 | * Returns -errno, or 0 for success. | ||
599 | */ | ||
600 | static inline int cpumask_parse(const char *buf, struct cpumask *dstp) | ||
601 | { | ||
602 | char *nl = strchr(buf, '\n'); | ||
603 | int len = nl ? nl - buf : strlen(buf); | ||
604 | |||
605 | return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpumask_bits); | ||
606 | } | ||
607 | |||
608 | /** | ||
594 | * cpulist_parse - extract a cpumask from a user string of ranges | 609 | * cpulist_parse - extract a cpumask from a user string of ranges |
595 | * @buf: the buffer to extract from | 610 | * @buf: the buffer to extract from |
596 | * @dstp: the cpumask to set. | 611 | * @dstp: the cpumask to set. |