linux/rust/helpers/mutex.c
Paolo Bonzini 4dbe28c0fa rust: add helper for mutex_trylock
After commit c5b6ababd2 ("locking/mutex: implement mutex_trylock_nested",
currently in the KVM tree) mutex_trylock() will be a macro when lockdep is
enabled.  Rust therefore needs the corresponding helper.  Just add it and
the rust/bindings/bindings_helpers_generated.rs Makefile rules will do
their thing.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-ID: <20250528083431.1875345-1-pbonzini@redhat.com>
Acked-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-28 06:28:30 -04:00

24 lines
455 B
C

// SPDX-License-Identifier: GPL-2.0
#include <linux/mutex.h>
void rust_helper_mutex_lock(struct mutex *lock)
{
mutex_lock(lock);
}
int rust_helper_mutex_trylock(struct mutex *lock)
{
return mutex_trylock(lock);
}
void rust_helper___mutex_init(struct mutex *mutex, const char *name,
struct lock_class_key *key)
{
__mutex_init(mutex, name, key);
}
void rust_helper_mutex_assert_is_held(struct mutex *mutex)
{
lockdep_assert_held(mutex);
}