[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a726b9ae-dfe0-48b7-9290-ed81fded7cd1@kernel.org>
Date: Thu, 10 Jul 2025 16:46:11 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Igor Korotin <igor.korotin.linux@...il.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Wolfram Sang <wsa+renesas@...g-engineering.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>, Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Viresh Kumar <viresh.kumar@...aro.org>,
Asahi Lina <lina+kernel@...hilina.net>,
Wedson Almeida Filho <wedsonaf@...il.com>, Alex Hung <alex.hung@....com>,
Tamir Duberstein <tamird@...il.com>,
Xiangfei Ding <dingxiangfei2009@...il.com>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, linux-i2c@...r.kernel.org
Subject: Re: [PATCH v2 1/4] rust: i2c: add basic I2C device and driver
abstractions
On 7/10/25 4:04 PM, Igor Korotin wrote:
> On 7/4/25 21:16, Danilo Krummrich wrote:
>>> +
>>> + 0
>>> + }
>>> +
>>> + extern "C" fn remove_callback(pdev: *mut bindings::i2c_client) {
>>> + // SAFETY: `pdev` is a valid pointer to a `struct i2c_client`.
>>> + let ptr = unsafe { bindings::i2c_get_clientdata(pdev) }.cast();
>>> +
>>> + // SAFETY: `remove_callback` is only ever called after a successful call to
>>> + // `probe_callback`, hence it's guaranteed that `ptr` points to a valid and initialized
>>> + // `KBox<T>` pointer created through `KBox::into_foreign`.
>>> + let _ = unsafe { KBox::<T>::from_foreign(ptr) };
>>
>> I like to do that as well, but I usually get asked to use drop() instead, let's
>> do that here as well. :)
>>
>
> Danilo, could you, please, explain this one a little bit more? I see the
> same pattern for all the implemented subsystems so far: auxiliary,
> platform, pci.
> If this pattern for these subsystems is to be changed, then I'm fine.
Yes, this is because I wrote those and wasn't caught not using drop(), but `let
_ = ...` instead. :)
It was already changed by [1], which you want to rebase onto, the changes are in
driver-core-next.
[1] https://lore.kernel.org/r/20250621195118.124245-8-dakr@kernel.org
Powered by blists - more mailing lists