brcm47xx: b44: add dummy phy device if we do not find any
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.10 / 208-b44-add-dummy-phy-device-if-we-do-not-find-any.patch
1 From 1a900b17b34ddca0336c739a2836bcb7f8aad5a8 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Fri, 25 Oct 2013 00:03:33 +0200
4 Subject: [PATCH 9/9] b44: add dummy phy device if we do not find any
5
6 ---
7 drivers/net/ethernet/broadcom/b44.c | 25 +++++++++++++++++++++----
8 1 file changed, 21 insertions(+), 4 deletions(-)
9
10 --- a/drivers/net/ethernet/broadcom/b44.c
11 +++ b/drivers/net/ethernet/broadcom/b44.c
12 @@ -2222,6 +2222,8 @@ static int b44_register_phy_one(struct b
13 struct ssb_device *sdev = bp->sdev;
14 struct phy_device *phydev;
15 int err;
16 + bool dummy_phy = false;
17 + struct phy_c45_device_ids c45_ids = {0};
18
19 mii_bus = mdiobus_alloc();
20 if (!mii_bus) {
21 @@ -2256,9 +2258,21 @@ static int b44_register_phy_one(struct b
22
23 phydev = bp->mii_bus->phy_map[bp->phy_addr];
24 if (!phydev) {
25 - dev_err(sdev->dev, "could not find PHY at %i\n", bp->phy_addr);
26 - err = -ENODEV;
27 - goto err_out_mdiobus_unregister;
28 + dummy_phy = true;
29 + dev_info(sdev->dev, "could not find PHY at %i, create dummy one\n",
30 + bp->phy_addr);
31 +
32 + phydev = phy_device_create(bp->mii_bus, bp->phy_addr, 0x0, false, &c45_ids);
33 + if (IS_ERR(phydev)) {
34 + err = PTR_ERR(phydev);
35 + dev_err(sdev->dev, "Can not create dummy PHY\n");
36 + goto err_out_mdiobus_unregister;
37 + }
38 + err = phy_device_register(phydev);
39 + if (err) {
40 + dev_err(sdev->dev, "failed to register MII bus\n");
41 + goto err_out_phy_free;
42 + }
43 }
44
45 err = phy_connect_direct(bp->dev, phydev, &b44_adjust_link,
46 @@ -2266,7 +2280,7 @@ static int b44_register_phy_one(struct b
47 if (err < 0) {
48 dev_err(sdev->dev, "could not attach PHY at %i\n",
49 bp->phy_addr);
50 - goto err_out_mdiobus_unregister;
51 + goto err_out_phy_free;
52 }
53
54 /* mask with MAC supported features */
55 @@ -2288,6 +2302,9 @@ static int b44_register_phy_one(struct b
56
57 return 0;
58
59 +err_out_phy_free:
60 + if (phydev && dummy_phy)
61 + phy_device_free(phydev);
62 err_out_mdiobus_unregister:
63 mdiobus_unregister(mii_bus);
64