aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Romieu <romieu@fr.zoreil.com>2008-11-20 01:05:25 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-20 01:42:45 -0500
commit8b4ab28dae8afa14f22d210c591046def2f4d742 (patch)
tree337ad3544c1d9a35e9e0353ca95a8245e3b768b7
parentf80d032b5fe95e3ce89f79210859b7ec799e1ccc (diff)
r8169: convert to net_device_ops
Based upon a patch by Stephen Hemminger. Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/r8169.c48
1 files changed, 32 insertions, 16 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index cb5042ef6dc7..bac58ca628dd 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -474,6 +474,7 @@ struct rtl8169_private {
474 void (*hw_start)(struct net_device *); 474 void (*hw_start)(struct net_device *);
475 unsigned int (*phy_reset_pending)(void __iomem *); 475 unsigned int (*phy_reset_pending)(void __iomem *);
476 unsigned int (*link_ok)(void __iomem *); 476 unsigned int (*link_ok)(void __iomem *);
477 int (*do_ioctl)(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd);
477 int pcie_cap; 478 int pcie_cap;
478 struct delayed_work task; 479 struct delayed_work task;
479 unsigned features; 480 unsigned features;
@@ -1829,9 +1830,11 @@ static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1829 struct rtl8169_private *tp = netdev_priv(dev); 1830 struct rtl8169_private *tp = netdev_priv(dev);
1830 struct mii_ioctl_data *data = if_mii(ifr); 1831 struct mii_ioctl_data *data = if_mii(ifr);
1831 1832
1832 if (!netif_running(dev)) 1833 return netif_running(dev) ? tp->do_ioctl(tp, data, cmd) : -ENODEV;
1833 return -ENODEV; 1834}
1834 1835
1836static int rtl_xmii_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd)
1837{
1835 switch (cmd) { 1838 switch (cmd) {
1836 case SIOCGMIIPHY: 1839 case SIOCGMIIPHY:
1837 data->phy_id = 32; /* Internal PHY */ 1840 data->phy_id = 32; /* Internal PHY */
@@ -1850,6 +1853,11 @@ static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1850 return -EOPNOTSUPP; 1853 return -EOPNOTSUPP;
1851} 1854}
1852 1855
1856static int rtl_tbi_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd)
1857{
1858 return -EOPNOTSUPP;
1859}
1860
1853static const struct rtl_cfg_info { 1861static const struct rtl_cfg_info {
1854 void (*hw_start)(struct net_device *); 1862 void (*hw_start)(struct net_device *);
1855 unsigned int region; 1863 unsigned int region;
@@ -1915,6 +1923,25 @@ static void rtl_disable_msi(struct pci_dev *pdev, struct rtl8169_private *tp)
1915 } 1923 }
1916} 1924}
1917 1925
1926static const struct net_device_ops rtl8169_netdev_ops = {
1927 .ndo_open = rtl8169_open,
1928 .ndo_stop = rtl8169_close,
1929 .ndo_get_stats = rtl8169_get_stats,
1930 .ndo_tx_timeout = rtl8169_tx_timeout,
1931 .ndo_validate_addr = eth_validate_addr,
1932 .ndo_change_mtu = rtl8169_change_mtu,
1933 .ndo_set_mac_address = rtl_set_mac_address,
1934 .ndo_do_ioctl = rtl8169_ioctl,
1935 .ndo_set_multicast_list = rtl_set_rx_mode,
1936#ifdef CONFIG_R8169_VLAN
1937 .ndo_vlan_rx_register = rtl8169_vlan_rx_register,
1938#endif
1939#ifdef CONFIG_NET_POLL_CONTROLLER
1940 .ndo_poll_controller = rtl8169_netpoll,
1941#endif
1942
1943};
1944
1918static int __devinit 1945static int __devinit
1919rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 1946rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1920{ 1947{
@@ -1941,6 +1968,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1941 } 1968 }
1942 1969
1943 SET_NETDEV_DEV(dev, &pdev->dev); 1970 SET_NETDEV_DEV(dev, &pdev->dev);
1971 dev->netdev_ops = &rtl8169_netdev_ops;
1944 tp = netdev_priv(dev); 1972 tp = netdev_priv(dev);
1945 tp->dev = dev; 1973 tp->dev = dev;
1946 tp->pci_dev = pdev; 1974 tp->pci_dev = pdev;
@@ -2076,6 +2104,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2076 tp->phy_reset_enable = rtl8169_tbi_reset_enable; 2104 tp->phy_reset_enable = rtl8169_tbi_reset_enable;
2077 tp->phy_reset_pending = rtl8169_tbi_reset_pending; 2105 tp->phy_reset_pending = rtl8169_tbi_reset_pending;
2078 tp->link_ok = rtl8169_tbi_link_ok; 2106 tp->link_ok = rtl8169_tbi_link_ok;
2107 tp->do_ioctl = rtl_tbi_ioctl;
2079 2108
2080 tp->phy_1000_ctrl_reg = ADVERTISE_1000FULL; /* Implied by TBI */ 2109 tp->phy_1000_ctrl_reg = ADVERTISE_1000FULL; /* Implied by TBI */
2081 } else { 2110 } else {
@@ -2084,8 +2113,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2084 tp->phy_reset_enable = rtl8169_xmii_reset_enable; 2113 tp->phy_reset_enable = rtl8169_xmii_reset_enable;
2085 tp->phy_reset_pending = rtl8169_xmii_reset_pending; 2114 tp->phy_reset_pending = rtl8169_xmii_reset_pending;
2086 tp->link_ok = rtl8169_xmii_link_ok; 2115 tp->link_ok = rtl8169_xmii_link_ok;
2087 2116 tp->do_ioctl = rtl_xmii_ioctl;
2088 dev->do_ioctl = rtl8169_ioctl;
2089 } 2117 }
2090 2118
2091 spin_lock_init(&tp->lock); 2119 spin_lock_init(&tp->lock);
@@ -2097,28 +2125,16 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2097 dev->dev_addr[i] = RTL_R8(MAC0 + i); 2125 dev->dev_addr[i] = RTL_R8(MAC0 + i);
2098 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); 2126 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
2099 2127
2100 dev->open = rtl8169_open;
2101 dev->hard_start_xmit = rtl8169_start_xmit; 2128 dev->hard_start_xmit = rtl8169_start_xmit;
2102 dev->get_stats = rtl8169_get_stats;
2103 SET_ETHTOOL_OPS(dev, &rtl8169_ethtool_ops); 2129 SET_ETHTOOL_OPS(dev, &rtl8169_ethtool_ops);
2104 dev->stop = rtl8169_close;
2105 dev->tx_timeout = rtl8169_tx_timeout;
2106 dev->set_multicast_list = rtl_set_rx_mode;
2107 dev->watchdog_timeo = RTL8169_TX_TIMEOUT; 2130 dev->watchdog_timeo = RTL8169_TX_TIMEOUT;
2108 dev->irq = pdev->irq; 2131 dev->irq = pdev->irq;
2109 dev->base_addr = (unsigned long) ioaddr; 2132 dev->base_addr = (unsigned long) ioaddr;
2110 dev->change_mtu = rtl8169_change_mtu;
2111 dev->set_mac_address = rtl_set_mac_address;
2112 2133
2113 netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT); 2134 netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT);
2114 2135
2115#ifdef CONFIG_R8169_VLAN 2136#ifdef CONFIG_R8169_VLAN
2116 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; 2137 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
2117 dev->vlan_rx_register = rtl8169_vlan_rx_register;
2118#endif
2119
2120#ifdef CONFIG_NET_POLL_CONTROLLER
2121 dev->poll_controller = rtl8169_netpoll;
2122#endif 2138#endif
2123 2139
2124 tp->intr_mask = 0xffff; 2140 tp->intr_mask = 0xffff;