Skip to content

Commit 8c0901b

Browse files
committed
Merge tag 'configfs-for-v7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/a.hindborg/linux
Pull configfs updates from Andreas Hindborg: - Switch the configfs rust bindings to use c string literals provided by the compiler, rather than a macro - A follow up on constifying `configfs_item_operations`, applying the change to the configfs sample * tag 'configfs-for-v7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/a.hindborg/linux: samples: configfs: Constify struct configfs_item_operations and configfs_group_operations rust: configfs: replace `kernel::c_str!` with C-Strings
2 parents 136114e + 6363844 commit 8c0901b

4 files changed

Lines changed: 11 additions & 12 deletions

File tree

drivers/block/rnull/configfs.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use super::{NullBlkDevice, THIS_MODULE};
44
use kernel::{
55
block::mq::gen_disk::{GenDisk, GenDiskBuilder},
6-
c_str,
76
configfs::{self, AttributeOperations},
87
configfs_attrs,
98
fmt::{self, Write as _},

rust/kernel/configfs.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
//!
2222
//! ```ignore
2323
//! use kernel::alloc::flags;
24-
//! use kernel::c_str;
2524
//! use kernel::configfs_attrs;
2625
//! use kernel::configfs;
2726
//! use kernel::new_mutex;
@@ -50,7 +49,7 @@
5049
//!
5150
//! try_pin_init!(Self {
5251
//! config <- configfs::Subsystem::new(
53-
//! c_str!("rust_configfs"), item_type, Configuration::new()
52+
//! c"rust_configfs", item_type, Configuration::new()
5453
//! ),
5554
//! })
5655
//! }
@@ -66,7 +65,7 @@
6665
//! impl Configuration {
6766
//! fn new() -> impl PinInit<Self, Error> {
6867
//! try_pin_init!(Self {
69-
//! message: c_str!("Hello World\n"),
68+
//! message: c"Hello World\n",
7069
//! bar <- new_mutex!((KBox::new([0; PAGE_SIZE], flags::GFP_KERNEL)?, 0)),
7170
//! })
7271
//! }
@@ -1000,7 +999,9 @@ macro_rules! configfs_attrs {
1000999
static [< $data:upper _ $name:upper _ATTR >]:
10011000
$crate::configfs::Attribute<$attr, $data, $data> =
10021001
unsafe {
1003-
$crate::configfs::Attribute::new(c_str!(::core::stringify!($name)))
1002+
$crate::configfs::Attribute::new(
1003+
$crate::c_str!(::core::stringify!($name)),
1004+
)
10041005
};
10051006
)*
10061007

samples/configfs/configfs_sample.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static void simple_child_release(struct config_item *item)
158158
kfree(to_simple_child(item));
159159
}
160160

161-
static struct configfs_item_operations simple_child_item_ops = {
161+
static const struct configfs_item_operations simple_child_item_ops = {
162162
.release = simple_child_release,
163163
};
164164

@@ -215,15 +215,15 @@ static void simple_children_release(struct config_item *item)
215215
kfree(to_simple_children(item));
216216
}
217217

218-
static struct configfs_item_operations simple_children_item_ops = {
218+
static const struct configfs_item_operations simple_children_item_ops = {
219219
.release = simple_children_release,
220220
};
221221

222222
/*
223223
* Note that, since no extra work is required on ->drop_item(),
224224
* no ->drop_item() is provided.
225225
*/
226-
static struct configfs_group_operations simple_children_group_ops = {
226+
static const struct configfs_group_operations simple_children_group_ops = {
227227
.make_item = simple_children_make_item,
228228
};
229229

@@ -292,7 +292,7 @@ static struct configfs_attribute *group_children_attrs[] = {
292292
* Note that, since no extra work is required on ->drop_item(),
293293
* no ->drop_item() is provided.
294294
*/
295-
static struct configfs_group_operations group_children_group_ops = {
295+
static const struct configfs_group_operations group_children_group_ops = {
296296
.make_group = group_children_make_group,
297297
};
298298

samples/rust/rust_configfs.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//! Rust configfs sample.
44
55
use kernel::alloc::flags;
6-
use kernel::c_str;
76
use kernel::configfs;
87
use kernel::configfs::configfs_attrs;
98
use kernel::new_mutex;
@@ -35,7 +34,7 @@ struct Configuration {
3534
impl Configuration {
3635
fn new() -> impl PinInit<Self, Error> {
3736
try_pin_init!(Self {
38-
message: c_str!("Hello World\n"),
37+
message: c"Hello World\n",
3938
bar <- new_mutex!((KBox::new([0; PAGE_SIZE], flags::GFP_KERNEL)?, 0)),
4039
})
4140
}
@@ -61,7 +60,7 @@ impl kernel::InPlaceModule for RustConfigfs {
6160

6261
try_pin_init!(Self {
6362
config <- configfs::Subsystem::new(
64-
c_str!("rust_configfs"), item_type, Configuration::new()
63+
c"rust_configfs", item_type, Configuration::new()
6564
),
6665
})
6766
}

0 commit comments

Comments
 (0)