diff options
author | juhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2011-12-15 13:25:23 +0000 |
---|---|---|
committer | juhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2011-12-15 13:25:23 +0000 |
commit | 08d268c8a7afcb41e16f878846f043c7d6c6be8b (patch) | |
tree | a75a898fedfe69eb33fd0be27e75efac08361d3d | |
parent | a82d9221c9ccfe1260a62fe816ca24625b0b9a7a (diff) |
ar71xx: ag71xx: check PHY IDs before accessing the switch registers
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@29541 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r-- | target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_ar7240.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_ar7240.c b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_ar7240.c index ffc494858..c0eca4ae4 100644 --- a/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_ar7240.c +++ b/target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_ar7240.c @@ -852,6 +852,14 @@ static struct ar7240sw *ar7240_probe(struct ag71xx *ag) u8 ver; int i; + phy_id1 = ar7240sw_phy_read(mii, 0, MII_PHYSID1); + phy_id2 = ar7240sw_phy_read(mii, 0, MII_PHYSID2); + if (phy_id1 != AR7240_PHY_ID1 || phy_id2 != AR7240_PHY_ID2) { + pr_err("%s: unknown phy id '%04x:%04x'\n", + ag->dev->name, phy_id1, phy_id2); + return NULL; + } + as = kzalloc(sizeof(*as), GFP_KERNEL); if (!as) return NULL; @@ -859,7 +867,6 @@ static struct ar7240sw *ar7240_probe(struct ag71xx *ag) as->mii_bus = mii; ctrl = ar7240sw_reg_read(mii, AR7240_REG_MASK_CTRL); - ver = (ctrl >> AR7240_MASK_CTRL_VERSION_S) & AR7240_MASK_CTRL_VERSION_M; if (ver != 1) { pr_err("%s: unsupported chip, ctrl=%08x\n", @@ -867,14 +874,6 @@ static struct ar7240sw *ar7240_probe(struct ag71xx *ag) return NULL; } - phy_id1 = ar7240sw_phy_read(mii, 0, MII_PHYSID1); - phy_id2 = ar7240sw_phy_read(mii, 0, MII_PHYSID2); - if (phy_id1 != AR7240_PHY_ID1 || phy_id2 != AR7240_PHY_ID2) { - pr_err("%s: unknown phy id '%04x:%04x'\n", - ag->dev->name, phy_id1, phy_id2); - return NULL; - } - swdev = &as->swdev; swdev->name = "AR7240 built-in switch"; swdev->ports = AR7240_NUM_PORTS - 1; |