e59244ac1a8ddd23f27bcc9b54187a152cfa16c2
[openwrt.git] / target / linux / lantiq / patches-3.2 / 0019-NET-MIPS-lantiq-non-existing-phy-was-not-handled-gra.patch
1 From 2bad6512b242b3b5f41414a830d7224d504d0825 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 19/73] 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 d3d4931..9fd6779 100644
21 --- a/drivers/net/ethernet/lantiq_etop.c
22 +++ b/drivers/net/ethernet/lantiq_etop.c
23 @@ -612,7 +612,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 @@ -624,7 +625,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 @@ -770,9 +772,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 @@ -868,7 +871,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->pldata = dev_get_platdata(&pdev->dev);
65 -- 
66 1.7.9.1
67