]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
r8152: Use ocp/mdio test and clear functions in r8157_hw_phy_cfg()
authorBirger Koblitz <mail@birger-koblitz.de>
Tue, 28 Apr 2026 03:44:58 +0000 (05:44 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 30 Apr 2026 00:56:15 +0000 (17:56 -0700)
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>
Link: https://patch.msgid.link/20260428-use_bit_functions-v1-1-6eb5a3507610@birger-koblitz.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/usb/r8152.c

index 7dba5f3fd052d4db475e61f5c622d89ada1948c1..ae834876aa1acc7a9af08a4c01b7a984c4ab8433 100644 (file)
@@ -7949,17 +7949,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) {
@@ -7973,19 +7967,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);