[PATCH v14 2/7] rust: pwm: Add Kconfig and basic data structures

Michal Wilczynski m.wilczynski at samsung.com
Wed Sep 24 13:10:57 PDT 2025



On 9/15/25 12:13, Uwe Kleine-König wrote:
> Hello Michal,
> 
> On Wed, Aug 20, 2025 at 10:35:37AM +0200, Michal Wilczynski wrote:
>> Introduce the foundational support for PWM abstractions in Rust.
>>
>> This commit adds the `RUST_PWM_ABSTRACTIONS` Kconfig option to enable
>> the feature, along with the necessary build-system support and C
>> helpers.
>>
>> It also introduces the first set of safe wrappers for the PWM
>> subsystem, covering the basic data carrying C structs and enums:
>> - `Polarity`: A safe wrapper for `enum pwm_polarity`.
>> - `Waveform`: A wrapper for `struct pwm_waveform`.
>> - `Args`: A wrapper for `struct pwm_args`.
>> - `State`: A wrapper for `struct pwm_state`.
> 
> Args, State and Polarity are only needed for the consumer side of the
> PWM API in Rust, right?
> 
> I don't particularily like like pwm_args and wonder if this really has
> to be exposed to Rust.

You're right that Args is primarily for the consumer side, and our
provider driver doesn't use it at all. I only included it for
completeness, so I'm happy to remove it from the abstractions.

I did use State on the provider side, however, to check if a channel is
enabled before writing new hardware values - I've seen your comment
about it that it's better to use the HW registers instead, I remember I
tried doing something like this back in May when started working on
this, but haven't succeeded - will refresh my memory and respond to the
driver comments.

> 
> I think for State (and thus Polarity) we have to have it for the
> forseeable future.
> 
> Best regards
> Uwe

Best regards,
-- 
Michal Wilczynski <m.wilczynski at samsung.com>



More information about the linux-riscv mailing list