From c8014fe1d4548da8b9ea54730852c48a7117b03f Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Mon, 4 May 2009 20:30:01 +0000 Subject: [PATCH] r6040: check for absent PHY Some devices have two R6040 MACs but the second one is not wired to any PHY, therefore the interface is just unusable. Warn the user about that and prevent device from registering. Tested-by: bifferos Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller --- drivers/net/r6040.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c index 6f97b47d74a6..65627253c988 100644 --- a/drivers/net/r6040.c +++ b/drivers/net/r6040.c @@ -742,6 +742,14 @@ static int r6040_up(struct net_device *dev) struct r6040_private *lp = netdev_priv(dev); void __iomem *ioaddr = lp->base; int ret; + u16 val; + + /* Check presence of a second PHY */ + val = r6040_phy_read(ioaddr, lp->phy_addr, 2); + if (val == 0xFFFF) { + printk(KERN_ERR DRV_NAME " no second PHY attached\n"); + return -EIO; + } /* Initialise and alloc RX/TX buffers */ r6040_init_txbufs(dev); -- 2.30.2