Commit 14cc3e2b authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] sem2mutex: misc static one-file mutexes

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 avatarIngo Molnar <mingo@elte.hu>
Cc: Dave Jones <davej@codemonkey.org.uk>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Jens Axboe <axboe@suse.de>
Cc: Neil Brown <neilb@cse.unsw.edu.au>
Acked-by: default avatarAlasdair G Kergon <agk@redhat.com>
Cc: Greg KH <greg@kroah.com>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Adam Belay <ambx1@neo.rr.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 353ab6e9
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <asm/system.h> #include <asm/system.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/unistd.h> #include <asm/unistd.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#include "ptrace.h" #include "ptrace.h"
...@@ -207,19 +207,19 @@ void die_if_kernel(const char *str, struct pt_regs *regs, int err) ...@@ -207,19 +207,19 @@ void die_if_kernel(const char *str, struct pt_regs *regs, int err)
die(str, regs, err); die(str, regs, err);
} }
static DECLARE_MUTEX(undef_sem); static DEFINE_MUTEX(undef_mutex);
static int (*undef_hook)(struct pt_regs *); static int (*undef_hook)(struct pt_regs *);
int request_undef_hook(int (*fn)(struct pt_regs *)) int request_undef_hook(int (*fn)(struct pt_regs *))
{ {
int ret = -EBUSY; int ret = -EBUSY;
down(&undef_sem); mutex_lock(&undef_mutex);
if (undef_hook == NULL) { if (undef_hook == NULL) {
undef_hook = fn; undef_hook = fn;
ret = 0; ret = 0;
} }
up(&undef_sem); mutex_unlock(&undef_mutex);
return ret; return ret;
} }
...@@ -228,12 +228,12 @@ int release_undef_hook(int (*fn)(struct pt_regs *)) ...@@ -228,12 +228,12 @@ int release_undef_hook(int (*fn)(struct pt_regs *))
{ {
int ret = -EINVAL; int ret = -EINVAL;
down(&undef_sem); mutex_lock(&undef_mutex);
if (undef_hook == fn) { if (undef_hook == fn) {
undef_hook = NULL; undef_hook = NULL;
ret = 0; ret = 0;
} }
up(&undef_sem); mutex_unlock(&undef_mutex);
return ret; return ret;
} }
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#ifdef CONFIG_X86_POWERNOW_K8_ACPI #ifdef CONFIG_X86_POWERNOW_K8_ACPI
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/mutex.h>
#include <acpi/processor.h> #include <acpi/processor.h>
#endif #endif
...@@ -49,7 +50,7 @@ ...@@ -49,7 +50,7 @@
#include "powernow-k8.h" #include "powernow-k8.h"
/* serialize freq changes */ /* serialize freq changes */
static DECLARE_MUTEX(fidvid_sem); static DEFINE_MUTEX(fidvid_mutex);
static struct powernow_k8_data *powernow_data[NR_CPUS]; static struct powernow_k8_data *powernow_data[NR_CPUS];
...@@ -943,17 +944,17 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi ...@@ -943,17 +944,17 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
if (cpufreq_frequency_table_target(pol, data->powernow_table, targfreq, relation, &newstate)) if (cpufreq_frequency_table_target(pol, data->powernow_table, targfreq, relation, &newstate))
goto err_out; goto err_out;
down(&fidvid_sem); mutex_lock(&fidvid_mutex);
powernow_k8_acpi_pst_values(data, newstate); powernow_k8_acpi_pst_values(data, newstate);
if (transition_frequency(data, newstate)) { if (transition_frequency(data, newstate)) {
printk(KERN_ERR PFX "transition frequency failed\n"); printk(KERN_ERR PFX "transition frequency failed\n");
ret = 1; ret = 1;
up(&fidvid_sem); mutex_unlock(&fidvid_mutex);
goto err_out; goto err_out;
} }
up(&fidvid_sem); mutex_unlock(&fidvid_mutex);
pol->cur = find_khz_freq_from_fid(data->currfid); pol->cur = find_khz_freq_from_fid(data->currfid);
ret = 0; ret = 0;
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/cpu.h> #include <linux/cpu.h>
#include <linux/mutex.h>
#include <asm/mtrr.h> #include <asm/mtrr.h>
...@@ -47,7 +48,7 @@ ...@@ -47,7 +48,7 @@
u32 num_var_ranges = 0; u32 num_var_ranges = 0;
unsigned int *usage_table; unsigned int *usage_table;
static DECLARE_MUTEX(mtrr_sem); static DEFINE_MUTEX(mtrr_mutex);
u32 size_or_mask, size_and_mask; u32 size_or_mask, size_and_mask;
...@@ -333,7 +334,7 @@ int mtrr_add_page(unsigned long base, unsigned long size, ...@@ -333,7 +334,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
/* No CPU hotplug when we change MTRR entries */ /* No CPU hotplug when we change MTRR entries */
lock_cpu_hotplug(); lock_cpu_hotplug();
/* Search for existing MTRR */ /* Search for existing MTRR */
down(&mtrr_sem); mutex_lock(&mtrr_mutex);
for (i = 0; i < num_var_ranges; ++i) { for (i = 0; i < num_var_ranges; ++i) {
mtrr_if->get(i, &lbase, &lsize, &ltype); mtrr_if->get(i, &lbase, &lsize, &ltype);
if (base >= lbase + lsize) if (base >= lbase + lsize)
...@@ -371,7 +372,7 @@ int mtrr_add_page(unsigned long base, unsigned long size, ...@@ -371,7 +372,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
printk(KERN_INFO "mtrr: no more MTRRs available\n"); printk(KERN_INFO "mtrr: no more MTRRs available\n");
error = i; error = i;
out: out:
up(&mtrr_sem); mutex_unlock(&mtrr_mutex);
unlock_cpu_hotplug(); unlock_cpu_hotplug();
return error; return error;
} }
...@@ -464,7 +465,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size) ...@@ -464,7 +465,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
max = num_var_ranges; max = num_var_ranges;
/* No CPU hotplug when we change MTRR entries */ /* No CPU hotplug when we change MTRR entries */
lock_cpu_hotplug(); lock_cpu_hotplug();
down(&mtrr_sem); mutex_lock(&mtrr_mutex);
if (reg < 0) { if (reg < 0) {
/* Search for existing MTRR */ /* Search for existing MTRR */
for (i = 0; i < max; ++i) { for (i = 0; i < max; ++i) {
...@@ -503,7 +504,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size) ...@@ -503,7 +504,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
set_mtrr(reg, 0, 0, 0); set_mtrr(reg, 0, 0, 0);
error = reg; error = reg;
out: out:
up(&mtrr_sem); mutex_unlock(&mtrr_mutex);
unlock_cpu_hotplug(); unlock_cpu_hotplug();
return error; return error;
} }
...@@ -685,7 +686,7 @@ void mtrr_ap_init(void) ...@@ -685,7 +686,7 @@ void mtrr_ap_init(void)
if (!mtrr_if || !use_intel()) if (!mtrr_if || !use_intel())
return; return;
/* /*
* Ideally we should hold mtrr_sem here to avoid mtrr entries changed, * Ideally we should hold mtrr_mutex here to avoid mtrr entries changed,
* but this routine will be called in cpu boot time, holding the lock * but this routine will be called in cpu boot time, holding the lock
* breaks it. This routine is called in two cases: 1.very earily time * breaks it. This routine is called in two cases: 1.very earily time
* of software resume, when there absolutely isn't mtrr entry changes; * of software resume, when there absolutely isn't mtrr entry changes;
......
...@@ -81,6 +81,7 @@ ...@@ -81,6 +81,7 @@
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/mutex.h>
#include <asm/msr.h> #include <asm/msr.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -114,7 +115,7 @@ MODULE_LICENSE("GPL"); ...@@ -114,7 +115,7 @@ MODULE_LICENSE("GPL");
static DEFINE_SPINLOCK(microcode_update_lock); static DEFINE_SPINLOCK(microcode_update_lock);
/* no concurrent ->write()s are allowed on /dev/cpu/microcode */ /* no concurrent ->write()s are allowed on /dev/cpu/microcode */
static DECLARE_MUTEX(microcode_sem); static DEFINE_MUTEX(microcode_mutex);
static void __user *user_buffer; /* user area microcode data buffer */ static void __user *user_buffer; /* user area microcode data buffer */
static unsigned int user_buffer_size; /* it's size */ static unsigned int user_buffer_size; /* it's size */
...@@ -444,7 +445,7 @@ static ssize_t microcode_write (struct file *file, const char __user *buf, size_ ...@@ -444,7 +445,7 @@ static ssize_t microcode_write (struct file *file, const char __user *buf, size_
return -EINVAL; return -EINVAL;
} }
down(&microcode_sem); mutex_lock(&microcode_mutex);
user_buffer = (void __user *) buf; user_buffer = (void __user *) buf;
user_buffer_size = (int) len; user_buffer_size = (int) len;
...@@ -453,7 +454,7 @@ static ssize_t microcode_write (struct file *file, const char __user *buf, size_ ...@@ -453,7 +454,7 @@ static ssize_t microcode_write (struct file *file, const char __user *buf, size_
if (!ret) if (!ret)
ret = (ssize_t)len; ret = (ssize_t)len;
up(&microcode_sem); mutex_unlock(&microcode_mutex);
return ret; return ret;
} }
......
...@@ -30,12 +30,13 @@ ...@@ -30,12 +30,13 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/net.h> #include <linux/net.h>
#include <linux/inet.h> #include <linux/inet.h>
#include <linux/mutex.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "sysctl.h" #include "sysctl.h"
#include "ds1603.h" #include "ds1603.h"
static DECLARE_MUTEX(lasat_info_sem); static DEFINE_MUTEX(lasat_info_mutex);
/* Strategy function to write EEPROM after changing string entry */ /* Strategy function to write EEPROM after changing string entry */
int sysctl_lasatstring(ctl_table *table, int *name, int nlen, int sysctl_lasatstring(ctl_table *table, int *name, int nlen,
...@@ -43,17 +44,17 @@ int sysctl_lasatstring(ctl_table *table, int *name, int nlen, ...@@ -43,17 +44,17 @@ int sysctl_lasatstring(ctl_table *table, int *name, int nlen,
void *newval, size_t newlen, void **context) void *newval, size_t newlen, void **context)
{ {
int r; int r;
down(&lasat_info_sem); mutex_lock(&lasat_info_mutex);
r = sysctl_string(table, name, r = sysctl_string(table, name,
nlen, oldval, oldlenp, newval, newlen, context); nlen, oldval, oldlenp, newval, newlen, context);
if (r < 0) { if (r < 0) {
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return r; return r;
} }
if (newval && newlen) { if (newval && newlen) {
lasat_write_eeprom_info(); lasat_write_eeprom_info();
} }
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return 1; return 1;
} }
...@@ -63,14 +64,14 @@ int proc_dolasatstring(ctl_table *table, int write, struct file *filp, ...@@ -63,14 +64,14 @@ int proc_dolasatstring(ctl_table *table, int write, struct file *filp,
void *buffer, size_t *lenp, loff_t *ppos) void *buffer, size_t *lenp, loff_t *ppos)
{ {
int r; int r;
down(&lasat_info_sem); mutex_lock(&lasat_info_mutex);
r = proc_dostring(table, write, filp, buffer, lenp, ppos); r = proc_dostring(table, write, filp, buffer, lenp, ppos);
if ( (!write) || r) { if ( (!write) || r) {
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return r; return r;
} }
lasat_write_eeprom_info(); lasat_write_eeprom_info();
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return 0; return 0;
} }
...@@ -79,14 +80,14 @@ int proc_dolasatint(ctl_table *table, int write, struct file *filp, ...@@ -79,14 +80,14 @@ int proc_dolasatint(ctl_table *table, int write, struct file *filp,
void *buffer, size_t *lenp, loff_t *ppos) void *buffer, size_t *lenp, loff_t *ppos)
{ {
int r; int r;
down(&lasat_info_sem); mutex_lock(&lasat_info_mutex);
r = proc_dointvec(table, write, filp, buffer, lenp, ppos); r = proc_dointvec(table, write, filp, buffer, lenp, ppos);
if ( (!write) || r) { if ( (!write) || r) {
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return r; return r;
} }
lasat_write_eeprom_info(); lasat_write_eeprom_info();
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return 0; return 0;
} }
...@@ -98,7 +99,7 @@ int proc_dolasatrtc(ctl_table *table, int write, struct file *filp, ...@@ -98,7 +99,7 @@ int proc_dolasatrtc(ctl_table *table, int write, struct file *filp,
void *buffer, size_t *lenp, loff_t *ppos) void *buffer, size_t *lenp, loff_t *ppos)
{ {
int r; int r;
down(&lasat_info_sem); mutex_lock(&lasat_info_mutex);
if (!write) { if (!write) {
rtctmp = ds1603_read(); rtctmp = ds1603_read();
/* check for time < 0 and set to 0 */ /* check for time < 0 and set to 0 */
...@@ -107,11 +108,11 @@ int proc_dolasatrtc(ctl_table *table, int write, struct file *filp, ...@@ -107,11 +108,11 @@ int proc_dolasatrtc(ctl_table *table, int write, struct file *filp,
} }
r = proc_dointvec(table, write, filp, buffer, lenp, ppos); r = proc_dointvec(table, write, filp, buffer, lenp, ppos);
if ( (!write) || r) { if ( (!write) || r) {
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return r; return r;
} }
ds1603_set(rtctmp); ds1603_set(rtctmp);
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return 0; return 0;
} }
#endif #endif
...@@ -122,16 +123,16 @@ int sysctl_lasat_intvec(ctl_table *table, int *name, int nlen, ...@@ -122,16 +123,16 @@ int sysctl_lasat_intvec(ctl_table *table, int *name, int nlen,
void *newval, size_t newlen, void **context) void *newval, size_t newlen, void **context)
{ {
int r; int r;
down(&lasat_info_sem); mutex_lock(&lasat_info_mutex);
r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen, context); r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen, context);
if (r < 0) { if (r < 0) {
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return r; return r;
} }
if (newval && newlen) { if (newval && newlen) {
lasat_write_eeprom_info(); lasat_write_eeprom_info();
} }
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return 1; return 1;
} }
...@@ -142,19 +143,19 @@ int sysctl_lasat_rtc(ctl_table *table, int *name, int nlen, ...@@ -142,19 +143,19 @@ int sysctl_lasat_rtc(ctl_table *table, int *name, int nlen,
void *newval, size_t newlen, void **context) void *newval, size_t newlen, void **context)
{ {
int r; int r;
down(&lasat_info_sem); mutex_lock(&lasat_info_mutex);
rtctmp = ds1603_read(); rtctmp = ds1603_read();
if (rtctmp < 0) if (rtctmp < 0)
rtctmp = 0; rtctmp = 0;
r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen, context); r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen, context);
if (r < 0) { if (r < 0) {
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return r; return r;
} }
if (newval && newlen) { if (newval && newlen) {
ds1603_set(rtctmp); ds1603_set(rtctmp);
} }
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return 1; return 1;
} }
#endif #endif
...@@ -192,13 +193,13 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp, ...@@ -192,13 +193,13 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp,
return 0; return 0;
} }
down(&lasat_info_sem); mutex_lock(&lasat_info_mutex);
if (write) { if (write) {
len = 0; len = 0;
p = buffer; p = buffer;
while (len < *lenp) { while (len < *lenp) {
if(get_user(c, p++)) { if(get_user(c, p++)) {
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return -EFAULT; return -EFAULT;
} }
if (c == 0 || c == '\n') if (c == 0 || c == '\n')
...@@ -209,7 +210,7 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp, ...@@ -209,7 +210,7 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp,
len = sizeof(proc_lasat_ipbuf) - 1; len = sizeof(proc_lasat_ipbuf) - 1;
if (copy_from_user(proc_lasat_ipbuf, buffer, len)) if (copy_from_user(proc_lasat_ipbuf, buffer, len))
{ {
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return -EFAULT; return -EFAULT;
} }
proc_lasat_ipbuf[len] = 0; proc_lasat_ipbuf[len] = 0;
...@@ -230,12 +231,12 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp, ...@@ -230,12 +231,12 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp,
len = *lenp; len = *lenp;
if (len) if (len)
if(copy_to_user(buffer, proc_lasat_ipbuf, len)) { if(copy_to_user(buffer, proc_lasat_ipbuf, len)) {
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return -EFAULT; return -EFAULT;
} }
if (len < *lenp) { if (len < *lenp) {
if(put_user('\n', ((char *) buffer) + len)) { if(put_user('\n', ((char *) buffer) + len)) {
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return -EFAULT; return -EFAULT;
} }
len++; len++;
...@@ -244,7 +245,7 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp, ...@@ -244,7 +245,7 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp,
*ppos += len; *ppos += len;
} }
update_bcastaddr(); update_bcastaddr();
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return 0; return 0;
} }
#endif /* defined(CONFIG_INET) */ #endif /* defined(CONFIG_INET) */
...@@ -256,10 +257,10 @@ static int sysctl_lasat_eeprom_value(ctl_table *table, int *name, int nlen, ...@@ -256,10 +257,10 @@ static int sysctl_lasat_eeprom_value(ctl_table *table, int *name, int nlen,
{ {
int r; int r;
down(&lasat_info_sem); mutex_lock(&lasat_info_mutex);
r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen, context); r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen, context);
if (r < 0) { if (r < 0) {
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return r; return r;
} }
...@@ -271,7 +272,7 @@ static int sysctl_lasat_eeprom_value(ctl_table *table, int *name, int nlen, ...@@ -271,7 +272,7 @@ static int sysctl_lasat_eeprom_value(ctl_table *table, int *name, int nlen,
lasat_write_eeprom_info(); lasat_write_eeprom_info();
lasat_init_board_info(); lasat_init_board_info();
} }
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return 0; return 0;
} }
...@@ -280,10 +281,10 @@ int proc_lasat_eeprom_value(ctl_table *table, int write, struct file *filp, ...@@ -280,10 +281,10 @@ int proc_lasat_eeprom_value(ctl_table *table, int write, struct file *filp,
void *buffer, size_t *lenp, loff_t *ppos) void *buffer, size_t *lenp, loff_t *ppos)
{ {
int r; int r;
down(&lasat_info_sem); mutex_lock(&lasat_info_mutex);
r = proc_dointvec(table, write, filp, buffer, lenp, ppos); r = proc_dointvec(table, write, filp, buffer, lenp, ppos);
if ( (!write) || r) { if ( (!write) || r) {
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return r; return r;
} }
if (filp && filp->f_dentry) if (filp && filp->f_dentry)
...@@ -294,7 +295,7 @@ int proc_lasat_eeprom_value(ctl_table *table, int write, struct file *filp, ...@@ -294,7 +295,7 @@ int proc_lasat_eeprom_value(ctl_table *table, int write, struct file *filp,
lasat_board_info.li_eeprom_info.debugaccess = lasat_board_info.li_debugaccess; lasat_board_info.li_eeprom_info.debugaccess = lasat_board_info.li_debugaccess;
} }
lasat_write_eeprom_info(); lasat_write_eeprom_info();
up(&lasat_info_sem); mutex_unlock(&lasat_info_mutex);
return 0; return 0;
} }
......
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/pgalloc.h> #include <asm/pgalloc.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
#include "mmu_decl.h" #include "mmu_decl.h"
static DECLARE_MUTEX(imlist_sem); static DEFINE_MUTEX(imlist_mutex);
struct vm_struct * imlist = NULL; struct vm_struct * imlist = NULL;
static int get_free_im_addr(unsigned long size, unsigned long *im_addr) static int get_free_im_addr(unsigned long size, unsigned long *im_addr)
...@@ -257,7 +257,7 @@ struct vm_struct * im_get_free_area(unsigned long size) ...@@ -257,7 +257,7 @@ struct vm_struct * im_get_free_area(unsigned long size)
struct vm_struct *area; struct vm_struct *area;
unsigned long addr; unsigned long addr;
down(&imlist_sem); mutex_lock(&imlist_mutex);
if (get_free_im_addr(size, &addr)) { if (get_free_im_addr(size, &addr)) {
printk(KERN_ERR "%s() cannot obtain addr for size 0x%lx\n", printk(KERN_ERR "%s() cannot obtain addr for size 0x%lx\n",
__FUNCTION__, size); __FUNCTION__, size);
...@@ -272,7 +272,7 @@ struct vm_struct * im_get_free_area(unsigned long size) ...@@ -272,7 +272,7 @@ struct vm_struct * im_get_free_area(unsigned long size)
__FUNCTION__, addr, size); __FUNCTION__, addr, size);
} }
next_im_done: next_im_done:
up(&imlist_sem); mutex_unlock(&imlist_mutex);
return area; return area;
} }
...@@ -281,9 +281,9 @@ struct vm_struct * im_get_area(unsigned long v_addr, unsigned long size, ...@@ -281,9 +281,9 @@ struct vm_struct * im_get_area(unsigned long v_addr, unsigned long size,
{ {
struct vm_struct *area; struct vm_struct *area;
down(&imlist_sem); mutex_lock(&imlist_mutex);
area = __im_get_area(v_addr, size, criteria); area = __im_get_area(v_addr, size, criteria);
up(&imlist_sem); mutex_unlock(&imlist_mutex);
return area; return area;
} }
...@@ -297,17 +297,17 @@ void im_free(void * addr) ...@@ -297,17 +297,17 @@ void im_free(void * addr)
printk(KERN_ERR "Trying to %s bad address (%p)\n", __FUNCTION__, addr); printk(KERN_ERR "Trying to %s bad address (%p)\n", __FUNCTION__, addr);
return; return;
} }
down(&imlist_sem); mutex_lock(&imlist_mutex);
for (p = &imlist ; (tmp = *p) ; p = &tmp->next) { for (p = &imlist ; (tmp = *p) ; p = &tmp->next) {
if (tmp->addr == addr) { if (tmp->addr == addr) {
*p = tmp->next; *p = tmp->next;
unmap_vm_area(tmp); unmap_vm_area(tmp);
kfree(tmp); kfree(tmp);
up(&imlist_sem); mutex_unlock(&imlist_mutex);
return; return;
} }
} }
up(&imlist_sem); mutex_unlock(&imlist_mutex);
printk(KERN_ERR "Trying to %s nonexistent area (%p)\n", __FUNCTION__, printk(KERN_ERR "Trying to %s nonexistent area (%p)\n", __FUNCTION__,
addr); addr);
} }
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#include <asm/spu.h> #include <asm/spu.h>
#include <asm/mmu_context.h> #include <asm/mmu_context.h>
...@@ -342,7 +342,7 @@ spu_free_irqs(struct spu *spu) ...@@ -342,7 +342,7 @@ spu_free_irqs(struct spu *spu)
} }
static LIST_HEAD(spu_list); static LIST_HEAD(spu_list);
static DECLARE_MUTEX(spu_mutex); static DEFINE_MUTEX(spu_mutex);
static void spu_init_channels(struct spu *spu) static void spu_init_channels(struct spu *spu)
{ {
...@@ -382,7 +382,7 @@ struct spu *spu_alloc(void) ...@@ -382,7 +382,7 @@ struct spu *spu_alloc(void)
{ {
struct spu *spu; struct spu *spu;
down(&spu_mutex); mutex_lock(&spu_mutex);
if (!list_empty(&spu_list)) { if (!list_empty(&spu_list)) {
spu = list_entry(spu_list.next, struct spu, list); spu = list_entry(spu_list.next, struct spu, list);
list_del_init(&spu->list); list_del_init(&spu->list);
...@@ -391,7 +391,7 @@ struct spu *spu_alloc(void) ...@@ -391,7 +391,7 @@ struct spu *spu_alloc(void)
pr_debug("No SPU left\n"); pr_debug("No SPU left\n");
spu = NULL; spu = NULL;
} }
up(&spu_mutex); mutex_unlock(&spu_mutex);
if (spu) if (spu)
spu_init_channels(spu); spu_init_channels(spu);
...@@ -402,9 +402,9 @@ EXPORT_SYMBOL_GPL(spu_alloc); ...@@ -402,9 +402,9 @@ EXPORT_SYMBOL_GPL(spu_alloc);
void spu_free(struct spu *spu) void spu_free(struct spu *spu)
{ {
down(&spu_mutex); mutex_lock(&spu_mutex);
list_add_tail(&spu->list, &spu_list); list_add_tail(&spu->list, &spu_list);
up(&spu_mutex); mutex_unlock(&spu_mutex);
} }
EXPORT_SYMBOL_GPL(spu_free); EXPORT_SYMBOL_GPL(spu_free);
...@@ -633,14 +633,14 @@ static int __init create_spu(struct device_node *spe) ...@@ -633,14 +633,14 @@ static int __init create_spu(struct device_node *spe)
spu->wbox_callback = NULL; spu->wbox_callback = NULL;
spu->stop_callback = NULL; spu->stop_callback = NULL;
down(&spu_mutex); mutex_lock(&spu_mutex);
spu->number = number++; spu->number = number++;
ret = spu_request_irqs(spu); ret = spu_request_irqs(spu);
if (ret) if (ret)
goto out_unmap; goto out_unmap;
list_add(&spu->list, &spu_list); list_add(&spu->list, &spu_list);
up(&spu_mutex); mutex_unlock(&spu_mutex);
pr_debug(KERN_DEBUG "Using SPE %s %02x %p %p %p %p %d\n", pr_debug(KERN_DEBUG "Using SPE %s %02x %p %p %p %p %d\n",
spu->name, spu->isrc, spu->local_store, spu->name, spu->isrc, spu->local_store,
...@@ -648,7 +648,7 @@ static int __init create_spu(struct device_node *spe) ...@@ -648,7 +648,7 @@ static int __init create_spu(struct device_node *spe)
goto out; goto out;
out_unmap: out_unmap:
up(&spu_mutex); mutex_unlock(&spu_mutex);
spu_unmap(spu); spu_unmap(spu);
out_free: out_free:
kfree(spu); kfree(spu);
...@@ -668,10 +668,10 @@ static void destroy_spu(struct spu *spu) ...@@ -668,10 +668,10 @@ static void destroy_spu(struct spu *spu)
static void cleanup_spu_base(void) static void cleanup_spu_base(void)
{ {
struct spu *spu, *tmp; struct spu *spu, *tmp;
down(&spu_mutex); mutex_lock(&spu_mutex);
list_for_each_entry_safe(spu, tmp, &spu_list, list) list_for_each_entry_safe(spu, tmp, &spu_list, list)
destroy_spu(spu); destroy_spu(spu);
up(&spu_mutex); mutex_unlock(&spu_mutex);
} }
module_exit(cleanup_spu_base); module_exit(cleanup_spu_base);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/cpufreq.h> #include <linux/cpufreq.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/mutex.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/machdep.h> #include <asm/machdep.h>
#include <asm/irq.h> #include <asm/irq.h>
...@@ -90,7 +91,7 @@ static void (*g5_switch_volt)(int speed_mode); ...@@ -90,7 +91,7 @@ static void (*g5_switch_volt)(int speed_mode);
static int (*g5_switch_freq)(int speed_mode); static int (*g5_switch_freq)(int speed_mode);
static int (*g5_query_freq)(void); static int (*g5_query_freq)(void);
static DECLARE_MUTEX(g5_switch_mutex); static DEFINE_MUTEX(g5_switch_mutex);
static struct smu_sdbp_fvt *g5_fvt_table; /* table of op. points */ static struct smu_sdbp_fvt *g5_fvt_table; /* table of op. points */
...@@ -327,7 +328,7 @@ static int g5_cpufreq_target(struct cpufreq_policy *policy, ...@@ -327,7 +328,7 @@ static int g5_cpufreq_target(struct cpufreq_policy *policy,
if (g5_pmode_cur == newstate) if (g5_pmode_cur == newstate)
return 0; return 0;
down(&g5_switch_mutex); mutex_lock(&g5_switch_mutex);
freqs.old = g5_cpu_freqs[g5_pmode_cur].frequency; freqs.old = g5_cpu_freqs[g5_pmode_cur].frequency;
freqs.new = g5_cpu_freqs[newstate].frequency; freqs.new = g5_cpu_freqs[newstate].frequency;
...@@ -337,7 +338,7 @@ static int g5_cpufreq_target(struct cpufreq_policy *policy, ...@@ -337,7 +338,7 @@ static int g5_cpufreq_target(struct cpufreq_policy *policy,
rc = g5_switch_freq(newstate); rc = g5_switch_freq(newstate);
cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
up(&g5_switch_mutex); mutex_unlock(&g5_switch_mutex);
return rc; return rc;
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/sysdev.h> #include <linux/sysdev.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/mutex.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -92,7 +93,7 @@ struct smu_device { ...@@ -92,7 +93,7 @@ struct smu_device {
* for now, just hard code that * for now, just hard code that
*/ */
static struct smu_device *smu; static struct smu_device *smu;
static DECLARE_MUTEX(smu_part_access); static DEFINE_MUTEX(smu_part_access);
static void smu_i2c_retry(unsigned long data); static void smu_i2c_retry(unsigned long data);
...@@ -976,11 +977,11 @@ struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size, ...@@ -976,11 +977,11 @@ struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size,
if (interruptible) { if (interruptible) {
int rc; int rc;
rc = down_interruptible(&smu_part_access); rc = mutex_lock_interruptible(&smu_part_access);
if (rc) if (rc)
return ERR_PTR(rc); return ERR_PTR(rc);
} else } else
down(&smu_part_access); mutex_lock(&smu_part_access);
part = (struct smu_sdbp_header *)get_property(smu->of_node, part = (struct smu_sdbp_header *)get_property(smu->of_node,
pname, size); pname, size);
...@@ -990,7 +991,7 @@ struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size, ...@@ -990,7 +991,7 @@ struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size,
if (part != NULL && size) if (part != NULL && size)
*size = part->len << 2; *size = part->len << 2;
} }
up(&smu_part_access); mutex_unlock(&smu_part_access);
return part; return part;
} }
......
...@@ -590,51 +590,51 @@ static void client_del(struct kcopyd_client *kc) ...@@ -590,51 +590,51 @@ static void client_del(struct kcopyd_client *kc)
up(&_client_lock); up(&_client_lock);
} }
static DECLARE_MUTEX(kcopyd_init_lock); static DEFINE_MUTEX(kcopyd_init_lock);
static int kcopyd_clients = 0; static int kcopyd_clients = 0;
static int kcopyd_init(void) static int kcopyd_init(void)
{ {
int r; int r;
down(&kcopyd_init_lock); mutex_lock(&kcopyd_init_lock);
if (kcopyd_clients) { if (kcopyd_clients) {
/* Already initialized. */ /* Already initialized. */
kcopyd_clients++; kcopyd_clients++;
up(&kcopyd_init_lock); mutex_unlock(&kcopyd_init_lock);
return 0; return 0;
} }
r = jobs_init(); r = jobs_init();
if (r) { if (r) {
up(&kcopyd_init_lock); mutex_unlock(&kcopyd_init_lock);
return r; return r;
} }
_kcopyd_wq = create_singlethread_workqueue("kcopyd"); _kcopyd_wq = create_singlethread_workqueue("kcopyd");
if (!_kcopyd_wq) { if (!_kcopyd_wq) {
jobs_exit(); jobs_exit();
up(&kcopyd_init_lock); mutex_unlock(&kcopyd_init_lock);
return -ENOMEM; return -ENOMEM;
} }
kcopyd_clients++; kcopyd_clients++;
INIT_WORK(&_kcopyd_work, do_work, NULL); INIT_WORK(&_kcopyd_work, do_work, NULL);
up(&kcopyd_init_lock); mutex_unlock(&kcopyd_init_lock);
return 0; return 0;
} }
static void kcopyd_exit(void) static void kcopyd_exit(void)
{ {
down(&kcopyd_init_lock); mutex_lock(&kcopyd_init_lock);
kcopyd_clients--; kcopyd_clients--;
if (!kcopyd_clients) { if (!kcopyd_clients) {
jobs_exit(); jobs_exit();
destroy_workqueue(_kcopyd_wq); destroy_workqueue(_kcopyd_wq);
_kcopyd_wq = NULL; _kcopyd_wq = NULL;
} }
up(&kcopyd_init_lock); mutex_unlock(&kcopyd_init_lock);
} }
int kcopyd_client_create(unsigned int nr_pages, struct kcopyd_client **result) int kcopyd_client_create(unsigned int nr_pages, struct kcopyd_client **result)
......
...@@ -105,6 +105,7 @@ ...@@ -105,6 +105,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <net/syncppp.h> #include <net/syncppp.h>
#include <linux/hdlc.h> #include <linux/hdlc.h>
#include <linux/mutex.h>
/* Version */ /* Version */
static const char version[] = "$Id: dscc4.c,v 1.173 2003/09/20 23:55:34 romieu Exp $ for Linux\n"; static const char version[] = "$Id: dscc4.c,v 1.173 2003/09/20 23:55:34 romieu Exp $ for Linux\n";
...@@ -112,7 +113,7 @@ static int debug; ...@@ -112,7 +113,7 @@ static int debug;
static int quartz; static int quartz;
#ifdef CONFIG_DSCC4_PCI_RST #ifdef CONFIG_DSCC4_PCI_RST
static DECLARE_MUTEX(dscc4_sem); static DEFINE_MUTEX(dscc4_mutex);
static u32 dscc4_pci_config_store[16]; static u32 dscc4_pci_config_store[16];
#endif #endif
...@@ -1018,7 +1019,7 @@ static void dscc4_pci_reset(struct pci_dev *pdev, void __iomem *ioaddr) ...@@ -1018,7 +1019,7 @@ static void dscc4_pci_reset(struct pci_dev *pdev, void __iomem *ioaddr)
{ {
int i; int i;
down(&dscc4_sem); mutex_lock(&dscc4_mutex);
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
pci_read_config_dword(pdev, i << 2, dscc4_pci_config_store + i); pci_read_config_dword(pdev, i << 2, dscc4_pci_config_store + i);
...@@ -1039,7 +1040,7 @@ static void dscc4_pci_reset(struct pci_dev *pdev, void __iomem *ioaddr) ...@@ -1039,7 +1040,7 @@ static void dscc4_pci_reset(struct pci_dev *pdev, void __iomem *ioaddr)
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
pci_write_config_dword(pdev, i << 2, dscc4_pci_config_store[i]); pci_write_config_dword(pdev, i << 2, dscc4_pci_config_store[i]);
up(&dscc4_sem); mutex_unlock(&dscc4_mutex);
} }
#else #else
#define dscc4_pci_reset(pdev,ioaddr) do {} while (0) #define dscc4_pci_reset(pdev,ioaddr) do {} while (0)
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/kmod.h> #include <linux/kmod.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/mutex.h>
#include <asm/irq.h> #include <asm/irq.h>
#undef PARPORT_PARANOID #undef PARPORT_PARANOID
...@@ -50,7 +51,7 @@ static DEFINE_SPINLOCK(full_list_lock); ...@@ -50,7 +51,7 @@ static DEFINE_SPINLOCK(full_list_lock);
static LIST_HEAD(drivers); static LIST_HEAD(drivers);
static DECLARE_MUTEX(registration_lock); static DEFINE_MUTEX(registration_lock);
/* What you can do to a port that's gone away.. */ /* What you can do to a port that's gone away.. */
static void dead_write_lines (struct parport *p, unsigned char b){} static void dead_write_lines (struct parport *p, unsigned char b){}
...@@ -158,11 +159,11 @@ int parport_register_driver (struct parport_driver *drv) ...@@ -158,11 +159,11 @@ int parport_register_driver (struct parport_driver *drv)
if (list_empty(&portlist)) if (list_empty(&portlist))
get_lowlevel_driver (); get_lowlevel_driver ();
down(&registration_lock); mutex_lock(&registration_lock);
list_for_each_entry(port, &portlist, list) list_for_each_entry(port, &portlist, list)
drv->attach(port); drv->attach(port);
list_add(&drv->list, &drivers); list_add(&drv->list, &drivers);
up(&registration_lock); mutex_unlock(&registration_lock);
return 0; return 0;
} }
...@@ -188,11 +189,11 @@ void parport_unregister_driver (struct parport_driver *drv) ...@@ -188,11 +189,11 @@ void parport_unregister_driver (struct parport_driver *drv)
{ {
struct parport *port; struct parport *port;
down(&registration_lock); mutex_lock(&registration_lock);
list_del_init(&drv->list); list_del_init(&drv->list);
list_for_each_entry(port, &portlist, list) list_for_each_entry(port, &portlist, list)
drv->detach(port); drv->detach(port);
up(&registration_lock); mutex_unlock(&registration_lock);
} }
static void free_port (struct parport *port) static void free_port (struct parport *port)
...@@ -366,7 +367,7 @@ void parport_announce_port (struct parport *port) ...@@ -366,7 +367,7 @@ void parport_announce_port (struct parport *port)
#endif #endif
parport_proc_register(port); parport_proc_register(port);
down(&registration_lock); mutex_lock(&registration_lock);
spin_lock_irq(&parportlist_lock); spin_lock_irq(&parportlist_lock);
list_add_tail(&port->list, &portlist); list_add_tail(&port->list, &portlist);
for (i = 1; i < 3; i++) { for (i = 1; i < 3; i++) {
...@@ -383,7 +384,7 @@ void parport_announce_port (struct parport *port) ...@@ -383,7 +384,7 @@ void parport_announce_port (struct parport *port)
if (slave) if (slave)
attach_driver_chain(slave); attach_driver_chain(slave);
} }
up(&registration_lock); mutex_unlock(&registration_lock);
} }
/** /**
...@@ -409,7 +410,7 @@ void parport_remove_port(struct parport *port) ...@@ -409,7 +410,7 @@ void parport_remove_port(struct parport *port)
{ {
int i; int i;
down(&registration_lock); mutex_lock(&registration_lock);
/* Spread the word. */ /* Spread the word. */
detach_driver_chain (port); detach_driver_chain (port);
...@@ -436,7 +437,7 @@ void parport_remove_port(struct parport *port) ...@@ -436,7 +437,7 @@ void parport_remove_port(struct parport *port)
} }
spin_unlock(&parportlist_lock); spin_unlock(&parportlist_lock);
up(&registration_lock); mutex_unlock(&registration_lock);
parport_proc_unregister(port); parport_proc_unregister(port);
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <linux/string.h> #include <linux/string.h>
#include <asm/pci-bridge.h> #include <asm/pci-bridge.h>
#include <asm/semaphore.h> #include <linux/mutex.h>
#include <asm/rtas.h> #include <asm/rtas.h>
#include <asm/vio.h> #include <asm/vio.h>
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "rpaphp.h" #include "rpaphp.h"
#include "rpadlpar.h" #include "rpadlpar.h"
static DECLARE_MUTEX(rpadlpar_sem); static DEFINE_MUTEX(rpadlpar_mutex);
#define DLPAR_MODULE_NAME "rpadlpar_io" #define DLPAR_MODULE_NAME "rpadlpar_io"
...@@ -300,7 +300,7 @@ int dlpar_add_slot(char *drc_name) ...@@ -300,7 +300,7 @@ int dlpar_add_slot(char *drc_name)
int node_type; int node_type;
int rc = -EIO; int rc = -EIO;
if (down_interruptible(&rpadlpar_sem)) if (mutex_lock_interruptible(&rpadlpar_mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
/* Find newly added node */ /* Find newly added node */
...@@ -324,7 +324,7 @@ int dlpar_add_slot(char *drc_name) ...@@ -324,7 +324,7 @@ int dlpar_add_slot(char *drc_name)
printk(KERN_INFO "%s: slot %s added\n", DLPAR_MODULE_NAME, drc_name); printk(KERN_INFO "%s: slot %s added\n", DLPAR_MODULE_NAME, drc_name);
exit: exit:
up(&rpadlpar_sem); mutex_unlock(&rpadlpar_mutex);
return rc; return rc;
} }
...@@ -417,7 +417,7 @@ int dlpar_remove_slot(char *drc_name) ...@@ -417,7 +417,7 @@ int dlpar_remove_slot(char *drc_name)
int node_type; int node_type;
int rc = 0; int rc = 0;
if (down_interruptible(&rpadlpar_sem)) if (mutex_lock_interruptible(&rpadlpar_mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
dn = find_dlpar_node(drc_name, &node_type); dn = find_dlpar_node(drc_name, &node_type);
...@@ -439,7 +439,7 @@ int dlpar_remove_slot(char *drc_name) ...@@ -439,7 +439,7 @@ int dlpar_remove_slot(char *drc_name)
} }
printk(KERN_INFO "%s: slot %s removed\n", DLPAR_MODULE_NAME, drc_name); printk(KERN_INFO "%s: slot %s removed\n", DLPAR_MODULE_NAME, drc_name);
exit: exit:
up(&rpadlpar_sem); mutex_unlock(&rpadlpar_mutex);
return rc; return rc;
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/mutex.h>
#include <asm/sn/addrs.h> #include <asm/sn/addrs.h>
#include <asm/sn/l1.h> #include <asm/sn/l1.h>
...@@ -81,7 +82,7 @@ static struct hotplug_slot_ops sn_hotplug_slot_ops = { ...@@ -81,7 +82,7 @@ static struct hotplug_slot_ops sn_hotplug_slot_ops = {
.get_power_status = get_power_status, .get_power_status = get_power_status,
}; };
static DECLARE_MUTEX(sn_hotplug_sem); static DEFINE_MUTEX(sn_hotplug_mutex);
static ssize_t path_show (struct hotplug_slot *bss_hotplug_slot, static ssize_t path_show (struct hotplug_slot *bss_hotplug_slot,
char *buf) char *buf)
...@@ -346,7 +347,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) ...@@ -346,7 +347,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
int rc; int rc;
/* Serialize the Linux PCI infrastructure */ /* Serialize the Linux PCI infrastructure */
down(&sn_hotplug_sem); mutex_lock(&sn_hotplug_mutex);
/* /*
* Power-on and initialize the slot in the SN * Power-on and initialize the slot in the SN
...@@ -354,7 +355,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) ...@@ -354,7 +355,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
*/ */
rc = sn_slot_enable(bss_hotplug_slot, slot->device_num); rc = sn_slot_enable(bss_hotplug_slot, slot->device_num);
if (rc) { if (rc) {
up(&sn_hotplug_sem); mutex_unlock(&sn_hotplug_mutex);
return rc; return rc;
} }
...@@ -362,7 +363,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) ...@@ -362,7 +363,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
PCI_DEVFN(slot->device_num + 1, 0)); PCI_DEVFN(slot->device_num + 1, 0));
if (!num_funcs) { if (!num_funcs) {
dev_dbg(slot->pci_bus->self, "no device in slot\n"); dev_dbg(slot->pci_bus->self, "no device in slot\n");
up(&sn_hotplug_sem); mutex_unlock(&sn_hotplug_mutex);
return -ENODEV; return -ENODEV;
} }
...@@ -402,7 +403,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) ...@@ -402,7 +403,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
if (new_ppb) if (new_ppb)
pci_bus_add_devices(new_bus); pci_bus_add_devices(new_bus);
up(&sn_hotplug_sem); mutex_unlock(&sn_hotplug_mutex);
if (rc == 0) if (rc == 0)
dev_dbg(slot->pci_bus->self, dev_dbg(slot->pci_bus->self,
...@@ -422,7 +423,7 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot) ...@@ -422,7 +423,7 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot)
int rc; int rc;
/* Acquire update access to the bus */ /* Acquire update access to the bus */
down(&sn_hotplug_sem); mutex_lock(&sn_hotplug_mutex);
/* is it okay to bring this slot down? */ /* is it okay to bring this slot down? */
rc = sn_slot_disable(bss_hotplug_slot, slot->device_num, rc = sn_slot_disable(bss_hotplug_slot, slot->device_num,
...@@ -450,7 +451,7 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot) ...@@ -450,7 +451,7 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot)
PCI_REQ_SLOT_DISABLE); PCI_REQ_SLOT_DISABLE);
leaving: leaving:
/* Release the bus lock */ /* Release the bus lock */
up(&sn_hotplug_sem); mutex_unlock(&sn_hotplug_mutex);
return rc; return rc;
} }
...@@ -462,9 +463,9 @@ static inline int get_power_status(struct hotplug_slot *bss_hotplug_slot, ...@@ -462,9 +463,9 @@ static inline int get_power_status(struct hotplug_slot *bss_hotplug_slot,
struct pcibus_info *pcibus_info; struct pcibus_info *pcibus_info;
pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus);
down(&sn_hotplug_sem); mutex_lock(&sn_hotplug_mutex);
*value = pcibus_info->pbi_enabled_devices & (1 << slot->device_num); *value = pcibus_info->pbi_enabled_devices & (1 << slot->device_num);
up(&sn_hotplug_sem); mutex_unlock(&sn_hotplug_mutex);
return 0; return 0;
} }
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/isapnp.h> #include <linux/isapnp.h>
#include <linux/mutex.h>
#include <asm/io.h> #include <asm/io.h>
#if 0 #if 0
...@@ -92,7 +93,7 @@ MODULE_LICENSE("GPL"); ...@@ -92,7 +93,7 @@ MODULE_LICENSE("GPL");
#define _LTAG_FIXEDMEM32RANGE 0x86 #define _LTAG_FIXEDMEM32RANGE 0x86
static unsigned char isapnp_checksum_value; static unsigned char isapnp_checksum_value;
static DECLARE_MUTEX(isapnp_cfg_mutex); static DEFINE_MUTEX(isapnp_cfg_mutex);
static int isapnp_detected; static int isapnp_detected;
static int isapnp_csn_count; static int isapnp_csn_count;
...@@ -903,7 +904,7 @@ int isapnp_cfg_begin(int csn, int logdev) ...@@ -903,7 +904,7 @@ int isapnp_cfg_begin(int csn, int logdev)
{ {
if (csn < 1 || csn > isapnp_csn_count || logdev > 10) if (csn < 1 || csn > isapnp_csn_count || logdev > 10)
return -EINVAL; return -EINVAL;
down(&isapnp_cfg_mutex); mutex_lock(&isapnp_cfg_mutex);
isapnp_wait(); isapnp_wait();
isapnp_key(); isapnp_key();
isapnp_wake(csn); isapnp_wake(csn);
...@@ -929,7 +930,7 @@ int isapnp_cfg_begin(int csn, int logdev) ...@@ -929,7 +930,7 @@ int isapnp_cfg_begin(int csn, int logdev)
int isapnp_cfg_end(void) int isapnp_cfg_end(void)
{ {
isapnp_wait(); isapnp_wait();
up(&isapnp_cfg_mutex); mutex_unlock(&isapnp_cfg_mutex);
return 0; return 0;
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/major.h> #include <linux/major.h>
#include <linux/kdev_t.h> #include <linux/kdev_t.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/mutex.h>
struct class *class3270; struct class *class3270;
...@@ -59,7 +60,7 @@ struct raw3270 { ...@@ -59,7 +60,7 @@ struct raw3270 {
#define RAW3270_FLAGS_CONSOLE 8 /* Device is the console. */ #define RAW3270_FLAGS_CONSOLE 8 /* Device is the console. */
/* Semaphore to protect global data of raw3270 (devices, views, etc). */ /* Semaphore to protect global data of raw3270 (devices, views, etc). */
static DECLARE_MUTEX(raw3270_sem); static DEFINE_MUTEX(raw3270_mutex);
/* List of 3270 devices. */ /* List of 3270 devices. */
static struct list_head raw3270_devices = LIST_HEAD_INIT(raw3270_devices); static struct list_head raw3270_devices = LIST_HEAD_INIT(raw3270_devices);
...@@ -815,7 +816,7 @@ raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc) ...@@ -815,7 +816,7 @@ raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc)
* number for it. Note: there is no device with minor 0, * number for it. Note: there is no device with minor 0,
* see special case for fs3270.c:fs3270_open(). * see special case for fs3270.c:fs3270_open().
*/ */
down(&raw3270_sem); mutex_lock(&raw3270_mutex);
/* Keep the list sorted. */ /* Keep the list sorted. */
minor = RAW3270_FIRSTMINOR; minor = RAW3270_FIRSTMINOR;
rp->minor = -1; rp->minor = -1;
...@@ -832,7 +833,7 @@ raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc) ...@@ -832,7 +833,7 @@ raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc)
rp->minor = minor; rp->minor = minor;
list_add_tail(&rp->list, &raw3270_devices); list_add_tail(&rp->list, &raw3270_devices);
} }
up(&raw3270_sem); mutex_unlock(&raw3270_mutex);
/* No free minor number? Then give up. */ /* No free minor number? Then give up. */
if (rp->minor == -1) if (rp->minor == -1)
return -EUSERS; return -EUSERS;
...@@ -1003,7 +1004,7 @@ raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor) ...@@ -1003,7 +1004,7 @@ raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor)
if (minor <= 0) if (minor <= 0)
return -ENODEV; return -ENODEV;
down(&raw3270_sem); mutex_lock(&raw3270_mutex);
rc = -ENODEV; rc = -ENODEV;
list_for_each_entry(rp, &raw3270_devices, list) { list_for_each_entry(rp, &raw3270_devices, list) {
if (rp->minor != minor) if (rp->minor != minor)
...@@ -1024,7 +1025,7 @@ raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor) ...@@ -1024,7 +1025,7 @@ raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor)
spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
break; break;
} }
up(&raw3270_sem); mutex_unlock(&raw3270_mutex);
return rc; return rc;
} }
...@@ -1038,7 +1039,7 @@ raw3270_find_view(struct raw3270_fn *fn, int minor) ...@@ -1038,7 +1039,7 @@ raw3270_find_view(struct raw3270_fn *fn, int minor)
struct raw3270_view *view, *tmp; struct raw3270_view *view, *tmp;
unsigned long flags; unsigned long flags;
down(&raw3270_sem); mutex_lock(&raw3270_mutex);
view = ERR_PTR(-ENODEV); view = ERR_PTR(-ENODEV);
list_for_each_entry(rp, &raw3270_devices, list) { list_for_each_entry(rp, &raw3270_devices, list) {
if (rp->minor != minor) if (rp->minor != minor)
...@@ -1057,7 +1058,7 @@ raw3270_find_view(struct raw3270_fn *fn, int minor) ...@@ -1057,7 +1058,7 @@ raw3270_find_view(struct raw3270_fn *fn, int minor)
spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
break; break;
} }
up(&raw3270_sem); mutex_unlock(&raw3270_mutex);
return view; return view;
} }
...@@ -1104,7 +1105,7 @@ raw3270_delete_device(struct raw3270 *rp) ...@@ -1104,7 +1105,7 @@ raw3270_delete_device(struct raw3270 *rp)
struct ccw_device *cdev; struct ccw_device *cdev;
/* Remove from device chain. */ /* Remove from device chain. */
down(&raw3270_sem); mutex_lock(&raw3270_mutex);
if (rp->clttydev) if (rp->clttydev)
class_device_destroy(class3270, class_device_destroy(class3270,
MKDEV(IBM_TTY3270_MAJOR, rp->minor)); MKDEV(IBM_TTY3270_MAJOR, rp->minor));
...@@ -1112,7 +1113,7 @@ raw3270_delete_device(struct raw3270 *rp) ...@@ -1112,7 +1113,7 @@ raw3270_delete_device(struct raw3270 *rp)
class_device_destroy(class3270, class_device_destroy(class3270,
MKDEV(IBM_FS3270_MAJOR, rp->minor)); MKDEV(IBM_FS3270_MAJOR, rp->minor));
list_del_init(&rp->list); list_del_init(&rp->list);
up(&raw3270_sem); mutex_unlock(&raw3270_mutex);
/* Disconnect from ccw_device. */ /* Disconnect from ccw_device. */
cdev = rp->cdev; cdev = rp->cdev;
...@@ -1208,13 +1209,13 @@ int raw3270_register_notifier(void (*notifier)(int, int)) ...@@ -1208,13 +1209,13 @@ int raw3270_register_notifier(void (*notifier)(int, int))
if (!np) if (!np)
return -ENOMEM; return -ENOMEM;
np->notifier = notifier; np->notifier = notifier;
down(&raw3270_sem); mutex_lock(&raw3270_mutex);
list_add_tail(&np->list, &raw3270_notifier); list_add_tail(&np->list, &raw3270_notifier);
list_for_each_entry(rp, &raw3270_devices, list) { list_for_each_entry(rp, &raw3270_devices, list) {
get_device(&rp->cdev->dev); get_device(&rp->cdev->dev);
notifier(rp->minor, 1); notifier(rp->minor, 1);
} }
up(&raw3270_sem); mutex_unlock(&raw3270_mutex);
return 0; return 0;
} }
...@@ -1222,14 +1223,14 @@ void raw3270_unregister_notifier(void (*notifier)(int, int)) ...@@ -1222,14 +1223,14 @@ void raw3270_unregister_notifier(void (*notifier)(int, int))
{ {
struct raw3270_notifier *np; struct raw3270_notifier *np;
down(&raw3270_sem); mutex_lock(&raw3270_mutex);
list_for_each_entry(np, &raw3270_notifier, list) list_for_each_entry(np, &raw3270_notifier, list)
if (np->notifier == notifier) { if (np->notifier == notifier) {
list_del(&np->list); list_del(&np->list);
kfree(np); kfree(np);
break; break;
} }
up(&raw3270_sem); mutex_unlock(&raw3270_mutex);
} }
/* /*
...@@ -1256,10 +1257,10 @@ raw3270_set_online (struct ccw_device *cdev) ...@@ -1256,10 +1257,10 @@ raw3270_set_online (struct ccw_device *cdev)
goto failure; goto failure;
raw3270_create_attributes(rp); raw3270_create_attributes(rp);
set_bit(RAW3270_FLAGS_READY, &rp->flags); set_bit(RAW3270_FLAGS_READY, &rp->flags);
down(&raw3270_sem); mutex_lock(&raw3270_mutex);
list_for_each_entry(np, &raw3270_notifier, list) list_for_each_entry(np, &raw3270_notifier, list)
np->notifier(rp->minor, 1); np->notifier(rp->minor, 1);
up(&raw3270_sem); mutex_unlock(&raw3270_mutex);
return 0; return 0;
failure: failure:
...@@ -1307,10 +1308,10 @@ raw3270_remove (struct ccw_device *cdev) ...@@ -1307,10 +1308,10 @@ raw3270_remove (struct ccw_device *cdev)
} }
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags); spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
down(&raw3270_sem); mutex_lock(&raw3270_mutex);
list_for_each_entry(np, &raw3270_notifier, list) list_for_each_entry(np, &raw3270_notifier, list)
np->notifier(rp->minor, 0); np->notifier(rp->minor, 0);
up(&raw3270_sem); mutex_unlock(&raw3270_mutex);
/* Reset 3270 device. */ /* Reset 3270 device. */
raw3270_reset_device(rp); raw3270_reset_device(rp);
...@@ -1370,13 +1371,13 @@ raw3270_init(void) ...@@ -1370,13 +1371,13 @@ raw3270_init(void)
rc = ccw_driver_register(&raw3270_ccw_driver); rc = ccw_driver_register(&raw3270_ccw_driver);
if (rc == 0) { if (rc == 0) {
/* Create attributes for early (= console) device. */ /* Create attributes for early (= console) device. */
down(&raw3270_sem); mutex_lock(&raw3270_mutex);
class3270 = class_create(THIS_MODULE, "3270"); class3270 = class_create(THIS_MODULE, "3270");
list_for_each_entry(rp, &raw3270_devices, list) { list_for_each_entry(rp, &raw3270_devices, list) {
get_device(&rp->cdev->dev); get_device(&rp->cdev->dev);
raw3270_create_attributes(rp); raw3270_create_attributes(rp);
} }
up(&raw3270_sem); mutex_unlock(&raw3270_mutex);
} }
return rc; return rc;
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/kmod.h> #include <linux/kmod.h>
#include <linux/sem.h> #include <linux/sem.h>
#include <linux/devfs_fs_kernel.h> #include <linux/devfs_fs_kernel.h>
#include <linux/mutex.h>
#define PHONE_NUM_DEVICES 256 #define PHONE_NUM_DEVICES 256
...@@ -37,7 +38,7 @@ ...@@ -37,7 +38,7 @@
*/ */
static struct phone_device *phone_device[PHONE_NUM_DEVICES]; static struct phone_device *phone_device[PHONE_NUM_DEVICES];
static DECLARE_MUTEX(phone_lock); static DEFINE_MUTEX(phone_lock);
/* /*
* Open a phone device. * Open a phone device.
...@@ -53,14 +54,14 @@ static int phone_open(struct inode *inode, struct file *file) ...@@ -53,14 +54,14 @@ static int phone_open(struct inode *inode, struct file *file)
if (minor >= PHONE_NUM_DEVICES) if (minor >= PHONE_NUM_DEVICES)
return -ENODEV; return -ENODEV;
down(&phone_lock); mutex_lock(&phone_lock);
p = phone_device[minor]; p = phone_device[minor];
if (p) if (p)
new_fops = fops_get(p->f_op); new_fops = fops_get(p->f_op);
if (!new_fops) { if (!new_fops) {
up(&phone_lock); mutex_unlock(&phone_lock);
request_module("char-major-%d-%d", PHONE_MAJOR, minor); request_module("char-major-%d-%d", PHONE_MAJOR, minor);
down(&phone_lock); mutex_lock(&phone_lock);
p = phone_device[minor]; p = phone_device[minor];
if (p == NULL || (new_fops = fops_get(p->f_op)) == NULL) if (p == NULL || (new_fops = fops_get(p->f_op)) == NULL)
{ {
...@@ -78,7 +79,7 @@ static int phone_open(struct inode *inode, struct file *file) ...@@ -78,7 +79,7 @@ static int phone_open(struct inode *inode, struct file *file)
} }
fops_put(old_fops); fops_put(old_fops);
end: end:
up(&phone_lock); mutex_unlock(&phone_lock);
return err; return err;
} }
...@@ -100,18 +101,18 @@ int phone_register_device(struct phone_device *p, int unit) ...@@ -100,18 +101,18 @@ int phone_register_device(struct phone_device *p, int unit)
end = unit + 1; /* enter the loop at least one time */ end = unit + 1; /* enter the loop at least one time */
} }
down(&phone_lock); mutex_lock(&phone_lock);
for (i = base; i < end; i++) { for (i = base; i < end; i++) {
if (phone_device[i] == NULL) { if (phone_device[i] == NULL) {
phone_device[i] = p; phone_device[i] = p;
p->minor = i; p->minor = i;
devfs_mk_cdev(MKDEV(PHONE_MAJOR,i), devfs_mk_cdev(MKDEV(PHONE_MAJOR,i),
S_IFCHR|S_IRUSR|S_IWUSR, "phone/%d", i); S_IFCHR|S_IRUSR|S_IWUSR, "phone/%d", i);
up(&phone_lock); mutex_unlock(&phone_lock);
return 0; return 0;
} }
} }
up(&phone_lock); mutex_unlock(&phone_lock);
return -ENFILE; return -ENFILE;
} }
...@@ -121,12 +122,12 @@ int phone_register_device(struct phone_device *p, int unit) ...@@ -121,12 +122,12 @@ int phone_register_device(struct phone_device *p, int unit)
void phone_unregister_device(struct phone_device *pfd) void phone_unregister_device(struct phone_device *pfd)
{ {
down(&phone_lock); mutex_lock(&phone_lock);
if (phone_device[pfd->minor] != pfd) if (phone_device[pfd->minor] != pfd)
panic("phone: bad unregister"); panic("phone: bad unregister");
devfs_remove("phone/%d", pfd->minor); devfs_remove("phone/%d", pfd->minor);
phone_device[pfd->minor] = NULL; phone_device[pfd->minor] = NULL;
up(&phone_lock); mutex_unlock(&phone_lock);
} }
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/netfilter.h> #include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h> #include <linux/netfilter_ipv4.h>
#include <linux/mutex.h>
#include <net/ip.h> #include <net/ip.h>
#include <net/route.h> #include <net/route.h>
...@@ -44,7 +45,7 @@ ...@@ -44,7 +45,7 @@
#include <net/ip_vs.h> #include <net/ip_vs.h>
/* semaphore for IPVS sockopts. And, [gs]etsockopt may sleep. */ /* semaphore for IPVS sockopts. And, [gs]etsockopt may sleep. */
static DECLARE_MUTEX(__ip_vs_mutex); static DEFINE_MUTEX(__ip_vs_mutex);
/* lock for service table */ /* lock for service table */
static DEFINE_RWLOCK(__ip_vs_svc_lock); static DEFINE_RWLOCK(__ip_vs_svc_lock);
...@@ -1950,7 +1951,7 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) ...@@ -1950,7 +1951,7 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
/* increase the module use count */ /* increase the module use count */
ip_vs_use_count_inc(); ip_vs_use_count_inc();
if (down_interruptible(&__ip_vs_mutex)) { if (mutex_lock_interruptible(&__ip_vs_mutex)) {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
goto out_dec; goto out_dec;
} }
...@@ -2041,7 +2042,7 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) ...@@ -2041,7 +2042,7 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
ip_vs_service_put(svc); ip_vs_service_put(svc);
out_unlock: out_unlock:
up(&__ip_vs_mutex); mutex_unlock(&__ip_vs_mutex);
out_dec: out_dec:
/* decrease the module use count */ /* decrease the module use count */
ip_vs_use_count_dec(); ip_vs_use_count_dec();
...@@ -2211,7 +2212,7 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) ...@@ -2211,7 +2212,7 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
if (copy_from_user(arg, user, get_arglen[GET_CMDID(cmd)]) != 0) if (copy_from_user(arg, user, get_arglen[GET_CMDID(cmd)]) != 0)
return -EFAULT; return -EFAULT;
if (down_interruptible(&__ip_vs_mutex)) if (mutex_lock_interruptible(&__ip_vs_mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
switch (cmd) { switch (cmd) {
...@@ -2330,7 +2331,7 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) ...@@ -2330,7 +2331,7 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
} }
out: out:
up(&__ip_vs_mutex); mutex_unlock(&__ip_vs_mutex);
return ret; return ret;
} }
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
/* FIXME: this is just for IP_NF_ASSERRT */ /* FIXME: this is just for IP_NF_ASSERRT */
#include <linux/netfilter_ipv4/ip_conntrack.h> #include <linux/netfilter_ipv4/ip_conntrack.h>
#include <linux/mutex.h>
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
...@@ -92,7 +93,7 @@ struct ipt_hashlimit_htable { ...@@ -92,7 +93,7 @@ struct ipt_hashlimit_htable {
}; };
static DEFINE_SPINLOCK(hashlimit_lock); /* protects htables list */ static DEFINE_SPINLOCK(hashlimit_lock); /* protects htables list */
static DECLARE_MUTEX(hlimit_mutex); /* additional checkentry protection */ static DEFINE_MUTEX(hlimit_mutex); /* additional checkentry protection */
static HLIST_HEAD(hashlimit_htables); static HLIST_HEAD(hashlimit_htables);
static kmem_cache_t *hashlimit_cachep __read_mostly; static kmem_cache_t *hashlimit_cachep __read_mostly;
...@@ -542,13 +543,13 @@ hashlimit_checkentry(const char *tablename, ...@@ -542,13 +543,13 @@ hashlimit_checkentry(const char *tablename,
* call vmalloc, and that can sleep. And we cannot just re-search * call vmalloc, and that can sleep. And we cannot just re-search
* the list of htable's in htable_create(), since then we would * the list of htable's in htable_create(), since then we would
* create duplicate proc files. -HW */ * create duplicate proc files. -HW */
down(&hlimit_mutex); mutex_lock(&hlimit_mutex);
r->hinfo = htable_find_get(r->name); r->hinfo = htable_find_get(r->name);
if (!r->hinfo && (htable_create(r) != 0)) { if (!r->hinfo && (htable_create(r) != 0)) {
up(&hlimit_mutex); mutex_unlock(&hlimit_mutex);
return 0; return 0;
} }
up(&hlimit_mutex); mutex_unlock(&hlimit_mutex);
/* Ugly hack: For SMP, we only want to use one set */ /* Ugly hack: For SMP, we only want to use one set */
r->u.master = r; r->u.master = r;
......
...@@ -13,26 +13,27 @@ ...@@ -13,26 +13,27 @@
#include <linux/socket.h> #include <linux/socket.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/mutex.h>
#include <net/sock.h> #include <net/sock.h>
#include <net/genetlink.h> #include <net/genetlink.h>
struct sock *genl_sock = NULL; struct sock *genl_sock = NULL;
static DECLARE_MUTEX(genl_sem); /* serialization of message processing */ static DEFINE_MUTEX(genl_mutex); /* serialization of message processing */
static void genl_lock(void) static void genl_lock(void)
{ {
down(&genl_sem); mutex_lock(&genl_mutex);
} }
static int genl_trylock(void) static int genl_trylock(void)
{ {
return down_trylock(&genl_sem); return !mutex_trylock(&genl_mutex);
} }
static void genl_unlock(void) static void genl_unlock(void)
{ {
up(&genl_sem); mutex_unlock(&genl_mutex);
if (genl_sock && genl_sock->sk_receive_queue.qlen) if (genl_sock && genl_sock->sk_receive_queue.qlen)
genl_sock->sk_data_ready(genl_sock, 0); genl_sock->sk_data_ready(genl_sock, 0);
......
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