aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorWolfgang Wegner2010-04-06 11:13:02 +0200
committerBen Warren2010-05-03 14:52:48 -0700
commit33f684d6d512992ed1ae37ec46e76bdeb0773bac (patch)
tree9fba35265fccc20d469d22d934c5f81b116b9f3d /drivers
parent23c34af48ff0dbff3bbaa8e94df3bf40350a709f (diff)
fix lockup in mcfmii/mii_discover_phy() in case communication fails
Signed-off-by: Wolfgang Wegner <w.wegner@astro-kom.de> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/mcfmii.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/drivers/net/mcfmii.c b/drivers/net/mcfmii.c
index 4acc29e42cb..060bdd73971 100644
--- a/drivers/net/mcfmii.c
+++ b/drivers/net/mcfmii.c
@@ -175,38 +175,39 @@ int mii_discover_phy(struct eth_device *dev)
#ifdef ET_DEBUG
printf("PHY type 0x%x pass %d type\n", phytype, pass);
#endif
- if (phytype != 0xffff) {
- phyaddr = phyno;
- phytype <<= 16;
- phytype |=
- mii_send(mk_mii_read(phyno, PHY_PHYIDR2));
+ if (phytype == 0xffff)
+ continue;
+ phyaddr = phyno;
+ phytype <<= 16;
+ phytype |=
+ mii_send(mk_mii_read(phyno, PHY_PHYIDR2));
#ifdef ET_DEBUG
- printf("PHY @ 0x%x pass %d\n", phyno, pass);
+ printf("PHY @ 0x%x pass %d\n", phyno, pass);
#endif
- for (i = 0; i < (sizeof(phyinfo) / sizeof(phy_info_t)); i++) {
- if (phyinfo[i].phyid == phytype) {
+ for (i = 0; (i < (sizeof(phyinfo) / sizeof(phy_info_t)))
+ && (phyinfo[i].phyid != 0); i++) {
+ if (phyinfo[i].phyid == phytype) {
#ifdef ET_DEBUG
- printf("phyid %x - %s\n",
- phyinfo[i].phyid,
- phyinfo[i].strid);
+ printf("phyid %x - %s\n",
+ phyinfo[i].phyid,
+ phyinfo[i].strid);
#endif
- strcpy(info->phy_name, phyinfo[i].strid);
- info->phyname_init = 1;
- found = 1;
- break;
- }
+ strcpy(info->phy_name, phyinfo[i].strid);
+ info->phyname_init = 1;
+ found = 1;
+ break;
}
+ }
- if (!found) {
+ if (!found) {
#ifdef ET_DEBUG
- printf("0x%08x\n", phytype);
+ printf("0x%08x\n", phytype);
#endif
- strcpy(info->phy_name, "unknown");
- info->phyname_init = 1;
- break;
- }
+ strcpy(info->phy_name, "unknown");
+ info->phyname_init = 1;
+ break;
}
}
}