Skip to content

Commit bc590b4

Browse files
hkallweitPaolo Abeni
authored andcommitted
r8169: check for PCI read error in probe
Check whether first PCI read returns 0xffffffff. Currently, if this is the case, the user sees the following misleading message: unknown chip XID fcf, contact r8169 maintainers (see MAINTAINERS file) Signed-off-by: Heiner Kallweit <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 3ea3c9c commit bc590b4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/net/ethernet/realtek/r8169_main.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5164,6 +5164,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
51645164
int jumbo_max, region, rc;
51655165
enum mac_version chipset;
51665166
struct net_device *dev;
5167+
u32 txconfig;
51675168
u16 xid;
51685169

51695170
dev = devm_alloc_etherdev(&pdev->dev, sizeof (*tp));
@@ -5218,7 +5219,13 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
52185219

52195220
tp->mmio_addr = pcim_iomap_table(pdev)[region];
52205221

5221-
xid = (RTL_R32(tp, TxConfig) >> 20) & 0xfcf;
5222+
txconfig = RTL_R32(tp, TxConfig);
5223+
if (txconfig == ~0U) {
5224+
dev_err(&pdev->dev, "PCI read failed\n");
5225+
return -EIO;
5226+
}
5227+
5228+
xid = (txconfig >> 20) & 0xfcf;
52225229

52235230
/* Identify chip attached to board */
52245231
chipset = rtl8169_get_mac_version(xid, tp->supports_gmii);

0 commit comments

Comments
 (0)