[PATCH v14 1/7] pwm: Export `pwmchip_release` for external use

Michal Wilczynski m.wilczynski at samsung.com
Wed Sep 24 12:30:34 PDT 2025



On 9/15/25 12:00, Uwe Kleine-König wrote:
> Hello,
> 
> On Wed, Aug 20, 2025 at 10:35:36AM +0200, Michal Wilczynski wrote:
>> The upcoming Rust abstraction layer for the PWM subsystem uses a custom
>> `dev->release` handler to safely manage the lifetime of its driver
>> data.
>>
>> To prevent leaking the memory of the `struct pwm_chip` (allocated by
>> `pwmchip_alloc`), this custom handler must also call the original
>> `pwmchip_release` function to complete the cleanup.
>>
>> Make `pwmchip_release` a global, exported function so that it can be
>> called from the Rust FFI bridge. This involves removing the `static`
>> keyword, adding a prototype to the public header, and exporting the
>> symbol.
>>
>> Signed-off-by: Michal Wilczynski <m.wilczynski at samsung.com>
> 
> I still somewhat dislike this patch. Isn't it possible to make the rust
> abstraction use the pointer that .release is set to when it calls
> pwmchip_alloc()?

Hi Uwe,

Sorry for the delay - I was on vacation and I hope you received my
out of office message.

I agree your suggestion is technically feasible. My concern was that it
would make the abstraction less readable and more complex, as it would
require the FFI wrapper to read the C function pointer and store it as
state within the driver's private data.

The current approach of calling a known, exported function felt more
direct. However, I absolutely agree with your point on C API purity and,
as you suggested, this can be revisited later if needed.

> 
> (I wouldn't further delay this series for this discussion, this can be
> handled just fine at a later point in time.)
> 
> Best regards
> Uwe

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



More information about the linux-riscv mailing list