Skip to content

Commit e3c6508

Browse files
dthompsokuba-moo
authored andcommitted
net: lan743x: avoid netdev-based logging before netdev registration
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_ 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. Signed-off-by: David Thompson <davthompson@nvidia.com> Link: https://patch.msgid.link/20260528165017.421576-1-davthompson@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 9c89f97 commit e3c6508

1 file changed

Lines changed: 21 additions & 27 deletions

File tree

drivers/net/ethernet/microchip/lan743x_main.c

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ static int lan743x_pci_init(struct lan743x_adapter *adapter,
108108
if (ret)
109109
goto return_error;
110110

111-
netif_info(adapter, probe, adapter->netdev,
112-
"PCI: Vendor ID = 0x%04X, Device ID = 0x%04X\n",
113-
pdev->vendor, pdev->device);
111+
dev_dbg(&adapter->pdev->dev,
112+
"PCI: Vendor ID = 0x%04X, Device ID = 0x%04X\n",
113+
pdev->vendor, pdev->device);
114114
bars = pci_select_bars(pdev, IORESOURCE_MEM);
115115
if (!test_bit(0, &bars))
116116
goto disable_device;
@@ -192,10 +192,10 @@ static int lan743x_csr_init(struct lan743x_adapter *adapter)
192192

193193
csr->id_rev = lan743x_csr_read(adapter, ID_REV);
194194
csr->fpga_rev = lan743x_csr_read(adapter, FPGA_REV);
195-
netif_info(adapter, probe, adapter->netdev,
196-
"ID_REV = 0x%08X, FPGA_REV = %d.%d\n",
197-
csr->id_rev, FPGA_REV_GET_MAJOR_(csr->fpga_rev),
198-
FPGA_REV_GET_MINOR_(csr->fpga_rev));
195+
dev_dbg(&adapter->pdev->dev,
196+
"ID_REV = 0x%08X, FPGA_REV = %d.%d\n",
197+
csr->id_rev, FPGA_REV_GET_MAJOR_(csr->fpga_rev),
198+
FPGA_REV_GET_MINOR_(csr->fpga_rev));
199199
if (!ID_REV_IS_VALID_CHIP_ID_(csr->id_rev))
200200
return -ENODEV;
201201

@@ -953,8 +953,8 @@ int lan743x_sgmii_read(struct lan743x_adapter *adapter, u8 mmd, u16 addr)
953953
u32 val;
954954

955955
if (mmd > 31) {
956-
netif_err(adapter, probe, adapter->netdev,
957-
"%s mmd should <= 31\n", __func__);
956+
dev_err(&adapter->pdev->dev,
957+
"%s mmd should <= 31\n", __func__);
958958
return -EINVAL;
959959
}
960960

@@ -983,8 +983,8 @@ static int lan743x_sgmii_write(struct lan743x_adapter *adapter,
983983
int ret;
984984

985985
if (mmd > 31) {
986-
netif_err(adapter, probe, adapter->netdev,
987-
"%s mmd should <= 31\n", __func__);
986+
dev_err(&adapter->pdev->dev,
987+
"%s mmd should <= 31\n", __func__);
988988
return -EINVAL;
989989
}
990990
mutex_lock(&adapter->sgmii_rw_lock);
@@ -1215,8 +1215,7 @@ static void lan743x_mac_set_address(struct lan743x_adapter *adapter,
12151215
lan743x_csr_write(adapter, MAC_RX_ADDRH, addr_hi);
12161216

12171217
ether_addr_copy(adapter->mac_address, addr);
1218-
netif_info(adapter, drv, adapter->netdev,
1219-
"MAC address set to %pM\n", addr);
1218+
dev_dbg(&adapter->pdev->dev, "MAC address set to %pM\n", addr);
12201219
}
12211220

12221221
static int lan743x_mac_init(struct lan743x_adapter *adapter)
@@ -1370,8 +1369,8 @@ static void lan743x_phy_interface_select(struct lan743x_adapter *adapter)
13701369
else
13711370
adapter->phy_interface = PHY_INTERFACE_MODE_RGMII;
13721371

1373-
netif_dbg(adapter, drv, adapter->netdev,
1374-
"selected phy interface: 0x%X\n", adapter->phy_interface);
1372+
dev_dbg(&adapter->pdev->dev,
1373+
"selected phy interface: 0x%X\n", adapter->phy_interface);
13751374
}
13761375

13771376
static void lan743x_rfe_open(struct lan743x_adapter *adapter)
@@ -3168,7 +3167,7 @@ static int lan743x_phylink_create(struct lan743x_adapter *adapter)
31683167
}
31693168

