Commit b76557d9 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Linus Torvalds

[PATCH] Lock initializer unifying (Network drivers)

To make spinlock/rwlock initialization consistent all over the kernel,
this patch converts explicit lock-initializers into spin_lock_init() and
rwlock_init() calls.

Currently, spinlocks and rwlocks are initialized in two different ways:

  lock = SPIN_LOCK_UNLOCKED
  spin_lock_init(&lock)

  rwlock = RW_LOCK_UNLOCKED
  rwlock_init(&rwlock)

this patch converts all explicit lock initializations to
spin_lock_init() or rwlock_init(). (Besides consistency this also helps
automatic lock validators and debugging code.)

The conversion was done with a script, it was verified manually and it
was reviewed, compiled and tested as far as possible on x86, ARM, PPC.

There is no runtime overhead or actual code change resulting out of this
patch, because spin_lock_init() and rwlock_init() are macros and are
thus equivalent to the explicit initialization method.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Acked-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent c83ff1d2
......@@ -466,7 +466,7 @@ int lance_open (struct net_device *dev)
return -EAGAIN;
res = lance_reset(dev);
lp->devlock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&lp->devlock);
netif_start_queue (dev);
return res;
......
......@@ -1260,7 +1260,7 @@ struct net_device * __init i82596_probe(int unit)
lp->scb.command = 0;
lp->scb.cmd = I596_NULL;
lp->scb.rfd = I596_NULL;
lp->lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&lp->lock);
err = register_netdev(dev);
if (err)
......
......@@ -606,7 +606,7 @@ static unsigned long __init lance_probe1( struct net_device *dev,
printk( " Use \"ifconfig hw ether ...\" to set the address.\n" );
}
lp->devlock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&lp->devlock);
MEM->init.mode = 0x0000; /* Disable Rx and Tx. */
for( i = 0; i < 6; i++ )
......
......@@ -666,7 +666,7 @@ static int __init depca_hw_init (struct net_device *dev, struct device *device)
outb(nicsr, DEPCA_NICSR);
}
lp->lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&lp->lock);
sprintf(lp->adapter_name, "%s (%s)",
depca_signature[lp->adapter], device->bus_id);
status = -EBUSY;
......
......@@ -518,7 +518,7 @@ static int ax_open(struct net_device *dev)
ax->flags &= (1 << AXF_INUSE); /* Clear ESCAPE & ERROR flags */
ax->buflock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&ax->buflock);
netif_start_queue(dev);
return 0;
......
......@@ -1218,7 +1218,7 @@ static int __devinit i82596_probe(struct net_device *dev,
lp->scb.command = 0;
lp->scb.cmd = I596_NULL;
lp->scb.rfd = I596_NULL;
lp->lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&lp->lock);
lp->dma_addr = dma_addr;
lp->dev = gen_dev;
......
......@@ -795,7 +795,7 @@ static int __devinit netdrv_init_one (struct pci_dev *pdev,
tp->pci_dev = pdev;
tp->board = ent->driver_data;
tp->mmio_addr = ioaddr;
tp->lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&tp->lock);
pci_set_drvdata(pdev, dev);
......
......@@ -1920,7 +1920,7 @@ ppp_register_channel(struct ppp_channel *chan)
#endif /* CONFIG_PPP_MULTILINK */
init_rwsem(&pch->chan_sem);
spin_lock_init(&pch->downl);
pch->upl = RW_LOCK_UNLOCKED;
rwlock_init(&pch->upl);
spin_lock_bh(&all_channels_lock);
pch->file.index = ++last_channel_index;
list_add(&pch->list, &new_channels);
......
......@@ -879,7 +879,7 @@ static int netdev_open(struct net_device *dev)
if (dev->if_port == 0)
dev->if_port = np->default_port;
np->mcastlock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&np->mcastlock);
set_rx_mode(dev);
writew(0, ioaddr + IntrEnable);
......
......@@ -895,7 +895,7 @@ static int tok_open(struct net_device *dev)
ti->sram_virt &= ~1; /* to reverse what we do in tok_close */
/* init the spinlock */
ti->lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&ti->lock);
init_timer(&ti->tr_timer);
i = tok_init_card(dev);
......
......@@ -1141,7 +1141,7 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
lp->asBitValid = TRUE;
lp->timeout = -1;
lp->gendev = gendev;
lp->lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&lp->lock);
init_timer(&lp->timer);
de4x5_parse_params(dev);
......@@ -1316,7 +1316,7 @@ de4x5_open(struct net_device *dev)
** Re-initialize the DE4X5...
*/
status = de4x5_init(dev);
lp->lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&lp->lock);
lp->state = OPEN;
de4x5_dbg_open(dev);
......
......@@ -259,7 +259,7 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
private->dev = dev;
private->pdev = pdev;
private->io_port = pci_resource_start(pdev, 0);
private->lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&private->lock);
dev->irq = pdev->irq;
dev->base_addr = private->io_port;
......
......@@ -584,7 +584,7 @@ static int __devinit xircom_init_one(struct pci_dev *pdev, const struct pci_devi
tp = netdev_priv(dev);
tp->lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&tp->lock);
tp->pdev = pdev;
tp->chip_id = chip_idx;
/* BugFixes: The 21143-TD hangs with PCI Write-and-Invalidate cycles. */
......
......@@ -225,7 +225,7 @@ static int cycx_wan_setup(struct wan_device *wandev, wandev_conf_t *conf)
card->hw.irq = irq;
card->hw.dpmsize = CYCX_WINDOWSIZE;
card->hw.fwid = CFID_X25_2X;
card->lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&card->lock);
init_waitqueue_head(&card->wait_stats);
rc = cycx_setup(&card->hw, conf->data, conf->data_size, conf->maddr);
......
......@@ -231,7 +231,7 @@ int cycx_x25_wan_init(struct cycx_device *card, wandev_conf_t *conf)
/* Initialize protocol-specific fields */
card->mbox = card->hw.dpmbase + X25_MBOX_OFFS;
card->u.x.connection_keys = 0;
card->u.x.lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&card->u.x.lock);
/* Configure adapter. Here we set reasonable defaults, then parse
* device configuration structure and set configuration options.
......
......@@ -2722,7 +2722,7 @@ struct net_device *_init_airo_card( unsigned short irq, int port,
set_bit(FLAG_MPI, &ai->flags);
}
ai->dev = dev;
ai->aux_lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&ai->aux_lock);
sema_init(&ai->sem, 1);
ai->config.len = 0;
ai->pci = pci;
......
......@@ -421,7 +421,7 @@ static int __init znet_probe (void)
znet->rx_dma = netinfo->dma1;
znet->tx_dma = netinfo->dma2;
znet->lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&znet->lock);
znet->sia_base = 0xe6; /* Magic address for the 82501 SIA */
znet->sia_size = 2;
/* maz: Despite the '593 being advertised above as using a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment