ramips: 6.1: ralink: fix ethernet driver with 6.1
authorMieczyslaw Nalewaj <namiltd@yahoo.com>
Thu, 8 Feb 2024 21:13:50 +0000 (22:13 +0100)
committerNick Hainke <vincent@systemli.org>
Sat, 10 Feb 2024 12:06:05 +0000 (13:06 +0100)
Fixes errors in the form of:
  make[9]: Entering directory '/home/nick/openwrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7620/linux-6.1.77'
    CC      drivers/net/ethernet/ralink/mtk_eth_soc.o
  drivers/net/ethernet/ralink/mtk_eth_soc.c: In function 'fe_init':
  drivers/net/ethernet/ralink/mtk_eth_soc.c:1368:51: warning: passing argument 2 of 'of_get_mac_address' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
   1368 |         of_get_mac_address(priv->dev->of_node, dev->dev_addr);
        |                                                ~~~^~~~~~~~~~
  In file included from drivers/net/ethernet/ralink/mtk_eth_soc.c:26:
  ./include/linux/of_net.h:16:59: note: expected 'u8 *' {aka 'unsigned char *'} but argument is of type 'const unsigned char *'
     16 | extern int of_get_mac_address(struct device_node *np, u8 *mac);
        |                                                       ~~~~^~~
  drivers/net/ethernet/ralink/mtk_eth_soc.c: In function 'fe_probe':
  drivers/net/ethernet/ralink/mtk_eth_soc.c:1641:9: error: too many arguments to function 'netif_napi_add'
   1641 |         netif_napi_add(netdev, &priv->rx_napi, fe_poll, napi_weight);
        |         ^~~~~~~~~~~~~~
  In file included from ./include/linux/etherdevice.h:21,
                   from drivers/net/ethernet/ralink/mtk_eth_soc.c:21:
  ./include/linux/netdevice.h:2611:1: note: declared here
   2611 | netif_napi_add(struct net_device *dev, struct napi_struct *napi,
        | ^~~~~~~~~~~~~~

Signed-off-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
[split commit and rewrite commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
target/linux/ramips/files/drivers/net/ethernet/ralink/ethtool.c
target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c

index a3abf30c71c74b91c9f6e3bd46ee74c91ab02e95..92cf0ef717dde0196c8e3cacce891cda93f922e7 100644 (file)
@@ -125,8 +125,15 @@ out_get_link:
        return ethtool_op_get_link(dev);
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
+static int fe_set_ringparam(struct net_device *dev,
+                           struct ethtool_ringparam *ring,
+                           struct kernel_ethtool_ringparam *kernel_rp,
+                           struct netlink_ext_ack *extack)
+#else
 static int fe_set_ringparam(struct net_device *dev,
                            struct ethtool_ringparam *ring)
+#endif
 {
        struct fe_priv *priv = netdev_priv(dev);
 
@@ -146,8 +153,15 @@ static int fe_set_ringparam(struct net_device *dev,
        return 0;
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
+static void fe_get_ringparam(struct net_device *dev,
+                            struct ethtool_ringparam *ring,
+                            struct kernel_ethtool_ringparam *kernel_rp,
+                            struct netlink_ext_ack *extack)
+#else
 static void fe_get_ringparam(struct net_device *dev,
                             struct ethtool_ringparam *ring)
+#endif
 {
        struct fe_priv *priv = netdev_priv(dev);
 
index 03e65a0c8a6d0fff6f35d22d0721b0a924c02c9a..35a3113804e74c452d1ea6611e268430b52d3340 100644 (file)
@@ -1365,10 +1365,8 @@ static int __init fe_init(struct net_device *dev)
 
        fe_reset_phy(priv);
 
-       of_get_mac_address(priv->dev->of_node, dev->dev_addr);
-
-       /* If the mac address is invalid, use random mac address  */
-       if (!is_valid_ether_addr(dev->dev_addr)) {
+       /* Set the MAC address if it is correct, if not use a random MAC address  */
+       if (of_get_ethdev_address(priv->dev->of_node, dev)) {
                eth_hw_addr_random(dev);
                dev_err(priv->dev, "generated random MAC address %pM\n",
                        dev->dev_addr);
@@ -1638,7 +1636,11 @@ static int fe_probe(struct platform_device *pdev)
                priv->tx_ring.tx_ring_size *= 4;
                priv->rx_ring.rx_ring_size *= 4;
        }
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
+       netif_napi_add_weight(netdev, &priv->rx_napi, fe_poll, napi_weight);
+#else
        netif_napi_add(netdev, &priv->rx_napi, fe_poll, napi_weight);
+#endif
        fe_set_ethtool_ops(netdev);
 
        err = register_netdev(netdev);