]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: eth: move init_mac() into configuration structure 21391/head
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Sun, 4 Jan 2026 20:21:23 +0000 (21:21 +0100)
committerStijn Tintel <stijn@linux-ipv6.be>
Fri, 9 Jan 2026 19:03:04 +0000 (21:03 +0200)
Avoid family checks where possible. Now that the init_mac()
functions are in perfect shape include them into the
configuration structure. While we are here rename them
to the new driver prefix.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/21391
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c
target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.h

index 81a47d6a2266b32e2d9a2955cad0c174a0bc77bd..c55e366bc3308aa293620ad6703e53d38618d4d3 100644 (file)
@@ -1325,7 +1325,7 @@ static int rtl838x_set_mac_address(struct net_device *dev, void *p)
        return 0;
 }
 
-static int rtl8380_init_mac(struct rtl838x_eth_priv *priv)
+static int rteth_838x_init_mac(struct rtl838x_eth_priv *priv)
 {
        pr_info("%s\n", __func__);
        /* fix timer for EEE */
@@ -1339,7 +1339,7 @@ static int rtl8380_init_mac(struct rtl838x_eth_priv *priv)
        return 0;
 }
 
-static int rtl8390_init_mac(struct rtl838x_eth_priv *priv)
+static int rteth_839x_init_mac(struct rtl838x_eth_priv *priv)
 {
        /* We will need to set-up EEE and the egress-rate limitation */
        return 0;
@@ -1350,7 +1350,7 @@ static int rteth_930x_init_mac(struct rtl838x_eth_priv *priv)
        return 0;
 }
 
-static int rtl931x_chip_init(struct rtl838x_eth_priv *priv)
+static int rteth_931x_init_mac(struct rtl838x_eth_priv *priv)
 {
        pr_info("In %s\n", __func__);
 
@@ -1485,6 +1485,7 @@ static const struct rteth_config rteth_838x_cfg = {
        .update_cntr = rtl838x_update_cntr,
        .create_tx_header = rtl838x_create_tx_header,
        .decode_tag = rtl838x_decode_tag,
+       .init_mac = &rteth_838x_init_mac,
        .netdev_ops = &rteth_838x_netdev_ops,
 };
 
@@ -1527,6 +1528,7 @@ static const struct rteth_config rteth_839x_cfg = {
        .update_cntr = rtl839x_update_cntr,
        .create_tx_header = rtl839x_create_tx_header,
        .decode_tag = rtl839x_decode_tag,
+       .init_mac = &rteth_839x_init_mac,
        .netdev_ops = &rteth_839x_netdev_ops,
 };
 
@@ -1575,6 +1577,7 @@ static const struct rteth_config rteth_930x_cfg = {
        .update_cntr = rtl930x_update_cntr,
        .create_tx_header = rtl930x_create_tx_header,
        .decode_tag = rtl930x_decode_tag,
+       .init_mac = &rteth_930x_init_mac,
        .netdev_ops = &rteth_930x_netdev_ops,
 };
 
@@ -1622,6 +1625,7 @@ static const struct rteth_config rteth_931x_cfg = {
        .update_cntr = rtl931x_update_cntr,
        .create_tx_header = rtl931x_create_tx_header,
        .decode_tag = rtl931x_decode_tag,
+       .init_mac = &rteth_931x_init_mac,
        .netdev_ops = &rteth_931x_netdev_ops,
 };
 
@@ -1716,14 +1720,7 @@ static int __init rtl838x_eth_probe(struct platform_device *pdev)
                return err;
        }
 
-       if (priv->r->family_id == RTL8380_FAMILY_ID)
-               rtl8380_init_mac(priv);
-       else if (priv->r->family_id == RTL8390_FAMILY_ID)
-               rtl8390_init_mac(priv);
-       else if (priv->r->family_id == RTL9300_FAMILY_ID)
-               rteth_930x_init_mac(priv);
-       else if (priv->r->family_id == RTL9310_FAMILY_ID)
-               rtl931x_chip_init(priv);
+       priv->r->init_mac(priv);
 
        /* Try to get mac address in the following order:
         * 1) from device tree data
index 144680f7d722f7fca7e93656f6d1b69cafbe7c54..01b8dc15c1d94021aa079ba04aa0fd68ef3e545d 100644 (file)
@@ -446,6 +446,7 @@ inline u32 rtl931x_get_mac_tx_pause_sts(int p)
 
 struct p_hdr;
 struct dsa_tag;
+struct rtl838x_eth_priv;
 
 struct rteth_config {
        int family_id;
@@ -480,6 +481,7 @@ struct rteth_config {
        void (*update_cntr)(int r, int work_done);
        void (*create_tx_header)(struct p_hdr *h, unsigned int dest_port, int prio);
        bool (*decode_tag)(struct p_hdr *h, struct dsa_tag *tag);
+       int (*init_mac)(struct rtl838x_eth_priv *priv);
        const struct net_device_ops *netdev_ops;
 };