Skip to content

Commit 14cc3e2

Browse files
Ingo MolnarLinus Torvalds
authored andcommitted
[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: Ingo 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: Alasdair 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: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 353ab6e commit 14cc3e2

20 files changed

Lines changed: 172 additions & 157 deletions

File tree

‎arch/arm26/kernel/traps.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <asm/system.h>
3535
#include <asm/uaccess.h>
3636
#include <asm/unistd.h>
37-
#include <asm/semaphore.h>
37+
#include <linux/mutex.h>
3838

3939
#include "ptrace.h"
4040

@@ -207,19 +207,19 @@ void die_if_kernel(const char *str, struct pt_regs *regs, int err)
207207
die(str, regs, err);
208208
}
209209

210-
static DECLARE_MUTEX(undef_sem);
210+
static DEFINE_MUTEX(undef_mutex);
211211
static int (*undef_hook)(struct pt_regs *);
212212

213213
int request_undef_hook(int (*fn)(struct pt_regs *))
214214
{
215215
int ret = -EBUSY;
216216

217-
down(&undef_sem);
217+
mutex_lock(&undef_mutex);
218218
if (undef_hook == NULL) {
219219
undef_hook = fn;
220220
ret = 0;
221221
}
222-
up(&undef_sem);
222+
mutex_unlock(&undef_mutex);
223223

224224
return ret;
225225
}
@@ -228,12 +228,12 @@ int release_undef_hook(int (*fn)(struct pt_regs *))
228228
{
229229
int ret = -EINVAL;
230230

231-
down(&undef_sem);
231+
mutex_lock(&undef_mutex);
232232
if (undef_hook == fn) {
233233
undef_hook = NULL;
234234
ret = 0;
235235
}
236-
up(&undef_sem);
236+
mutex_unlock(&undef_mutex);
237237

238238
return ret;
239239
}

‎arch/i386/kernel/cpu/cpufreq/powernow-k8.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
#ifdef CONFIG_X86_POWERNOW_K8_ACPI
4242
#include <linux/acpi.h>
43+
#include <linux/mutex.h>
4344
#include <acpi/processor.h>
4445
#endif
4546

@@ -49,7 +50,7 @@
4950
#include "powernow-k8.h"
5051

5152
/* serialize freq changes */
52-
static DECLARE_MUTEX(fidvid_sem);
53+
static DEFINE_MUTEX(fidvid_mutex);
5354

5455
static struct powernow_k8_data *powernow_data[NR_CPUS];
5556

@@ -943,17 +944,17 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
943944
if (cpufreq_frequency_table_target(pol, data->powernow_table, targfreq, relation, &newstate))
944945
goto err_out;
945946

946-
down(&fidvid_sem);
947+
mutex_lock(&fidvid_mutex);
947948

948949
powernow_k8_acpi_pst_values(data, newstate);
949950

950951
if (transition_frequency(data, newstate)) {
951952
printk(KERN_ERR PFX "transition frequency failed\n");
952953
ret = 1;
953-
up(&fidvid_sem);
954+
mutex_unlock(&fidvid_mutex);
954955
goto err_out;
955956
}
956-
up(&fidvid_sem);
957+
mutex_unlock(&fidvid_mutex);
957958

958959
pol->cur = find_khz_freq_from_fid(data->currfid);
959960
ret = 0;

‎arch/i386/kernel/cpu/mtrr/main.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <linux/pci.h>
3737
#include <linux/smp.h>
3838
#include <linux/cpu.h>
39+
#include <linux/mutex.h>
3940

4041
#include <asm/mtrr.h>
4142

@@ -47,7 +48,7 @@
4748
u32 num_var_ranges = 0;
4849

4950
unsigned int *usage_table;
50-
static DECLARE_MUTEX(mtrr_sem);
51+
static DEFINE_MUTEX(mtrr_mutex);
5152

5253
u32 size_or_mask, size_and_mask;
5354

@@ -333,7 +334,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
333334
/* No CPU hotplug when we change MTRR entries */
334335
lock_cpu_hotplug();
335336
/* Search for existing MTRR */
336-
down(&mtrr_sem);
337+
mutex_lock(&mtrr_mutex);
337338
for (i = 0; i < num_var_ranges; ++i) {
338339
mtrr_if->get(i, &lbase, &lsize, &ltype);
339340
if (base >= lbase + lsize)
@@ -371,7 +372,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
371372
printk(KERN_INFO "mtrr: no more MTRRs available\n");
372373
error = i;
373374
out:
374-
up(&mtrr_sem);
375+
mutex_unlock(&mtrr_mutex);
375376
unlock_cpu_hotplug();
376377
return error;
377378
}
@@ -464,7 +465,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
464465
max = num_var_ranges;
465466
/* No CPU hotplug when we change MTRR entries */
466467
lock_cpu_hotplug();
467-
down(&mtrr_sem);
468+
mutex_lock(&mtrr_mutex);
468469
if (reg < 0) {
469470
/* Search for existing MTRR */
470471
for (i = 0; i < max; ++i) {
@@ -503,7 +504,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
503504
set_mtrr(reg, 0, 0, 0);
504505
error = reg;
505506
out:
506-
up(&mtrr_sem);
507+
mutex_unlock(&mtrr_mutex);
507508
unlock_cpu_hotplug();
508509
return error;
509510
}
@@ -685,7 +686,7 @@ void mtrr_ap_init(void)
685686
if (!mtrr_if || !use_intel())
686687
return;
687688
/*
688-
* Ideally we should hold mtrr_sem here to avoid mtrr entries changed,
689+
* Ideally we should hold mtrr_mutex here to avoid mtrr entries changed,
689690
* but this routine will be called in cpu boot time, holding the lock
690691
* breaks it. This routine is called in two cases: 1.very earily time
691692
* of software resume, when there absolutely isn't mtrr entry changes;

‎arch/i386/kernel/microcode.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#include <linux/miscdevice.h>
8282
#include <linux/spinlock.h>
8383
#include <linux/mm.h>
84+
#include <linux/mutex.h>
8485

8586
#include <asm/msr.h>
8687
#include <asm/uaccess.h>
@@ -114,7 +115,7 @@ MODULE_LICENSE("GPL");
114115
static DEFINE_SPINLOCK(microcode_update_lock);
115116

116117
/* no concurrent ->write()s are allowed on /dev/cpu/microcode */
117-
static DECLARE_MUTEX(microcode_sem);
118+
static DEFINE_MUTEX(microcode_mutex);
118119

119120
static void __user *user_buffer; /* user area microcode data buffer */
120121
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_
444445
return -EINVAL;
445446
}
446447

447-
down(&microcode_sem);
448+
mutex_lock(&microcode_mutex);
448449

449450
user_buffer = (void __user *) buf;
450451
user_buffer_size = (int) len;
@@ -453,7 +454,7 @@ static ssize_t microcode_write (struct file *file, const char __user *buf, size_
453454
if (!ret)
454455
ret = (ssize_t)len;
455456

456-
up(&microcode_sem);
457+
mutex_unlock(&microcode_mutex);
457458

458459
return ret;
459460
}

0 commit comments

Comments
 (0)