Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <hkallweit1@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/75b54d23-fefe-2bf4-7e80-c9d3bc91af11@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Heiner Kallweit and committed by
Paolo Abeni
bc590b47 3ea3c9cf

+8 -1
+8 -1
drivers/net/ethernet/realtek/r8169_main.c
··· 5164 5164 int jumbo_max, region, rc; 5165 5165 enum mac_version chipset; 5166 5166 struct net_device *dev; 5167 + u32 txconfig; 5167 5168 u16 xid; 5168 5169 5169 5170 dev = devm_alloc_etherdev(&pdev->dev, sizeof (*tp)); ··· 5219 5218 5220 5219 tp->mmio_addr = pcim_iomap_table(pdev)[region]; 5221 5220 5222 - xid = (RTL_R32(tp, TxConfig) >> 20) & 0xfcf; 5221 + txconfig = RTL_R32(tp, TxConfig); 5222 + if (txconfig == ~0U) { 5223 + dev_err(&pdev->dev, "PCI read failed\n"); 5224 + return -EIO; 5225 + } 5226 + 5227 + xid = (txconfig >> 20) & 0xfcf; 5223 5228 5224 5229 /* Identify chip attached to board */ 5225 5230 chipset = rtl8169_get_mac_version(xid, tp->supports_gmii);