Explorar o código

realtek: eth: move init_mac() into configuration structure

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 <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/21391
Signed-off-by: Stijn Tintel <[email protected]>
Markus Stockhausen hai 1 semana
pai
achega
7b351062d2

+ 8 - 11
target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c

@@ -1325,7 +1325,7 @@ static int rtl838x_set_mac_address(struct net_device *dev, void *p)
 	return 0;
 	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__);
 	pr_info("%s\n", __func__);
 	/* fix timer for EEE */
 	/* fix timer for EEE */
@@ -1339,7 +1339,7 @@ static int rtl8380_init_mac(struct rtl838x_eth_priv *priv)
 	return 0;
 	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 */
 	/* We will need to set-up EEE and the egress-rate limitation */
 	return 0;
 	return 0;
@@ -1350,7 +1350,7 @@ static int rteth_930x_init_mac(struct rtl838x_eth_priv *priv)
 	return 0;
 	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__);
 	pr_info("In %s\n", __func__);
 
 
@@ -1485,6 +1485,7 @@ static const struct rteth_config rteth_838x_cfg = {
 	.update_cntr = rtl838x_update_cntr,
 	.update_cntr = rtl838x_update_cntr,
 	.create_tx_header = rtl838x_create_tx_header,
 	.create_tx_header = rtl838x_create_tx_header,
 	.decode_tag = rtl838x_decode_tag,
 	.decode_tag = rtl838x_decode_tag,
+	.init_mac = &rteth_838x_init_mac,
 	.netdev_ops = &rteth_838x_netdev_ops,
 	.netdev_ops = &rteth_838x_netdev_ops,
 };
 };
 
 
@@ -1527,6 +1528,7 @@ static const struct rteth_config rteth_839x_cfg = {
 	.update_cntr = rtl839x_update_cntr,
 	.update_cntr = rtl839x_update_cntr,
 	.create_tx_header = rtl839x_create_tx_header,
 	.create_tx_header = rtl839x_create_tx_header,
 	.decode_tag = rtl839x_decode_tag,
 	.decode_tag = rtl839x_decode_tag,
+	.init_mac = &rteth_839x_init_mac,
 	.netdev_ops = &rteth_839x_netdev_ops,
 	.netdev_ops = &rteth_839x_netdev_ops,
 };
 };
 
 
@@ -1575,6 +1577,7 @@ static const struct rteth_config rteth_930x_cfg = {
 	.update_cntr = rtl930x_update_cntr,
 	.update_cntr = rtl930x_update_cntr,
 	.create_tx_header = rtl930x_create_tx_header,
 	.create_tx_header = rtl930x_create_tx_header,
 	.decode_tag = rtl930x_decode_tag,
 	.decode_tag = rtl930x_decode_tag,
+	.init_mac = &rteth_930x_init_mac,
 	.netdev_ops = &rteth_930x_netdev_ops,
 	.netdev_ops = &rteth_930x_netdev_ops,
 };
 };
 
 
@@ -1622,6 +1625,7 @@ static const struct rteth_config rteth_931x_cfg = {
 	.update_cntr = rtl931x_update_cntr,
 	.update_cntr = rtl931x_update_cntr,
 	.create_tx_header = rtl931x_create_tx_header,
 	.create_tx_header = rtl931x_create_tx_header,
 	.decode_tag = rtl931x_decode_tag,
 	.decode_tag = rtl931x_decode_tag,
+	.init_mac = &rteth_931x_init_mac,
 	.netdev_ops = &rteth_931x_netdev_ops,
 	.netdev_ops = &rteth_931x_netdev_ops,
 };
 };
 
 
@@ -1716,14 +1720,7 @@ static int __init rtl838x_eth_probe(struct platform_device *pdev)
 		return err;
 		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:
 	/* Try to get mac address in the following order:
 	 * 1) from device tree data
 	 * 1) from device tree data

+ 2 - 0
target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.h

@@ -446,6 +446,7 @@ inline u32 rtl931x_get_mac_tx_pause_sts(int p)
 
 
 struct p_hdr;
 struct p_hdr;
 struct dsa_tag;
 struct dsa_tag;
+struct rtl838x_eth_priv;
 
 
 struct rteth_config {
 struct rteth_config {
 	int family_id;
 	int family_id;
@@ -480,6 +481,7 @@ struct rteth_config {
 	void (*update_cntr)(int r, int work_done);
 	void (*update_cntr)(int r, int work_done);
 	void (*create_tx_header)(struct p_hdr *h, unsigned int dest_port, int prio);
 	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);
 	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;
 	const struct net_device_ops *netdev_ops;
 };
 };