mirror of https://github.com/torvalds/linux.git
rust: configfs: use `core::ffi::CStr` method names
Prepare for `core::ffi::CStr` taking the place of `kernel::str::CStr` by avoid methods that only exist on the latter. Also avoid `Deref<Target=BStr> for CStr` as that impl doesn't exist on `core::ffi::CStr`. Link: https://github.com/Rust-for-Linux/linux/issues/1075 Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Tamir Duberstein <tamird@gmail.com> Acked-by: Andreas Hindborg <a.hindborg@kernel.org> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
parent
7ad635c936
commit
a3a7d09ab8
|
|
@ -263,7 +263,7 @@ pub fn new(
|
||||||
try_pin_init!(Self {
|
try_pin_init!(Self {
|
||||||
group <- pin_init::init_zeroed().chain(|v: &mut Opaque<bindings::config_group>| {
|
group <- pin_init::init_zeroed().chain(|v: &mut Opaque<bindings::config_group>| {
|
||||||
let place = v.get();
|
let place = v.get();
|
||||||
let name = name.as_bytes_with_nul().as_ptr();
|
let name = name.to_bytes_with_nul().as_ptr();
|
||||||
// SAFETY: It is safe to initialize a group once it has been zeroed.
|
// SAFETY: It is safe to initialize a group once it has been zeroed.
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::config_group_init_type_name(place, name.cast(), item_type.as_ptr())
|
bindings::config_group_init_type_name(place, name.cast(), item_type.as_ptr())
|
||||||
|
|
@ -613,7 +613,7 @@ impl<const ID: u64, O, Data> Attribute<ID, O, Data>
|
||||||
pub const fn new(name: &'static CStr) -> Self {
|
pub const fn new(name: &'static CStr) -> Self {
|
||||||
Self {
|
Self {
|
||||||
attribute: Opaque::new(bindings::configfs_attribute {
|
attribute: Opaque::new(bindings::configfs_attribute {
|
||||||
ca_name: name.as_char_ptr(),
|
ca_name: crate::str::as_char_ptr_in_const_context(name),
|
||||||
ca_owner: core::ptr::null_mut(),
|
ca_owner: core::ptr::null_mut(),
|
||||||
ca_mode: 0o660,
|
ca_mode: 0o660,
|
||||||
show: Some(Self::show),
|
show: Some(Self::show),
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ impl configfs::AttributeOperations<0> for Configuration {
|
||||||
|
|
||||||
fn show(container: &Configuration, page: &mut [u8; PAGE_SIZE]) -> Result<usize> {
|
fn show(container: &Configuration, page: &mut [u8; PAGE_SIZE]) -> Result<usize> {
|
||||||
pr_info!("Show message\n");
|
pr_info!("Show message\n");
|
||||||
let data = container.message;
|
let data = container.message.to_bytes();
|
||||||
page[0..data.len()].copy_from_slice(data);
|
page[0..data.len()].copy_from_slice(data);
|
||||||
Ok(data.len())
|
Ok(data.len())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue