summaryrefslogtreecommitdiff
path: root/rust/kernel
diff options
context:
space:
mode:
authorDaniel Almeida <daniel.almeida@collabora.com>2025-07-29 14:31:40 -0300
committerMark Brown <broonie@kernel.org>2025-08-10 21:09:33 +0100
commitf7fbf3091f4cc4133574852f655593e1613d1af0 (patch)
treeb3358c406b6c80cc2276dec2b1c786a5bc1eb7a1 /rust/kernel
parent8f5ae30d69d7543eee0d70083daf4de8fe15d585 (diff)
rust: regulator: remove needless &mut from member functions
Regulator functions like "regulator_enable()" and "regulator_disable()" already provide their own locking through "regulator_lock_dependent()", so we can safely call the Rust API with a shared reference. This was already the case with Regulator::set_voltage() on the Rust side, but it was forgotten for Regulator::enable() and Regulator::disable(). Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com> Link: https://patch.msgid.link/20250729-regulator-send-sync-v1-1-8bcbd546b940@collabora.com Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'rust/kernel')
-rw-r--r--rust/kernel/regulator.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/rust/kernel/regulator.rs b/rust/kernel/regulator.rs
index 65f3a125348f..d56aa229e838 100644
--- a/rust/kernel/regulator.rs
+++ b/rust/kernel/regulator.rs
@@ -203,20 +203,20 @@ pub struct Error<State: RegulatorState> {
/// // A fictictious probe function that obtains a regulator and sets it up.
/// fn probe(dev: &Device) -> Result<PrivateData> {
/// // Obtain a reference to a (fictitious) regulator.
-/// let mut regulator = Regulator::<Dynamic>::get(dev, c_str!("vcc"))?;
+/// let regulator = Regulator::<Dynamic>::get(dev, c_str!("vcc"))?;
///
/// Ok(PrivateData { regulator })
/// }
///
/// // A fictictious function that indicates that the device is going to be used.
-/// fn open(dev: &Device, data: &mut PrivateData) -> Result {
+/// fn open(dev: &Device, data: &PrivateData) -> Result {
/// // Increase the `enabled` reference count.
/// data.regulator.enable()?;
///
/// Ok(())
/// }
///
-/// fn close(dev: &Device, data: &mut PrivateData) -> Result {
+/// fn close(dev: &Device, data: &PrivateData) -> Result {
/// // Decrease the `enabled` reference count.
/// data.regulator.disable()?;
///
@@ -289,12 +289,12 @@ impl<T: RegulatorState> Regulator<T> {
})
}
- fn enable_internal(&mut self) -> Result {
+ fn enable_internal(&self) -> Result {
// SAFETY: Safe as per the type invariants of `Regulator`.
to_result(unsafe { bindings::regulator_enable(self.inner.as_ptr()) })
}
- fn disable_internal(&mut self) -> Result {
+ fn disable_internal(&self) -> Result {
// SAFETY: Safe as per the type invariants of `Regulator`.
to_result(unsafe { bindings::regulator_disable(self.inner.as_ptr()) })
}
@@ -310,7 +310,7 @@ impl Regulator<Disabled> {
pub fn try_into_enabled(self) -> Result<Regulator<Enabled>, Error<Disabled>> {
// We will be transferring the ownership of our `regulator_get()` count to
// `Regulator<Enabled>`.
- let mut regulator = ManuallyDrop::new(self);
+ let regulator = ManuallyDrop::new(self);
regulator
.enable_internal()
@@ -339,7 +339,7 @@ impl Regulator<Enabled> {
pub fn try_into_disabled(self) -> Result<Regulator<Disabled>, Error<Enabled>> {
// We will be transferring the ownership of our `regulator_get()` count
// to `Regulator<Disabled>`.
- let mut regulator = ManuallyDrop::new(self);
+ let regulator = ManuallyDrop::new(self);
regulator
.disable_internal()
@@ -366,12 +366,12 @@ impl Regulator<Dynamic> {
}
/// Increases the `enabled` reference count.
- pub fn enable(&mut self) -> Result {
+ pub fn enable(&self) -> Result {
self.enable_internal()
}
/// Decreases the `enabled` reference count.
- pub fn disable(&mut self) -> Result {
+ pub fn disable(&self) -> Result {
self.disable_internal()
}
}