31703169
adapter->phylink = pl;
3171-
netdev_dbg(netdev, "lan743x phylink created");
3170+
dev_dbg(&adapter->pdev->dev, "lan743x phylink created");
31723171

31733172
return 0;
31743173
}
@@ -3581,30 +3580,26 @@ static int lan743x_mdiobus_init(struct lan743x_adapter *adapter)
35813580
adapter->mdiobus->priv = (void *)adapter;
35823581
if (adapter->is_pci11x1x) {
35833582
if (adapter->is_sgmii_en) {
3584-
netif_dbg(adapter, drv, adapter->netdev,
3585-
"SGMII operation\n");
3583+
dev_dbg(&adapter->pdev->dev, "SGMII operation\n");
35863584
adapter->mdiobus->read = lan743x_mdiobus_read_c22;
35873585
adapter->mdiobus->write = lan743x_mdiobus_write_c22;
35883586
adapter->mdiobus->read_c45 = lan743x_mdiobus_read_c45;
35893587
adapter->mdiobus->write_c45 = lan743x_mdiobus_write_c45;
35903588
adapter->mdiobus->name = "lan743x-mdiobus-c45";
3591-
netif_dbg(adapter, drv, adapter->netdev,
3592-
"lan743x-mdiobus-c45\n");
3589+
dev_dbg(&adapter->pdev->dev, "lan743x-mdiobus-c45\n");
35933590
} else {
3594-
netif_dbg(adapter, drv, adapter->netdev,
3595-
"RGMII operation\n");
3591+
dev_dbg(&adapter->pdev->dev, "RGMII operation\n");
35963592
// Only C22 support when RGMII I/F
35973593
adapter->mdiobus->read = lan743x_mdiobus_read_c22;
35983594
adapter->mdiobus->write = lan743x_mdiobus_write_c22;
35993595
adapter->mdiobus->name = "lan743x-mdiobus";
3600-
netif_dbg(adapter, drv, adapter->netdev,
3601-
"lan743x-mdiobus\n");
3596+
dev_dbg(&adapter->pdev->dev, "lan743x-mdiobus\n");
36023597
}
36033598
} else {
36043599
adapter->mdiobus->read = lan743x_mdiobus_read_c22;
36053600
adapter->mdiobus->write = lan743x_mdiobus_write_c22;
36063601
adapter->mdiobus->name = "lan743x-mdiobus";
3607-
netif_dbg(adapter, drv, adapter->netdev, "lan743x-mdiobus\n");
3602+
dev_dbg(&adapter->pdev->dev, "lan743x-mdiobus\n");
36083603
}
36093604

36103605
snprintf(adapter->mdiobus->id, MII_BUS_ID_SIZE,
@@ -3696,8 +3691,7 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
36963691

36973692
ret = lan743x_phylink_create(adapter);
36983693
if (ret < 0) {
3699-
netif_err(adapter, probe, netdev,
3700-
"failed to setup phylink (%d)\n", ret);
3694+
dev_err(&pdev->dev, "failed to setup phylink (%d)\n", ret);
37013695
goto cleanup_mdiobus;
37023696
}
37033697

0 commit comments

Comments
 (0)