Skip to content

Commit 15f2f93

Browse files
committed
rust: use the build_error! macro, not the hidden function
Code and some examples were using the function, rather than the macro. The macro is what is documented. Thus move users to the macro. Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20241123222849.350287-1-ojeda@kernel.org [ Applied the change to the new miscdevice cases. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 2a87f8b commit 15f2f93

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

rust/kernel/block/mq/operations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub trait Operations: Sized {
3535
/// Called by the kernel to poll the device for completed requests. Only
3636
/// used for poll queues.
3737
fn poll() -> bool {
38-
crate::build_error(crate::error::VTABLE_DEFAULT_ERROR)
38+
crate::build_error!(crate::error::VTABLE_DEFAULT_ERROR)
3939
}
4040
}
4141

rust/kernel/miscdevice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub trait MiscDevice {
116116
_cmd: u32,
117117
_arg: usize,
118118
) -> Result<isize> {
119-
kernel::build_error(VTABLE_DEFAULT_ERROR)
119+
kernel::build_error!(VTABLE_DEFAULT_ERROR)
120120
}
121121

122122
/// Handler for ioctls.
@@ -132,7 +132,7 @@ pub trait MiscDevice {
132132
_cmd: u32,
133133
_arg: usize,
134134
) -> Result<isize> {
135-
kernel::build_error(VTABLE_DEFAULT_ERROR)
135+
kernel::build_error!(VTABLE_DEFAULT_ERROR)
136136
}
137137
}
138138

rust/kernel/net/phy.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -587,17 +587,17 @@ pub trait Driver {
587587

588588
/// Issues a PHY software reset.
589589
fn soft_reset(_dev: &mut Device) -> Result {
590-
kernel::build_error(VTABLE_DEFAULT_ERROR)
590+
kernel::build_error!(VTABLE_DEFAULT_ERROR)
591591
}
592592

593593
/// Sets up device-specific structures during discovery.
594594
fn probe(_dev: &mut Device) -> Result {
595-
kernel::build_error(VTABLE_DEFAULT_ERROR)
595+
kernel::build_error!(VTABLE_DEFAULT_ERROR)
596596
}
597597

598598
/// Probes the hardware to determine what abilities it has.
599599
fn get_features(_dev: &mut Device) -> Result {
600-
kernel::build_error(VTABLE_DEFAULT_ERROR)
600+
kernel::build_error!(VTABLE_DEFAULT_ERROR)
601601
}
602602

603603
/// Returns true if this is a suitable driver for the given phydev.
@@ -609,32 +609,32 @@ pub trait Driver {
609609
/// Configures the advertisement and resets auto-negotiation
610610
/// if auto-negotiation is enabled.
611611
fn config_aneg(_dev: &mut Device) -> Result {
612-
kernel::build_error(VTABLE_DEFAULT_ERROR)
612+
kernel::build_error!(VTABLE_DEFAULT_ERROR)
613613
}
614614

615615
/// Determines the negotiated speed and duplex.
616616
fn read_status(_dev: &mut Device) -> Result<u16> {
617-
kernel::build_error(VTABLE_DEFAULT_ERROR)
617+
kernel::build_error!(VTABLE_DEFAULT_ERROR)
618618
}
619619

620620
/// Suspends the hardware, saving state if needed.
621621
fn suspend(_dev: &mut Device) -> Result {
622-
kernel::build_error(VTABLE_DEFAULT_ERROR)
622+
kernel::build_error!(VTABLE_DEFAULT_ERROR)
623623
}
624624

625625
/// Resumes the hardware, restoring state if needed.
626626
fn resume(_dev: &mut Device) -> Result {
627-
kernel::build_error(VTABLE_DEFAULT_ERROR)
627+
kernel::build_error!(VTABLE_DEFAULT_ERROR)
628628
}
629629

630630
/// Overrides the default MMD read function for reading a MMD register.
631631
fn read_mmd(_dev: &mut Device, _devnum: u8, _regnum: u16) -> Result<u16> {
632-
kernel::build_error(VTABLE_DEFAULT_ERROR)
632+
kernel::build_error!(VTABLE_DEFAULT_ERROR)
633633
}
634634

635635
/// Overrides the default MMD write function for writing a MMD register.
636636
fn write_mmd(_dev: &mut Device, _devnum: u8, _regnum: u16, _val: u16) -> Result {
637-
kernel::build_error(VTABLE_DEFAULT_ERROR)
637+
kernel::build_error!(VTABLE_DEFAULT_ERROR)
638638
}
639639

640640
/// Callback for notification of link change.

rust/macros/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ pub fn module(ts: TokenStream) -> TokenStream {
123123
/// used on the Rust side, it should not be possible to call the default
124124
/// implementation. This is done to ensure that we call the vtable methods
125125
/// through the C vtable, and not through the Rust vtable. Therefore, the
126-
/// default implementation should call `kernel::build_error`, which prevents
126+
/// default implementation should call `kernel::build_error!`, which prevents
127127
/// calls to this function at compile time:
128128
///
129129
/// ```compile_fail
130130
/// # // Intentionally missing `use`s to simplify `rusttest`.
131-
/// kernel::build_error(VTABLE_DEFAULT_ERROR)
131+
/// kernel::build_error!(VTABLE_DEFAULT_ERROR)
132132
/// ```
133133
///
134134
/// Note that you might need to import [`kernel::error::VTABLE_DEFAULT_ERROR`].
@@ -145,11 +145,11 @@ pub fn module(ts: TokenStream) -> TokenStream {
145145
/// #[vtable]
146146
/// pub trait Operations: Send + Sync + Sized {
147147
/// fn foo(&self) -> Result<()> {
148-
/// kernel::build_error(VTABLE_DEFAULT_ERROR)
148+
/// kernel::build_error!(VTABLE_DEFAULT_ERROR)
149149
/// }
150150
///
151151
/// fn bar(&self) -> Result<()> {
152-
/// kernel::build_error(VTABLE_DEFAULT_ERROR)
152+
/// kernel::build_error!(VTABLE_DEFAULT_ERROR)
153153
/// }
154154
/// }
155155
///

0 commit comments

Comments
 (0)