diff options
| author | Uwe Kleine-König <u.kleine-koenig@baylibre.com> | 2025-10-25 14:23:56 +0200 |
|---|---|---|
| committer | Uwe Kleine-König <ukleinek@kernel.org> | 2025-11-07 10:22:43 +0100 |
| commit | a69a54f8dffb105b2df2e606b4c9f61127d006ac (patch) | |
| tree | 13f748d4a0aedc28316e811c771dbaffeebde400 | |
| parent | 264b501bb40dd22e8c4ab2c8a3378e32c2e04ec6 (diff) | |
rust: pwm: Drop wrapping of PWM polarity and state
These were introduced and used in an earlier revision of the patch that
became commit fb3957af9ec6 ("pwm: Add Rust driver for T-HEAD TH1520
SoC"). The variant that was actually applied sticks to the modern
waveform abstraction only (and other drivers are supposed to do that,
too), so they can be dropped.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20251025122359.361372-2-u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
| -rw-r--r-- | rust/kernel/pwm.rs | 56 |
1 files changed, 1 insertions, 55 deletions
diff --git a/rust/kernel/pwm.rs b/rust/kernel/pwm.rs index 6f2f78c687d5..b19661b83b0f 100644 --- a/rust/kernel/pwm.rs +++ b/rust/kernel/pwm.rs @@ -15,38 +15,7 @@ use crate::{ prelude::*, types::{ARef, AlwaysRefCounted, Opaque}, }; -use core::{convert::TryFrom, marker::PhantomData, ptr::NonNull}; - -/// PWM polarity. Mirrors [`enum pwm_polarity`](srctree/include/linux/pwm.h). -#[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub enum Polarity { - /// Normal polarity (duty cycle defines the high period of the signal). - Normal, - - /// Inversed polarity (duty cycle defines the low period of the signal). - Inversed, -} - -impl TryFrom<bindings::pwm_polarity> for Polarity { - type Error = Error; - - fn try_from(polarity: bindings::pwm_polarity) -> Result<Self, Error> { - match polarity { - bindings::pwm_polarity_PWM_POLARITY_NORMAL => Ok(Polarity::Normal), - bindings::pwm_polarity_PWM_POLARITY_INVERSED => Ok(Polarity::Inversed), - _ => Err(EINVAL), - } - } -} - -impl From<Polarity> for bindings::pwm_polarity { - fn from(polarity: Polarity) -> Self { - match polarity { - Polarity::Normal => bindings::pwm_polarity_PWM_POLARITY_NORMAL, - Polarity::Inversed => bindings::pwm_polarity_PWM_POLARITY_INVERSED, - } - } -} +use core::{marker::PhantomData, ptr::NonNull}; /// Represents a PWM waveform configuration. /// Mirrors struct [`struct pwm_waveform`](srctree/include/linux/pwm.h). @@ -89,22 +58,6 @@ impl From<Waveform> for bindings::pwm_waveform { } } -/// Wrapper for PWM state [`struct pwm_state`](srctree/include/linux/pwm.h). -#[repr(transparent)] -pub struct State(bindings::pwm_state); - -impl State { - /// Creates a `State` wrapper by taking ownership of a C `pwm_state` value. - pub(crate) fn from_c(c_state: bindings::pwm_state) -> Self { - State(c_state) - } - - /// Returns `true` if the PWM signal is enabled. - pub fn enabled(&self) -> bool { - self.0.enabled - } -} - /// Describes the outcome of a `round_waveform` operation. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum RoundingOutcome { @@ -164,13 +117,6 @@ impl Device { Some(unsafe { CStr::from_char_ptr(label_ptr) }) } - /// Gets a copy of the current state of this PWM device. - pub fn state(&self) -> State { - // SAFETY: `self.as_raw()` gives a valid pointer. `(*self.as_raw()).state` - // is a valid `pwm_state` struct. `State::from_c` copies this data. - State::from_c(unsafe { (*self.as_raw()).state }) - } - /// Sets the PWM waveform configuration and enables the PWM signal. pub fn set_waveform(&self, wf: &Waveform, exact: bool) -> Result { let c_wf = bindings::pwm_waveform::from(*wf); |
