[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <dd850b46-1e9f-4812-a356-41ae6fd0ce59@gmail.com>
Date: Thu, 10 Jul 2025 15:04:59 +0100
From: Igor Korotin <igor.korotin.linux@...il.com>
To: Danilo Krummrich <dakr@...nel.org>
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/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.
Otherwise I'm not sure I understand the difference between these 3 and
I2C Adapter abstraction
Thanks
Igor
Powered by blists - more mailing lists