aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/au1000_eth.c
diff options
context:
space:
mode:
authorWang Chen <wangchen@cn.fujitsu.com>2008-11-13 02:37:49 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-13 02:37:49 -0500
commit454d7c9b14e20fd1949e2686e9de4a2926e01476 (patch)
treefae8bd1bfb5fd496977a0639ad71c54a2ee278ae /drivers/net/au1000_eth.c
parent7a12122c7a00347da9669cfcde82954c9e3d6f5e (diff)
netdevice: safe convert to netdev_priv() #part-1
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/au1000_eth.c')
-rw-r--r--drivers/net/au1000_eth.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index 2b69b2bbd14c..ecc2573b3dce 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -193,7 +193,7 @@ struct au1000_private *au_macs[NUM_ETH_INTERFACES];
193 */ 193 */
194static int au1000_mdio_read(struct net_device *dev, int phy_addr, int reg) 194static int au1000_mdio_read(struct net_device *dev, int phy_addr, int reg)
195{ 195{
196 struct au1000_private *aup = (struct au1000_private *) dev->priv; 196 struct au1000_private *aup = netdev_priv(dev);
197 volatile u32 *const mii_control_reg = &aup->mac->mii_control; 197 volatile u32 *const mii_control_reg = &aup->mac->mii_control;
198 volatile u32 *const mii_data_reg = &aup->mac->mii_data; 198 volatile u32 *const mii_data_reg = &aup->mac->mii_data;
199 u32 timedout = 20; 199 u32 timedout = 20;
@@ -228,7 +228,7 @@ static int au1000_mdio_read(struct net_device *dev, int phy_addr, int reg)
228static void au1000_mdio_write(struct net_device *dev, int phy_addr, 228static void au1000_mdio_write(struct net_device *dev, int phy_addr,
229 int reg, u16 value) 229 int reg, u16 value)
230{ 230{
231 struct au1000_private *aup = (struct au1000_private *) dev->priv; 231 struct au1000_private *aup = netdev_priv(dev);
232 volatile u32 *const mii_control_reg = &aup->mac->mii_control; 232 volatile u32 *const mii_control_reg = &aup->mac->mii_control;
233 volatile u32 *const mii_data_reg = &aup->mac->mii_data; 233 volatile u32 *const mii_data_reg = &aup->mac->mii_data;
234 u32 timedout = 20; 234 u32 timedout = 20;
@@ -283,7 +283,7 @@ static int au1000_mdiobus_reset(struct mii_bus *bus)
283 283
284static int mii_probe (struct net_device *dev) 284static int mii_probe (struct net_device *dev)
285{ 285{
286 struct au1000_private *const aup = (struct au1000_private *) dev->priv; 286 struct au1000_private *const aup = netdev_priv(dev);
287 struct phy_device *phydev = NULL; 287 struct phy_device *phydev = NULL;
288 288
289#if defined(AU1XXX_PHY_STATIC_CONFIG) 289#if defined(AU1XXX_PHY_STATIC_CONFIG)
@@ -415,7 +415,7 @@ void ReleaseDB(struct au1000_private *aup, db_dest_t *pDB)
415 415
416static void enable_rx_tx(struct net_device *dev) 416static void enable_rx_tx(struct net_device *dev)
417{ 417{
418 struct au1000_private *aup = (struct au1000_private *) dev->priv; 418 struct au1000_private *aup = netdev_priv(dev);
419 419
420 if (au1000_debug > 4) 420 if (au1000_debug > 4)
421 printk(KERN_INFO "%s: enable_rx_tx\n", dev->name); 421 printk(KERN_INFO "%s: enable_rx_tx\n", dev->name);
@@ -426,7 +426,7 @@ static void enable_rx_tx(struct net_device *dev)
426 426
427static void hard_stop(struct net_device *dev) 427static void hard_stop(struct net_device *dev)
428{ 428{
429 struct au1000_private *aup = (struct au1000_private *) dev->priv; 429 struct au1000_private *aup = netdev_priv(dev);
430 430
431 if (au1000_debug > 4) 431 if (au1000_debug > 4)
432 printk(KERN_INFO "%s: hard stop\n", dev->name); 432 printk(KERN_INFO "%s: hard stop\n", dev->name);
@@ -438,7 +438,7 @@ static void hard_stop(struct net_device *dev)
438static void enable_mac(struct net_device *dev, int force_reset) 438static void enable_mac(struct net_device *dev, int force_reset)
439{ 439{
440 unsigned long flags; 440 unsigned long flags;
441 struct au1000_private *aup = (struct au1000_private *) dev->priv; 441 struct au1000_private *aup = netdev_priv(dev);
442 442
443 spin_lock_irqsave(&aup->lock, flags); 443 spin_lock_irqsave(&aup->lock, flags);
444 444
@@ -457,7 +457,7 @@ static void enable_mac(struct net_device *dev, int force_reset)
457 457
458static void reset_mac_unlocked(struct net_device *dev) 458static void reset_mac_unlocked(struct net_device *dev)
459{ 459{
460 struct au1000_private *const aup = (struct au1000_private *) dev->priv; 460 struct au1000_private *const aup = netdev_priv(dev);
461 int i; 461 int i;
462 462
463 hard_stop(dev); 463 hard_stop(dev);
@@ -483,7 +483,7 @@ static void reset_mac_unlocked(struct net_device *dev)
483 483
484static void reset_mac(struct net_device *dev) 484static void reset_mac(struct net_device *dev)
485{ 485{
486 struct au1000_private *const aup = (struct au1000_private *) dev->priv; 486 struct au1000_private *const aup = netdev_priv(dev);
487 unsigned long flags; 487 unsigned long flags;
488 488
489 if (au1000_debug > 4) 489 if (au1000_debug > 4)
@@ -572,7 +572,7 @@ static int __init au1000_init_module(void)
572 572
573static int au1000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 573static int au1000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
574{ 574{
575 struct au1000_private *aup = (struct au1000_private *)dev->priv; 575 struct au1000_private *aup = netdev_priv(dev);
576 576
577 if (aup->phy_dev) 577 if (aup->phy_dev)
578 return phy_ethtool_gset(aup->phy_dev, cmd); 578 return phy_ethtool_gset(aup->phy_dev, cmd);
@@ -582,7 +582,7 @@ static int au1000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
582 582
583static int au1000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 583static int au1000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
584{ 584{
585 struct au1000_private *aup = (struct au1000_private *)dev->priv; 585 struct au1000_private *aup = netdev_priv(dev);
586 586
587 if (!capable(CAP_NET_ADMIN)) 587 if (!capable(CAP_NET_ADMIN))
588 return -EPERM; 588 return -EPERM;
@@ -596,7 +596,7 @@ static int au1000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
596static void 596static void
597au1000_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 597au1000_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
598{ 598{
599 struct au1000_private *aup = (struct au1000_private *)dev->priv; 599 struct au1000_private *aup = netdev_priv(dev);
600 600
601 strcpy(info->driver, DRV_NAME); 601 strcpy(info->driver, DRV_NAME);
602 strcpy(info->version, DRV_VERSION); 602 strcpy(info->version, DRV_VERSION);
@@ -652,7 +652,7 @@ static struct net_device * au1000_probe(int port_num)
652 printk("%s: Au1xx0 Ethernet found at 0x%x, irq %d\n", 652 printk("%s: Au1xx0 Ethernet found at 0x%x, irq %d\n",
653 dev->name, base, irq); 653 dev->name, base, irq);
654 654
655 aup = dev->priv; 655 aup = netdev_priv(dev);
656 656
657 spin_lock_init(&aup->lock); 657 spin_lock_init(&aup->lock);
658 658
@@ -817,7 +817,7 @@ err_out:
817 */ 817 */
818static int au1000_init(struct net_device *dev) 818static int au1000_init(struct net_device *dev)
819{ 819{
820 struct au1000_private *aup = (struct au1000_private *) dev->priv; 820 struct au1000_private *aup = netdev_priv(dev);
821 unsigned long flags; 821 unsigned long flags;
822 int i; 822 int i;
823 u32 control; 823 u32 control;
@@ -868,7 +868,7 @@ static int au1000_init(struct net_device *dev)
868static void 868static void
869au1000_adjust_link(struct net_device *dev) 869au1000_adjust_link(struct net_device *dev)
870{ 870{
871 struct au1000_private *aup = (struct au1000_private *) dev->priv; 871 struct au1000_private *aup = netdev_priv(dev);
872 struct phy_device *phydev = aup->phy_dev; 872 struct phy_device *phydev = aup->phy_dev;
873 unsigned long flags; 873 unsigned long flags;
874 874
@@ -947,7 +947,7 @@ au1000_adjust_link(struct net_device *dev)
947static int au1000_open(struct net_device *dev) 947static int au1000_open(struct net_device *dev)
948{ 948{
949 int retval; 949 int retval;
950 struct au1000_private *aup = (struct au1000_private *) dev->priv; 950 struct au1000_private *aup = netdev_priv(dev);
951 951
952 if (au1000_debug > 4) 952 if (au1000_debug > 4)
953 printk("%s: open: dev=%p\n", dev->name, dev); 953 printk("%s: open: dev=%p\n", dev->name, dev);
@@ -982,7 +982,7 @@ static int au1000_open(struct net_device *dev)
982static int au1000_close(struct net_device *dev) 982static int au1000_close(struct net_device *dev)
983{ 983{
984 unsigned long flags; 984 unsigned long flags;
985 struct au1000_private *const aup = (struct au1000_private *) dev->priv; 985 struct au1000_private *const aup = netdev_priv(dev);
986 986
987 if (au1000_debug > 4) 987 if (au1000_debug > 4)
988 printk("%s: close: dev=%p\n", dev->name, dev); 988 printk("%s: close: dev=%p\n", dev->name, dev);
@@ -1013,7 +1013,7 @@ static void __exit au1000_cleanup_module(void)
1013 for (i = 0; i < num_ifs; i++) { 1013 for (i = 0; i < num_ifs; i++) {
1014 dev = iflist[i].dev; 1014 dev = iflist[i].dev;
1015 if (dev) { 1015 if (dev) {
1016 aup = (struct au1000_private *) dev->priv; 1016 aup = netdev_priv(dev);
1017 unregister_netdev(dev); 1017 unregister_netdev(dev);
1018 mdiobus_unregister(aup->mii_bus); 1018 mdiobus_unregister(aup->mii_bus);
1019 mdiobus_free(aup->mii_bus); 1019 mdiobus_free(aup->mii_bus);
@@ -1035,7 +1035,7 @@ static void __exit au1000_cleanup_module(void)
1035 1035
1036static void update_tx_stats(struct net_device *dev, u32 status) 1036static void update_tx_stats(struct net_device *dev, u32 status)
1037{ 1037{
1038 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1038 struct au1000_private *aup = netdev_priv(dev);
1039 struct net_device_stats *ps = &dev->stats; 1039 struct net_device_stats *ps = &dev->stats;
1040 1040
1041 if (status & TX_FRAME_ABORTED) { 1041 if (status & TX_FRAME_ABORTED) {
@@ -1064,7 +1064,7 @@ static void update_tx_stats(struct net_device *dev, u32 status)
1064 */ 1064 */
1065static void au1000_tx_ack(struct net_device *dev) 1065static void au1000_tx_ack(struct net_device *dev)
1066{ 1066{
1067 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1067 struct au1000_private *aup = netdev_priv(dev);
1068 volatile tx_dma_t *ptxd; 1068 volatile tx_dma_t *ptxd;
1069 1069
1070 ptxd = aup->tx_dma_ring[aup->tx_tail]; 1070 ptxd = aup->tx_dma_ring[aup->tx_tail];
@@ -1091,7 +1091,7 @@ static void au1000_tx_ack(struct net_device *dev)
1091 */ 1091 */
1092static int au1000_tx(struct sk_buff *skb, struct net_device *dev) 1092static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
1093{ 1093{
1094 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1094 struct au1000_private *aup = netdev_priv(dev);
1095 struct net_device_stats *ps = &dev->stats; 1095 struct net_device_stats *ps = &dev->stats;
1096 volatile tx_dma_t *ptxd; 1096 volatile tx_dma_t *ptxd;
1097 u32 buff_stat; 1097 u32 buff_stat;
@@ -1145,7 +1145,7 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
1145 1145
1146static inline void update_rx_stats(struct net_device *dev, u32 status) 1146static inline void update_rx_stats(struct net_device *dev, u32 status)
1147{ 1147{
1148 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1148 struct au1000_private *aup = netdev_priv(dev);
1149 struct net_device_stats *ps = &dev->stats; 1149 struct net_device_stats *ps = &dev->stats;
1150 1150
1151 ps->rx_packets++; 1151 ps->rx_packets++;
@@ -1173,7 +1173,7 @@ static inline void update_rx_stats(struct net_device *dev, u32 status)
1173 */ 1173 */
1174static int au1000_rx(struct net_device *dev) 1174static int au1000_rx(struct net_device *dev)
1175{ 1175{
1176 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1176 struct au1000_private *aup = netdev_priv(dev);
1177 struct sk_buff *skb; 1177 struct sk_buff *skb;
1178 volatile rx_dma_t *prxd; 1178 volatile rx_dma_t *prxd;
1179 u32 buff_stat, status; 1179 u32 buff_stat, status;
@@ -1275,7 +1275,7 @@ static void au1000_tx_timeout(struct net_device *dev)
1275 1275
1276static void set_rx_mode(struct net_device *dev) 1276static void set_rx_mode(struct net_device *dev)
1277{ 1277{
1278 struct au1000_private *aup = (struct au1000_private *) dev->priv; 1278 struct au1000_private *aup = netdev_priv(dev);
1279 1279
1280 if (au1000_debug > 4) 1280 if (au1000_debug > 4)
1281 printk("%s: set_rx_mode: flags=%x\n", dev->name, dev->flags); 1281 printk("%s: set_rx_mode: flags=%x\n", dev->name, dev->flags);
@@ -1307,7 +1307,7 @@ static void set_rx_mode(struct net_device *dev)
1307 1307
1308static int au1000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1308static int au1000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1309{ 1309{
1310 struct au1000_private *aup = (struct au1000_private *)dev->priv; 1310 struct au1000_private *aup = netdev_priv(dev);
1311 1311
1312 if (!netif_running(dev)) return -EINVAL; 1312 if (!netif_running(dev)) return -EINVAL;
1313 1313