blob: 2d5a8f705f62428d681a4afc3233c15ef45487bb [file] [log] [blame]
From 938e9a44c1cc00c4ace2698dbef4e91215fcb0b2 Mon Sep 17 00:00:00 2001
From: David Wang <davidwang@quantatw.com>
Date: Tue, 7 Nov 2023 21:55:15 +0800
Subject: [PATCH 23/23] drivers: net: sync npcm-emc
---
drivers/misc/gbmc/npcm7xx_emc.c | 34 +++++++++-------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/drivers/misc/gbmc/npcm7xx_emc.c b/drivers/misc/gbmc/npcm7xx_emc.c
index 2af7c27a42e0..47fb8b1d5438 100644
--- a/drivers/misc/gbmc/npcm7xx_emc.c
+++ b/drivers/misc/gbmc/npcm7xx_emc.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-// nuvoton/NPCM-6.1-OpenBMC: 33351a123dcfbd93bc60dfd0e2de7e769b548e7f
// Copyright (c) 2014-2019 Nuvoton Technology corporation.
#ifdef CONFIG_NPCM7XX_EMC_ETH_DEBUG
@@ -23,7 +22,6 @@
#include <linux/ctype.h>
#include <linux/debugfs.h>
#include <linux/reset.h>
-#include <linux/version.h>
#include <linux/clk.h>
@@ -37,7 +35,6 @@
#include <linux/mfd/syscon.h>
#include <linux/if_ether.h>
-#include <linux/if_vlan.h>
#include <net/ip.h>
#include <net/ncsi.h>
@@ -693,7 +690,7 @@ static void adjust_link(struct net_device *netdev)
}
static void npcm7xx_write_cam(struct net_device *netdev,
- unsigned int x, const unsigned char *pval)
+ unsigned int x, unsigned char *pval)
{
struct npcm7xx_ether *ether = netdev_priv(netdev);
u32 msw, lsw;
@@ -1177,7 +1174,7 @@ static int npcm7xx_set_mac_address(struct net_device *netdev, void *addr)
if (!is_valid_ether_addr((u8 *)address->sa_data))
return -EADDRNOTAVAIL;
- eth_hw_addr_set(netdev, address->sa_data);
+ memcpy(netdev->dev_addr, address->sa_data, netdev->addr_len);
npcm7xx_write_cam(netdev, CAM0, netdev->dev_addr);
return 0;
@@ -1836,18 +1833,19 @@ static void get_mac_address(struct net_device *netdev)
struct platform_device *pdev = ether->pdev;
struct device_node *np = ether->pdev->dev.of_node;
int err;
- u8 dev_addr[6];
- err = of_get_mac_address(np, dev_addr);
-
- if (is_valid_ether_addr(dev_addr))
- eth_hw_addr_set(netdev, dev_addr);
- else
+ err = of_get_mac_address(np, netdev->dev_addr);
+ if (err) {
eth_hw_addr_random(netdev);
-
- dev_info(&pdev->dev, "%s: device MAC address : %pM\n",
- pdev->name, netdev->dev_addr);
-
+ dev_info(&pdev->dev,
+ "%s: device MAC address (random generator) %pM\n",
+ netdev->name, netdev->dev_addr);
+ } else {
+ if (is_valid_ether_addr(netdev->dev_addr)) {
+ dev_info(&pdev->dev, "%s: device MAC address : %pM\n",
+ pdev->name, netdev->dev_addr);
+ }
+ }
}
static int npcm7xx_mii_setup(struct net_device *netdev)
@@ -2054,11 +2052,7 @@ static int npcm7xx_ether_probe(struct platform_device *pdev)
spin_lock_init(&ether->lock);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5,19,0)
netif_napi_add(netdev, &ether->napi, npcm7xx_poll, RX_POLL_SIZE);
-#else
- netif_napi_add_weight(netdev, &ether->napi, npcm7xx_poll, RX_POLL_SIZE);
-#endif
if (pdev->dev.of_node &&
of_get_property(pdev->dev.of_node, "use-ncsi", NULL)) {
@@ -2168,4 +2162,4 @@ MODULE_AUTHOR("Nuvoton Technology Corp.");
MODULE_DESCRIPTION("NPCM750 EMC driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:npcm750-emc");
-MODULE_VERSION(DRV_MODULE_VERSION);
+MODULE_VERSION(DRV_MODULE_VERSION);
\ No newline at end of file
--
2.25.1