* [PATCH net-next v2 0/2] Clean up usage of ffi types
@ 2025-06-25 12:25 Tamir Duberstein
2025-06-25 12:25 ` [PATCH net-next v2 1/2] Use unqualified references to " Tamir Duberstein
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Tamir Duberstein @ 2025-06-25 12:25 UTC (permalink / raw)
To: FUJITA Tomonori, Trevor Gross, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Danilo Krummrich, David S. Miller,
Andrew Lunn
Cc: netdev, rust-for-linux, linux-kernel, Tamir Duberstein
Remove qualification of ffi types which are included in the prelude and
change `as` casts to target the proper ffi type alias rather than the
underlying primitive.
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
Changes in v2:
- Use unqualified types.
- Remove Fixes tag.
- Link to v1: https://lore.kernel.org/r/20250611-correct-type-cast-v1-1-06c1cf970727@gmail.com
---
Tamir Duberstein (2):
Use unqualified references to ffi types
Cast to the proper type
rust/kernel/net/phy.rs | 34 +++++++++++++---------------------
1 file changed, 13 insertions(+), 21 deletions(-)
---
base-commit: 0303584766b7bdb6564c7e8f13e0b59b6ef44984
change-id: 20250611-correct-type-cast-1de8876ddfc1
Best regards,
--
Tamir Duberstein <tamird@gmail.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next v2 1/2] Use unqualified references to ffi types
2025-06-25 12:25 [PATCH net-next v2 0/2] Clean up usage of ffi types Tamir Duberstein
@ 2025-06-25 12:25 ` Tamir Duberstein
2025-06-28 2:34 ` FUJITA Tomonori
2025-06-25 12:25 ` [PATCH net-next v2 2/2] Cast to the proper type Tamir Duberstein
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Tamir Duberstein @ 2025-06-25 12:25 UTC (permalink / raw)
To: FUJITA Tomonori, Trevor Gross, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Danilo Krummrich, David S. Miller,
Andrew Lunn
Cc: netdev, rust-for-linux, linux-kernel, Tamir Duberstein
Remove unnecessary qualifications; `kernel::ffi::*` is included in
`kernel::prelude`.
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
rust/kernel/net/phy.rs | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
index 65ac4d59ad77..9b4dc09403e4 100644
--- a/rust/kernel/net/phy.rs
+++ b/rust/kernel/net/phy.rs
@@ -312,9 +312,7 @@ impl<T: Driver> Adapter<T> {
/// # Safety
///
/// `phydev` must be passed by the corresponding callback in `phy_driver`.
- unsafe extern "C" fn soft_reset_callback(
- phydev: *mut bindings::phy_device,
- ) -> crate::ffi::c_int {
+ unsafe extern "C" fn soft_reset_callback(phydev: *mut bindings::phy_device) -> c_int {
from_result(|| {
// SAFETY: This callback is called only in contexts
// where we hold `phy_device->lock`, so the accessors on
@@ -328,7 +326,7 @@ impl<T: Driver> Adapter<T> {
/// # Safety
///
/// `phydev` must be passed by the corresponding callback in `phy_driver`.
- unsafe extern "C" fn probe_callback(phydev: *mut bindings::phy_device) -> crate::ffi::c_int {
+ unsafe extern "C" fn probe_callback(phydev: *mut bindings::phy_device) -> c_int {
from_result(|| {
// SAFETY: This callback is called only in contexts
// where we can exclusively access `phy_device` because
@@ -343,9 +341,7 @@ impl<T: Driver> Adapter<T> {
/// # Safety
///
/// `phydev` must be passed by the corresponding callback in `phy_driver`.
- unsafe extern "C" fn get_features_callback(
- phydev: *mut bindings::phy_device,
- ) -> crate::ffi::c_int {
+ unsafe extern "C" fn get_features_callback(phydev: *mut bindings::phy_device) -> c_int {
from_result(|| {
// SAFETY: This callback is called only in contexts
// where we hold `phy_device->lock`, so the accessors on
@@ -359,7 +355,7 @@ impl<T: Driver> Adapter<T> {
/// # Safety
///
/// `phydev` must be passed by the corresponding callback in `phy_driver`.
- unsafe extern "C" fn suspend_callback(phydev: *mut bindings::phy_device) -> crate::ffi::c_int {
+ unsafe extern "C" fn suspend_callback(phydev: *mut bindings::phy_device) -> c_int {
from_result(|| {
// SAFETY: The C core code ensures that the accessors on
// `Device` are okay to call even though `phy_device->lock`
@@ -373,7 +369,7 @@ impl<T: Driver> Adapter<T> {
/// # Safety
///
/// `phydev` must be passed by the corresponding callback in `phy_driver`.
- unsafe extern "C" fn resume_callback(phydev: *mut bindings::phy_device) -> crate::ffi::c_int {
+ unsafe extern "C" fn resume_callback(phydev: *mut bindings::phy_device) -> c_int {
from_result(|| {
// SAFETY: The C core code ensures that the accessors on
// `Device` are okay to call even though `phy_device->lock`
@@ -387,9 +383,7 @@ impl<T: Driver> Adapter<T> {
/// # Safety
///
/// `phydev` must be passed by the corresponding callback in `phy_driver`.
- unsafe extern "C" fn config_aneg_callback(
- phydev: *mut bindings::phy_device,
- ) -> crate::ffi::c_int {
+ unsafe extern "C" fn config_aneg_callback(phydev: *mut bindings::phy_device) -> c_int {
from_result(|| {
// SAFETY: This callback is called only in contexts
// where we hold `phy_device->lock`, so the accessors on
@@ -403,9 +397,7 @@ impl<T: Driver> Adapter<T> {
/// # Safety
///
/// `phydev` must be passed by the corresponding callback in `phy_driver`.
- unsafe extern "C" fn read_status_callback(
- phydev: *mut bindings::phy_device,
- ) -> crate::ffi::c_int {
+ unsafe extern "C" fn read_status_callback(phydev: *mut bindings::phy_device) -> c_int {
from_result(|| {
// SAFETY: This callback is called only in contexts
// where we hold `phy_device->lock`, so the accessors on
@@ -422,7 +414,7 @@ impl<T: Driver> Adapter<T> {
unsafe extern "C" fn match_phy_device_callback(
phydev: *mut bindings::phy_device,
_phydrv: *const bindings::phy_driver,
- ) -> crate::ffi::c_int {
+ ) -> c_int {
// SAFETY: This callback is called only in contexts
// where we hold `phy_device->lock`, so the accessors on
// `Device` are okay to call.
--
2.50.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v2 2/2] Cast to the proper type
2025-06-25 12:25 [PATCH net-next v2 0/2] Clean up usage of ffi types Tamir Duberstein
2025-06-25 12:25 ` [PATCH net-next v2 1/2] Use unqualified references to " Tamir Duberstein
@ 2025-06-25 12:25 ` Tamir Duberstein
2025-06-30 13:18 ` [PATCH net-next v2 0/2] Clean up usage of ffi types Tamir Duberstein
2025-07-01 8:00 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 6+ messages in thread
From: Tamir Duberstein @ 2025-06-25 12:25 UTC (permalink / raw)
To: FUJITA Tomonori, Trevor Gross, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Danilo Krummrich, David S. Miller,
Andrew Lunn
Cc: netdev, rust-for-linux, linux-kernel, Tamir Duberstein
Use the ffi type rather than the resolved underlying type.
Acked-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
rust/kernel/net/phy.rs | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
index 9b4dc09403e4..5fa6b7e97887 100644
--- a/rust/kernel/net/phy.rs
+++ b/rust/kernel/net/phy.rs
@@ -163,20 +163,20 @@ pub fn set_speed(&mut self, speed: u32) {
let phydev = self.0.get();
// SAFETY: The struct invariant ensures that we may access
// this field without additional synchronization.
- unsafe { (*phydev).speed = speed as i32 };
+ unsafe { (*phydev).speed = speed as c_int };
}
/// Sets duplex mode.
pub fn set_duplex(&mut self, mode: DuplexMode) {
let phydev = self.0.get();
let v = match mode {
- DuplexMode::Full => bindings::DUPLEX_FULL as i32,
- DuplexMode::Half => bindings::DUPLEX_HALF as i32,
- DuplexMode::Unknown => bindings::DUPLEX_UNKNOWN as i32,
+ DuplexMode::Full => bindings::DUPLEX_FULL,
+ DuplexMode::Half => bindings::DUPLEX_HALF,
+ DuplexMode::Unknown => bindings::DUPLEX_UNKNOWN,
};
// SAFETY: The struct invariant ensures that we may access
// this field without additional synchronization.
- unsafe { (*phydev).duplex = v };
+ unsafe { (*phydev).duplex = v as c_int };
}
/// Reads a PHY register.
--
2.50.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 1/2] Use unqualified references to ffi types
2025-06-25 12:25 ` [PATCH net-next v2 1/2] Use unqualified references to " Tamir Duberstein
@ 2025-06-28 2:34 ` FUJITA Tomonori
0 siblings, 0 replies; 6+ messages in thread
From: FUJITA Tomonori @ 2025-06-28 2:34 UTC (permalink / raw)
To: tamird
Cc: fujita.tomonori, tmgross, ojeda, alex.gaynor, boqun.feng, gary,
bjorn3_gh, lossin, a.hindborg, aliceryhl, dakr, davem, andrew,
netdev, rust-for-linux, linux-kernel
On Wed, 25 Jun 2025 05:25:38 -0700
Tamir Duberstein <tamird@gmail.com> wrote:
> Remove unnecessary qualifications; `kernel::ffi::*` is included in
> `kernel::prelude`.
>
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>
> ---
> rust/kernel/net/phy.rs | 24 ++++++++----------------
> 1 file changed, 8 insertions(+), 16 deletions(-)
Reviewed-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 0/2] Clean up usage of ffi types
2025-06-25 12:25 [PATCH net-next v2 0/2] Clean up usage of ffi types Tamir Duberstein
2025-06-25 12:25 ` [PATCH net-next v2 1/2] Use unqualified references to " Tamir Duberstein
2025-06-25 12:25 ` [PATCH net-next v2 2/2] Cast to the proper type Tamir Duberstein
@ 2025-06-30 13:18 ` Tamir Duberstein
2025-07-01 8:00 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 6+ messages in thread
From: Tamir Duberstein @ 2025-06-30 13:18 UTC (permalink / raw)
To: FUJITA Tomonori, Trevor Gross, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Danilo Krummrich, David S. Miller,
Andrew Lunn
Cc: netdev, rust-for-linux, linux-kernel
On Wed, Jun 25, 2025 at 8:25 AM Tamir Duberstein <tamird@gmail.com> wrote:
>
> Remove qualification of ffi types which are included in the prelude and
> change `as` casts to target the proper ffi type alias rather than the
> underlying primitive.
>
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Hello, I believe both patches in this series have been reviewed; is
any further action required?
Thanks.
Tamir
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 0/2] Clean up usage of ffi types
2025-06-25 12:25 [PATCH net-next v2 0/2] Clean up usage of ffi types Tamir Duberstein
` (2 preceding siblings ...)
2025-06-30 13:18 ` [PATCH net-next v2 0/2] Clean up usage of ffi types Tamir Duberstein
@ 2025-07-01 8:00 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-07-01 8:00 UTC (permalink / raw)
To: Tamir Duberstein
Cc: fujita.tomonori, tmgross, ojeda, alex.gaynor, boqun.feng, gary,
bjorn3_gh, lossin, a.hindborg, aliceryhl, dakr, davem, andrew,
netdev, rust-for-linux, linux-kernel
Hello:
This series was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Wed, 25 Jun 2025 05:25:37 -0700 you wrote:
> Remove qualification of ffi types which are included in the prelude and
> change `as` casts to target the proper ffi type alias rather than the
> underlying primitive.
>
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>
> ---
> Changes in v2:
> - Use unqualified types.
> - Remove Fixes tag.
> - Link to v1: https://lore.kernel.org/r/20250611-correct-type-cast-v1-1-06c1cf970727@gmail.com
>
> [...]
Here is the summary with links:
- [net-next,v2,1/2] Use unqualified references to ffi types
https://git.kernel.org/netdev/net-next/c/22955d942f28
- [net-next,v2,2/2] Cast to the proper type
https://git.kernel.org/netdev/net-next/c/c9a7bcd2c016
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-07-01 7:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-25 12:25 [PATCH net-next v2 0/2] Clean up usage of ffi types Tamir Duberstein
2025-06-25 12:25 ` [PATCH net-next v2 1/2] Use unqualified references to " Tamir Duberstein
2025-06-28 2:34 ` FUJITA Tomonori
2025-06-25 12:25 ` [PATCH net-next v2 2/2] Cast to the proper type Tamir Duberstein
2025-06-30 13:18 ` [PATCH net-next v2 0/2] Clean up usage of ffi types Tamir Duberstein
2025-07-01 8:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).