Skip to content

Commit 1ae284e

Browse files
committed
FIXM: rust: spi: Add spi_message_init
Signed-off-by: Esteban Blanc <[email protected]>
1 parent c7fdc10 commit 1ae284e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

rust/helpers.c

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/spinlock.h>
3232
#include <linux/wait.h>
3333
#include <linux/workqueue.h>
34+
#include <linux/spi/spi.h>
3435

3536
__noreturn void rust_helper_BUG(void)
3637
{
@@ -157,6 +158,13 @@ void rust_helper_init_work_with_key(struct work_struct *work, work_func_t func,
157158
}
158159
EXPORT_SYMBOL_GPL(rust_helper_init_work_with_key);
159160

161+
void rust_helper_spi_message_init(struct spi_message *m)
162+
{
163+
memset(m, 0, sizeof *m);
164+
spi_message_init_no_memset(m);
165+
}
166+
EXPORT_SYMBOL_GPL(rust_helper_spi_message_init);
167+
160168
/*
161169
* `bindgen` binds the C `size_t` type as the Rust `usize` type, so we can
162170
* use it in contexts where Rust expects a `usize` like slice (array) indices.

rust/kernel/spi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ impl SpiMessage {
295295
}
296296
/// Equivalent of `spi_message_init`
297297
pub fn spi_message_init(&mut self) {
298+
unsafe { bindings::spi_message_init(&mut self.0) }
298299
}
299300
}
300301

0 commit comments

Comments
 (0)