[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <67e3a691-0ba8-4c21-97e1-4471f2a1a87c@samsung.com>
Date: Wed, 24 Sep 2025 21:30:34 +0200
From: Michal Wilczynski <m.wilczynski@...sung.com>
To: Uwe Kleine-König <ukleinek@...nel.org>
Cc: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>, Andreas
Hindborg <a.hindborg@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>, Trevor
Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>, Guo Ren
<guoren@...nel.org>, Fu Wei <wefu@...hat.com>, Rob Herring
<robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
<conor+dt@...nel.org>, Paul Walmsley <paul.walmsley@...ive.com>, Palmer
Dabbelt <palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>, Alexandre
Ghiti <alex@...ti.fr>, Marek Szyprowski <m.szyprowski@...sung.com>, Benno
Lossin <lossin@...nel.org>, Michael Turquette <mturquette@...libre.com>,
Drew Fustini <fustini@...nel.org>, Daniel Almeida
<daniel.almeida@...labora.com>, linux-kernel@...r.kernel.org,
linux-pwm@...r.kernel.org, rust-for-linux@...r.kernel.org,
linux-riscv@...ts.infradead.org, devicetree@...r.kernel.org
Subject: Re: [PATCH v14 1/7] pwm: Export `pwmchip_release` for external use
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@...sung.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@...sung.com>
Powered by blists - more mailing lists