Skip to content

Commit 2e8c339

Browse files
hkallweitdavem330
authored andcommitted
r8169: fix PHY driver check on platforms w/o module softdeps
On Android/x86 the module loading infrastructure can't deal with softdeps. Therefore the check for presence of the Realtek PHY driver module fails. mdiobus_register() will try to load the PHY driver module, therefore move the check to after this call and explicitly check that a dedicated PHY driver is bound to the PHY device. Fixes: f325937 ("r8169: check that Realtek PHY driver module is loaded") Reported-by: Chih-Wei Huang <[email protected]> Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e00dd94 commit 2e8c339

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

drivers/net/ethernet/realtek/r8169_main.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5285,6 +5285,13 @@ static int r8169_mdio_register(struct rtl8169_private *tp)
52855285
if (!tp->phydev) {
52865286
mdiobus_unregister(new_bus);
52875287
return -ENODEV;
5288+
} else if (!tp->phydev->drv) {
5289+
/* Most chip versions fail with the genphy driver.
5290+
* Therefore ensure that the dedicated PHY driver is loaded.
5291+
*/
5292+
dev_err(&pdev->dev, "realtek.ko not loaded, maybe it needs to be added to initramfs?\n");
5293+
mdiobus_unregister(new_bus);
5294+
return -EUNATCH;
52885295
}
52895296

52905297
/* PHY will be woken up in rtl_open() */
@@ -5446,15 +5453,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
54465453
int chipset, region;
54475454
int jumbo_max, rc;
54485455

5449-
/* Some tools for creating an initramfs don't consider softdeps, then
5450-
* r8169.ko may be in initramfs, but realtek.ko not. Then the generic
5451-
* PHY driver is used that doesn't work with most chip versions.
5452-
*/
5453-
if (!driver_find("RTL8201CP Ethernet", &mdio_bus_type)) {
5454-
dev_err(&pdev->dev, "realtek.ko not loaded, maybe it needs to be added to initramfs?\n");
5455-
return -ENOENT;
5456-
}
5457-
54585456
dev = devm_alloc_etherdev(&pdev->dev, sizeof (*tp));
54595457
if (!dev)
54605458
return -ENOMEM;

0 commit comments

Comments
 (0)