Skip to content

Commit

Permalink
netdevice: safe convert to netdev_priv() #part-3
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Wang Chen authored and David S. Miller committed Nov 13, 2008
1 parent 4cf1653 commit 8f15ea4
Show file tree
Hide file tree
Showing 25 changed files with 253 additions and 244 deletions.
2 changes: 1 addition & 1 deletion drivers/net/sgiseeq.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ static void timeout(struct net_device *dev)

static void sgiseeq_set_multicast(struct net_device *dev)
{
struct sgiseeq_private *sp = (struct sgiseeq_private *) dev->priv;
struct sgiseeq_private *sp = netdev_priv(dev);
unsigned char oldmode = sp->mode;

if(dev->flags & IFF_PROMISC)
Expand Down
64 changes: 32 additions & 32 deletions drivers/net/sis900.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
if (ret)
goto err_out;

sis_priv = net_dev->priv;
sis_priv = netdev_priv(net_dev);
net_dev->base_addr = ioaddr;
net_dev->irq = pci_dev->irq;
sis_priv->pci_dev = pci_dev;
Expand Down Expand Up @@ -569,7 +569,7 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,

static int __devinit sis900_mii_probe(struct net_device * net_dev)
{
struct sis900_private * sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
const char *dev_name = pci_name(sis_priv->pci_dev);
u16 poll_bit = MII_STAT_LINK, status = 0;
unsigned long timeout = jiffies + 5 * HZ;
Expand Down Expand Up @@ -697,7 +697,7 @@ static int __devinit sis900_mii_probe(struct net_device * net_dev)

static u16 sis900_default_phy(struct net_device * net_dev)
{
struct sis900_private * sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
struct mii_phy *phy = NULL, *phy_home = NULL,
*default_phy = NULL, *phy_lan = NULL;
u16 status;
Expand Down Expand Up @@ -998,7 +998,7 @@ static void sis900_poll(struct net_device *dev)
static int
sis900_open(struct net_device *net_dev)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
long ioaddr = net_dev->base_addr;
int ret;

Expand Down Expand Up @@ -1054,7 +1054,7 @@ sis900_open(struct net_device *net_dev)
static void
sis900_init_rxfilter (struct net_device * net_dev)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
long ioaddr = net_dev->base_addr;
u32 rfcrSave;
u32 i;
Expand Down Expand Up @@ -1092,7 +1092,7 @@ sis900_init_rxfilter (struct net_device * net_dev)
static void
sis900_init_tx_ring(struct net_device *net_dev)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
long ioaddr = net_dev->base_addr;
int i;

Expand Down Expand Up @@ -1126,7 +1126,7 @@ sis900_init_tx_ring(struct net_device *net_dev)
static void
sis900_init_rx_ring(struct net_device *net_dev)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
long ioaddr = net_dev->base_addr;
int i;

Expand Down Expand Up @@ -1197,7 +1197,7 @@ sis900_init_rx_ring(struct net_device *net_dev)

static void sis630_set_eq(struct net_device *net_dev, u8 revision)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
u16 reg14h, eq_value=0, max_value=0, min_value=0;
int i, maxcount=10;

Expand Down Expand Up @@ -1270,7 +1270,7 @@ static void sis630_set_eq(struct net_device *net_dev, u8 revision)
static void sis900_timer(unsigned long data)
{
struct net_device *net_dev = (struct net_device *)data;
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
struct mii_phy *mii_phy = sis_priv->mii;
static const int next_tick = 5*HZ;
u16 status;
Expand Down Expand Up @@ -1340,7 +1340,7 @@ static void sis900_timer(unsigned long data)

static void sis900_check_mode(struct net_device *net_dev, struct mii_phy *mii_phy)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
long ioaddr = net_dev->base_addr;
int speed, duplex;

Expand Down Expand Up @@ -1419,7 +1419,7 @@ static void sis900_set_mode (long ioaddr, int speed, int duplex)

static void sis900_auto_negotiate(struct net_device *net_dev, int phy_addr)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
int i = 0;
u32 status;

Expand Down Expand Up @@ -1454,7 +1454,7 @@ static void sis900_auto_negotiate(struct net_device *net_dev, int phy_addr)

static void sis900_read_mode(struct net_device *net_dev, int *speed, int *duplex)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
struct mii_phy *phy = sis_priv->mii;
int phy_addr = sis_priv->cur_phy;
u32 status;
Expand Down Expand Up @@ -1509,7 +1509,7 @@ static void sis900_read_mode(struct net_device *net_dev, int *speed, int *duplex

static void sis900_tx_timeout(struct net_device *net_dev)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
long ioaddr = net_dev->base_addr;
unsigned long flags;
int i;
Expand Down Expand Up @@ -1568,7 +1568,7 @@ static void sis900_tx_timeout(struct net_device *net_dev)
static int
sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
long ioaddr = net_dev->base_addr;
unsigned int entry;
unsigned long flags;
Expand Down Expand Up @@ -1638,7 +1638,7 @@ sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
static irqreturn_t sis900_interrupt(int irq, void *dev_instance)
{
struct net_device *net_dev = dev_instance;
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
int boguscnt = max_interrupt_work;
long ioaddr = net_dev->base_addr;
u32 status;
Expand Down Expand Up @@ -1700,7 +1700,7 @@ static irqreturn_t sis900_interrupt(int irq, void *dev_instance)

static int sis900_rx(struct net_device *net_dev)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
long ioaddr = net_dev->base_addr;
unsigned int entry = sis_priv->cur_rx % NUM_RX_DESC;
u32 rx_status = sis_priv->rx_ring[entry].cmdsts;
Expand Down Expand Up @@ -1849,7 +1849,7 @@ static int sis900_rx(struct net_device *net_dev)

static void sis900_finish_xmit (struct net_device *net_dev)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);

for (; sis_priv->dirty_tx != sis_priv->cur_tx; sis_priv->dirty_tx++) {
struct sk_buff *skb;
Expand Down Expand Up @@ -1918,7 +1918,7 @@ static void sis900_finish_xmit (struct net_device *net_dev)
static int sis900_close(struct net_device *net_dev)
{
long ioaddr = net_dev->base_addr;
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
struct sk_buff *skb;
int i;

Expand Down Expand Up @@ -1973,7 +1973,7 @@ static int sis900_close(struct net_device *net_dev)
static void sis900_get_drvinfo(struct net_device *net_dev,
struct ethtool_drvinfo *info)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);

strcpy (info->driver, SIS900_MODULE_NAME);
strcpy (info->version, SIS900_DRV_VERSION);
Expand All @@ -1982,26 +1982,26 @@ static void sis900_get_drvinfo(struct net_device *net_dev,

static u32 sis900_get_msglevel(struct net_device *net_dev)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
return sis_priv->msg_enable;
}

static void sis900_set_msglevel(struct net_device *net_dev, u32 value)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
sis_priv->msg_enable = value;
}

static u32 sis900_get_link(struct net_device *net_dev)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
return mii_link_ok(&sis_priv->mii_info);
}

static int sis900_get_settings(struct net_device *net_dev,
struct ethtool_cmd *cmd)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
spin_lock_irq(&sis_priv->lock);
mii_ethtool_gset(&sis_priv->mii_info, cmd);
spin_unlock_irq(&sis_priv->lock);
Expand All @@ -2011,7 +2011,7 @@ static int sis900_get_settings(struct net_device *net_dev,
static int sis900_set_settings(struct net_device *net_dev,
struct ethtool_cmd *cmd)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
int rt;
spin_lock_irq(&sis_priv->lock);
rt = mii_ethtool_sset(&sis_priv->mii_info, cmd);
Expand All @@ -2021,7 +2021,7 @@ static int sis900_set_settings(struct net_device *net_dev,

static int sis900_nway_reset(struct net_device *net_dev)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
return mii_nway_restart(&sis_priv->mii_info);
}

Expand All @@ -2038,7 +2038,7 @@ static int sis900_nway_reset(struct net_device *net_dev)

static int sis900_set_wol(struct net_device *net_dev, struct ethtool_wolinfo *wol)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
long pmctrl_addr = net_dev->base_addr + pmctrl;
u32 cfgpmcsr = 0, pmctrl_bits = 0;

Expand Down Expand Up @@ -2109,7 +2109,7 @@ static const struct ethtool_ops sis900_ethtool_ops = {

static int mii_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd)
{
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
struct mii_ioctl_data *data = if_mii(rq);

switch(cmd) {
Expand Down Expand Up @@ -2143,7 +2143,7 @@ static int mii_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd)

static int sis900_set_config(struct net_device *dev, struct ifmap *map)
{
struct sis900_private *sis_priv = dev->priv;
struct sis900_private *sis_priv = netdev_priv(dev);
struct mii_phy *mii_phy = sis_priv->mii;

u16 status;
Expand Down Expand Up @@ -2266,7 +2266,7 @@ static inline u16 sis900_mcast_bitnr(u8 *addr, u8 revision)
static void set_rx_mode(struct net_device *net_dev)
{
long ioaddr = net_dev->base_addr;
struct sis900_private * sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
u16 mc_filter[16] = {0}; /* 256/128 bits multicast hash table */
int i, table_entries;
u32 rx_mode;
Expand Down Expand Up @@ -2341,7 +2341,7 @@ static void set_rx_mode(struct net_device *net_dev)

static void sis900_reset(struct net_device *net_dev)
{
struct sis900_private * sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
long ioaddr = net_dev->base_addr;
int i = 0;
u32 status = TxRCMP | RxRCMP;
Expand Down Expand Up @@ -2374,7 +2374,7 @@ static void sis900_reset(struct net_device *net_dev)
static void __devexit sis900_remove(struct pci_dev *pci_dev)
{
struct net_device *net_dev = pci_get_drvdata(pci_dev);
struct sis900_private * sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
struct mii_phy *phy = NULL;

while (sis_priv->first_mii) {
Expand Down Expand Up @@ -2418,7 +2418,7 @@ static int sis900_suspend(struct pci_dev *pci_dev, pm_message_t state)
static int sis900_resume(struct pci_dev *pci_dev)
{
struct net_device *net_dev = pci_get_drvdata(pci_dev);
struct sis900_private *sis_priv = net_dev->priv;
struct sis900_private *sis_priv = netdev_priv(net_dev);
long ioaddr = net_dev->base_addr;

if(!netif_running(net_dev))
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/smc9194.c
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ static int __init smc_probe(struct net_device *dev, int ioaddr)
printk("ADDR: %pM\n", dev->dev_addr);

/* set the private data to zero by default */
memset(dev->priv, 0, sizeof(struct smc_local));
memset(netdev_priv(dev), 0, sizeof(struct smc_local));

/* Grab the IRQ */
retval = request_irq(dev->irq, &smc_interrupt, 0, DRV_NAME, dev);
Expand Down Expand Up @@ -1108,7 +1108,7 @@ static int smc_open(struct net_device *dev)
int i; /* used to set hw ethernet address */

/* clear out all the junk that was put here before... */
memset(dev->priv, 0, sizeof(struct smc_local));
memset(netdev_priv(dev), 0, sizeof(struct smc_local));

/* reset the hardware */

Expand Down Expand Up @@ -1164,7 +1164,7 @@ static void smc_timeout(struct net_device *dev)
smc_enable( dev->base_addr );
dev->trans_start = jiffies;
/* clear anything saved */
((struct smc_local *)dev->priv)->saved_skb = NULL;
((struct smc_local *)netdev_priv(dev))->saved_skb = NULL;
netif_wake_queue(dev);
}

Expand Down
Loading

0 comments on commit 8f15ea4

Please sign in to comment.