f18827ac0da9177875292772ce0958d0f2d1db58
[openwrt/svn-archive/archive.git] / target / linux / lantiq / patches-3.3 / 0016-NET-MIPS-lantiq-non-existing-phy-was-not-handled-gra.patch
1 From d6a9d52bfcc2d8f163e95920cf3678847bb97f18 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Tue, 15 Nov 2011 14:52:21 +0100
4 Subject: [PATCH 16/70] NET: MIPS: lantiq: non existing phy was not handled
5 gracefully
6
7 The code blindly assumed that that a PHY device was present causing a BadVA.
8 In addition the driver should not fail to load incase no PHY was found.
9 Instead we print the following line and continue with no attached PHY.
10
11 etop: mdio probe failed
12
13 Signed-off-by: John Crispin <blogic@openwrt.org>
14 Cc: netdev@vger.kernel.org
15 ---
16 drivers/net/ethernet/lantiq_etop.c | 14 ++++++++------
17 1 files changed, 8 insertions(+), 6 deletions(-)
18
19 diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
20 index e799b88..5a8ca89 100644
21 --- a/drivers/net/ethernet/lantiq_etop.c
22 +++ b/drivers/net/ethernet/lantiq_etop.c
23 @@ -614,7 +614,8 @@ ltq_etop_open(struct net_device *dev)
24 ltq_dma_open(&ch->dma);
25 napi_enable(&ch->napi);
26 }
27 - phy_start(priv->phydev);
28 + if (priv->phydev)
29 + phy_start(priv->phydev);
30 netif_tx_start_all_queues(dev);
31 return 0;
32 }
33 @@ -626,7 +627,8 @@ ltq_etop_stop(struct net_device *dev)
34 int i;
35
36 netif_tx_stop_all_queues(dev);
37 - phy_stop(priv->phydev);
38 + if (priv->phydev)
39 + phy_stop(priv->phydev);
40 for (i = 0; i < MAX_DMA_CHAN; i++) {
41 struct ltq_etop_chan *ch = &priv->ch[i];
42
43 @@ -772,9 +774,10 @@ ltq_etop_init(struct net_device *dev)
44 if (err)
45 goto err_netdev;
46 ltq_etop_set_multicast_list(dev);
47 - err = ltq_etop_mdio_init(dev);
48 - if (err)
49 - goto err_netdev;
50 + if (!ltq_etop_mdio_init(dev))
51 + dev->ethtool_ops = &ltq_etop_ethtool_ops;
52 + else
53 + pr_warn("etop: mdio probe failed\n");;
54 return 0;
55
56 err_netdev:
57 @@ -870,7 +873,6 @@ ltq_etop_probe(struct platform_device *pdev)
58 dev = alloc_etherdev_mq(sizeof(struct ltq_etop_priv), 4);
59 strcpy(dev->name, "eth%d");
60 dev->netdev_ops = &ltq_eth_netdev_ops;
61 - dev->ethtool_ops = &ltq_etop_ethtool_ops;
62 priv = netdev_priv(dev);
63 priv->res = res;
64 priv->pdev = pdev;
65 --
66 1.7.9.1
67