Skip to content

Commit 2e4ea70

Browse files
ericwouddavem330
authored andcommitted
net: phy: realtek: Change rtlgen_get_speed() to rtlgen_decode_speed()
The value of the register to determine the speed, is retrieved differently when using Clause 45 only. To use the rtlgen_get_speed() function in this case, pass the value of the register as argument to rtlgen_get_speed(). The function would then always return 0, so change it to void. A better name for this function now is rtlgen_decode_speed(). Replace a call to genphy_read_status() followed by rtlgen_get_speed() with a call to rtlgen_read_status() in rtl822x_read_status(). Add reading speed to rtl822x_c45_read_status(). Signed-off-by: Eric Woudstra <[email protected]> Reviewed-by: Russell King (Oracle) <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ad5ce74 commit 2e4ea70

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

drivers/net/phy/realtek.c

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171

7272
#define RTL822X_VND2_GANLPAR 0xa414
7373

74+
#define RTL822X_VND2_PHYSR 0xa434
75+
7476
#define RTL8366RB_POWER_SAVE 0x15
7577
#define RTL8366RB_POWER_SAVE_ON BIT(12)
7678

@@ -551,17 +553,8 @@ static int rtl8366rb_config_init(struct phy_device *phydev)
551553
}
552554

553555
/* get actual speed to cover the downshift case */
554-
static int rtlgen_get_speed(struct phy_device *phydev)
556+
static void rtlgen_decode_speed(struct phy_device *phydev, int val)
555557
{
556-
int val;
557-
558-
if (!phydev->link)
559-
return 0;
560-
561-
val = phy_read_paged(phydev, 0xa43, 0x12);
562-
if (val < 0)
563-
return val;
564-
565558
switch (val & RTLGEN_SPEED_MASK) {
566559
case 0x0000:
567560
phydev->speed = SPEED_10;
@@ -584,19 +577,26 @@ static int rtlgen_get_speed(struct phy_device *phydev)
584577
default:
585578
break;
586579
}
587-
588-
return 0;
589580
}
590581

591582
static int rtlgen_read_status(struct phy_device *phydev)
592583
{
593-
int ret;
584+
int ret, val;
594585

595586
ret = genphy_read_status(phydev);
596587
if (ret < 0)
597588
return ret;
598589

599-
return rtlgen_get_speed(phydev);
590+
if (!phydev->link)
591+
return 0;
592+
593+
val = phy_read_paged(phydev, 0xa43, 0x12);
594+
if (val < 0)
595+
return val;
596+
597+
rtlgen_decode_speed(phydev, val);
598+
599+
return 0;
600600
}
601601

602602
static int rtlgen_read_mmd(struct phy_device *phydev, int devnum, u16 regnum)
@@ -817,8 +817,6 @@ static void rtl822xb_update_interface(struct phy_device *phydev)
817817

818818
static int rtl822x_read_status(struct phy_device *phydev)
819819
{
820-
int ret;
821-
822820
if (phydev->autoneg == AUTONEG_ENABLE) {
823821
int lpadv = phy_read_paged(phydev, 0xa5d, 0x13);
824822

@@ -829,11 +827,7 @@ static int rtl822x_read_status(struct phy_device *phydev)
829827
lpadv);
830828
}
831829

832-
ret = genphy_read_status(phydev);
833-
if (ret < 0)
834-
return ret;
835-
836-
return rtlgen_get_speed(phydev);
830+
return rtlgen_read_status(phydev);
837831
}
838832

839833
static int rtl822xb_read_status(struct phy_device *phydev)
@@ -894,6 +888,16 @@ static int rtl822x_c45_read_status(struct phy_device *phydev)
894888
mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val);
895889
}
896890

891+
if (!phydev->link)
892+
return 0;
893+
894+
/* Read actual speed from vendor register. */
895+
val = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL822X_VND2_PHYSR);
896+
if (val < 0)
897+
return val;
898+
899+
rtlgen_decode_speed(phydev, val);
900+
897901
return 0;
898902
}
899903

0 commit comments

Comments
 (0)