lkml.org 
[lkml]   [2012]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] net: phylib: add error checking if no phy found
Date
From: Dong Aisheng <dong.aisheng@linaro.org>

Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
---
drivers/net/phy/mdio_bus.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 88cc5db..d8e044d 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -101,6 +101,7 @@ static struct class mdio_bus_class = {
int mdiobus_register(struct mii_bus *bus)
{
int i, err;
+ u32 phynum = 0;

if (NULL == bus || NULL == bus->name ||
NULL == bus->read ||
@@ -134,12 +135,20 @@ int mdiobus_register(struct mii_bus *bus)
if (IS_ERR(phydev)) {
err = PTR_ERR(phydev);
goto error;
+ } else if (phydev != NULL) {
+ phynum++;
}
}
}

+ if (!phynum) {
+ err = -ENODEV;
+ printk(KERN_ERR "%s: no phys found\n", bus->name);
+ goto error;
+ }
+
bus->state = MDIOBUS_REGISTERED;
- pr_info("%s: probed\n", bus->name);
+ pr_info("%s: %d phys probed\n", bus->name, phynum);
return 0;

error:
--
1.7.0.4



\
 
 \ /
  Last update: 2012-03-13 11:59    [W:0.030 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site