Skip to content

Commit 2433572

Browse files
plappermaulrobimarko
authored andcommitted
realtek: dsa: drop rtldsa_get_mib_desc()
rtldsa_get_mib_desc() is always well defined and only looks into the configuration structure. Drop it and use direct data assignment where needed. While we are here drop all NULL checks because mib_desc is never unset. Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de> Link: openwrt/openwrt#22219 Signed-off-by: Robert Marko <robimarko@gmail.com>
1 parent 5fad34e commit 2433572

1 file changed

Lines changed: 5 additions & 41 deletions

File tree

  • target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx

target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,6 @@ static void rtldsa_93xx_phylink_mac_link_up(struct dsa_switch *ds, int port,
529529
sw_w32_mask(0, 0x3, priv->r->mac_port_ctrl(port));
530530
}
531531

532-
static const struct rtldsa_mib_desc *rtldsa_get_mib_desc(struct rtl838x_switch_priv *priv)
533-
{
534-
return priv->r->mib_desc;
535-
}
536-
537532
static bool rtldsa_read_mib_item(struct rtl838x_switch_priv *priv, int port,
538533
const struct rtldsa_mib_item *mib_item,
539534
u64 *data)
@@ -641,9 +636,7 @@ static void rtldsa_update_port_counters(struct rtl838x_switch_priv *priv, int po
641636
const struct rtldsa_mib_desc *mib_desc;
642637
ktime_t now;
643638

644-
mib_desc = rtldsa_get_mib_desc(priv);
645-
if (!mib_desc)
646-
return;
639+
mib_desc = priv->r->mib_desc;
647640

648641
/* Prevent unnecessary updates when the user accesses different stats quickly.
649642
* This compensates a bit for always updating all stats, even when just a
@@ -818,9 +811,7 @@ static void rtldsa_get_strings(struct dsa_switch *ds,
818811
if (port < 0 || port >= priv->cpu_port)
819812
return;
820813

821-
mib_desc = rtldsa_get_mib_desc(priv);
822-
if (!mib_desc)
823-
return;
814+
mib_desc = priv->r->mib_desc;
824815

825816
for (int i = 0; i < mib_desc->list_count; i++)
826817
ethtool_puts(&data, mib_desc->list[i].name);
@@ -836,10 +827,7 @@ static void rtldsa_get_ethtool_stats(struct dsa_switch *ds, int port,
836827
if (port < 0 || port >= priv->cpu_port)
837828
return;
838829

839-
mib_desc = rtldsa_get_mib_desc(priv);
840-
if (!mib_desc)
841-
return;
842-
830+
mib_desc = priv->r->mib_desc;
843831
for (int i = 0; i < mib_desc->list_count; i++) {
844832
mib_item = &mib_desc->list[i].item;
845833
rtldsa_read_mib_item(priv, port, mib_item, &data[i]);
@@ -849,19 +837,14 @@ static void rtldsa_get_ethtool_stats(struct dsa_switch *ds, int port,
849837
static int rtldsa_get_sset_count(struct dsa_switch *ds, int port, int sset)
850838
{
851839
struct rtl838x_switch_priv *priv = ds->priv;
852-
const struct rtldsa_mib_desc *mib_desc;
853840

854841
if (sset != ETH_SS_STATS)
855842
return 0;
856843

857844
if (port < 0 || port >= priv->cpu_port)
858845
return 0;
859846

860-
mib_desc = rtldsa_get_mib_desc(priv);
861-
if (!mib_desc)
862-
return 0;
863-
864-
return mib_desc->list_count;
847+
return priv->r->mib_desc->list_count;
865848
}
866849

867850
static void rtldsa_get_eth_phy_stats(struct dsa_switch *ds, int port,
@@ -873,9 +856,6 @@ static void rtldsa_get_eth_phy_stats(struct dsa_switch *ds, int port,
873856
if (port < 0 || port >= priv->cpu_port)
874857
return;
875858

876-
if (!rtldsa_get_mib_desc(priv))
877-
return;
878-
879859
rtldsa_counters_lock(priv, port);
880860

881861
rtldsa_update_port_counters(priv, port);
@@ -894,9 +874,6 @@ static void rtldsa_get_eth_mac_stats(struct dsa_switch *ds, int port,
894874
if (port < 0 || port >= priv->cpu_port)
895875
return;
896876

897-
if (!rtldsa_get_mib_desc(priv))
898-
return;
899-
900877
rtldsa_counters_lock(priv, port);
901878

902879
rtldsa_update_port_counters(priv, port);
@@ -943,9 +920,6 @@ static void rtldsa_get_eth_ctrl_stats(struct dsa_switch *ds, int port,
943920
if (port < 0 || port >= priv->cpu_port)
944921
return;
945922

946-
if (!rtldsa_get_mib_desc(priv))
947-
return;
948-
949923
rtldsa_counters_lock(priv, port);
950924

951925
rtldsa_update_port_counters(priv, port);
@@ -966,9 +940,7 @@ static void rtldsa_get_rmon_stats(struct dsa_switch *ds, int port,
966940
if (port < 0 || port >= priv->cpu_port)
967941
return;
968942

969-
mib_desc = rtldsa_get_mib_desc(priv);
970-
if (!mib_desc)
971-
return;
943+
mib_desc = priv->r->mib_desc;
972944

973945
rtldsa_counters_lock(priv, port);
974946

@@ -1014,11 +986,6 @@ static void rtldsa_get_stats64(struct dsa_switch *ds, int port,
1014986
if (port < 0 || port >= priv->cpu_port)
1015987
return;
1016988

1017-
if (!rtldsa_get_mib_desc(priv)) {
1018-
dev_get_tstats64(dsa_to_port(ds, port)->user, s);
1019-
return;
1020-
}
1021-
1022989
if (priv->r->stat_update_counters_atomically)
1023990
priv->r->stat_update_counters_atomically(priv, port);
1024991

@@ -1037,9 +1004,6 @@ static void rtldsa_get_pause_stats(struct dsa_switch *ds, int port,
10371004
if (port < 0 || port >= priv->cpu_port)
10381005
return;
10391006

1040-
if (!rtldsa_get_mib_desc(priv))
1041-
return;
1042-
10431007
rtldsa_counters_lock(priv, port);
10441008

10451009
rtldsa_update_port_counters(priv, port);

0 commit comments

Comments
 (0)