diff options
author | Wang Chen <wangchen@cn.fujitsu.com> | 2008-11-13 02:38:36 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-13 02:38:36 -0500 |
commit | 8f15ea42b64941001a401cf855a0869e24f3a845 (patch) | |
tree | 27c7534ad70ebda6986491daeac0ebe0f1ca54ed /drivers/net/sungem.c | |
parent | 4cf1653aa90c6320dc8032443b5e322820aa28b1 (diff) |
netdevice: safe convert to netdev_priv() #part-3
We have some reasons to kill netdev->priv:
1. netdev->priv is equal to netdev_priv().
2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
netdev_priv() is more flexible than netdev->priv.
But we cann't kill netdev->priv, because so many drivers reference to it
directly.
This patch is a safe convert for netdev->priv to netdev_priv(netdev).
Since all of the netdev->priv is only for read.
But it is too big to be sent in one mail.
I split it to 4 parts and make every part smaller than 100,000 bytes,
which is max size allowed by vger.
Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sungem.c')
-rw-r--r-- | drivers/net/sungem.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c index deb114801da9..44be8dfbcf17 100644 --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c | |||
@@ -164,7 +164,7 @@ static u16 __phy_read(struct gem *gp, int phy_addr, int reg) | |||
164 | 164 | ||
165 | static inline int _phy_read(struct net_device *dev, int mii_id, int reg) | 165 | static inline int _phy_read(struct net_device *dev, int mii_id, int reg) |
166 | { | 166 | { |
167 | struct gem *gp = dev->priv; | 167 | struct gem *gp = netdev_priv(dev); |
168 | return __phy_read(gp, mii_id, reg); | 168 | return __phy_read(gp, mii_id, reg); |
169 | } | 169 | } |
170 | 170 | ||
@@ -197,7 +197,7 @@ static void __phy_write(struct gem *gp, int phy_addr, int reg, u16 val) | |||
197 | 197 | ||
198 | static inline void _phy_write(struct net_device *dev, int mii_id, int reg, int val) | 198 | static inline void _phy_write(struct net_device *dev, int mii_id, int reg, int val) |
199 | { | 199 | { |
200 | struct gem *gp = dev->priv; | 200 | struct gem *gp = netdev_priv(dev); |
201 | __phy_write(gp, mii_id, reg, val & 0xffff); | 201 | __phy_write(gp, mii_id, reg, val & 0xffff); |
202 | } | 202 | } |
203 | 203 | ||
@@ -932,7 +932,7 @@ static int gem_poll(struct napi_struct *napi, int budget) | |||
932 | static irqreturn_t gem_interrupt(int irq, void *dev_id) | 932 | static irqreturn_t gem_interrupt(int irq, void *dev_id) |
933 | { | 933 | { |
934 | struct net_device *dev = dev_id; | 934 | struct net_device *dev = dev_id; |
935 | struct gem *gp = dev->priv; | 935 | struct gem *gp = netdev_priv(dev); |
936 | unsigned long flags; | 936 | unsigned long flags; |
937 | 937 | ||
938 | /* Swallow interrupts when shutting the chip down, though | 938 | /* Swallow interrupts when shutting the chip down, though |
@@ -978,7 +978,7 @@ static void gem_poll_controller(struct net_device *dev) | |||
978 | 978 | ||
979 | static void gem_tx_timeout(struct net_device *dev) | 979 | static void gem_tx_timeout(struct net_device *dev) |
980 | { | 980 | { |
981 | struct gem *gp = dev->priv; | 981 | struct gem *gp = netdev_priv(dev); |
982 | 982 | ||
983 | printk(KERN_ERR "%s: transmit timed out, resetting\n", dev->name); | 983 | printk(KERN_ERR "%s: transmit timed out, resetting\n", dev->name); |
984 | if (!gp->running) { | 984 | if (!gp->running) { |
@@ -1017,7 +1017,7 @@ static __inline__ int gem_intme(int entry) | |||
1017 | 1017 | ||
1018 | static int gem_start_xmit(struct sk_buff *skb, struct net_device *dev) | 1018 | static int gem_start_xmit(struct sk_buff *skb, struct net_device *dev) |
1019 | { | 1019 | { |
1020 | struct gem *gp = dev->priv; | 1020 | struct gem *gp = netdev_priv(dev); |
1021 | int entry; | 1021 | int entry; |
1022 | u64 ctrl; | 1022 | u64 ctrl; |
1023 | unsigned long flags; | 1023 | unsigned long flags; |
@@ -2190,7 +2190,7 @@ static void gem_stop_phy(struct gem *gp, int wol) | |||
2190 | 2190 | ||
2191 | static int gem_do_start(struct net_device *dev) | 2191 | static int gem_do_start(struct net_device *dev) |
2192 | { | 2192 | { |
2193 | struct gem *gp = dev->priv; | 2193 | struct gem *gp = netdev_priv(dev); |
2194 | unsigned long flags; | 2194 | unsigned long flags; |
2195 | 2195 | ||
2196 | spin_lock_irqsave(&gp->lock, flags); | 2196 | spin_lock_irqsave(&gp->lock, flags); |
@@ -2237,7 +2237,7 @@ static int gem_do_start(struct net_device *dev) | |||
2237 | 2237 | ||
2238 | static void gem_do_stop(struct net_device *dev, int wol) | 2238 | static void gem_do_stop(struct net_device *dev, int wol) |
2239 | { | 2239 | { |
2240 | struct gem *gp = dev->priv; | 2240 | struct gem *gp = netdev_priv(dev); |
2241 | unsigned long flags; | 2241 | unsigned long flags; |
2242 | 2242 | ||
2243 | spin_lock_irqsave(&gp->lock, flags); | 2243 | spin_lock_irqsave(&gp->lock, flags); |
@@ -2312,7 +2312,7 @@ static void gem_reset_task(struct work_struct *work) | |||
2312 | 2312 | ||
2313 | static int gem_open(struct net_device *dev) | 2313 | static int gem_open(struct net_device *dev) |
2314 | { | 2314 | { |
2315 | struct gem *gp = dev->priv; | 2315 | struct gem *gp = netdev_priv(dev); |
2316 | int rc = 0; | 2316 | int rc = 0; |
2317 | 2317 | ||
2318 | mutex_lock(&gp->pm_mutex); | 2318 | mutex_lock(&gp->pm_mutex); |
@@ -2331,7 +2331,7 @@ static int gem_open(struct net_device *dev) | |||
2331 | 2331 | ||
2332 | static int gem_close(struct net_device *dev) | 2332 | static int gem_close(struct net_device *dev) |
2333 | { | 2333 | { |
2334 | struct gem *gp = dev->priv; | 2334 | struct gem *gp = netdev_priv(dev); |
2335 | 2335 | ||
2336 | mutex_lock(&gp->pm_mutex); | 2336 | mutex_lock(&gp->pm_mutex); |
2337 | 2337 | ||
@@ -2350,7 +2350,7 @@ static int gem_close(struct net_device *dev) | |||
2350 | static int gem_suspend(struct pci_dev *pdev, pm_message_t state) | 2350 | static int gem_suspend(struct pci_dev *pdev, pm_message_t state) |
2351 | { | 2351 | { |
2352 | struct net_device *dev = pci_get_drvdata(pdev); | 2352 | struct net_device *dev = pci_get_drvdata(pdev); |
2353 | struct gem *gp = dev->priv; | 2353 | struct gem *gp = netdev_priv(dev); |
2354 | unsigned long flags; | 2354 | unsigned long flags; |
2355 | 2355 | ||
2356 | mutex_lock(&gp->pm_mutex); | 2356 | mutex_lock(&gp->pm_mutex); |
@@ -2414,7 +2414,7 @@ static int gem_suspend(struct pci_dev *pdev, pm_message_t state) | |||
2414 | static int gem_resume(struct pci_dev *pdev) | 2414 | static int gem_resume(struct pci_dev *pdev) |
2415 | { | 2415 | { |
2416 | struct net_device *dev = pci_get_drvdata(pdev); | 2416 | struct net_device *dev = pci_get_drvdata(pdev); |
2417 | struct gem *gp = dev->priv; | 2417 | struct gem *gp = netdev_priv(dev); |
2418 | unsigned long flags; | 2418 | unsigned long flags; |
2419 | 2419 | ||
2420 | printk(KERN_INFO "%s: resuming\n", dev->name); | 2420 | printk(KERN_INFO "%s: resuming\n", dev->name); |
@@ -2488,7 +2488,7 @@ static int gem_resume(struct pci_dev *pdev) | |||
2488 | 2488 | ||
2489 | static struct net_device_stats *gem_get_stats(struct net_device *dev) | 2489 | static struct net_device_stats *gem_get_stats(struct net_device *dev) |
2490 | { | 2490 | { |
2491 | struct gem *gp = dev->priv; | 2491 | struct gem *gp = netdev_priv(dev); |
2492 | struct net_device_stats *stats = &gp->net_stats; | 2492 | struct net_device_stats *stats = &gp->net_stats; |
2493 | 2493 | ||
2494 | spin_lock_irq(&gp->lock); | 2494 | spin_lock_irq(&gp->lock); |
@@ -2524,7 +2524,7 @@ static struct net_device_stats *gem_get_stats(struct net_device *dev) | |||
2524 | static int gem_set_mac_address(struct net_device *dev, void *addr) | 2524 | static int gem_set_mac_address(struct net_device *dev, void *addr) |
2525 | { | 2525 | { |
2526 | struct sockaddr *macaddr = (struct sockaddr *) addr; | 2526 | struct sockaddr *macaddr = (struct sockaddr *) addr; |
2527 | struct gem *gp = dev->priv; | 2527 | struct gem *gp = netdev_priv(dev); |
2528 | unsigned char *e = &dev->dev_addr[0]; | 2528 | unsigned char *e = &dev->dev_addr[0]; |
2529 | 2529 | ||
2530 | if (!is_valid_ether_addr(macaddr->sa_data)) | 2530 | if (!is_valid_ether_addr(macaddr->sa_data)) |
@@ -2552,7 +2552,7 @@ static int gem_set_mac_address(struct net_device *dev, void *addr) | |||
2552 | 2552 | ||
2553 | static void gem_set_multicast(struct net_device *dev) | 2553 | static void gem_set_multicast(struct net_device *dev) |
2554 | { | 2554 | { |
2555 | struct gem *gp = dev->priv; | 2555 | struct gem *gp = netdev_priv(dev); |
2556 | u32 rxcfg, rxcfg_new; | 2556 | u32 rxcfg, rxcfg_new; |
2557 | int limit = 10000; | 2557 | int limit = 10000; |
2558 | 2558 | ||
@@ -2601,7 +2601,7 @@ static void gem_set_multicast(struct net_device *dev) | |||
2601 | 2601 | ||
2602 | static int gem_change_mtu(struct net_device *dev, int new_mtu) | 2602 | static int gem_change_mtu(struct net_device *dev, int new_mtu) |
2603 | { | 2603 | { |
2604 | struct gem *gp = dev->priv; | 2604 | struct gem *gp = netdev_priv(dev); |
2605 | 2605 | ||
2606 | if (new_mtu < GEM_MIN_MTU || new_mtu > GEM_MAX_MTU) | 2606 | if (new_mtu < GEM_MIN_MTU || new_mtu > GEM_MAX_MTU) |
2607 | return -EINVAL; | 2607 | return -EINVAL; |
@@ -2632,7 +2632,7 @@ static int gem_change_mtu(struct net_device *dev, int new_mtu) | |||
2632 | 2632 | ||
2633 | static void gem_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 2633 | static void gem_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
2634 | { | 2634 | { |
2635 | struct gem *gp = dev->priv; | 2635 | struct gem *gp = netdev_priv(dev); |
2636 | 2636 | ||
2637 | strcpy(info->driver, DRV_NAME); | 2637 | strcpy(info->driver, DRV_NAME); |
2638 | strcpy(info->version, DRV_VERSION); | 2638 | strcpy(info->version, DRV_VERSION); |
@@ -2641,7 +2641,7 @@ static void gem_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info | |||
2641 | 2641 | ||
2642 | static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 2642 | static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
2643 | { | 2643 | { |
2644 | struct gem *gp = dev->priv; | 2644 | struct gem *gp = netdev_priv(dev); |
2645 | 2645 | ||
2646 | if (gp->phy_type == phy_mii_mdio0 || | 2646 | if (gp->phy_type == phy_mii_mdio0 || |
2647 | gp->phy_type == phy_mii_mdio1) { | 2647 | gp->phy_type == phy_mii_mdio1) { |
@@ -2687,7 +2687,7 @@ static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
2687 | 2687 | ||
2688 | static int gem_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 2688 | static int gem_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
2689 | { | 2689 | { |
2690 | struct gem *gp = dev->priv; | 2690 | struct gem *gp = netdev_priv(dev); |
2691 | 2691 | ||
2692 | /* Verify the settings we care about. */ | 2692 | /* Verify the settings we care about. */ |
2693 | if (cmd->autoneg != AUTONEG_ENABLE && | 2693 | if (cmd->autoneg != AUTONEG_ENABLE && |
@@ -2718,7 +2718,7 @@ static int gem_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
2718 | 2718 | ||
2719 | static int gem_nway_reset(struct net_device *dev) | 2719 | static int gem_nway_reset(struct net_device *dev) |
2720 | { | 2720 | { |
2721 | struct gem *gp = dev->priv; | 2721 | struct gem *gp = netdev_priv(dev); |
2722 | 2722 | ||
2723 | if (!gp->want_autoneg) | 2723 | if (!gp->want_autoneg) |
2724 | return -EINVAL; | 2724 | return -EINVAL; |
@@ -2735,13 +2735,13 @@ static int gem_nway_reset(struct net_device *dev) | |||
2735 | 2735 | ||
2736 | static u32 gem_get_msglevel(struct net_device *dev) | 2736 | static u32 gem_get_msglevel(struct net_device *dev) |
2737 | { | 2737 | { |
2738 | struct gem *gp = dev->priv; | 2738 | struct gem *gp = netdev_priv(dev); |
2739 | return gp->msg_enable; | 2739 | return gp->msg_enable; |
2740 | } | 2740 | } |
2741 | 2741 | ||
2742 | static void gem_set_msglevel(struct net_device *dev, u32 value) | 2742 | static void gem_set_msglevel(struct net_device *dev, u32 value) |
2743 | { | 2743 | { |
2744 | struct gem *gp = dev->priv; | 2744 | struct gem *gp = netdev_priv(dev); |
2745 | gp->msg_enable = value; | 2745 | gp->msg_enable = value; |
2746 | } | 2746 | } |
2747 | 2747 | ||
@@ -2753,7 +2753,7 @@ static void gem_set_msglevel(struct net_device *dev, u32 value) | |||
2753 | 2753 | ||
2754 | static void gem_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | 2754 | static void gem_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) |
2755 | { | 2755 | { |
2756 | struct gem *gp = dev->priv; | 2756 | struct gem *gp = netdev_priv(dev); |
2757 | 2757 | ||
2758 | /* Add more when I understand how to program the chip */ | 2758 | /* Add more when I understand how to program the chip */ |
2759 | if (gp->has_wol) { | 2759 | if (gp->has_wol) { |
@@ -2767,7 +2767,7 @@ static void gem_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |||
2767 | 2767 | ||
2768 | static int gem_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | 2768 | static int gem_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) |
2769 | { | 2769 | { |
2770 | struct gem *gp = dev->priv; | 2770 | struct gem *gp = netdev_priv(dev); |
2771 | 2771 | ||
2772 | if (!gp->has_wol) | 2772 | if (!gp->has_wol) |
2773 | return -EOPNOTSUPP; | 2773 | return -EOPNOTSUPP; |
@@ -2789,7 +2789,7 @@ static const struct ethtool_ops gem_ethtool_ops = { | |||
2789 | 2789 | ||
2790 | static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | 2790 | static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
2791 | { | 2791 | { |
2792 | struct gem *gp = dev->priv; | 2792 | struct gem *gp = netdev_priv(dev); |
2793 | struct mii_ioctl_data *data = if_mii(ifr); | 2793 | struct mii_ioctl_data *data = if_mii(ifr); |
2794 | int rc = -EOPNOTSUPP; | 2794 | int rc = -EOPNOTSUPP; |
2795 | unsigned long flags; | 2795 | unsigned long flags; |
@@ -2921,7 +2921,7 @@ static void gem_remove_one(struct pci_dev *pdev) | |||
2921 | struct net_device *dev = pci_get_drvdata(pdev); | 2921 | struct net_device *dev = pci_get_drvdata(pdev); |
2922 | 2922 | ||
2923 | if (dev) { | 2923 | if (dev) { |
2924 | struct gem *gp = dev->priv; | 2924 | struct gem *gp = netdev_priv(dev); |
2925 | 2925 | ||
2926 | unregister_netdev(dev); | 2926 | unregister_netdev(dev); |
2927 | 2927 | ||
@@ -3024,7 +3024,7 @@ static int __devinit gem_init_one(struct pci_dev *pdev, | |||
3024 | } | 3024 | } |
3025 | SET_NETDEV_DEV(dev, &pdev->dev); | 3025 | SET_NETDEV_DEV(dev, &pdev->dev); |
3026 | 3026 | ||
3027 | gp = dev->priv; | 3027 | gp = netdev_priv(dev); |
3028 | 3028 | ||
3029 | err = pci_request_regions(pdev, DRV_NAME); | 3029 | err = pci_request_regions(pdev, DRV_NAME); |
3030 | if (err) { | 3030 | if (err) { |