From: Miguel Ojeda <ojeda@kernel.org>
To: stable@vger.kernel.org
Cc: Miguel Ojeda <ojeda@kernel.org>,
Chunfeng Song <springbreeze@stu.pku.edu.cn>,
FUJITA Tomonori <fujita.tomonori@gmail.com>,
Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH 6.18.y 1/2] Revert "rust: net: phy: fix off-by-one bit positions in device status accessors"
Date: Mon, 28 Sep 2026 12:48:54 +0200 [thread overview]
Message-ID: <20260928104855.205416-1-ojeda@kernel.org> (raw)
This reverts commit 3267aea7cdd5d5c8851718b148cd25ff1a5374ac.
It was not meant to be backported before 7.1.y -- its tag said:
Cc: stable@vger.kernel.org # Only 7.1.y and later (requires bindgen's raw pointer accessors).
Cc: Chunfeng Song <springbreeze@stu.pku.edu.cn>
Cc: FUJITA Tomonori <fujita.tomonori@gmail.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/stable/SEWP216MB9770116738884C46F156A686FAF98D2@SEWP216MB977011.KORP216.PROD.OUTLOOK.COM/
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
rust/kernel/net/phy.rs | 38 ++++++++++++++++++++------------------
1 file changed, 20 insertions(+), 18 deletions(-)
diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
index 1d17bf1ae87d..bf6272d87a7b 100644
--- a/rust/kernel/net/phy.rs
+++ b/rust/kernel/net/phy.rs
@@ -123,37 +123,39 @@ pub fn state(&self) -> DeviceState {
/// Gets the current link state.
///
/// It returns true if the link is up.
- #[inline]
pub fn is_link_up(&self) -> bool {
- let phydev = self.0.get().cast_const();
- // SAFETY: By the type invariant of `Device`, `phydev` points to a valid
- // `struct phy_device`, and there is no concurrent write to this field.
- let link = unsafe { bindings::phy_device::link_raw(phydev) };
- link == 1
+ const LINK_IS_UP: u64 = 1;
+ // TODO: the code to access to the bit field will be replaced with automatically
+ // generated code by bindgen when it becomes possible.
+ // SAFETY: The struct invariant ensures that we may access
+ // this field without additional synchronization.
+ let bit_field = unsafe { &(*self.0.get())._bitfield_1 };
+ bit_field.get(14, 1) == LINK_IS_UP
}
/// Gets the current auto-negotiation configuration.
///
/// It returns true if auto-negotiation is enabled.
- #[inline]
pub fn is_autoneg_enabled(&self) -> bool {
- let phydev = self.0.get().cast_const();
- // SAFETY: By the type invariant of `Device`, `phydev` points to a valid
- // `struct phy_device`, and there is no concurrent write to this field.
- let autoneg = unsafe { bindings::phy_device::autoneg_raw(phydev) };
- autoneg == bindings::AUTONEG_ENABLE
+ // TODO: the code to access to the bit field will be replaced with automatically
+ // generated code by bindgen when it becomes possible.
+ // SAFETY: The struct invariant ensures that we may access
+ // this field without additional synchronization.
+ let bit_field = unsafe { &(*self.0.get())._bitfield_1 };
+ bit_field.get(13, 1) == u64::from(bindings::AUTONEG_ENABLE)
}
/// Gets the current auto-negotiation state.
///
/// It returns true if auto-negotiation is completed.
- #[inline]
pub fn is_autoneg_completed(&self) -> bool {
- let phydev = self.0.get().cast_const();
- // SAFETY: By the type invariant of `Device`, `phydev` points to a valid
- // `struct phy_device`, and there is no concurrent write to this field.
- let completed = unsafe { bindings::phy_device::autoneg_complete_raw(phydev) };
- completed == 1
+ const AUTONEG_COMPLETED: u64 = 1;
+ // TODO: the code to access to the bit field will be replaced with automatically
+ // generated code by bindgen when it becomes possible.
+ // SAFETY: The struct invariant ensures that we may access
+ // this field without additional synchronization.
+ let bit_field = unsafe { &(*self.0.get())._bitfield_1 };
+ bit_field.get(15, 1) == AUTONEG_COMPLETED
}
/// Sets the speed of the PHY.
base-commit: 1b357ecb321392158d507b04672ffee57bfa071d
--
2.55.0
next reply other threads:[~2026-09-28 10:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 10:48 Miguel Ojeda [this message]
2026-09-28 10:48 ` [PATCH 6.18.y 2/2] rust: net: phy: fix off-by-one bit positions in device status accessors Miguel Ojeda
2026-09-29 5:13 ` Miguel Ojeda
2026-09-28 22:39 ` [PATCH 6.18.y 1/2] Revert "rust: net: phy: fix off-by-one bit positions in device status accessors" Sasha Levin
2026-09-29 5:14 ` Miguel Ojeda
2026-09-30 12:19 ` Greg KH
2026-09-30 12:18 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260928104855.205416-1-ojeda@kernel.org \
--to=ojeda@kernel.org \
--cc=fujita.tomonori@gmail.com \
--cc=kuba@kernel.org \
--cc=springbreeze@stu.pku.edu.cn \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox