netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: cast to the proper type
@ 2025-06-11 10:28 Tamir Duberstein
  2025-06-11 11:42 ` Alice Ryhl
  2025-06-23 11:39 ` Alice Ryhl
  0 siblings, 2 replies; 14+ messages in thread
From: Tamir Duberstein @ 2025-06-11 10:28 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.

Fixes: f20fd5449ada ("rust: core abstractions for network PHY drivers")
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 32ea43ece646..905e6534c083 100644
--- a/rust/kernel/net/phy.rs
+++ b/rust/kernel/net/phy.rs
@@ -163,17 +163,17 @@ 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 crate::ffi::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,
+        } as crate::ffi::c_int;
         // SAFETY: The struct invariant ensures that we may access
         // this field without additional synchronization.
         unsafe { (*phydev).duplex = v };

---
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
change-id: 20250611-correct-type-cast-1de8876ddfc1

Best regards,
--  
Tamir Duberstein <tamird@gmail.com>


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-06-24 11:56 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-11 10:28 [PATCH] rust: cast to the proper type Tamir Duberstein
2025-06-11 11:42 ` Alice Ryhl
2025-06-11 13:30   ` Tamir Duberstein
2025-06-11 13:41     ` Tamir Duberstein
2025-06-12  0:48       ` FUJITA Tomonori
2025-06-12  0:48     ` FUJITA Tomonori
2025-06-12  0:54       ` Tamir Duberstein
2025-06-19 15:29         ` Tamir Duberstein
2025-06-19 22:54           ` FUJITA Tomonori
2025-06-19 23:24             ` Tamir Duberstein
2025-06-20  1:05               ` FUJITA Tomonori
2025-06-20 17:25                 ` Miguel Ojeda
2025-06-23 11:39 ` Alice Ryhl
2025-06-24 11:56   ` Tamir Duberstein

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).