* [PATCH net] net: lan743x: avoid netdev-based logging before netdev registration
@ 2026-05-15 21:52 David Thompson
0 siblings, 0 replies; only message in thread
From: David Thompson @ 2026-05-15 21:52 UTC (permalink / raw)
To: bryan.whitehead, UNGLinuxDriver, andrew+netdev, davem, edumazet,
kuba, pabeni
Cc: netdev, linux-kernel, David Thompson
This patch updates the lan743x driver to prevent the use of netdev-based
logging APIs (such as netdev_dbg) before the network device has been
successfully registered. Using netdev-based logging prior to registration
results in log messages referencing "(unnamed net_device) (uninitialized)",
which can be confusing and less informative.
The driver must use netif_msg_x APIs and device-based logging (e.g. dev_dbg)
until netdev registration is complete. This ensures log entries are
associated with the correct device context and improves log clarity. After
registration, netdev-based logging APIs can be used safely.
Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
Signed-off-by: David Thompson <davthompson@nvidia.com>
---
drivers/net/ethernet/microchip/lan743x_main.c | 72 ++++++++++++-------
1 file changed, 45 insertions(+), 27 deletions(-)
diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index f3332417162e..53492573f08d 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -108,9 +108,10 @@ static int lan743x_pci_init(struct lan743x_adapter *adapter,
if (ret)
goto return_error;
- netif_info(adapter, probe, adapter->netdev,
- "PCI: Vendor ID = 0x%04X, Device ID = 0x%04X\n",
- pdev->vendor, pdev->device);
+ if (netif_msg_probe(adapter))
+ pci_info(pdev,
+ "PCI: Vendor ID = 0x%04X, Device ID = 0x%04X\n",
+ pdev->vendor, pdev->device);
bars = pci_select_bars(pdev, IORESOURCE_MEM);
if (!test_bit(0, &bars))
goto disable_device;
@@ -192,10 +193,11 @@ static int lan743x_csr_init(struct lan743x_adapter *adapter)
csr->id_rev = lan743x_csr_read(adapter, ID_REV);
csr->fpga_rev = lan743x_csr_read(adapter, FPGA_REV);
- netif_info(adapter, probe, adapter->netdev,
- "ID_REV = 0x%08X, FPGA_REV = %d.%d\n",
- csr->id_rev, FPGA_REV_GET_MAJOR_(csr->fpga_rev),
- FPGA_REV_GET_MINOR_(csr->fpga_rev));
+ if (netif_msg_probe(adapter))
+ dev_info(&adapter->pdev->dev,
+ "ID_REV = 0x%08X, FPGA_REV = %d.%d\n",
+ csr->id_rev, FPGA_REV_GET_MAJOR_(csr->fpga_rev),
+ FPGA_REV_GET_MINOR_(csr->fpga_rev));
if (!ID_REV_IS_VALID_CHIP_ID_(csr->id_rev))
return -ENODEV;
@@ -953,8 +955,9 @@ int lan743x_sgmii_read(struct lan743x_adapter *adapter, u8 mmd, u16 addr)
u32 val;
if (mmd > 31) {
- netif_err(adapter, probe, adapter->netdev,
- "%s mmd should <= 31\n", __func__);
+ if (netif_msg_probe(adapter))
+ dev_err(&adapter->pdev->dev,
+ "%s mmd should <= 31\n", __func__);
return -EINVAL;
}
@@ -983,8 +986,9 @@ static int lan743x_sgmii_write(struct lan743x_adapter *adapter,
int ret;
if (mmd > 31) {
- netif_err(adapter, probe, adapter->netdev,
- "%s mmd should <= 31\n", __func__);
+ if (netif_msg_probe(adapter))
+ dev_err(&adapter->pdev->dev,
+ "%s mmd should <= 31\n", __func__);
return -EINVAL;
}
mutex_lock(&adapter->sgmii_rw_lock);
@@ -1215,8 +1219,14 @@ static void lan743x_mac_set_address(struct lan743x_adapter *adapter,
lan743x_csr_write(adapter, MAC_RX_ADDRH, addr_hi);
ether_addr_copy(adapter->mac_address, addr);
- netif_info(adapter, drv, adapter->netdev,
- "MAC address set to %pM\n", addr);
+ if (netif_msg_drv(adapter)) {
+ if (adapter->netdev->reg_state == NETREG_REGISTERED)
+ netdev_info(adapter->netdev,
+ "MAC address set to %pM\n", addr);
+ else
+ dev_info(&adapter->pdev->dev,
+ "MAC address set to %pM\n", addr);
+ }
}
static int lan743x_mac_init(struct lan743x_adapter *adapter)
@@ -1370,8 +1380,9 @@ static void lan743x_phy_interface_select(struct lan743x_adapter *adapter)
else
adapter->phy_interface = PHY_INTERFACE_MODE_RGMII;
- netif_dbg(adapter, drv, adapter->netdev,
- "selected phy interface: 0x%X\n", adapter->phy_interface);
+ if (netif_msg_drv(adapter))
+ dev_dbg(&adapter->pdev->dev,
+ "selected phy interface: 0x%X\n", adapter->phy_interface);
}
static void lan743x_rfe_open(struct lan743x_adapter *adapter)
@@ -3168,7 +3179,7 @@ static int lan743x_phylink_create(struct lan743x_adapter *adapter)
}
adapter->phylink = pl;
- netdev_dbg(netdev, "lan743x phylink created");
+ dev_dbg(&adapter->pdev->dev, "lan743x phylink created");
return 0;
}
@@ -3581,30 +3592,36 @@ static int lan743x_mdiobus_init(struct lan743x_adapter *adapter)
adapter->mdiobus->priv = (void *)adapter;
if (adapter->is_pci11x1x) {
if (adapter->is_sgmii_en) {
- netif_dbg(adapter, drv, adapter->netdev,
- "SGMII operation\n");
+ if (netif_msg_drv(adapter))
+ dev_dbg(&adapter->pdev->dev,
+ "SGMII operation\n");
adapter->mdiobus->read = lan743x_mdiobus_read_c22;
adapter->mdiobus->write = lan743x_mdiobus_write_c22;
adapter->mdiobus->read_c45 = lan743x_mdiobus_read_c45;
adapter->mdiobus->write_c45 = lan743x_mdiobus_write_c45;
adapter->mdiobus->name = "lan743x-mdiobus-c45";
- netif_dbg(adapter, drv, adapter->netdev,
- "lan743x-mdiobus-c45\n");
+ if (netif_msg_drv(adapter))
+ dev_dbg(&adapter->pdev->dev,
+ "lan743x-mdiobus-c45\n");
} else {
- netif_dbg(adapter, drv, adapter->netdev,
- "RGMII operation\n");
+ if (netif_msg_drv(adapter))
+ dev_dbg(&adapter->pdev->dev,
+ "RGMII operation\n");
// Only C22 support when RGMII I/F
adapter->mdiobus->read = lan743x_mdiobus_read_c22;
adapter->mdiobus->write = lan743x_mdiobus_write_c22;
adapter->mdiobus->name = "lan743x-mdiobus";
- netif_dbg(adapter, drv, adapter->netdev,
- "lan743x-mdiobus\n");
+ if (netif_msg_drv(adapter))
+ dev_dbg(&adapter->pdev->dev,
+ "lan743x-mdiobus\n");
}
} else {
adapter->mdiobus->read = lan743x_mdiobus_read_c22;
adapter->mdiobus->write = lan743x_mdiobus_write_c22;
adapter->mdiobus->name = "lan743x-mdiobus";
- netif_dbg(adapter, drv, adapter->netdev, "lan743x-mdiobus\n");
+ if (netif_msg_drv(adapter))
+ dev_dbg(&adapter->pdev->dev,
+ "lan743x-mdiobus\n");
}
snprintf(adapter->mdiobus->id, MII_BUS_ID_SIZE,
@@ -3696,8 +3713,9 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
ret = lan743x_phylink_create(adapter);
if (ret < 0) {
- netif_err(adapter, probe, netdev,
- "failed to setup phylink (%d)\n", ret);
+ if (netif_msg_probe(adapter))
+ dev_err(&pdev->dev,
+ "failed to setup phylink (%d)\n", ret);
goto cleanup_mdiobus;
}
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-05-15 21:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-15 21:52 [PATCH net] net: lan743x: avoid netdev-based logging before netdev registration David Thompson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.