* [PATCH net-next] r8152: Use ocp/mdio test and clear functions in r8157_hw_phy_cfg()
@ 2026-04-28 3:44 Birger Koblitz
2026-04-30 1:00 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Birger Koblitz @ 2026-04-28 3:44 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: linux-usb, netdev, linux-kernel, Chih Kai Hsu, Birger Koblitz
Replace explicit testing of bits and clearing these bits by existing
functions ocp_word_test_and_clr_bits() and r8152_mdio_test_and_clr_bit()
to re-use this code.
This allows to remove the "ocp_data" variable. Also remove the "ret" variable
which was incorrectly used for the r8153_phy_status() return value which
is a u16, so that the remaining "data" variable is sufficient.
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
The ocp and mdio bit test-and-clear functions were added in the last
netdev patch submission cycle at the same time as the support for
the RTL8157. Make use of these new functions in the PHY setup of
that Chip.
---
drivers/net/usb/r8152.c | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 7337bf1b7d6ad03572edbc492706c07a8f58760f..c7c1b07d4159d50a1641894235a011e467e5d3e7 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -7952,17 +7952,11 @@ static void r8156b_hw_phy_cfg(struct r8152 *tp)
static void r8157_hw_phy_cfg(struct r8152 *tp)
{
- u32 ocp_data;
u16 data;
- int ret;
r8156b_wait_loading_flash(tp);
- ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_MISC_0);
- if (ocp_data & PCUT_STATUS) {
- ocp_data &= ~PCUT_STATUS;
- ocp_write_word(tp, MCU_TYPE_USB, USB_MISC_0, ocp_data);
- }
+ ocp_word_test_and_clr_bits(tp, MCU_TYPE_USB, USB_MISC_0, PCUT_STATUS);
data = r8153_phy_status(tp, 0);
switch (data) {
@@ -7976,19 +7970,13 @@ static void r8157_hw_phy_cfg(struct r8152 *tp)
break;
}
- data = r8152_mdio_read(tp, MII_BMCR);
- if (data & BMCR_PDOWN) {
- data &= ~BMCR_PDOWN;
- r8152_mdio_write(tp, MII_BMCR, data);
- }
+ r8152_mdio_test_and_clr_bit(tp, MII_BMCR, BMCR_PDOWN);
r8153_aldps_en(tp, false);
rtl_eee_enable(tp, false);
- ret = r8153_phy_status(tp, PHY_STAT_LAN_ON);
- if (ret < 0)
- return;
- WARN_ON_ONCE(ret != PHY_STAT_LAN_ON);
+ data = r8153_phy_status(tp, PHY_STAT_LAN_ON);
+ WARN_ON_ONCE(data != PHY_STAT_LAN_ON);
/* PFM mode */
ocp_word_clr_bits(tp, MCU_TYPE_PLA, PLA_PHY_PWR, PFM_PWM_SWITCH);
---
base-commit: 35c2c39832e569449b9192fa1afbbc4c66227af7
change-id: 20260427-use_bit_functions-06fa965bb832
Best regards,
--
Birger Koblitz <mail@birger-koblitz.de>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] r8152: Use ocp/mdio test and clear functions in r8157_hw_phy_cfg()
2026-04-28 3:44 [PATCH net-next] r8152: Use ocp/mdio test and clear functions in r8157_hw_phy_cfg() Birger Koblitz
@ 2026-04-30 1:00 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-04-30 1:00 UTC (permalink / raw)
To: Birger Koblitz
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, linux-usb, netdev,
linux-kernel, hsu.chih.kai
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 28 Apr 2026 05:44:58 +0200 you wrote:
> Replace explicit testing of bits and clearing these bits by existing
> functions ocp_word_test_and_clr_bits() and r8152_mdio_test_and_clr_bit()
> to re-use this code.
>
> This allows to remove the "ocp_data" variable. Also remove the "ret" variable
> which was incorrectly used for the r8153_phy_status() return value which
> is a u16, so that the remaining "data" variable is sufficient.
>
> [...]
Here is the summary with links:
- [net-next] r8152: Use ocp/mdio test and clear functions in r8157_hw_phy_cfg()
https://git.kernel.org/netdev/net-next/c/b7ebbf9f7aea
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] 2+ messages in thread
end of thread, other threads:[~2026-04-30 1:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-28 3:44 [PATCH net-next] r8152: Use ocp/mdio test and clear functions in r8157_hw_phy_cfg() Birger Koblitz
2026-04-30 1: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