Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

[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
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -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)
    	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 *))
{
{
	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;
}
}
+5 −4
Original line number Original line Diff line number Diff line
@@ -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 @@
#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
	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;
+7 −6
Original line number Original line Diff line number Diff line
@@ -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 @@
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,
	/* 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,
		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)
	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)
		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)
	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;
+4 −3
Original line number Original line Diff line number Diff line
@@ -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");
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_
		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_
	if (!ret)
	if (!ret)
		ret = (ssize_t)len;
		ret = (ssize_t)len;


	up(&microcode_sem);
	mutex_unlock(&microcode_mutex);


	return ret;
	return ret;
}
}
+32 −31
Original line number Original line Diff line number Diff line
@@ -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,
		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,
		       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,
		       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,
		       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,
	}
	}
	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,
		    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,
		    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,
		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,
			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,
			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,
		*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,
{
{
	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,
		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,
		       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,
			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;
}
}


Loading