Commit 97d1f15b authored by Arjan van de Ven's avatar Arjan van de Ven Committed by Linus Torvalds

[PATCH] sem2mutex: kernel/

Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.
Signed-off-by: default avatarArjan van de Ven <arjan@infradead.org>
Signed-off-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 e723ccd8
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/unistd.h> #include <linux/unistd.h>
#include <linux/file.h> #include <linux/file.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mutex.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
/* /*
...@@ -41,7 +42,7 @@ struct kthread_stop_info ...@@ -41,7 +42,7 @@ struct kthread_stop_info
/* Thread stopping is done by setthing this var: lock serializes /* Thread stopping is done by setthing this var: lock serializes
* multiple kthread_stop calls. */ * multiple kthread_stop calls. */
static DECLARE_MUTEX(kthread_stop_lock); static DEFINE_MUTEX(kthread_stop_lock);
static struct kthread_stop_info kthread_stop_info; static struct kthread_stop_info kthread_stop_info;
int kthread_should_stop(void) int kthread_should_stop(void)
...@@ -173,7 +174,7 @@ int kthread_stop_sem(struct task_struct *k, struct semaphore *s) ...@@ -173,7 +174,7 @@ int kthread_stop_sem(struct task_struct *k, struct semaphore *s)
{ {
int ret; int ret;
down(&kthread_stop_lock); mutex_lock(&kthread_stop_lock);
/* It could exit after stop_info.k set, but before wake_up_process. */ /* It could exit after stop_info.k set, but before wake_up_process. */
get_task_struct(k); get_task_struct(k);
...@@ -194,7 +195,7 @@ int kthread_stop_sem(struct task_struct *k, struct semaphore *s) ...@@ -194,7 +195,7 @@ int kthread_stop_sem(struct task_struct *k, struct semaphore *s)
wait_for_completion(&kthread_stop_info.done); wait_for_completion(&kthread_stop_info.done);
kthread_stop_info.k = NULL; kthread_stop_info.k = NULL;
ret = kthread_stop_info.err; ret = kthread_stop_info.err;
up(&kthread_stop_lock); mutex_unlock(&kthread_stop_lock);
return ret; return ret;
} }
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/mutex.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
...@@ -63,15 +64,15 @@ static DEFINE_SPINLOCK(modlist_lock); ...@@ -63,15 +64,15 @@ static DEFINE_SPINLOCK(modlist_lock);
static DECLARE_MUTEX(module_mutex); static DECLARE_MUTEX(module_mutex);
static LIST_HEAD(modules); static LIST_HEAD(modules);
static DECLARE_MUTEX(notify_mutex); static DEFINE_MUTEX(notify_mutex);
static struct notifier_block * module_notify_list; static struct notifier_block * module_notify_list;
int register_module_notifier(struct notifier_block * nb) int register_module_notifier(struct notifier_block * nb)
{ {
int err; int err;
down(&notify_mutex); mutex_lock(&notify_mutex);
err = notifier_chain_register(&module_notify_list, nb); err = notifier_chain_register(&module_notify_list, nb);
up(&notify_mutex); mutex_unlock(&notify_mutex);
return err; return err;
} }
EXPORT_SYMBOL(register_module_notifier); EXPORT_SYMBOL(register_module_notifier);
...@@ -79,9 +80,9 @@ EXPORT_SYMBOL(register_module_notifier); ...@@ -79,9 +80,9 @@ EXPORT_SYMBOL(register_module_notifier);
int unregister_module_notifier(struct notifier_block * nb) int unregister_module_notifier(struct notifier_block * nb)
{ {
int err; int err;
down(&notify_mutex); mutex_lock(&notify_mutex);
err = notifier_chain_unregister(&module_notify_list, nb); err = notifier_chain_unregister(&module_notify_list, nb);
up(&notify_mutex); mutex_unlock(&notify_mutex);
return err; return err;
} }
EXPORT_SYMBOL(unregister_module_notifier); EXPORT_SYMBOL(unregister_module_notifier);
...@@ -1989,9 +1990,9 @@ sys_init_module(void __user *umod, ...@@ -1989,9 +1990,9 @@ sys_init_module(void __user *umod,
/* Drop lock so they can recurse */ /* Drop lock so they can recurse */
up(&module_mutex); up(&module_mutex);
down(&notify_mutex); mutex_lock(&notify_mutex);
notifier_call_chain(&module_notify_list, MODULE_STATE_COMING, mod); notifier_call_chain(&module_notify_list, MODULE_STATE_COMING, mod);
up(&notify_mutex); mutex_unlock(&notify_mutex);
/* Start the module */ /* Start the module */
if (mod->init != NULL) if (mod->init != NULL)
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/mutex.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/pm_legacy.h> #include <linux/pm_legacy.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/mutex.h>
int pm_active; int pm_active;
...@@ -40,7 +41,7 @@ int pm_active; ...@@ -40,7 +41,7 @@ int pm_active;
* until a resume but that will be fine. * until a resume but that will be fine.
*/ */
static DECLARE_MUTEX(pm_devs_lock); static DEFINE_MUTEX(pm_devs_lock);
static LIST_HEAD(pm_devs); static LIST_HEAD(pm_devs);
/** /**
...@@ -67,9 +68,9 @@ struct pm_dev *pm_register(pm_dev_t type, ...@@ -67,9 +68,9 @@ struct pm_dev *pm_register(pm_dev_t type,
dev->id = id; dev->id = id;
dev->callback = callback; dev->callback = callback;
down(&pm_devs_lock); mutex_lock(&pm_devs_lock);
list_add(&dev->entry, &pm_devs); list_add(&dev->entry, &pm_devs);
up(&pm_devs_lock); mutex_unlock(&pm_devs_lock);
} }
return dev; return dev;
} }
...@@ -85,9 +86,9 @@ struct pm_dev *pm_register(pm_dev_t type, ...@@ -85,9 +86,9 @@ struct pm_dev *pm_register(pm_dev_t type,
void pm_unregister(struct pm_dev *dev) void pm_unregister(struct pm_dev *dev)
{ {
if (dev) { if (dev) {
down(&pm_devs_lock); mutex_lock(&pm_devs_lock);
list_del(&dev->entry); list_del(&dev->entry);
up(&pm_devs_lock); mutex_unlock(&pm_devs_lock);
kfree(dev); kfree(dev);
} }
...@@ -118,7 +119,7 @@ void pm_unregister_all(pm_callback callback) ...@@ -118,7 +119,7 @@ void pm_unregister_all(pm_callback callback)
if (!callback) if (!callback)
return; return;
down(&pm_devs_lock); mutex_lock(&pm_devs_lock);
entry = pm_devs.next; entry = pm_devs.next;
while (entry != &pm_devs) { while (entry != &pm_devs) {
struct pm_dev *dev = list_entry(entry, struct pm_dev, entry); struct pm_dev *dev = list_entry(entry, struct pm_dev, entry);
...@@ -126,7 +127,7 @@ void pm_unregister_all(pm_callback callback) ...@@ -126,7 +127,7 @@ void pm_unregister_all(pm_callback callback)
if (dev->callback == callback) if (dev->callback == callback)
__pm_unregister(dev); __pm_unregister(dev);
} }
up(&pm_devs_lock); mutex_unlock(&pm_devs_lock);
} }
/** /**
...@@ -234,7 +235,7 @@ int pm_send_all(pm_request_t rqst, void *data) ...@@ -234,7 +235,7 @@ int pm_send_all(pm_request_t rqst, void *data)
{ {
struct list_head *entry; struct list_head *entry;
down(&pm_devs_lock); mutex_lock(&pm_devs_lock);
entry = pm_devs.next; entry = pm_devs.next;
while (entry != &pm_devs) { while (entry != &pm_devs) {
struct pm_dev *dev = list_entry(entry, struct pm_dev, entry); struct pm_dev *dev = list_entry(entry, struct pm_dev, entry);
...@@ -246,13 +247,13 @@ int pm_send_all(pm_request_t rqst, void *data) ...@@ -246,13 +247,13 @@ int pm_send_all(pm_request_t rqst, void *data)
*/ */
if (rqst == PM_SUSPEND) if (rqst == PM_SUSPEND)
pm_undo_all(dev); pm_undo_all(dev);
up(&pm_devs_lock); mutex_unlock(&pm_devs_lock);
return status; return status;
} }
} }
entry = entry->next; entry = entry->next;
} }
up(&pm_devs_lock); mutex_unlock(&pm_devs_lock);
return 0; return 0;
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/cpu.h> #include <linux/cpu.h>
#include <linux/profile.h> #include <linux/profile.h>
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/mutex.h>
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
...@@ -44,7 +45,7 @@ static cpumask_t prof_cpu_mask = CPU_MASK_ALL; ...@@ -44,7 +45,7 @@ static cpumask_t prof_cpu_mask = CPU_MASK_ALL;
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits); static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits);
static DEFINE_PER_CPU(int, cpu_profile_flip); static DEFINE_PER_CPU(int, cpu_profile_flip);
static DECLARE_MUTEX(profile_flip_mutex); static DEFINE_MUTEX(profile_flip_mutex);
#endif /* CONFIG_SMP */ #endif /* CONFIG_SMP */
static int __init profile_setup(char * str) static int __init profile_setup(char * str)
...@@ -243,7 +244,7 @@ static void profile_flip_buffers(void) ...@@ -243,7 +244,7 @@ static void profile_flip_buffers(void)
{ {
int i, j, cpu; int i, j, cpu;
down(&profile_flip_mutex); mutex_lock(&profile_flip_mutex);
j = per_cpu(cpu_profile_flip, get_cpu()); j = per_cpu(cpu_profile_flip, get_cpu());
put_cpu(); put_cpu();
on_each_cpu(__profile_flip_buffers, NULL, 0, 1); on_each_cpu(__profile_flip_buffers, NULL, 0, 1);
...@@ -259,14 +260,14 @@ static void profile_flip_buffers(void) ...@@ -259,14 +260,14 @@ static void profile_flip_buffers(void)
hits[i].hits = hits[i].pc = 0; hits[i].hits = hits[i].pc = 0;
} }
} }
up(&profile_flip_mutex); mutex_unlock(&profile_flip_mutex);
} }
static void profile_discard_flip_buffers(void) static void profile_discard_flip_buffers(void)
{ {
int i, cpu; int i, cpu;
down(&profile_flip_mutex); mutex_lock(&profile_flip_mutex);
i = per_cpu(cpu_profile_flip, get_cpu()); i = per_cpu(cpu_profile_flip, get_cpu());
put_cpu(); put_cpu();
on_each_cpu(__profile_flip_buffers, NULL, 0, 1); on_each_cpu(__profile_flip_buffers, NULL, 0, 1);
...@@ -274,7 +275,7 @@ static void profile_discard_flip_buffers(void) ...@@ -274,7 +275,7 @@ static void profile_discard_flip_buffers(void)
struct profile_hit *hits = per_cpu(cpu_profile_hits, cpu)[i]; struct profile_hit *hits = per_cpu(cpu_profile_hits, cpu)[i];
memset(hits, 0, NR_PROFILE_HIT*sizeof(struct profile_hit)); memset(hits, 0, NR_PROFILE_HIT*sizeof(struct profile_hit));
} }
up(&profile_flip_mutex); mutex_unlock(&profile_flip_mutex);
} }
void profile_hit(int type, void *__pc) void profile_hit(int type, void *__pc)
......
...@@ -44,12 +44,13 @@ ...@@ -44,12 +44,13 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/rslib.h> #include <linux/rslib.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/mutex.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
/* This list holds all currently allocated rs control structures */ /* This list holds all currently allocated rs control structures */
static LIST_HEAD (rslist); static LIST_HEAD (rslist);
/* Protection for the list */ /* Protection for the list */
static DECLARE_MUTEX(rslistlock); static DEFINE_MUTEX(rslistlock);
/** /**
* rs_init - Initialize a Reed-Solomon codec * rs_init - Initialize a Reed-Solomon codec
...@@ -161,7 +162,7 @@ errrs: ...@@ -161,7 +162,7 @@ errrs:
*/ */
void free_rs(struct rs_control *rs) void free_rs(struct rs_control *rs)
{ {
down(&rslistlock); mutex_lock(&rslistlock);
rs->users--; rs->users--;
if(!rs->users) { if(!rs->users) {
list_del(&rs->list); list_del(&rs->list);
...@@ -170,7 +171,7 @@ void free_rs(struct rs_control *rs) ...@@ -170,7 +171,7 @@ void free_rs(struct rs_control *rs)
kfree(rs->genpoly); kfree(rs->genpoly);
kfree(rs); kfree(rs);
} }
up(&rslistlock); mutex_unlock(&rslistlock);
} }
/** /**
...@@ -201,7 +202,7 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim, ...@@ -201,7 +202,7 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
if (nroots < 0 || nroots >= (1<<symsize)) if (nroots < 0 || nroots >= (1<<symsize))
return NULL; return NULL;
down(&rslistlock); mutex_lock(&rslistlock);
/* Walk through the list and look for a matching entry */ /* Walk through the list and look for a matching entry */
list_for_each(tmp, &rslist) { list_for_each(tmp, &rslist) {
...@@ -228,7 +229,7 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim, ...@@ -228,7 +229,7 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
list_add(&rs->list, &rslist); list_add(&rs->list, &rslist);
} }
out: out:
up(&rslistlock); mutex_unlock(&rslistlock);
return rs; return rs;
} }
......
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