net: fec: Do not use netdev messages too early [Linux 4.4.187]

This Linux kernel change "net: fec: Do not use netdev messages too early" is included in the Linux 4.4.187 release. This change is authored by Fabio Estevam <festevam [at] gmail.com> on Thu Jun 6 09:40:33 2019 -0300. The commit for this change in Linux stable tree is b5133a8 (patch) which is from upstream commit a19a058. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream a19a058.

net: fec: Do not use netdev messages too early

[ Upstream commit a19a0582363b9a5f8ba812f34f1b8df394898780 ]

When a valid MAC address is not found the current messages
are shown:

fec 2188000.ethernet (unnamed net_device) (uninitialized): Invalid MAC address: 00:00:00:00:00:00
fec 2188000.ethernet (unnamed net_device) (uninitialized): Using random MAC address: aa:9f:25:eb:7e:aa

Since the network device has not been registered at this point, it is better
to use dev_err()/dev_info() instead, which will provide cleaner log
messages like these:

fec 2188000.ethernet: Invalid MAC address: 00:00:00:00:00:00
fec 2188000.ethernet: Using random MAC address: aa:9f:25:eb:7e:aa

Tested on a imx6dl-pico-pi board.

Signed-off-by: Fabio Estevam <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>

There are 6 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/ethernet/freescale/fec_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index ae8e4fc..0ee164d 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1699,10 +1699,10 @@ static void fec_get_mac(struct net_device *ndev)
     */
    if (!is_valid_ether_addr(iap)) {
        /* Report it and use a random ethernet address instead */
-       netdev_err(ndev, "Invalid MAC address: %pM\n", iap);
+       dev_err(&fep->pdev->dev, "Invalid MAC address: %pM\n", iap);
        eth_hw_addr_random(ndev);
-       netdev_info(ndev, "Using random MAC address: %pM\n",
-               ndev->dev_addr);
+       dev_info(&fep->pdev->dev, "Using random MAC address: %pM\n",
+            ndev->dev_addr);
        return;
    }

Leave a Reply

Your email address will not be published. Required fields are marked *