[ixp4xx] move the latch-led driver into a separated patch
[openwrt.git] / target / linux / ixp4xx / patches / 140-ixp4xx_net_driver_no_phy.patch
1 Index: linux-2.6.21.7/drivers/net/ixp4xx/mac_driver.c
2 ===================================================================
3 --- linux-2.6.21.7.orig/drivers/net/ixp4xx/mac_driver.c
4 +++ linux-2.6.21.7/drivers/net/ixp4xx/mac_driver.c
5 @@ -161,6 +161,16 @@ static int media_check(struct net_device
6  {
7         struct mac_info *mac = netdev_priv(dev);
8  
9 +       if ( mac->mii.phy_id < 0 ) {
10 +               if ( init ) {
11 +                       netif_carrier_on(mac->mii.dev);
12 +                       mac->mii.full_duplex = 1;
13 +                       update_duplex_mode(dev);
14 +                       return 1;
15 +               }
16 +               return 0;
17 +       }
18 +
19         if (mii_check_media(&mac->mii, netif_msg_link(mac), init)) {
20                 update_duplex_mode(dev);
21                 return 1;
22 @@ -448,7 +458,12 @@ static int ixmac_ioctl(struct net_device
23                 return -EINVAL;
24         if (!try_module_get(THIS_MODULE))
25                 return -ENODEV;
26 -       rc = generic_mii_ioctl(&mac->mii, if_mii(rq), cmd, &duplex_changed);
27 +       if ( mac->mii.phy_id < 0 ) {
28 +               duplex_changed = 0;
29 +               rc = -EOPNOTSUPP;
30 +       } else {
31 +               rc = generic_mii_ioctl(&mac->mii, if_mii(rq), cmd, &duplex_changed);
32 +       }
33         module_put(THIS_MODULE);
34         if (duplex_changed)
35                 update_duplex_mode(dev);
36 @@ -478,6 +493,9 @@ static void ixmac_get_drvinfo(struct net
37  static int ixmac_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
38  {
39         struct mac_info *mac = netdev_priv(dev);
40 +       if ( mac->mii.phy_id < 0 ) {
41 +               return 0;
42 +       }
43         mii_ethtool_gset(&mac->mii, cmd);
44         return 0;
45  }
46 @@ -486,6 +504,9 @@ static int ixmac_set_settings(struct net
47  {
48         struct mac_info *mac = netdev_priv(dev);
49         int rc;
50 +       if ( mac->mii.phy_id < 0 ) {
51 +               return -EOPNOTSUPP;
52 +       }
53         rc = mii_ethtool_sset(&mac->mii, cmd);
54         return rc;
55  }
56 @@ -493,12 +514,18 @@ static int ixmac_set_settings(struct net
57  static int ixmac_nway_reset(struct net_device *dev)
58  {
59         struct mac_info *mac = netdev_priv(dev);
60 +       if ( mac->mii.phy_id < 0 ) {
61 +               return -EOPNOTSUPP;
62 +       }
63         return mii_nway_restart(&mac->mii);
64  }
65  
66  static u32 ixmac_get_link(struct net_device *dev)
67  {
68         struct mac_info *mac = netdev_priv(dev);
69 +       if ( mac->mii.phy_id < 0 ) {
70 +               return 1;
71 +       }
72         return mii_link_ok(&mac->mii);
73  }
74