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: f32593773549 ("r8169: check that Realtek PHY driver module is loaded")
Reported-by: Chih-Wei Huang <cwhuang@android-x86.org>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Heiner Kallweit and committed by David S. Miller 2e8c339b e00dd941

Changed files
+7 -9
drivers
net
ethernet
realtek
+7 -9
drivers/net/ethernet/realtek/r8169_main.c
··· 5285 5285 if (!tp->phydev) { 5286 5286 mdiobus_unregister(new_bus); 5287 5287 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; 5288 5295 } 5289 5296 5290 5297 /* PHY will be woken up in rtl_open() */ ··· 5452 5445 struct net_device *dev; 5453 5446 int chipset, region; 5454 5447 int jumbo_max, rc; 5455 - 5456 - /* Some tools for creating an initramfs don't consider softdeps, then 5457 - * r8169.ko may be in initramfs, but realtek.ko not. Then the generic 5458 - * PHY driver is used that doesn't work with most chip versions. 5459 - */ 5460 - if (!driver_find("RTL8201CP Ethernet", &mdio_bus_type)) { 5461 - dev_err(&pdev->dev, "realtek.ko not loaded, maybe it needs to be added to initramfs?\n"); 5462 - return -ENOENT; 5463 - } 5464 5448 5465 5449 dev = devm_alloc_etherdev(&pdev->dev, sizeof (*tp)); 5466 5450 if (!dev)