Commit 330c54ca authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Linus Torvalds

[PATCH] Lock initializer unifying: character devices

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.

That's the second batch of the unifying patches.
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 2a113c8a
......@@ -629,7 +629,7 @@ static int __devinit hvc_probe(
kobject_init(&hp->kobj);
hp->kobj.ktype = &hvc_kobj_type;
hp->lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&hp->lock);
spin_lock(&hvc_structs_lock);
hp->index = ++hvc_count;
list_add_tail(&(hp->next), &hvc_structs);
......
......@@ -631,7 +631,7 @@ static int __devinit hvcs_probe(
/* hvcsd->tty is zeroed out with the memset */
memset(hvcsd, 0x00, sizeof(*hvcsd));
hvcsd->lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&hvcsd->lock);
/* Automatically incs the refcount the first time */
kobject_init(&hvcsd->kobj);
/* Set up the callback for terminating the hvcs_struct's life */
......
......@@ -1331,7 +1331,7 @@ static int __init hvsi_console_init(void)
INIT_WORK(&hp->handshaker, hvsi_handshaker, hp);
init_waitqueue_head(&hp->emptyq);
init_waitqueue_head(&hp->stateq);
hp->lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&hp->lock);
hp->index = hvsi_count;
hp->inbuf_end = hp->inbuf;
hp->state = HVSI_CLOSED;
......
......@@ -540,7 +540,7 @@ static int create_entropy_store(int size, const char *name,
return -ENOMEM;
}
memset(r->pool, 0, POOLBYTES);
r->lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&r->lock);
r->name = name;
*ret_bucket = r;
return 0;
......
......@@ -739,7 +739,7 @@ static int __devinit sonypi_probe(void)
sonypi_device.model = pcidev ?
SONYPI_DEVICE_MODEL_TYPE1 : SONYPI_DEVICE_MODEL_TYPE2;
sonypi_device.fifo_lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&sonypi_device.fifo_lock);
sonypi_device.fifo = kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL,
&sonypi_device.fifo_lock);
if (IS_ERR(sonypi_device.fifo)) {
......@@ -852,7 +852,7 @@ static int __devinit sonypi_probe(void)
printk(KERN_INFO "%s input method installed.\n",
sonypi_device.input_key_dev.name);
sonypi_device.input_fifo_lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&sonypi_device.input_fifo_lock);
sonypi_device.input_fifo =
kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL,
&sonypi_device.input_fifo_lock);
......
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