bmips: enet: add compatibility with kernel 6.1
Make bmips ethernet drivers compatible with 6.1 kernel. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
This commit is contained in:
		| @@ -25,6 +25,7 @@ | |||||||
| #include <linux/phy.h> | #include <linux/phy.h> | ||||||
| #include <linux/platform_device.h> | #include <linux/platform_device.h> | ||||||
| #include <linux/reset.h> | #include <linux/reset.h> | ||||||
|  | #include <linux/version.h> | ||||||
|  |  | ||||||
| /* DMA channels */ | /* DMA channels */ | ||||||
| #define DMA_CHAN_WIDTH			0x10 | #define DMA_CHAN_WIDTH			0x10 | ||||||
| @@ -1503,6 +1504,7 @@ static int bcm6348_emac_probe(struct platform_device *pdev) | |||||||
| 	struct bcm6348_emac *emac; | 	struct bcm6348_emac *emac; | ||||||
| 	struct bcm6348_iudma *iudma; | 	struct bcm6348_iudma *iudma; | ||||||
| 	struct net_device *ndev; | 	struct net_device *ndev; | ||||||
|  | 	unsigned char dev_addr[ETH_ALEN]; | ||||||
| 	unsigned i; | 	unsigned i; | ||||||
| 	int num_resets; | 	int num_resets; | ||||||
| 	int ret; | 	int ret; | ||||||
| @@ -1564,12 +1566,13 @@ static int bcm6348_emac_probe(struct platform_device *pdev) | |||||||
| 	emac->old_duplex = -1; | 	emac->old_duplex = -1; | ||||||
| 	emac->old_pause = -1; | 	emac->old_pause = -1; | ||||||
|  |  | ||||||
| 	of_get_mac_address(node, ndev->dev_addr); | 	of_get_mac_address(node, dev_addr); | ||||||
| 	if (is_valid_ether_addr(ndev->dev_addr)) { | 	if (is_valid_ether_addr(dev_addr)) { | ||||||
| 		dev_info(dev, "mtd mac %pM\n", ndev->dev_addr); | 		dev_addr_set(ndev, dev_addr); | ||||||
|  | 		dev_info(dev, "mtd mac %pM\n", dev_addr); | ||||||
| 	} else { | 	} else { | ||||||
| 		random_ether_addr(ndev->dev_addr); | 		eth_hw_addr_random(ndev); | ||||||
| 		dev_info(dev, "random mac %pM\n", ndev->dev_addr); | 		dev_info(dev, "random mac\n"); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	emac->rx_skb_size = ALIGN(ndev->mtu + ENET_MTU_OVERHEAD, | 	emac->rx_skb_size = ALIGN(ndev->mtu + ENET_MTU_OVERHEAD, | ||||||
| @@ -1644,7 +1647,11 @@ static int bcm6348_emac_probe(struct platform_device *pdev) | |||||||
| 	ndev->min_mtu = ETH_ZLEN - ETH_HLEN; | 	ndev->min_mtu = ETH_ZLEN - ETH_HLEN; | ||||||
| 	ndev->mtu = ETH_DATA_LEN - VLAN_ETH_HLEN; | 	ndev->mtu = ETH_DATA_LEN - VLAN_ETH_HLEN; | ||||||
| 	ndev->max_mtu = ENET_MAX_MTU - VLAN_ETH_HLEN; | 	ndev->max_mtu = ENET_MAX_MTU - VLAN_ETH_HLEN; | ||||||
|  | #if LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0) | ||||||
|  | 	netif_napi_add(ndev, &emac->napi, bcm6348_emac_poll); | ||||||
|  | #else | ||||||
| 	netif_napi_add(ndev, &emac->napi, bcm6348_emac_poll, 16); | 	netif_napi_add(ndev, &emac->napi, bcm6348_emac_poll, 16); | ||||||
|  | #endif | ||||||
| 	SET_NETDEV_DEV(ndev, dev); | 	SET_NETDEV_DEV(ndev, dev); | ||||||
|  |  | ||||||
| 	ret = devm_register_netdev(dev, ndev); | 	ret = devm_register_netdev(dev, ndev); | ||||||
|   | |||||||
| @@ -20,6 +20,7 @@ | |||||||
| #include <linux/pm_domain.h> | #include <linux/pm_domain.h> | ||||||
| #include <linux/pm_runtime.h> | #include <linux/pm_runtime.h> | ||||||
| #include <linux/reset.h> | #include <linux/reset.h> | ||||||
|  | #include <linux/version.h> | ||||||
|  |  | ||||||
| /* MTU */ | /* MTU */ | ||||||
| #define ENETSW_TAG_SIZE			(6 + VLAN_HLEN) | #define ENETSW_TAG_SIZE			(6 + VLAN_HLEN) | ||||||
| @@ -908,6 +909,7 @@ static int bcm6368_enetsw_probe(struct platform_device *pdev) | |||||||
| 	struct bcm6368_enetsw *priv; | 	struct bcm6368_enetsw *priv; | ||||||
| 	struct net_device *ndev; | 	struct net_device *ndev; | ||||||
| 	struct resource *res; | 	struct resource *res; | ||||||
|  | 	unsigned char dev_addr[ETH_ALEN]; | ||||||
| 	unsigned i; | 	unsigned i; | ||||||
| 	int num_resets; | 	int num_resets; | ||||||
| 	int ret; | 	int ret; | ||||||
| @@ -995,12 +997,13 @@ static int bcm6368_enetsw_probe(struct platform_device *pdev) | |||||||
| 	priv->tx_ring_size = ENETSW_DEF_TX_DESC; | 	priv->tx_ring_size = ENETSW_DEF_TX_DESC; | ||||||
| 	priv->copybreak = ENETSW_DEF_CPY_BREAK; | 	priv->copybreak = ENETSW_DEF_CPY_BREAK; | ||||||
|  |  | ||||||
| 	of_get_mac_address(node, ndev->dev_addr); | 	of_get_mac_address(node, dev_addr); | ||||||
| 	if (is_valid_ether_addr(ndev->dev_addr)) { | 	if (is_valid_ether_addr(dev_addr)) { | ||||||
| 		dev_info(dev, "mtd mac %pM\n", ndev->dev_addr); | 		dev_addr_set(ndev, dev_addr); | ||||||
|  | 		dev_info(dev, "mtd mac %pM\n", dev_addr); | ||||||
| 	} else { | 	} else { | ||||||
| 		random_ether_addr(ndev->dev_addr); | 		eth_hw_addr_random(ndev); | ||||||
| 		dev_info(dev, "random mac %pM\n", ndev->dev_addr); | 		dev_info(dev, "random mac\n"); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	priv->rx_buf_size = ALIGN(ndev->mtu + ENETSW_MTU_OVERHEAD, | 	priv->rx_buf_size = ALIGN(ndev->mtu + ENETSW_MTU_OVERHEAD, | ||||||
| @@ -1065,7 +1068,11 @@ static int bcm6368_enetsw_probe(struct platform_device *pdev) | |||||||
| 	ndev->min_mtu = ETH_ZLEN; | 	ndev->min_mtu = ETH_ZLEN; | ||||||
| 	ndev->mtu = ETH_DATA_LEN + ENETSW_TAG_SIZE; | 	ndev->mtu = ETH_DATA_LEN + ENETSW_TAG_SIZE; | ||||||
| 	ndev->max_mtu = ETH_DATA_LEN + ENETSW_TAG_SIZE; | 	ndev->max_mtu = ETH_DATA_LEN + ENETSW_TAG_SIZE; | ||||||
|  | #if LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0) | ||||||
|  | 	netif_napi_add(ndev, &priv->napi, bcm6368_enetsw_poll); | ||||||
|  | #else | ||||||
| 	netif_napi_add(ndev, &priv->napi, bcm6368_enetsw_poll, 16); | 	netif_napi_add(ndev, &priv->napi, bcm6368_enetsw_poll, 16); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	ret = devm_register_netdev(dev, ndev); | 	ret = devm_register_netdev(dev, ndev); | ||||||
| 	if (ret) { | 	if (ret) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Álvaro Fernández Rojas
					Álvaro Fernández Rojas