Skip to content

Commit 4d86ac6

Browse files
jonasjelonekrobimarko
authored andcommitted
realtek: pcs: drop unneeded SerDes number range checks
By using references to pre-initiated SerDes instances instead of plain SerDes number, there is no need to check for the range anymore in various places. During driver/pcs init it is ensured that only valid SerDes will reach the configuration functions. Signed-off-by: Jonas Jelonek <[email protected]> Link: openwrt/openwrt#21146 Signed-off-by: Robert Marko <[email protected]> (cherry picked from commit 18eea05)
1 parent d2a3474 commit 4d86ac6

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,6 @@ static int rtpcs_838x_setup_serdes(struct rtpcs_serdes *sds,
544544
{
545545
int ret;
546546

547-
if (sds->id > 5)
548-
return -EINVAL;
549547
if (!rtpcs_838x_sds_is_mode_supported(sds, mode))
550548
return -EINVAL;
551549

@@ -585,10 +583,6 @@ static void rtpcs_930x_sds_set(struct rtpcs_serdes *sds, u32 mode)
585583
u8 sds_id = sds->id;
586584

587585
pr_info("%s %d\n", __func__, mode);
588-
if (sds_id < 0 || sds_id > 11) {
589-
pr_err("Wrong SerDes number: %d\n", sds_id);
590-
return;
591-
}
592586

593587
regmap_write_bits(sds->ctrl->map, rtpcs_930x_sds_regs[sds_id],
594588
RTL930X_SDS_MASK << rtpcs_930x_sds_lsb[sds_id],
@@ -602,11 +596,6 @@ static u32 rtpcs_930x_sds_mode_get(struct rtpcs_serdes *sds)
602596
u8 sds_id = sds->id;
603597
u32 v;
604598

605-
if (sds_id < 0 || sds_id > 11) {
606-
pr_err("Wrong SerDes number: %d\n", sds_id);
607-
return 0;
608-
}
609-
610599
regmap_read(sds->ctrl->map, rtpcs_930x_sds_regs[sds_id], &v);
611600
v >>= rtpcs_930x_sds_lsb[sds_id];
612601

@@ -959,11 +948,6 @@ static void rtpcs_930x_sds_mode_set(struct rtpcs_serdes *sds,
959948
u32 mode;
960949
u32 submode;
961950

962-
if (sds->id < 0 || sds->id > 11) {
963-
pr_err("%s: invalid SerDes number: %d\n", __func__, sds->id);
964-
return;
965-
}
966-
967951
switch (phy_mode) {
968952
case PHY_INTERFACE_MODE_SGMII:
969953
case PHY_INTERFACE_MODE_1000BASEX:
@@ -2231,9 +2215,6 @@ static int rtpcs_930x_setup_serdes(struct rtpcs_serdes *sds,
22312215
{
22322216
int calib_tries = 0;
22332217

2234-
if (sds->id < 0 || sds->id > 11)
2235-
return -EINVAL;
2236-
22372218
/* Rely on setup from U-boot for some modes, e.g. USXGMII */
22382219
switch (phy_mode) {
22392220
case PHY_INTERFACE_MODE_1000BASEX:
@@ -2680,9 +2661,6 @@ static int rtpcs_931x_setup_serdes(struct rtpcs_serdes *sds,
26802661
u32 sds_id = sds->id;
26812662
int chiptype = 0;
26822663

2683-
if (sds_id < 0 || sds_id > 13)
2684-
return -EINVAL;
2685-
26862664
/*
26872665
* TODO: USXGMII is currently the swiss army knife to declare 10G
26882666
* multi port PHYs. Real devices use other modes instead. Especially
@@ -2835,7 +2813,7 @@ static int rtpcs_931x_setup_serdes(struct rtpcs_serdes *sds,
28352813

28362814
rtpcs_931x_sds_cmu_type_set(sds, mode, chiptype);
28372815

2838-
if (sds_id >= 2 && sds_id <= 13) {
2816+
if (sds_id >= 2) {
28392817
if (chiptype)
28402818
rtpcs_sds_write(sds, 0x2E, 0x1, board_sds_tx_type1[sds_id - 2]);
28412819
else {
@@ -2954,9 +2932,6 @@ static int rtpcs_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
29542932
struct rtpcs_ctrl *ctrl = link->ctrl;
29552933
int ret = 0;
29562934

2957-
if (link->sds->id < 0)
2958-
return 0;
2959-
29602935
/*
29612936
* TODO: This (or copies of this) will be the central function for configuring the
29622937
* link between PHY and SerDes. As of now a lot of the code is scattered throughout

0 commit comments

Comments
 (0)