summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2026-02-19 22:08:53 +0300
committerAlexei Starovoitov <ast@kernel.org>2026-02-19 22:08:53 +0300
commitb0a67f310bfa5e13d66c9f6b4bd88ea504a576a9 (patch)
treef203082c07e790f8d4214075b8c81ace9717bd40 /rust
parent4c51f90d45dca71e7974ed5a7c40b9c04a6c6762 (diff)
parent8bf22c33e7a172fbc72464f4cc484d23a6b412ba (diff)
downloadlinux-b0a67f310bfa5e13d66c9f6b4bd88ea504a576a9.tar.xz
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf before 7.0-rc1
Cross-merge BPF and other fixes after downstream PR. No conflicts. Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'rust')
-rw-r--r--rust/bindings/lib.rs13
-rw-r--r--rust/helpers/binder.c13
-rw-r--r--rust/helpers/usb.c3
-rw-r--r--rust/kernel/miscdevice.rs10
-rw-r--r--rust/kernel/seq_file.rs4
-rw-r--r--rust/kernel/sync/arc.rs3
-rw-r--r--rust/kernel/usb.rs21
7 files changed, 46 insertions, 21 deletions
diff --git a/rust/bindings/lib.rs b/rust/bindings/lib.rs
index 0c57cf9b4004..19f57c5b2fa2 100644
--- a/rust/bindings/lib.rs
+++ b/rust/bindings/lib.rs
@@ -67,3 +67,16 @@ mod bindings_helper {
}
pub use bindings_raw::*;
+
+pub const compat_ptr_ioctl: Option<
+ unsafe extern "C" fn(*mut file, ffi::c_uint, ffi::c_ulong) -> ffi::c_long,
+> = {
+ #[cfg(CONFIG_COMPAT)]
+ {
+ Some(bindings_raw::compat_ptr_ioctl)
+ }
+ #[cfg(not(CONFIG_COMPAT))]
+ {
+ None
+ }
+};
diff --git a/rust/helpers/binder.c b/rust/helpers/binder.c
index 224d38a92f1d..a2327f1b3c94 100644
--- a/rust/helpers/binder.c
+++ b/rust/helpers/binder.c
@@ -7,20 +7,21 @@
#include <linux/list_lru.h>
#include <linux/task_work.h>
-unsigned long rust_helper_list_lru_count(struct list_lru *lru)
+__rust_helper unsigned long rust_helper_list_lru_count(struct list_lru *lru)
{
return list_lru_count(lru);
}
-unsigned long rust_helper_list_lru_walk(struct list_lru *lru,
- list_lru_walk_cb isolate, void *cb_arg,
- unsigned long nr_to_walk)
+__rust_helper unsigned long rust_helper_list_lru_walk(struct list_lru *lru,
+ list_lru_walk_cb isolate,
+ void *cb_arg,
+ unsigned long nr_to_walk)
{
return list_lru_walk(lru, isolate, cb_arg, nr_to_walk);
}
-void rust_helper_init_task_work(struct callback_head *twork,
- task_work_func_t func)
+__rust_helper void rust_helper_init_task_work(struct callback_head *twork,
+ task_work_func_t func)
{
init_task_work(twork, func);
}
diff --git a/rust/helpers/usb.c b/rust/helpers/usb.c
index fb2aad0cbf4d..eff1cf7be3c2 100644
--- a/rust/helpers/usb.c
+++ b/rust/helpers/usb.c
@@ -2,7 +2,8 @@
#include <linux/usb.h>
-struct usb_device *rust_helper_interface_to_usbdev(struct usb_interface *intf)
+__rust_helper struct usb_device *
+rust_helper_interface_to_usbdev(struct usb_interface *intf)
{
return interface_to_usbdev(intf);
}
diff --git a/rust/kernel/miscdevice.rs b/rust/kernel/miscdevice.rs
index d698cddcb4a5..c3c2052c9206 100644
--- a/rust/kernel/miscdevice.rs
+++ b/rust/kernel/miscdevice.rs
@@ -20,7 +20,7 @@ use crate::{
seq_file::SeqFile,
types::{ForeignOwnable, Opaque},
};
-use core::{marker::PhantomData, mem::MaybeUninit, pin::Pin};
+use core::{marker::PhantomData, pin::Pin};
/// Options for creating a misc device.
#[derive(Copy, Clone)]
@@ -32,8 +32,7 @@ pub struct MiscDeviceOptions {
impl MiscDeviceOptions {
/// Create a raw `struct miscdev` ready for registration.
pub const fn into_raw<T: MiscDevice>(self) -> bindings::miscdevice {
- // SAFETY: All zeros is valid for this C type.
- let mut result: bindings::miscdevice = unsafe { MaybeUninit::zeroed().assume_init() };
+ let mut result: bindings::miscdevice = pin_init::zeroed();
result.minor = bindings::MISC_DYNAMIC_MINOR as ffi::c_int;
result.name = crate::str::as_char_ptr_in_const_context(self.name);
result.fops = MiscdeviceVTable::<T>::build();
@@ -411,7 +410,7 @@ impl<T: MiscDevice> MiscdeviceVTable<T> {
compat_ioctl: if T::HAS_COMPAT_IOCTL {
Some(Self::compat_ioctl)
} else if T::HAS_IOCTL {
- Some(bindings::compat_ptr_ioctl)
+ bindings::compat_ptr_ioctl
} else {
None
},
@@ -420,8 +419,7 @@ impl<T: MiscDevice> MiscdeviceVTable<T> {
} else {
None
},
- // SAFETY: All zeros is a valid value for `bindings::file_operations`.
- ..unsafe { MaybeUninit::zeroed().assume_init() }
+ ..pin_init::zeroed()
};
const fn build() -> &'static bindings::file_operations {
diff --git a/rust/kernel/seq_file.rs b/rust/kernel/seq_file.rs
index 855e533813a6..518265558d66 100644
--- a/rust/kernel/seq_file.rs
+++ b/rust/kernel/seq_file.rs
@@ -4,7 +4,7 @@
//!
//! C header: [`include/linux/seq_file.h`](srctree/include/linux/seq_file.h)
-use crate::{bindings, c_str, fmt, str::CStrExt as _, types::NotThreadSafe, types::Opaque};
+use crate::{bindings, fmt, str::CStrExt as _, types::NotThreadSafe, types::Opaque};
/// A utility for generating the contents of a seq file.
#[repr(transparent)]
@@ -36,7 +36,7 @@ impl SeqFile {
unsafe {
bindings::seq_printf(
self.inner.get(),
- c_str!("%pA").as_char_ptr(),
+ c"%pA".as_char_ptr(),
core::ptr::from_ref(&args).cast::<crate::ffi::c_void>(),
);
}
diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs
index 289f77abf415..921e19333b89 100644
--- a/rust/kernel/sync/arc.rs
+++ b/rust/kernel/sync/arc.rs
@@ -240,6 +240,9 @@ impl<T> Arc<T> {
// `Arc` object.
Ok(unsafe { Self::from_inner(inner) })
}
+
+ /// The offset that the value is stored at.
+ pub const DATA_OFFSET: usize = core::mem::offset_of!(ArcInner<T>, data);
}
impl<T: ?Sized> Arc<T> {
diff --git a/rust/kernel/usb.rs b/rust/kernel/usb.rs
index 67ce5c85c619..0e1b9a88f4f1 100644
--- a/rust/kernel/usb.rs
+++ b/rust/kernel/usb.rs
@@ -6,14 +6,23 @@
//! C header: [`include/linux/usb.h`](srctree/include/linux/usb.h)
use crate::{
- bindings, device,
- device_id::{RawDeviceId, RawDeviceIdIndex},
+ bindings,
+ device,
+ device_id::{
+ RawDeviceId,
+ RawDeviceIdIndex, //
+ },
driver,
- error::{from_result, to_result, Result},
+ error::{
+ from_result,
+ to_result, //
+ },
prelude::*,
- str::CStr,
- types::{AlwaysRefCounted, Opaque},
- ThisModule,
+ types::{
+ AlwaysRefCounted,
+ Opaque, //
+ },
+ ThisModule, //
};
use core::{
marker::PhantomData,