Skip to content

Commit 7365676

Browse files
vireshkYuryNorov
authored andcommitted
rust: Add cpumask helpers
In order to prepare for adding Rust abstractions for cpumask, add the required helpers for inline cpumask functions that cannot be called by rust code directly. Reviewed-by: Alice Ryhl <[email protected]> Signed-off-by: Viresh Kumar <[email protected]> Signed-off-by: Yury Norov [NVIDIA] <[email protected]>
1 parent 1e7933a commit 7365676

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

rust/bindings/bindings_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/blk-mq.h>
1111
#include <linux/blk_types.h>
1212
#include <linux/blkdev.h>
13+
#include <linux/cpumask.h>
1314
#include <linux/cred.h>
1415
#include <linux/device/faux.h>
1516
#include <linux/errname.h>

rust/helpers/cpumask.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <linux/cpumask.h>
4+
5+
void rust_helper_cpumask_set_cpu(unsigned int cpu, struct cpumask *dstp)
6+
{
7+
cpumask_set_cpu(cpu, dstp);
8+
}
9+
10+
void rust_helper_cpumask_clear_cpu(int cpu, struct cpumask *dstp)
11+
{
12+
cpumask_clear_cpu(cpu, dstp);
13+
}
14+
15+
void rust_helper_cpumask_setall(struct cpumask *dstp)
16+
{
17+
cpumask_setall(dstp);
18+
}
19+
20+
unsigned int rust_helper_cpumask_weight(struct cpumask *srcp)
21+
{
22+
return cpumask_weight(srcp);
23+
}
24+
25+
void rust_helper_cpumask_copy(struct cpumask *dstp, const struct cpumask *srcp)
26+
{
27+
cpumask_copy(dstp, srcp);
28+
}
29+
30+
bool rust_helper_alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
31+
{
32+
return alloc_cpumask_var(mask, flags);
33+
}
34+
35+
bool rust_helper_zalloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
36+
{
37+
return zalloc_cpumask_var(mask, flags);
38+
}
39+
40+
#ifndef CONFIG_CPUMASK_OFFSTACK
41+
void rust_helper_free_cpumask_var(cpumask_var_t mask)
42+
{
43+
free_cpumask_var(mask);
44+
}
45+
#endif

rust/helpers/helpers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "bug.c"
1212
#include "build_assert.c"
1313
#include "build_bug.c"
14+
#include "cpumask.c"
1415
#include "cred.c"
1516
#include "device.c"
1617
#include "err.c"

0 commit comments

Comments
 (0)