mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
Merge tag 'rust-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux
Pull Rust updates from Miguel Ojeda:
"Toolchain and infrastructure:
- Enable a set of Clippy lints: 'ptr_as_ptr', 'ptr_cast_constness',
'as_ptr_cast_mut', 'as_underscore', 'cast_lossless' and
'ref_as_ptr'
These are intended to avoid type casts with the 'as' operator,
which are quite powerful, into restricted variants that are less
powerful and thus should help to avoid mistakes
- Remove the 'author' key now that most instances were moved to the
plural one in the previous cycle
'kernel' crate:
- New 'bug' module: add 'warn_on!' macro which reuses the existing
'BUG'/'WARN' infrastructure, i.e. it respects the usual sysctls and
kernel parameters:
warn_on!(value == 42);
To avoid duplicating the assembly code, the same strategy is
followed as for the static branch code in order to share the
assembly between both C and Rust
This required a few rearrangements on C arch headers -- the
existing C macros should still generate the same outputs, thus no
functional change expected there
- 'workqueue' module: add delayed work items, including a
'DelayedWork' struct, a 'impl_has_delayed_work!' macro and an
'enqueue_delayed' method, e.g.:
/// Enqueue the struct for execution on the system workqueue,
/// where its value will be printed 42 jiffies later.
fn print_later(value: Arc<MyStruct>) {
let _ = workqueue::system().enqueue_delayed(value, 42);
}
- New 'bits' module: add support for 'bit' and 'genmask' functions,
with runtime- and compile-time variants, e.g.:
static_assert!(0b00010000 == bit_u8(4));
static_assert!(0b00011110 == genmask_u8(1..=4));
assert!(checked_bit_u32(u32::BITS).is_none());
- 'uaccess' module: add 'UserSliceReader::strcpy_into_buf', which
reads NUL-terminated strings from userspace into a '&CStr'
Introduce 'UserPtr' newtype, similar in purpose to '__user' in C,
to minimize mistakes handling userspace pointers, including mixing
them up with integers and leaking them via the 'Debug' trait. Add
it to the prelude, too
- Start preparations for the replacement of our custom 'CStr' type
with the analogous type in the 'core' standard library. This will
take place across several cycles to make it easier. For this one,
it includes a new 'fmt' module, using upstream method names and
some other cleanups
Replace 'fmt!' with a re-export, which helps Clippy lint properly,
and clean up the found 'uninlined-format-args' instances
- 'dma' module:
- Clarify wording and be consistent in 'coherent' nomenclature
- Convert the 'read!()' and 'write!()' macros to return a 'Result'
- Add 'as_slice()', 'write()' methods in 'CoherentAllocation'
- Expose 'count()' and 'size()' in 'CoherentAllocation' and add
the corresponding type invariants
- Implement 'CoherentAllocation::dma_handle_with_offset()'
- 'time' module:
- Make 'Instant' generic over clock source. This allows the
compiler to assert that arithmetic expressions involving the
'Instant' use 'Instants' based on the same clock source
- Make 'HrTimer' generic over the timer mode. 'HrTimer' timers
take a 'Duration' or an 'Instant' when setting the expiry time,
depending on the timer mode. With this change, the compiler can
check the type matches the timer mode
- Add an abstraction for 'fsleep'. 'fsleep' is a flexible sleep
function that will select an appropriate sleep method depending
on the requested sleep time
- Avoid 64-bit divisions on 32-bit hardware when calculating
timestamps
- Seal the 'HrTimerMode' trait. This prevents users of the
'HrTimerMode' from implementing the trait on their own types
- Pass the correct timer mode ID to 'hrtimer_start_range_ns()'
- 'list' module: remove 'OFFSET' constants, allowing to remove
pointer arithmetic; now 'impl_list_item!' invokes
'impl_has_list_links!' or 'impl_has_list_links_self_ptr!'. Other
simplifications too
- 'types' module: remove 'ForeignOwnable::PointedTo' in favor of a
constant, which avoids exposing the type of the opaque pointer, and
require 'into_foreign' to return non-null
Remove the 'Either<L, R>' type as well. It is unused, and we want
to encourage the use of custom enums for concrete use cases
- 'sync' module: implement 'Borrow' and 'BorrowMut' for 'Arc' types
to allow them to be used in generic APIs
- 'alloc' module: implement 'Borrow' and 'BorrowMut' for 'Box<T, A>';
and 'Borrow', 'BorrowMut' and 'Default' for 'Vec<T, A>'
- 'Opaque' type: add 'cast_from' method to perform a restricted cast
that cannot change the inner type and use it in callers of
'container_of!'. Rename 'raw_get' to 'cast_into' to match it
- 'rbtree' module: add 'is_empty' method
- 'sync' module: new 'aref' submodule to hold 'AlwaysRefCounted' and
'ARef', which are moved from the too general 'types' module which
we want to reduce or eventually remove. Also fix a safety comment
in 'static_lock_class'
'pin-init' crate:
- Add 'impl<T, E> [Pin]Init<T, E> for Result<T, E>', so results are
now (pin-)initializers
- Add 'Zeroable::init_zeroed()' that delegates to 'init_zeroed()'
- New 'zeroed()', a safe version of 'mem::zeroed()' and also provide
it via 'Zeroable::zeroed()'
- Implement 'Zeroable' for 'Option<&T>', 'Option<&mut T>' and for
'Option<[unsafe] [extern "abi"] fn(...args...) -> ret>' for
'"Rust"' and '"C"' ABIs and up to 20 arguments
- Changed blanket impls of 'Init' and 'PinInit' from 'impl<T, E>
[Pin]Init<T, E> for T' to 'impl<T> [Pin]Init<T> for T'
- Renamed 'zeroed()' to 'init_zeroed()'
- Upstream dev news: improve CI more to deny warnings, use
'--all-targets'. Check the synchronization status of the two
'-next' branches in upstream and the kernel
MAINTAINERS:
- Add Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki and Lorenzo
Stoakes as reviewers (thanks everyone)
And a few other cleanups and improvements"
* tag 'rust-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux: (76 commits)
rust: Add warn_on macro
arm64/bug: Add ARCH_WARN_ASM macro for BUG/WARN asm code sharing with Rust
riscv/bug: Add ARCH_WARN_ASM macro for BUG/WARN asm code sharing with Rust
x86/bug: Add ARCH_WARN_ASM macro for BUG/WARN asm code sharing with Rust
rust: kernel: move ARef and AlwaysRefCounted to sync::aref
rust: sync: fix safety comment for `static_lock_class`
rust: types: remove `Either<L, R>`
rust: kernel: use `core::ffi::CStr` method names
rust: str: add `CStr` methods matching `core::ffi::CStr`
rust: str: remove unnecessary qualification
rust: use `kernel::{fmt,prelude::fmt!}`
rust: kernel: add `fmt` module
rust: kernel: remove `fmt!`, fix clippy::uninlined-format-args
scripts: rust: emit path candidates in panic message
scripts: rust: replace length checks with match
rust: list: remove nonexistent generic parameter in link
rust: bits: add support for bits/genmask macros
rust: list: remove OFFSET constants
rust: list: add `impl_list_item!` examples
rust: list: use fully qualified path
...
This commit is contained in:
@@ -22032,6 +22032,10 @@ K: \b(?i:rust)\b
|
||||
|
||||
RUST [ALLOC]
|
||||
M: Danilo Krummrich <dakr@kernel.org>
|
||||
R: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
|
||||
R: Vlastimil Babka <vbabka@suse.cz>
|
||||
R: Liam R. Howlett <Liam.Howlett@oracle.com>
|
||||
R: Uladzislau Rezki <urezki@gmail.com>
|
||||
L: rust-for-linux@vger.kernel.org
|
||||
S: Maintained
|
||||
T: git https://github.com/Rust-for-Linux/linux.git alloc-next
|
||||
|
||||
@@ -479,11 +479,17 @@ export rust_common_flags := --edition=2021 \
|
||||
-Wrust_2018_idioms \
|
||||
-Wunreachable_pub \
|
||||
-Wclippy::all \
|
||||
-Wclippy::as_ptr_cast_mut \
|
||||
-Wclippy::as_underscore \
|
||||
-Wclippy::cast_lossless \
|
||||
-Wclippy::ignored_unit_patterns \
|
||||
-Wclippy::mut_mut \
|
||||
-Wclippy::needless_bitwise_bool \
|
||||
-Aclippy::needless_lifetimes \
|
||||
-Wclippy::no_mangle_with_rust_abi \
|
||||
-Wclippy::ptr_as_ptr \
|
||||
-Wclippy::ptr_cast_constness \
|
||||
-Wclippy::ref_as_ptr \
|
||||
-Wclippy::undocumented_unsafe_blocks \
|
||||
-Wclippy::unnecessary_safety_comment \
|
||||
-Wclippy::unnecessary_safety_doc \
|
||||
|
||||
@@ -21,16 +21,21 @@
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_GENERIC_BUG
|
||||
|
||||
#define __BUG_ENTRY(flags) \
|
||||
#define __BUG_ENTRY_START \
|
||||
.pushsection __bug_table,"aw"; \
|
||||
.align 2; \
|
||||
14470: .long 14471f - .; \
|
||||
_BUGVERBOSE_LOCATION(__FILE__, __LINE__) \
|
||||
.short flags; \
|
||||
|
||||
#define __BUG_ENTRY_END \
|
||||
.align 2; \
|
||||
.popsection; \
|
||||
14471:
|
||||
|
||||
#define __BUG_ENTRY(flags) \
|
||||
__BUG_ENTRY_START \
|
||||
_BUGVERBOSE_LOCATION(__FILE__, __LINE__) \
|
||||
.short flags; \
|
||||
__BUG_ENTRY_END
|
||||
#else
|
||||
#define __BUG_ENTRY(flags)
|
||||
#endif
|
||||
@@ -41,4 +46,24 @@ _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \
|
||||
|
||||
#define ASM_BUG() ASM_BUG_FLAGS(0)
|
||||
|
||||
#ifdef CONFIG_DEBUG_BUGVERBOSE
|
||||
#define __BUG_LOCATION_STRING(file, line) \
|
||||
".long " file "- .;" \
|
||||
".short " line ";"
|
||||
#else
|
||||
#define __BUG_LOCATION_STRING(file, line)
|
||||
#endif
|
||||
|
||||
#define __BUG_ENTRY_STRING(file, line, flags) \
|
||||
__stringify(__BUG_ENTRY_START) \
|
||||
__BUG_LOCATION_STRING(file, line) \
|
||||
".short " flags ";" \
|
||||
__stringify(__BUG_ENTRY_END)
|
||||
|
||||
#define ARCH_WARN_ASM(file, line, flags, size) \
|
||||
__BUG_ENTRY_STRING(file, line, flags) \
|
||||
__stringify(brk BUG_BRK_IMM)
|
||||
|
||||
#define ARCH_WARN_REACHABLE
|
||||
|
||||
#endif /* __ASM_ASM_BUG_H */
|
||||
|
||||
@@ -31,40 +31,45 @@ typedef u32 bug_insn_t;
|
||||
|
||||
#ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
|
||||
#define __BUG_ENTRY_ADDR RISCV_INT " 1b - ."
|
||||
#define __BUG_ENTRY_FILE RISCV_INT " %0 - ."
|
||||
#define __BUG_ENTRY_FILE(file) RISCV_INT " " file " - ."
|
||||
#else
|
||||
#define __BUG_ENTRY_ADDR RISCV_PTR " 1b"
|
||||
#define __BUG_ENTRY_FILE RISCV_PTR " %0"
|
||||
#define __BUG_ENTRY_FILE(file) RISCV_PTR " " file
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_BUGVERBOSE
|
||||
#define __BUG_ENTRY \
|
||||
#define __BUG_ENTRY(file, line, flags) \
|
||||
__BUG_ENTRY_ADDR "\n\t" \
|
||||
__BUG_ENTRY_FILE "\n\t" \
|
||||
RISCV_SHORT " %1\n\t" \
|
||||
RISCV_SHORT " %2"
|
||||
__BUG_ENTRY_FILE(file) "\n\t" \
|
||||
RISCV_SHORT " " line "\n\t" \
|
||||
RISCV_SHORT " " flags
|
||||
#else
|
||||
#define __BUG_ENTRY \
|
||||
__BUG_ENTRY_ADDR "\n\t" \
|
||||
RISCV_SHORT " %2"
|
||||
#define __BUG_ENTRY(file, line, flags) \
|
||||
__BUG_ENTRY_ADDR "\n\t" \
|
||||
RISCV_SHORT " " flags
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_GENERIC_BUG
|
||||
#define __BUG_FLAGS(flags) \
|
||||
do { \
|
||||
__asm__ __volatile__ ( \
|
||||
|
||||
#define ARCH_WARN_ASM(file, line, flags, size) \
|
||||
"1:\n\t" \
|
||||
"ebreak\n" \
|
||||
".pushsection __bug_table,\"aw\"\n\t" \
|
||||
"2:\n\t" \
|
||||
__BUG_ENTRY "\n\t" \
|
||||
".org 2b + %3\n\t" \
|
||||
__BUG_ENTRY(file, line, flags) "\n\t" \
|
||||
".org 2b + " size "\n\t" \
|
||||
".popsection" \
|
||||
|
||||
#define __BUG_FLAGS(flags) \
|
||||
do { \
|
||||
__asm__ __volatile__ ( \
|
||||
ARCH_WARN_ASM("%0", "%1", "%2", "%3") \
|
||||
: \
|
||||
: "i" (__FILE__), "i" (__LINE__), \
|
||||
"i" (flags), \
|
||||
"i" (sizeof(struct bug_entry))); \
|
||||
} while (0)
|
||||
|
||||
#else /* CONFIG_GENERIC_BUG */
|
||||
#define __BUG_FLAGS(flags) do { \
|
||||
__asm__ __volatile__ ("ebreak\n"); \
|
||||
@@ -78,6 +83,8 @@ do { \
|
||||
|
||||
#define __WARN_FLAGS(flags) __BUG_FLAGS(BUGFLAG_WARNING|(flags))
|
||||
|
||||
#define ARCH_WARN_REACHABLE
|
||||
|
||||
#define HAVE_ARCH_BUG
|
||||
|
||||
#include <asm-generic/bug.h>
|
||||
|
||||
+28
-28
@@ -32,45 +32,42 @@
|
||||
#ifdef CONFIG_GENERIC_BUG
|
||||
|
||||
#ifdef CONFIG_X86_32
|
||||
# define __BUG_REL(val) ".long " __stringify(val)
|
||||
# define __BUG_REL(val) ".long " val
|
||||
#else
|
||||
# define __BUG_REL(val) ".long " __stringify(val) " - ."
|
||||
# define __BUG_REL(val) ".long " val " - ."
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_BUGVERBOSE
|
||||
#define __BUG_ENTRY(file, line, flags) \
|
||||
"2:\t" __BUG_REL("1b") "\t# bug_entry::bug_addr\n" \
|
||||
"\t" __BUG_REL(file) "\t# bug_entry::file\n" \
|
||||
"\t.word " line "\t# bug_entry::line\n" \
|
||||
"\t.word " flags "\t# bug_entry::flags\n"
|
||||
#else
|
||||
#define __BUG_ENTRY(file, line, flags) \
|
||||
"2:\t" __BUG_REL("1b") "\t# bug_entry::bug_addr\n" \
|
||||
"\t.word " flags "\t# bug_entry::flags\n"
|
||||
#endif
|
||||
|
||||
#define _BUG_FLAGS_ASM(ins, file, line, flags, size, extra) \
|
||||
"1:\t" ins "\n" \
|
||||
".pushsection __bug_table,\"aw\"\n" \
|
||||
__BUG_ENTRY(file, line, flags) \
|
||||
"\t.org 2b + " size "\n" \
|
||||
".popsection\n" \
|
||||
extra
|
||||
|
||||
#define _BUG_FLAGS(ins, flags, extra) \
|
||||
do { \
|
||||
asm_inline volatile("1:\t" ins "\n" \
|
||||
".pushsection __bug_table,\"aw\"\n" \
|
||||
"2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
|
||||
"\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \
|
||||
"\t.word %c1" "\t# bug_entry::line\n" \
|
||||
"\t.word %c2" "\t# bug_entry::flags\n" \
|
||||
"\t.org 2b+%c3\n" \
|
||||
".popsection\n" \
|
||||
extra \
|
||||
asm_inline volatile(_BUG_FLAGS_ASM(ins, "%c0", \
|
||||
"%c1", "%c2", "%c3", extra) \
|
||||
: : "i" (__FILE__), "i" (__LINE__), \
|
||||
"i" (flags), \
|
||||
"i" (sizeof(struct bug_entry))); \
|
||||
} while (0)
|
||||
|
||||
#else /* !CONFIG_DEBUG_BUGVERBOSE */
|
||||
|
||||
#define _BUG_FLAGS(ins, flags, extra) \
|
||||
do { \
|
||||
asm_inline volatile("1:\t" ins "\n" \
|
||||
".pushsection __bug_table,\"aw\"\n" \
|
||||
"2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
|
||||
"\t.word %c0" "\t# bug_entry::flags\n" \
|
||||
"\t.org 2b+%c1\n" \
|
||||
".popsection\n" \
|
||||
extra \
|
||||
: : "i" (flags), \
|
||||
"i" (sizeof(struct bug_entry))); \
|
||||
} while (0)
|
||||
|
||||
#endif /* CONFIG_DEBUG_BUGVERBOSE */
|
||||
#define ARCH_WARN_ASM(file, line, flags, size) \
|
||||
_BUG_FLAGS_ASM(ASM_UD2, file, line, flags, size, "")
|
||||
|
||||
#else
|
||||
|
||||
@@ -92,11 +89,14 @@ do { \
|
||||
* were to trigger, we'd rather wreck the machine in an attempt to get the
|
||||
* message out than not know about it.
|
||||
*/
|
||||
|
||||
#define ARCH_WARN_REACHABLE ANNOTATE_REACHABLE(1b)
|
||||
|
||||
#define __WARN_FLAGS(flags) \
|
||||
do { \
|
||||
__auto_type __flags = BUGFLAG_WARNING|(flags); \
|
||||
instrumentation_begin(); \
|
||||
_BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE(1b)); \
|
||||
_BUG_FLAGS(ASM_UD2, __flags, ARCH_WARN_REACHABLE); \
|
||||
instrumentation_end(); \
|
||||
} while (0)
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ use kernel::{
|
||||
cpumask::CpumaskVar,
|
||||
device::{Core, Device},
|
||||
error::code::*,
|
||||
fmt,
|
||||
macros::vtable,
|
||||
module_platform_driver, of, opp, platform,
|
||||
prelude::*,
|
||||
@@ -19,7 +18,7 @@ use kernel::{
|
||||
|
||||
/// Finds exact supply name from the OF node.
|
||||
fn find_supply_name_exact(dev: &Device, name: &str) -> Option<CString> {
|
||||
let prop_name = CString::try_from_fmt(fmt!("{}-supply", name)).ok()?;
|
||||
let prop_name = CString::try_from_fmt(fmt!("{name}-supply")).ok()?;
|
||||
dev.fwnode()?
|
||||
.property_present(&prop_name)
|
||||
.then(|| CString::try_from_fmt(fmt!("{name}")).ok())
|
||||
@@ -221,7 +220,7 @@ impl platform::Driver for CPUFreqDTDriver {
|
||||
module_platform_driver! {
|
||||
type: CPUFreqDTDriver,
|
||||
name: "cpufreq-dt",
|
||||
author: "Viresh Kumar <viresh.kumar@linaro.org>",
|
||||
authors: ["Viresh Kumar <viresh.kumar@linaro.org>"],
|
||||
description: "Generic CPUFreq DT driver",
|
||||
license: "GPL v2",
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ impl DecFifo {
|
||||
let mut out = 0;
|
||||
let mut exp = 1;
|
||||
for i in 0..poplen {
|
||||
out += self.decimals[self.len + i] as u16 * exp;
|
||||
out += u16::from(self.decimals[self.len + i]) * exp;
|
||||
exp *= 10;
|
||||
}
|
||||
Some((out, NUM_CHARS_BITS[poplen]))
|
||||
@@ -425,7 +425,7 @@ impl Iterator for SegmentIterator<'_> {
|
||||
match self.segment {
|
||||
Segment::Binary(data) => {
|
||||
if self.offset < data.len() {
|
||||
let byte = data[self.offset] as u16;
|
||||
let byte = u16::from(data[self.offset]);
|
||||
self.offset += 1;
|
||||
Some((byte, 8))
|
||||
} else {
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::driver::NovaDriver;
|
||||
kernel::module_auxiliary_driver! {
|
||||
type: NovaDriver,
|
||||
name: "Nova",
|
||||
author: "Danilo Krummrich",
|
||||
authors: ["Danilo Krummrich"],
|
||||
description: "Nova GPU driver",
|
||||
license: "GPL v2",
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ kernel::pci_device_table!(
|
||||
MODULE_PCI_TABLE,
|
||||
<NovaCore as pci::Driver>::IdInfo,
|
||||
[(
|
||||
pci::DeviceId::from_id(bindings::PCI_VENDOR_ID_NVIDIA, bindings::PCI_ANY_ID as _),
|
||||
pci::DeviceId::from_id(bindings::PCI_VENDOR_ID_NVIDIA, bindings::PCI_ANY_ID as u32),
|
||||
()
|
||||
)]
|
||||
);
|
||||
|
||||
@@ -30,11 +30,12 @@ pub(crate) struct Firmware {
|
||||
|
||||
impl Firmware {
|
||||
pub(crate) fn new(dev: &device::Device, chipset: Chipset, ver: &str) -> Result<Firmware> {
|
||||
let mut chip_name = CString::try_from_fmt(fmt!("{}", chipset))?;
|
||||
let mut chip_name = CString::try_from_fmt(fmt!("{chipset}"))?;
|
||||
chip_name.make_ascii_lowercase();
|
||||
let chip_name = &*chip_name;
|
||||
|
||||
let request = |name_| {
|
||||
CString::try_from_fmt(fmt!("nvidia/{}/gsp/{}-{}.bin", &*chip_name, name_, ver))
|
||||
CString::try_from_fmt(fmt!("nvidia/{chip_name}/gsp/{name_}-{ver}.bin"))
|
||||
.and_then(|path| firmware::Firmware::request(&path, dev))
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ pub(crate) const MODULE_NAME: &kernel::str::CStr = <LocalModule as kernel::Modul
|
||||
kernel::module_pci_driver! {
|
||||
type: driver::NovaCore,
|
||||
name: "NovaCore",
|
||||
author: "Danilo Krummrich",
|
||||
authors: ["Danilo Krummrich"],
|
||||
description: "Nova Core GPU driver",
|
||||
license: "GPL v2",
|
||||
firmware: [],
|
||||
|
||||
@@ -36,7 +36,7 @@ impl NV_PMC_BOOT_0 {
|
||||
pub(crate) fn chipset(self) -> Result<Chipset> {
|
||||
self.architecture()
|
||||
.map(|arch| {
|
||||
((arch as u32) << Self::IMPLEMENTATION.len()) | self.implementation() as u32
|
||||
((arch as u32) << Self::IMPLEMENTATION.len()) | u32::from(self.implementation())
|
||||
})
|
||||
.and_then(Chipset::try_from)
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ macro_rules! register {
|
||||
pub(crate) fn [<set_ $field>](mut self, value: $to_type) -> Self {
|
||||
const MASK: u32 = $name::[<$field:upper _MASK>];
|
||||
const SHIFT: u32 = $name::[<$field:upper _SHIFT>];
|
||||
let value = ((value as u32) << SHIFT) & MASK;
|
||||
let value = (u32::from(value) << SHIFT) & MASK;
|
||||
self.0 = (self.0 & !MASK) | value;
|
||||
|
||||
self
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
use kernel::prelude::*;
|
||||
use kernel::time::{Delta, Instant};
|
||||
use kernel::time::{Delta, Instant, Monotonic};
|
||||
|
||||
pub(crate) const fn to_lowercase_bytes<const N: usize>(s: &str) -> [u8; N] {
|
||||
let src = s.as_bytes();
|
||||
@@ -33,7 +33,7 @@ pub(crate) const fn const_bytes_to_str(bytes: &[u8]) -> &str {
|
||||
/// TODO[DLAY]: replace with `read_poll_timeout` once it is available.
|
||||
/// (https://lore.kernel.org/lkml/20250220070611.214262-8-fujita.tomonori@gmail.com/)
|
||||
pub(crate) fn wait_on<R, F: Fn() -> Option<R>>(timeout: Delta, cond: F) -> Result<R> {
|
||||
let start_time = Instant::now();
|
||||
let start_time = Instant::<Monotonic>::now();
|
||||
|
||||
loop {
|
||||
if let Some(ret) = cond() {
|
||||
|
||||
@@ -34,6 +34,9 @@ obj-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.o
|
||||
obj-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.o
|
||||
|
||||
always-$(subst y,$(CONFIG_RUST),$(CONFIG_JUMP_LABEL)) += kernel/generated_arch_static_branch_asm.rs
|
||||
ifndef CONFIG_UML
|
||||
always-$(subst y,$(CONFIG_RUST),$(CONFIG_BUG)) += kernel/generated_arch_warn_asm.rs kernel/generated_arch_reachable_asm.rs
|
||||
endif
|
||||
|
||||
# Avoids running `$(RUSTC)` when it may not be available.
|
||||
ifdef CONFIG_RUST
|
||||
@@ -541,5 +544,10 @@ $(obj)/kernel.o: $(src)/kernel/lib.rs $(obj)/build_error.o $(obj)/pin_init.o \
|
||||
ifdef CONFIG_JUMP_LABEL
|
||||
$(obj)/kernel.o: $(obj)/kernel/generated_arch_static_branch_asm.rs
|
||||
endif
|
||||
ifndef CONFIG_UML
|
||||
ifdef CONFIG_BUG
|
||||
$(obj)/kernel.o: $(obj)/kernel/generated_arch_warn_asm.rs $(obj)/kernel/generated_arch_reachable_asm.rs
|
||||
endif
|
||||
endif
|
||||
|
||||
endif # CONFIG_RUST
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
)]
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[allow(clippy::cast_lossless)]
|
||||
#[allow(clippy::ptr_as_ptr)]
|
||||
#[allow(clippy::ref_as_ptr)]
|
||||
#[allow(clippy::undocumented_unsafe_blocks)]
|
||||
#[cfg_attr(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES, allow(unnecessary_transmutes))]
|
||||
mod bindings_raw {
|
||||
|
||||
@@ -6,3 +6,8 @@ __noreturn void rust_helper_BUG(void)
|
||||
{
|
||||
BUG();
|
||||
}
|
||||
|
||||
bool rust_helper_WARN_ON(bool cond)
|
||||
{
|
||||
return WARN_ON(cond);
|
||||
}
|
||||
|
||||
@@ -30,21 +30,22 @@
|
||||
#include "mutex.c"
|
||||
#include "of.c"
|
||||
#include "page.c"
|
||||
#include "platform.c"
|
||||
#include "pci.c"
|
||||
#include "pid_namespace.c"
|
||||
#include "platform.c"
|
||||
#include "poll.c"
|
||||
#include "property.c"
|
||||
#include "rbtree.c"
|
||||
#include "regulator.c"
|
||||
#include "rcu.c"
|
||||
#include "refcount.c"
|
||||
#include "regulator.c"
|
||||
#include "security.c"
|
||||
#include "signal.c"
|
||||
#include "slab.c"
|
||||
#include "spinlock.c"
|
||||
#include "sync.c"
|
||||
#include "task.c"
|
||||
#include "time.c"
|
||||
#include "uaccess.c"
|
||||
#include "vmalloc.c"
|
||||
#include "wait.c"
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/ktime.h>
|
||||
#include <linux/timekeeping.h>
|
||||
|
||||
void rust_helper_fsleep(unsigned long usecs)
|
||||
{
|
||||
fsleep(usecs);
|
||||
}
|
||||
|
||||
ktime_t rust_helper_ktime_get_real(void)
|
||||
{
|
||||
return ktime_get_real();
|
||||
}
|
||||
|
||||
ktime_t rust_helper_ktime_get_boottime(void)
|
||||
{
|
||||
return ktime_get_boottime();
|
||||
}
|
||||
|
||||
ktime_t rust_helper_ktime_get_clocktai(void)
|
||||
{
|
||||
return ktime_get_clocktai();
|
||||
}
|
||||
|
||||
s64 rust_helper_ktime_to_us(const ktime_t kt)
|
||||
{
|
||||
return ktime_to_us(kt);
|
||||
}
|
||||
|
||||
s64 rust_helper_ktime_to_ms(const ktime_t kt)
|
||||
{
|
||||
return ktime_to_ms(kt);
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
/generated_arch_static_branch_asm.rs
|
||||
/generated_arch_warn_asm.rs
|
||||
/generated_arch_reachable_asm.rs
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user