/// // 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()?;
///
})
}
- 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()) })
}
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()
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()
}
/// 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()
}
}