Skip to contentSkip to conversation

: MUTEX: Introduce mutex implementation

PATCH In review David Howells 9 participants 37 messages Dec 16, 2005 – Dec 19, 2005

Subsystems (84)
lore
Share & tools
lore

David Howells

author maintainer
#0 lore raw

cover : MUTEX: Introduce mutex implementation

This set of patches implements mutexes as an alternative to semaphores where such more restricted behaviour is appropriate.

There are several changes that might be appropriate to these patches:

(1) Name DECLARE_MUTEX as DEFINE_MUTEX in linux/mutex-*.h

(2) Make mutex_trylock()'s return value consistent with semaphores rather than everything else.

(3) Drop the testing module (patch 12/12). I'm not sure I've got the plumbing correct in the master makefile.

Patches to come after Christmas will include sem -> completion conversions and sem -> mutex conversions.

Merry Christmas!

David

author maintainer
#1 lore raw

PATCH 1/12 : MUTEX: Implement mutexes

The attached patch introduces a simple mutex implementation as an alternative to the usual semaphore implementation where simple mutex functionality is all that is required.

This is useful in two ways:

(1) A number of archs only provide very simple atomic instructions (such as XCHG on i386, TAS on M68K, SWAP on FRV) which aren't sufficient to implement full semaphore support directly. Instead spinlocks must be employed to implement fuller functionality.

(2) This makes it more obvious that a mutex is a mutex and restricts the capabilites to make it more easier to debug.

This patch set does the following:

(1) Renames DECLARE_MUTEX and DECLARE_MUTEX_LOCKED to be DECLARE_SEM_MUTEX and DECLARE_SEM_MUTEX_LOCKED for counting semaphores.

(2) Provides a wrapper around the counting semaphore to provide a default mutex implementation with certain added debugging capabilities that aren't appropriate for a counting semaphore due to the nature of such. The type is:

struct mutex

Available mutex operations are:

mutex_init()
mutex_init_locked()
mutex_trylock()
mutex_lock()
mutex_lock_interruptible()
mutex_unlock()
mutex_is_locked()

Note that the trylock op has the opposite result logic to down_trylock, but in keeping with rwsems and spinlocks it returns true on success. In addition the following static initialisers are available:

DECLARE_MUTEX();
struct mutex name = MUTEX_UNLOCKED(name);

(3) Provides an xchg() based mutex template selectable by setting CONFIG_ARCH_XCHG_MUTEX that, by default, uses xchg() to manipulate the state. This mutex only requires two states.

If something more appropriate is available, the use of xchg() may be overridden by the arch by #defining the following macros in asm/system.h:

__mutex_trylock(mutex)
__mutex_release(mutex)
mutex_is_locked(mutex)

Furthermore the two state values involved may also be overridden by #defining:

__MUTEX_STATE_UNLOCKED
__MUTEX_STATE_LOCKED

Overriding is possible by setting CONFIG_ARCH_IMPLEMENTS_MUTEX and supplying asm/mutex.h

Partial overriding is possible by #defining mutex_grab(), mutex_release() and is_mutex_locked() to perform the appropriate optimised functions.

(4) Provides a cmpxchg() based semaphore template selectable by setting CONFIG_ARCH_CMPXCHG_MUTEX that, by default, uses cmpxchg() to manipulate the state. This mutex requires three states.

The use of cmpxchg() may be overridden by #defining the following macro in asm/system.h:

__mutex_cmpxchg().

The macro should be able to deal with unsigned long values as it's used to store the address of the thread info struct when mutex owner debugging is enabled.

(5) If the arch wishes to provide the entire mutex implementation itself, it should set CONFIG_ARCH_IMPLEMENTS_MUTEX and provide asm/mutex.h.

(6) Provides linux/mutex.h as a common include for gaining access to mutex semaphores.

(7) Provides a debugging config option CONFIG_DEBUG_MUTEX_OWNER by which the mutex owner can be tracked and by which over-upping can be detected.

---
warthog>diffstat -p1 mutex-core-2615rc5-2.diff

 include/linux/mutex-cmpxchg.h |  109 ++++++++++++++++++++++++++
 include/linux/mutex-default.h |  127 +++++++++++++++++++++++++++++++
 include/linux/mutex-xchg.h    |  171 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/mutex.h         |   46 +++++++++++
 lib/Kconfig.debug             |    8 +
 5 files changed, 461 insertions(+)
include/linux/mutex-cmpxchg.h +109 -0
diff -uNrp linux-2.6.15-rc5/include/linux/mutex-cmpxchg.h linux-2.6.15-rc5-mutex/include/linux/mutex-cmpxchg.h
@@ -0,0 +1,109 @@
+/* mutex-cmpxchg.h: compare-and-exchange-based mutexes
+ *
+ * Copyright (C) 2005 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells ([email protected])
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ *
+ * This requires the arch to define CONFIG_ARCH_CMPXCHG_MUTEX
+ *
+ * The arch must also provide a cmpxchg() capable of dealing with a long
+ *
+ * See kernel/mutex-cmpxchg.c for the slow-path implementation.
+ */
+#ifndef _LINUX_MUTEX_CMPXCHG_H
+#define _LINUX_MUTEX_CMPXCHG_H
+
+#ifndef _LINUX_MUTEX_H
+#error linux/mutex-cmpxchg.h should not be included directly; use linux/mutex.h instead
+#endif
+
+#ifndef __ASSEMBLY__
+
+#include <linux/linkage.h>
+#include <linux/wait.h>
+#include <linux/spinlock.h>
+#include <asm/system.h>
+
+/*
+ * the mutex semaphore definition
+ * - if state is 0, then the mutex is available
+ * - if state is non-zero, then the mutex is busy and the state points to the
+ *   owner if debugging
+ *   - if the bottom bit is clear, then there are no waiters
+ *   - if the bottom bit is set, then there are processes waiting for the mutex
+ * - if wait_list is not empty, then there are processes waiting for the mutex
+ */
+struct mutex {
+	volatile unsigned long	state;
+	spinlock_t		wait_lock;
+	struct list_head	wait_list;
+};
+
+/*
+ * attempt to exchange the state of the mutex for a different one
+ */
+#ifndef __mutex_cmpxchg
+#define __mutex_cmpxchg(m, old, new) cmpxchg(&(m)->state, (old), (new))
+#endif
+
+/*
+ * mutex_is_locked() returns non-zero if the mutex is locked
+ */
+#define mutex_is_locked(mutex)	((mutex)->state)
+
+#ifdef CONFIG_DEBUG_MUTEX_OWNER
+#define __mutex_owner() ((unsigned long) current_thread_info())
+#else
+#define __mutex_owner() 2UL
+#endif
+
+#define MUTEX_UNLOCKED(name)					\
+{								\
+	.state		= 0,					\
+	.wait_lock	= SPIN_LOCK_UNLOCKED,			\
+	.wait_list	= LIST_HEAD_INIT((name).wait_list)	\
+}
+
+#define DECLARE_MUTEX(name) \
+	struct mutex name = MUTEX_UNLOCKED(name)
+
+static inline void __mutex_init(struct mutex *mutex, unsigned state)
+{
+	mutex->state = state;
+	spin_lock_init(&mutex->wait_lock);
+	INIT_LIST_HEAD(&mutex->wait_list);
+}
+
+static inline void mutex_init(struct mutex *mutex)
+{
+	__mutex_init(mutex, 0);
+}
+
+static inline void mutex_init_locked(struct mutex *mutex)
+{
+	__mutex_init(mutex, __mutex_owner());
+}
+
+/*
+ * attempt to grab the mutex without waiting for it to become available
+ * - returns true if we acquired it
+ */
+static inline int mutex_trylock(struct mutex *mutex)
+{
+	unsigned long state = __mutex_owner();
+
+	return likely(__mutex_cmpxchg(mutex, 0, state) == 0);
+}
+
+extern void fastcall mutex_lock(struct mutex *mutex);
+extern int fastcall  mutex_lock_interruptible(struct mutex *mutex);
+extern void fastcall mutex_unlock(struct mutex *mutex);
+
+
+#endif /* __ASSEMBLY__ */
+#endif /* _LINUX_MUTEX_CMPXCHG_H */
include/linux/mutex-default.h +127 -0

127 lines not on this page · raw message

include/linux/mutex-xchg.h +171 -0

171 lines not on this page · raw message

include/linux/mutex.h +46 -0

46 lines not on this page · raw message

lib/Kconfig.debug +8 -0
diff -uNrp linux-2.6.15-rc5/lib/Kconfig.debug linux-2.6.15-rc5-mutex/lib/Kconfig.debug
@@ -111,6 +111,14 @@ config DEBUG_SPINLOCK_SLEEP
 	  If you say Y here, various routines which may sleep will become very
 	  noisy if they are called with a spinlock held.
 
+config DEBUG_MUTEX_OWNER
+	bool "Mutex owner tracking and checking"
+	depends on DEBUG_KERNEL
+	help
+	  If you say Y here, the process currently owning a mutex will be
+	  remembered, and a warning will be issued if anyone other than that
+	  process releases it.
+
 config DEBUG_KOBJECT
 	bool "kobject debugging"
 	depends on DEBUG_KERNEL
#2 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 11 lines · David Howells

The attached patch introduces a simple mutex implementation as an alternative to the usual semaphore implementation where simple mutex functionality is all that is required.

This is useful in two ways:

(1) A number of archs only provide very simple atomic instructions (such as XCHG on i386, TAS on M68K, SWAP on FRV) which aren't sufficient to implement full semaphore support directly. Instead spinlocks must be employed to implement fuller functionality.

Quoted 8 lines

(2) This makes it more obvious that a mutex is a mutex and restricts the capabilites to make it more easier to debug.

This patch set does the following:

(1) Renames DECLARE_MUTEX and DECLARE_MUTEX_LOCKED to be DECLARE_SEM_MUTEX and DECLARE_SEM_MUTEX_LOCKED for counting semaphores.

Could we really get rid of that "MUTEX" part. A counting semaphore is _not_ a mutex, although a mutex _is_ a counting semaphore. As is a Jack Russell is a dog, but a dog is not a Jack Russell.

What's the reason not to just use DECLARE_SEM and DECLARE_SEM_LOCKED?

-- Steve

#3 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 2 lines · Steven Rostedt

What's the reason not to just use DECLARE_SEM and DECLARE_SEM_LOCKED?

I still don't see the reason for _any_ of these changes.

There's one big reason to stay with what we have: it's always better to not make changes unnecessarily. That's a BIG reason. It's the _changes_ that need to have strong arguments for them as actually buying us something.

Linus

author maintainer
#4 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 6 lines · Linus Torvalds

I still don't see the reason for _any_ of these changes.

There's one big reason to stay with what we have: it's always better to not make changes unnecessarily. That's a BIG reason. It's the _changes_ that need to have strong arguments for them as actually buying us something.

I assume your referring to the introduction of the specific mutex concept as a whole, not just renaming DECLARE_MUTEX.

For certain architectures, only interrupt disablement, basic spinlocks and mutexes can be implemented directly; all other synchronisation primitives have to be implemented in terms of these. For the purpose of this discussion, I'm ignoring the architectures that might not even have that much; as far as I can see, such as those can't be made to do SMP at all SMP, and so there interrupt disablement is the only requirement.

Linux supports a number of those archs. Amongst them are 68000 (TAS), arm (SWP I think), i386 (XCHG), and FRV (SWAP). I'm also looking at another that only has BSET/BCLR.

All of these can only atomically do an unconditional exchange of one state for another, sufficient to implement a spinlock. They may then use spinlocks and interrupt disablement to sandwich the semaphore implementation, or they may not even try to make semaphores fully atomic.

Furthermore, having to disable interrupts can be a slow process on some archs, notably FRV as far as I'm concerned - though a cute way to do this lazily has been pointed out. Still, I need to use spinlocks to implement semaphores.

Since only about a dozen of the usages of semaphores are actually _as_ semaphores, and the other 400 or so are as mutexes, being able to speed up the mutex implementation drastically would be a very big plus.

Note also that almost all (if not all) the usages of counting semaphores are in the drivers, and none (or almost none) are in the core code, this would be a really big win, and would possibly allow counting semaphores to be ditched entirely on platform configurations where they're not needed.

There are also other reasons for defining a strict mutex type: by forcing the restriction of the type, it makes it harder to accidentally violate the semantics (something that's all too easy with counting semaphores); further, this makes it easier to debug as it's easier to catch errors when they do happen. Also, as I understand it, Ingo suggests that having a separate mutex type will make realtime constraints easier to deal with.

Now, whilst you may have concerns that this will mess everything up, I think disruption can be held to a minimum by making the default case a simple wrapper around the counting semaphores. That way any platform in which the semaphore implementation is pretty much optimal as a mutex already (for instance x86), no changes need to be made to the arch.

The big problem with doing it this way is that it will incur more source churn as semaphores are turned into mutexes. However, if you want the counting semaphore API to stay exactly as it is now, and the changes to be limited to a direct rename only (with no other changes to existing code, except perhaps the inclusion of an extra header file), that is possible:

	  struct semaphore   	    -> struct mutex
	  init_MUTEX		    -> mutex_init
	  init_MUTEX_LOCKED	    -> mutex_init_locked
	  DECLARE_MUTEX		    -> DEFINE_MUTEX
	  DECLARE_MUTEX_LOCKED	    -> [should probably be using a completion]
	  down			    -> mutex_lock
	  down_interruptible	    -> mutex_lock_interruptible
	  down_trylock		    -> mutex_trylock
	  up			    -> mutex_unlock
	  sem_is_locked		    -> mutex_is_locked

Whilst it would be nice to script these changes, I'm not sure it's entirely practical, unless we change _all_ counting semaphores to mutexes, and then convert back those that _should_ be counting semaphores. Doing that, however, would reduce the chances of error greatly.

So please don't just turn down mutexes because you aren't interested in "lesser" architectures. We should be able to guarantee that the mutexes won't be any worse than counting semaphores for implementing mutexes - even on major architecture - if only by wrapping the counting semaphore so that we can check the constraints aren't violated when the debugging is turned on.

As I suggested above, I can change the mutex patches so that it's merely a matter of renaming the symbols, which can possibly be scripted; that should reduce the chance of errors drastically.

David

#5 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 4 lines · David Howells

Linux supports a number of those archs. Amongst them are 68000 (TAS), arm (SWP I think), i386 (XCHG), and FRV (SWAP). I'm also looking at another that only has BSET/BCLR.

Don't bother putting i386 in that list.

Quite frankly, you've done it before, and I think it's intellectually totally dishonest.

i386 does semaphores with a "lock decl". You CANNOT DO IT FASTER. I dare you. Why the hell do you try to make it sound as if x86 would need this new thing, when it absolutely does NOT need it.

Yes, x86 _also_ has an xchg instruction, but hey, that's a total non-argument. We don't actually use that.

Of the other architectures you list, only ARM is really important. And no, arm doesn't do swap. It does LL/SC (except they call it "ldrex/strex", which I assume stands for "load/store with reservation and X just because X is cool. Yeah, we're cool" (*)).

68k is dead. Nobody cares. So just say it outright: this is totally just a FRV feature, and NOBODY ELSE IS IN THE LEAST INTERESTED.

Ok? Just to inject a little honesty here.

Linus

(*) Actually, some arm docs I found implies that "ex" stands for "exclusive", but that leaves me wondering what the "r" stands for?

#6 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 7 lines · Linus Torvalds

Of the other architectures you list, only ARM is really important. And no, arm doesn't do swap. It does LL/SC (except they call it "ldrex/strex", which I assume stands for "load/store with reservation and X just because X is cool. Yeah, we're cool" (*)).

(*) Actually, some arm docs I found implies that "ex" stands for "exclusive", but that leaves me wondering what the "r" stands for?

FYI. The standard instructions:

ldr = load register
str = store register

The new (ARM architecture v6 and above) atomic instructions:

ldrex = load register exclusive
strex = store register exclusive

Previous architecture versions only have the 32-bit and 8 bit unconditional swap instructions. Luckily they're unlikely to be used for SMP in the field.

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
#7 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

In reply to Linus Torvalds
Quoted 4 lines · Linus Torvalds

Of the other architectures you list, only ARM is really important. And no, arm doesn't do swap. It does LL/SC (except they call it "ldrex/strex", which I assume stands for "load/store with reservation and X just because X is cool. Yeah, we're cool" (*)).

Well, if you really want to be honest, you have to consider that the ldrex/strex instructions are available only on ARM architecture level 6 and above, or in other words with only about 1% of all ARM deployments out there. The other 99% of actual ARM processors in the field only have the atomic swap (swp) instruction which is insufficient for implementing a counting semaphore (we therefore have to disable interrupts, do the semaphore update and enable interrupts again which is much slower than a swp-based mutex).

Nicolas

#8 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 9 lines · Nicolas Pitre

Well, if you really want to be honest, you have to consider that the ldrex/strex instructions are available only on ARM architecture level 6 and above, or in other words with only about 1% of all ARM deployments out there. The other 99% of actual ARM processors in the field only have the atomic swap (swp) instruction which is insufficient for implementing a counting semaphore (we therefore have to disable interrupts, do the semaphore update and enable interrupts again which is much slower than a swp-based mutex).

Ehh.. Have you seen any SMP arm machines with the old ones?

Yes, there are some shared-memory things out there. I thought they were basically never used in SMP configs, but just with two independent CPU's that just happened to share (at least part of) memory.

In fact, I thought it was more common that you had one ARM core, and then a specialized comm chip or something?

As far as I can tell from the Linux arm assembly (which I admittedly don't read very well at all), the non-ARMv6 semaphore code just disables interrupts and does the semaphore without any atomic instructions at all. Which is fine for UP (in fact, I'm not even convinced you need to disable interrupts, since any interrupts - even if they do a "trylock+up" - should always leave the counter in the same state it was before).

So afaik, Linux simply doesn't support pre-ARMv6 in SMP configurations, and never has (and I'd assume never will).

Or am I missing something?

Linus

#9 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 11 lines · Linus Torvalds
Quoted 9 lines · Nicolas Pitre

Well, if you really want to be honest, you have to consider that the ldrex/strex instructions are available only on ARM architecture level 6 and above, or in other words with only about 1% of all ARM deployments out there. The other 99% of actual ARM processors in the field only have the atomic swap (swp) instruction which is insufficient for implementing a counting semaphore (we therefore have to disable interrupts, do the semaphore update and enable interrupts again which is much slower than a swp-based mutex).

Quoted 1 line

Ehh.. Have you seen any SMP arm machines with the old ones?

No. I never saw any SMP on ARM yet. About only RMK did.

Quoted 3 lines

As far as I can tell from the Linux arm assembly (which I admittedly don't read very well at all), the non-ARMv6 semaphore code just disables interrupts and does the semaphore without any atomic instructions at all.

Exact, and that's because on pre-ARMv6 you have UP only, and the only atomic instruction on pre-ARMv6 is the swp instruction which doesn't cut it for semaphores.

Quoted 3 lines

Which is fine for UP (in fact, I'm not even convinced you need to disable interrupts, since any interrupts - even if they do a "trylock+up" - should always leave the counter in the same state it was before).

I don't think I follow you here. The down() implementation goes like this:

1) disable interrupts
2) load semaphore count into register
3) decrement register value (remember if it goes negative)
4) store register value to semaphore count location
5) enable interrupts
6) if the count went negative go to sleep

The up() goes like this:

1) disable interrupts
2) load semaphore count into register
3) increment register value (remember if it remains < 1)
4) store register value to semaphore count location
5) enable interrupts
6) if the sem count is still < 1 then wake up someone

Now if you don't disable interrupts then nothing prevents an interrupt handler, or another thread if kernel preemption is allowed, to come along right between (2) and (4) to call up() or down() which will make the sem count inconsistent as soon as the interrupted down() or up() is resumed.

Quoted 2 lines

So afaik, Linux simply doesn't support pre-ARMv6 in SMP configurations, and never has (and I'd assume never will).

Indeed.

Quoted 1 line

Or am I missing something?

I understand this thread is about simple mutex (locked/unlocked) vs full counting semaphores. And I'm presuming that we still care about best performances with pre-ARMv6 support, maybe even more than ARMv6 and above given the current deployment figures using Linux.

In that case, a simple mutex_lock implementation on pre-ARMv6 would look like this:

__lock:

	mov	r1, #1			@ 1 = lock flag
	swp	r2, r1, [r0]		@ lock the mutex, get current state
	cmp	r2, #0			@ was it unlocked?
	beq	__continue		@ if so we're done
	mov	r1, #2			@ 2 = contended lock
	swp	r2, r1, [r0]		@ upgrade the lock to contended
	cmp	r2, #0			@ was it unlocked in the mean time?
	beq	__continue		@ if so we just acquired the lock
	bl	__sleep			@ go to sleep
	b	__lock

__continue:

Here you can even have the 4 first instructions inline for the fast uncontended case and the rest out of line, making it much smaller than the counting semaphore implementation with the same inline property.

And for completeness, here's the mutex_unlock:

__unlock:

	mov	r1, #0			@ 0 = unlocked
	swp	r2, r1, [r0]		@ unlock mutex, get current state
	cmp	r2, #2			@ was it contended?
	bleq	__wake			@ if so call wake_up

And the mutex_trylock is trivial as well.

That's it. 4 inline instructions for locking, 4 inline instructions for unlocking, no disabling/enabling of interrupts needed any more.

Nicolas

#10 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 7 lines · Nicolas Pitre

Now if you don't disable interrupts then nothing prevents an interrupt handler, or another thread if kernel preemption is allowed, to come along right between (2) and (4) to call up() or down() which will make the sem count inconsistent as soon as the interrupted down() or up() is resumed.

Well, the one thing that is preventing this is the fact that interrupts don't call up and down, since down can schedule. Now they might do a down_trylock, but then if it would succeed, it would most likely call the up. So the semaphore would be back to what it was before the interrupt took place.

But you do have a case about preemption.

-- Steve

#11 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

In reply to Nicolas Pitre
Quoted 3 lines · Nicolas Pitre

Now if you don't disable interrupts then nothing prevents an interrupt handler, or another thread if kernel preemption is allowed

Preemption, yes. Interrupts no.

Quoted 4 lines

to come
along right between (2) and (4) to call up() or down() which will make the sem count inconsistent as soon as the interrupted down() or up() is resumed.

An interrupt can never change the value without changing it back, except for the old-fashioned use of "up()" as a completion (which I don't think we do any more - we used to do it for IO completion a looong time ago).

So I think the interrupt disable could be removed for UP, at least for non-preemption.

(Of course, maybe it's not worth it. It might not be a big performance issue).

Linus

#12 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 3 lines · Linus Torvalds

An interrupt can never change the value without changing it back, except for the old-fashioned use of "up()" as a completion (which I don't think we do any more - we used to do it for IO completion a looong time ago).

I doubt you can guarantee that statement, or has the kernel source been audited for this recently?

However, the real consideration is stability - if a semaphore was used for a completion and it was merged, would it be found and fixed? Probably not, because it won't cause any problems on architectures where semaphores have atomic properties. Unless of course sparse can be extended to detect the use of unbalanced semaphores in interrupt contexts.

Quoted 2 lines

(Of course, maybe it's not worth it. It might not be a big performance issue).

Balancing the elimination of 4 instructions per semaphore operation, totalling about 4 to 6 cycles, vs stability I'd go for stability unless we can prove the above assertion via (eg) sparse.

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
#13 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 8 lines · Russell King
Quoted 3 lines · Linus Torvalds

An interrupt can never change the value without changing it back, except for the old-fashioned use of "up()" as a completion (which I don't think we do any more - we used to do it for IO completion a looong time ago).

I doubt you can guarantee that statement, or has the kernel source been audited for this recently?

Well, _if_ it's a noticeable performance win, we should just do it. We already know that people don't call "down()" in interrupts (it just wouldn't work), we can instrument "up()" too.

It's easy enough to add a "might_sleep()" to the up(). Not strictly true, but conceptually it would make sense to make up/down match in that sense. We'd have to mark the (few) places that do down_trylock() + up() in interrupt context with a special "up_in_interrupt()", but that would be ok even from a documentation standpoint.

Quoted 4 lines

However, the real consideration is stability - if a semaphore was used for a completion and it was merged, would it be found and fixed? Probably not, because it won't cause any problems on architectures where semaphores have atomic properties.

Actually, the reason we have completions is that using semaphores as completions caused some really subtle problems that had nothing to do with atomicity of the operations themselves, so if you find somebody who uses a semaphore from an interrupt, I think we want to know about it.

Completions actually have another - and more important - property than the fact that they have a more logical name for a particular usage.

The completion has "don't touch me" guarantees. A thread or interrupt that does an "up()" on a semaphore may still touch the memory that was allocated for the semaphore after the "down()" part has been released. And THAT was the reason for the completions: we allocate them on the stack or in temporary allocations, and the thing that does the "down()" to wait for something to finish will also do the _release_ of the memory.

With semaphores, that caused problems, because the side doing the "up()" would thus possibly touch memory that got released from under it.

This problem happens only on SMP (since you need to have the downer and the upper running at the same time), but it's totally independent of the other atomicity issues. And almost any semaphore that is used as a completion from an interrupt will have this problem, so yes, if you find somebody doing an "up()" in interrupt context, we'll fix it.

It would be good to make the rules clear, that you can never touch a semaphore from irq context without changing it back before you return.

Of course, that still leaves the following sequence

	if (!down_trylock(..)) {
		... do something ..
		up(..);
	}

which is actually used from interrupts too. At least the console layer does that (printk() can happen from interrupts, and we do a down_trylock on the console semaphore. But that one shouldn't mess with the _count_, although it does mean that the wait-queue preparation etc (for when the fast case fails) does still need to be protected against interrupts.

But that would be the slow case, so from a performance standpoint, it would still allow the case that really _matters_ to be done with interrupts enabled.

Quoted 2 lines

Unless of course sparse can be extended to detect the use of unbalanced semaphores in interrupt contexts.

In theory, yes, but in practice I'd much rather just do the stupid brute force things.

Quoted 6 lines
Quoted 2 lines

(Of course, maybe it's not worth it. It might not be a big performance issue).

Balancing the elimination of 4 instructions per semaphore operation, totalling about 4 to 6 cycles, vs stability I'd go for stability unless we can prove the above assertion via (eg) sparse.

I agree, if arm interrupt disables are fast. For example, on x86 (where this isn't needed, because you can have an "interrupt-safe" decrement by just having it as a single instruction, even if it isn't SMP-safe), disabling and re-enabling interrupts is just one instruction each, but the combination is usually something like 50+ cycles. So if this was an issue on x86, we'd definitely care.

But if you don't think it's a big issue on ARM, it just doesn't matter.

Linus

#14 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 5 lines · Linus Torvalds

It's easy enough to add a "might_sleep()" to the up(). Not strictly true, but conceptually it would make sense to make up/down match in that sense. We'd have to mark the (few) places that do down_trylock() + up() in interrupt context with a special "up_in_interrupt()", but that would be ok even from a documentation standpoint.

Actually, I don't think you want might_sleep(): there are a few cases where we do an up() from under a spinlock, which will spuriously trigger this. I'd suggest WARN_ON(in_interrupt()) instead.

James

#15 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 4 lines · James Bottomley

Actually, I don't think you want might_sleep(): there are a few cases where we do an up() from under a spinlock, which will spuriously trigger this. I'd suggest WARN_ON(in_interrupt()) instead.

Ahh, good point. Yes.

However, if even the arm people aren't all that interested in this, maybe it simply doesn't matter. A lot of other architectures either have "decrement in memory" or can already use ll/sc for it.

(of course, on some architectures, ll/sc is really really slow, so they might well prefer using a normal load and store instead).

Linus

#16 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

In reply to Linus Torvalds
Quoted 9 lines · Linus Torvalds
Quoted 6 lines · Russell King
Quoted 3 lines · Linus Torvalds

An interrupt can never change the value without changing it back, except for the old-fashioned use of "up()" as a completion (which I don't think we do any more - we used to do it for IO completion a looong time ago).

Quoted 6 lines
Quoted 2 lines

I doubt you can guarantee that statement, or has the kernel source been audited for this recently?

Well, _if_ it's a noticeable performance win, we should just do it. We already know that people don't call "down()" in interrupts (it just wouldn't work), we can instrument "up()" too.

And how would that prevent the kernel preemption issue?

Quoted 4 lines
Quoted 3 lines

Balancing the elimination of 4 instructions per semaphore operation, totalling about 4 to 6 cycles, vs stability I'd go for stability unless we can prove the above assertion via (eg) sparse.

Quoted 8 lines

I agree, if arm interrupt disables are fast. For example, on x86 (where this isn't needed, because you can have an "interrupt-safe" decrement by just having it as a single instruction, even if it isn't SMP-safe), disabling and re-enabling interrupts is just one instruction each, but the combination is usually something like 50+ cycles. So if this was an issue on x86, we'd definitely care.

But if you don't think it's a big issue on ARM, it just doesn't matter.

Let's see. The core of the uncontended down() on ARM looks like this:

	mrs     r0, cpsr
	orr     r1, r0, #128
	msr     cpsr_c, r1
	ldr     r1, [%0]
	subs     r1, r1, #1
	str     r1, [%0]
	msr     cpsr_c, r0
	blt	__contention

On a 624MHz ARMv5 processor I can execute this sequence approximately 266100 times in 10 ms, which means approx 23 cycles. The uncontended up() is the same except the sub is replaced by an add.

Removing the interrupt masking/unmasking reduces the above sequence to 4 instructions using 6 cycles. However it becomes completely unsafe wrt usage of up() from interrupt handlers, and it is completely preemption unsafe.

Now if we consider simple mutexes, the core of it becomes this on ARM:

	mov	r0, #1
	swp	r1, r0, [%0]
	cmp	r1, #0
	bne	__contention

The above takes 8 cycles. It uses 4 instructions, and it could even be reduced to 3 when gcc's cse optimization can find a register that already contains the value 1 (then using only 7 cycles). It is interrupt safe. It is preemption safe. It is small.

So if you think ARM is important, and if you consider the above a good enough improvement (I do), then that should talk in favor of simple mutexes for the kernel. And it will have the nice side effect of making it easier on some other more obscur architectures.

Nicolas

#17 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 21 lines · Nicolas Pitre
Quoted 8 lines · Linus Torvalds

I agree, if arm interrupt disables are fast. For example, on x86 (where this isn't needed, because you can have an "interrupt-safe" decrement by just having it as a single instruction, even if it isn't SMP-safe), disabling and re-enabling interrupts is just one instruction each, but the combination is usually something like 50+ cycles. So if this was an issue on x86, we'd definitely care.

But if you don't think it's a big issue on ARM, it just doesn't matter.

Let's see. The core of the uncontended down() on ARM looks like this:

	mrs     r0, cpsr
	orr     r1, r0, #128
	msr     cpsr_c, r1
	ldr     r1, [%0]
	subs     r1, r1, #1
	str     r1, [%0]
	msr     cpsr_c, r0
	blt	__contention
Quoted 6 lines

On a 624MHz ARMv5 processor I can execute this sequence approximately 266100 times in 10 ms, which means approx 23 cycles. The uncontended up() is the same except the sub is replaced by an add.

Removing the interrupt masking/unmasking reduces the above sequence to 4 instructions using 6 cycles.

I think you're comparing applies with oranges here - you measured the above function by executing it, and the reduced version by some other method (you appear to be absolutely certain that it's 6 cycles, but the previous was approximate).

Quoted 11 lines

Now if we consider simple mutexes, the core of it becomes this on ARM:

	mov	r0, #1
	swp	r1, r0, [%0]
	cmp	r1, #0
	bne	__contention

The above takes 8 cycles. It uses 4 instructions, and it could even be reduced to 3 when gcc's cse optimization can find a register that already contains the value 1 (then using only 7 cycles). It is interrupt safe. It is preemption safe. It is small.

That's over-simplified, and is the easy bit. Now work out how you handle the unlock operation.

You don't know whether the lock is contended or not in the unlock path, so you always have to do the "wake up" thing. (You can't rely on the value of the lock since another thread may well be between this swp instruction and entering the __contention function. Hence you can't use the value of the lock to determine whether there's anyone sleeping on it.)

Therefore, I suspect that while the lock may be faster, the unlock won't be.

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
#18 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 8 lines · Russell King
Quoted 4 lines
	mov	r0, #1
	swp	r1, r0, [%0]
	cmp	r1, #0
	bne	__contention

That's over-simplified, and is the easy bit. Now work out how you handle the unlock operation.

Quoted 6 lines

You don't know whether the lock is contended or not in the unlock path, so you always have to do the "wake up" thing. (You can't rely on the value of the lock since another thread may well be between this swp instruction and entering the __contention function. Hence you can't use the value of the lock to determine whether there's anyone sleeping on it.)

Here's a slightly less efficient way to determine if anyone else has swp'd behind your back (apologies if I get my ARM assembly wrong, it's been a few years):

	swp	r1, r13, [%0]	# load r1 from addr and store r13 there
	cmp	r1, #0		# is r1 0?
	streq	r13, [%0, #4]	# if it is, store a copy of r13 at the
				# next address
	blne	__lock_contention

I'm assuming that r13 (the stack pointer) will be different for each task, and (with this being a mutex), we won't try to double-acquire it. Unlock is then:

	mov	r0, #0		# put 0 in r0
	swp	r1, r0, [%0]	# release the lock
	ldr	r0, [%0, #4]	# load the copy
	cmp	r0, r1		# did it change?
	blne	__unlock_contention

In __unlock_contention, thread1 would try to re-acquire the mutex (at [%0]), and if it does, wake up the first waiter. Obviously it's unfair as thread3 could come along and grab the mutex, but that's not a huge deal.

Note that we're not checking the value of r13 at the unlock site as lock and unlock can be done at different stack levels. We're checking to see if the value last written to the lock was the one by the successful acquirer.

#19 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 16 lines · Matthew Wilcox
Quoted 8 lines · Russell King
Quoted 4 lines
	mov	r0, #1
	swp	r1, r0, [%0]
	cmp	r1, #0
	bne	__contention

That's over-simplified, and is the easy bit. Now work out how you handle the unlock operation.

Quoted 6 lines

You don't know whether the lock is contended or not in the unlock path, so you always have to do the "wake up" thing. (You can't rely on the value of the lock since another thread may well be between this swp instruction and entering the __contention function. Hence you can't use the value of the lock to determine whether there's anyone sleeping on it.)

Quoted 3 lines

Here's a slightly less efficient way to determine if anyone else has swp'd behind your back (apologies if I get my ARM assembly wrong, it's been a few years):

No need to be less efficient. See the mail I just sent with additional details.

Nicolas

#20 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

In reply to Russell King
Quoted 26 lines · Russell King
Quoted 25 lines · Nicolas Pitre
Quoted 8 lines · Linus Torvalds

I agree, if arm interrupt disables are fast. For example, on x86 (where this isn't needed, because you can have an "interrupt-safe" decrement by just having it as a single instruction, even if it isn't SMP-safe), disabling and re-enabling interrupts is just one instruction each, but the combination is usually something like 50+ cycles. So if this was an issue on x86, we'd definitely care.

But if you don't think it's a big issue on ARM, it just doesn't matter.

Let's see. The core of the uncontended down() on ARM looks like this:

	mrs     r0, cpsr
	orr     r1, r0, #128
	msr     cpsr_c, r1
	ldr     r1, [%0]
	subs     r1, r1, #1
	str     r1, [%0]
	msr     cpsr_c, r0
	blt	__contention

On a 624MHz ARMv5 processor I can execute this sequence approximately 266100 times in 10 ms, which means approx 23 cycles. The uncontended up() is the same except the sub is replaced by an add.

Quoted 7 lines
Quoted 2 lines

Removing the interrupt masking/unmasking reduces the above sequence to 4 instructions using 6 cycles.

I think you're comparing applies with oranges here - you measured the above function by executing it, and the reduced version by some other method (you appear to be absolutely certain that it's 6 cycles, but the previous was approximate).

They were _all_ measured execution times (I learned not to trust the manual for those). Here's the boring details in case you didn't trust me:

The above 6 cycles was deduced from executing the given sequence of instructions 1014100 times within 10 ms at 624 MHz.

Quoted 11 lines
Quoted 11 lines

Now if we consider simple mutexes, the core of it becomes this on ARM:

	mov	r0, #1
	swp	r1, r0, [%0]
	cmp	r1, #0
	bne	__contention

The above takes 8 cycles. It uses 4 instructions, and it could even be reduced to 3 when gcc's cse optimization can find a register that already contains the value 1 (then using only 7 cycles). It is interrupt safe. It is preemption safe. It is small.

And for completeness: 762700 times within 10 ms at 624 MHz.

Quoted 2 lines

That's over-simplified, and is the easy bit. Now work out how you handle the unlock operation.

I exposed that in a previous post in this thread already.

Quoted 6 lines

You don't know whether the lock is contended or not in the unlock path, so you always have to do the "wake up" thing. (You can't rely on the value of the lock since another thread may well be between this swp instruction and entering the __contention function. Hence you can't use the value of the lock to determine whether there's anyone sleeping on it.)

No. For simplicity in this mail I only provided the inline portion of the mutex. Let me provide again the __contention part which should be out of line:

__contention:

	mov	r0, #2			@ 2 = contended lock flag
	swp	r1, r0, [%0]		@ upgrade the lock, get current value
	cmp	r1, #0			@ has it just been unlocked?
	moveq	pc, lr			@ if so we now own it.
	stmfd	sp!, {r2, r3, ip, lr}	@ save whatever regs (needs %0 too)
	bl	__sleep
	ldmfd	sp!, {r2, r3, ip, lr}
	mov	r0, #1			@ try to lock again
	swp	r1, r0, [%0]		@ and get current state
	cmp	r1, #0			@ if it was locked again
	bne	__contention		@ then we loop again
	mov	pc, lr			@ otherwise we own it at last

Note that it needs task state and wait queue handling added which means that part should probably have a C helper like the current semaphore implementation. But you should have the basic idea now.

Quoted 2 lines

Therefore, I suspect that while the lock may be faster, the unlock won't be.

Not at all. The inlined unlock goes like this:

	mov	r0, #0			@ 0 = unlock flag
	swp	r1, r0, [%0]		@ unlock and get current state
	cmp	r1, #2			@ was it contended?
	bleq	__wake_up		@ if so wake up one thread

Again 4 instructions (possibly 3 if cse is possible) and therefore with the same 7-8 cycle cost.

The only issue has to do with the fact that the lock might have been unlocked right before we go to upgrade it to contended. We already catch that case since by locking the mutex with the contended flag we effectively own it at that point. But then a superfluous wake-up will be done even if there is no contention anymore. But as you see this kind of false contention is harmless and should be extremely rare (the window for it is really small).

Nicolas

#21 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

In reply to Linus Torvalds
Quoted 9 lines · Linus Torvalds
Quoted 3 lines · Nicolas Pitre

Now if you don't disable interrupts then nothing prevents an interrupt handler, or another thread if kernel preemption is allowed

Preemption, yes. Interrupts no.

Quoted 8 lines
Quoted 4 lines

to come
along right between (2) and (4) to call up() or down() which will make the sem count inconsistent as soon as the interrupted down() or up() is resumed.

An interrupt can never change the value without changing it back, except for the old-fashioned use of "up()" as a completion (which I don't think we do any more - we used to do it for IO completion a looong time ago).

Maybe, but I would not bet anything on that statement. I'm sure there are people still using semaphores for IO completion, calling up() from interrupt handlers. And the fact is that it still works fine.

Quoted 2 lines

So I think the interrupt disable could be removed for UP, at least for non-preemption.

This is IMHO too fragile and too easy to screw up. And it puts extra conditions on the usage of semaphores that don't exist today.

This is why I think spliting counting semaphores and mutexes _is_ a good thing. There is no special "no from interrupt" issue to care about with the unlock operation, it has better performances where the count is not important (the vast majority of all semaphores) and it produces even smaller code (and we're all for smaller kernels, right?).

Nicolas

#22 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

In reply to Nicolas Pitre
Quoted 5 lines · Nicolas Pitre

out there. The other 99% of actual ARM processors in the field only have the atomic swap (swp) instruction which is insufficient for implementing a counting semaphore (we therefore have to disable interrupts, do the semaphore update and enable interrupts again which is much slower than a swp-based mutex).

There are other approaches depending on how your CPU behaves and the probability of splitting an "atomic operation" including checking the return address range in the IRQ handler and ifs its in the 'atomic ops' page jumping to a recovery function. If you are sneaky in how you lay out your virtual address space it becomes a single unconditional or on kernel->kernel interrupt returns.

#23 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 7 lines · Alan Cox
Quoted 5 lines · Nicolas Pitre

out there. The other 99% of actual ARM processors in the field only have the atomic swap (swp) instruction which is insufficient for implementing a counting semaphore (we therefore have to disable interrupts, do the semaphore update and enable interrupts again which is much slower than a swp-based mutex).

Quoted 6 lines

There are other approaches depending on how your CPU behaves and the probability of splitting an "atomic operation" including checking the return address range in the IRQ handler and ifs its in the 'atomic ops' page jumping to a recovery function. If you are sneaky in how you lay out your virtual address space it becomes a single unconditional or on kernel->kernel interrupt returns.

Well we sort of do something similar to implement cmpxchg for NPTL usage from user space (forcing the abortion of the operation if an interrupt happens in the middle of it). But it's more hassle to do in kernel space.

Nicolas

#24 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

In reply to Steven Rostedt
Quoted 4 lines · Steven Rostedt
Quoted 2 lines · David Howells

This patch set does the following:

Quoted 9 lines
Quoted 3 lines

(1) Renames DECLARE_MUTEX and DECLARE_MUTEX_LOCKED to be DECLARE_SEM_MUTEX and DECLARE_SEM_MUTEX_LOCKED for counting semaphores.

Could we really get rid of that "MUTEX" part. A counting semaphore is _not_ a mutex, although a mutex _is_ a counting semaphore. As is a Jack Russell is a dog, but a dog is not a Jack Russell.

Really?

A Jack Russell is a dog because anything you say about a dog can also be said about a Jack Russell.

A counting semaphore is a mutex for the same reason (and observe that 99% of users use the semaphore as a mutex). A mutex definitely is not a counting semaphore. David's implementation of mutexes don't count at all.

If you want to use a semaphore as a mutex, DECLARE_SEM_MUTEX isn't a terrible name.

Signature · 3 lines
SUSE Labs, Novell Inc.

Send instant messages to your online friends http://au.messenger.yahoo.com 
#25 lore raw

Re: [PATCH 1/12]: MUTEX: Implement mutexes

Quoted 15 lines · Nick Piggin
Quoted 4 lines · Steven Rostedt
Quoted 2 lines · David Howells

This patch set does the following:

Quoted 9 lines
Quoted 3 lines

(1) Renames DECLARE_MUTEX and DECLARE_MUTEX_LOCKED to be DECLARE_SEM_MUTEX and DECLARE_SEM_MUTEX_LOCKED for counting semaphores.

Could we really get rid of that "MUTEX" part. A counting semaphore is _not_ a mutex, although a mutex _is_ a counting semaphore. As is a Jack Russell is a dog, but a dog is not a Jack Russell.

Quoted 4 lines

Really?

A Jack Russell is a dog because anything you say about a dog can also be said about a Jack Russell.

I said a Jack Russell _is_ a dog, but a dog is not a Jack Russell. Everything you can say about a dog you can't say about a Jack Russell. Since, a dog can have other characteristics than a Jack Russell has. A dog can be big and lazy, but I would not say that about a Jack Russell.

Quoted 5 lines

A counting semaphore is a mutex for the same reason (and observe that 99% of users use the semaphore as a mutex). A mutex definitely is not a counting semaphore. David's implementation of mutexes don't count at all.

But a counting semaphore of (one) _is_ a mutex! But a mutex can't have
more than one. As for David's code, that's just arguing implementation,
and not the semantics of it.

-- Steve

author maintainer
#26 lore raw

PATCH 2/12 : MUTEX: Provide SWAP-based mutex for FRV

In reply to David Howells

The attached patch permits the FRV architecture to make use of the xchg() based mutex, overriding the use of xchg() with something based on the FRV SWAP/SWAPI atomic op instructions. Note that xchg() in FRV is not actually based on SWAP/SWAPI at the moment.

The patch also renames DECLARE_MUTEX*() for this arch to DECLARE_SEM_MUTEX*().

---
warthog>diffstat -p1 mutex-frv-2615rc5-2.diff

 arch/frv/Kconfig         |    4 ++++
 arch/frv/kernel/irq.c    |    2 +-
 include/asm-frv/system.h |   19 +++++++++++++++++++
 3 files changed, 24 insertions(+), 1 deletion(-)
arch/frv/Kconfig +4 -0
diff -uNrp linux-2.6.15-rc5/arch/frv/Kconfig linux-2.6.15-rc5-mutex/arch/frv/Kconfig
@@ -10,6 +10,10 @@ config UID16
 	bool
 	default y
 
+config ARCH_XCHG_MUTEX
+	bool
+	default y
+
 config RWSEM_GENERIC_SPINLOCK
 	bool
 	default y
include/asm-frv/system.h +19 -0
diff -uNrp linux-2.6.15-rc5/include/asm-frv/system.h linux-2.6.15-rc5-mutex/include/asm-frv/system.h
@@ -99,6 +99,25 @@ do {							\
 	((__get_PSR() & PSR_PIL) >= PSR_PIL_14)
 
 /*
+ * mutex implementation
+ */
+#define __mutex_trylock(mutex)					\
+({								\
+	int oldstate;						\
+								\
+	asm volatile("swap%I0 %M0,%1"				\
+		     : "+m"(mutex->state), "=r"(oldstate)	\
+		     : "1"(1)					\
+		     : "memory");				\
+								\
+	oldstate == 0;						\
+})
+
+#define __mutex_release(mutex)	do { (mutex)->state = 0; } while(0)
+
+#define mutex_is_locked(mutex)	((mutex)->state)
+
+/*
  * Force strict CPU ordering.
  */
 #define nop()			asm volatile ("nop"::)
arch/frv/kernel/irq.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/frv/kernel/irq.c linux-2.6.15-rc5-mutex/arch/frv/kernel/irq.c
@@ -503,7 +503,7 @@ void free_irq(unsigned int irq, void *de
  * unassigned IRQ will cause GxICR_DETECT to be set
  */
 
-static DECLARE_MUTEX(probe_sem);
+static DECLARE_SEM_MUTEX(probe_sem);
 
 /**
  *	probe_irq_on	- begin an interrupt autodetect
author maintainer
#27 lore raw

PATCH 3/12 : MUTEX: Rename DECLARE_MUTEX for arch/ dir

In reply to David Howells

The attached patch renames DECLARE_MUTEX*() to DECLARE_SEM_MUTEX*() for the rest of the arch/ directory.

---
warthog>diffstat -p1 mutex-arch-2615rc5-2.diff

 arch/arm/common/rtctime.c                    |    2 +-
 arch/arm/kernel/ecard.c                      |    2 +-
 arch/arm/kernel/irq.c                        |    2 +-
 arch/arm/mach-aaec2000/clock.c               |    2 +-
 arch/arm/mach-integrator/clock.c             |    2 +-
 arch/arm/mach-pxa/ssp.c                      |    2 +-
 arch/arm/mach-realview/clock.c               |    2 +-
 arch/arm/mach-s3c2410/clock.c                |    2 +-
 arch/arm/mach-versatile/clock.c              |    2 +-
 arch/arm/plat-omap/clock.c                   |    2 +-
 arch/arm26/kernel/traps.c                    |    2 +-
 arch/i386/kernel/cpu/cpufreq/powernow-k8.c   |    2 +-
 arch/i386/kernel/cpu/mtrr/main.c             |    2 +-
 arch/i386/kernel/microcode.c                 |    2 +-
 arch/i386/mach-voyager/voyager_thread.c      |    2 +-
 arch/ia64/hp/sim/simserial.c                 |    2 +-
 arch/ia64/ia32/sys_ia32.c                    |    2 +-
 arch/ia64/sn/kernel/mca.c                    |    2 +-
 arch/ia64/sn/kernel/sn2/sn_hwperf.c          |    2 +-
 arch/ia64/sn/kernel/xpc_main.c               |    4 ++--
 arch/mips/lasat/picvue.c                     |    2 +-
 arch/mips/lasat/sysctl.c                     |    2 +-
 arch/powerpc/kernel/kprobes.c                |    2 +-
 arch/powerpc/mm/imalloc.c                    |    2 +-
 arch/powerpc/platforms/iseries/viopath.c     |    2 +-
 arch/powerpc/platforms/powermac/cpufreq_64.c |    2 +-
 arch/ppc/4xx_io/serial_sicc.c                |    2 +-
 arch/ppc/syslib/mv64x60.c                    |    2 +-
 arch/s390/kernel/debug.c                     |    2 +-
 arch/um/drivers/port_kern.c                  |    2 +-
 arch/x86_64/Kconfig                          |    4 ++++
 arch/x86_64/kernel/kprobes.c                 |    2 +-
 arch/x86_64/kernel/mce.c                     |    2 +-
 33 files changed, 37 insertions(+), 33 deletions(-)
arch/arm/common/rtctime.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/arm/common/rtctime.c linux-2.6.15-rc5-mutex/arch/arm/common/rtctime.c
@@ -34,7 +34,7 @@ static unsigned long rtc_irq_data;
 /*
  * rtc_sem protects rtc_inuse and rtc_ops
  */
-static DECLARE_MUTEX(rtc_sem);
+static DECLARE_SEM_MUTEX(rtc_sem);
 static unsigned long rtc_inuse;
 static struct rtc_ops *rtc_ops;
 
arch/arm/kernel/ecard.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/arm/kernel/ecard.c linux-2.6.15-rc5-mutex/arch/arm/kernel/ecard.c
@@ -206,7 +206,7 @@ static void ecard_task_readbytes(struct 
 
 static DECLARE_WAIT_QUEUE_HEAD(ecard_wait);
 static struct ecard_request *ecard_req;
-static DECLARE_MUTEX(ecard_sem);
+static DECLARE_SEM_MUTEX(ecard_sem);
 
 /*
  * Set up the expansion card daemon's page tables.
arch/arm/kernel/irq.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/arm/kernel/irq.c linux-2.6.15-rc5-mutex/arch/arm/kernel/irq.c
@@ -821,7 +821,7 @@ void free_irq(unsigned int irq, void *de
 
 EXPORT_SYMBOL(free_irq);
 
-static DECLARE_MUTEX(probe_sem);
+static DECLARE_SEM_MUTEX(probe_sem);
 
 /* Start the interrupt probing.  Unlike other architectures,
  * we don't return a mask of interrupts from probe_irq_on,
arch/arm/mach-aaec2000/clock.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/arm/mach-aaec2000/clock.c linux-2.6.15-rc5-mutex/arch/arm/mach-aaec2000/clock.c
@@ -22,7 +22,7 @@
 #include "clock.h"
 
 static LIST_HEAD(clocks);
-static DECLARE_MUTEX(clocks_sem);
+static DECLARE_SEM_MUTEX(clocks_sem);
 
 struct clk *clk_get(struct device *dev, const char *id)
 {
arch/arm/mach-integrator/clock.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/arm/mach-integrator/clock.c linux-2.6.15-rc5-mutex/arch/arm/mach-integrator/clock.c
@@ -22,7 +22,7 @@
 #include "clock.h"
 
 static LIST_HEAD(clocks);
-static DECLARE_MUTEX(clocks_sem);
+static DECLARE_SEM_MUTEX(clocks_sem);
 
 struct clk *clk_get(struct device *dev, const char *id)
 {
arch/arm/mach-pxa/ssp.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/arm/mach-pxa/ssp.c linux-2.6.15-rc5-mutex/arch/arm/mach-pxa/ssp.c
@@ -59,7 +59,7 @@ static const struct ssp_info_ ssp_info[P
 #endif
 };
 
-static DECLARE_MUTEX(sem);
+static DECLARE_SEM_MUTEX(sem);
 static int use_count[PXA_SSP_PORTS] = {0, 0, 0};
 
 static irqreturn_t ssp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
arch/arm/mach-realview/clock.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/arm/mach-realview/clock.c linux-2.6.15-rc5-mutex/arch/arm/mach-realview/clock.c
@@ -21,7 +21,7 @@
 #include "clock.h"
 
 static LIST_HEAD(clocks);
-static DECLARE_MUTEX(clocks_sem);
+static DECLARE_SEM_MUTEX(clocks_sem);
 
 struct clk *clk_get(struct device *dev, const char *id)
 {
arch/arm/mach-s3c2410/clock.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/arm/mach-s3c2410/clock.c linux-2.6.15-rc5-mutex/arch/arm/mach-s3c2410/clock.c
@@ -52,7 +52,7 @@
 /* clock information */
 
 static LIST_HEAD(clocks);
-static DECLARE_MUTEX(clocks_sem);
+static DECLARE_SEM_MUTEX(clocks_sem);
 
 /* old functions */
 
arch/arm/mach-versatile/clock.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/arm/mach-versatile/clock.c linux-2.6.15-rc5-mutex/arch/arm/mach-versatile/clock.c
@@ -22,7 +22,7 @@
 #include "clock.h"
 
 static LIST_HEAD(clocks);
-static DECLARE_MUTEX(clocks_sem);
+static DECLARE_SEM_MUTEX(clocks_sem);
 
 struct clk *clk_get(struct device *dev, const char *id)
 {
arch/arm/plat-omap/clock.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/arm/plat-omap/clock.c linux-2.6.15-rc5-mutex/arch/arm/plat-omap/clock.c
@@ -27,7 +27,7 @@
 #include <asm/arch/clock.h>
 
 LIST_HEAD(clocks);
-static DECLARE_MUTEX(clocks_sem);
+static DECLARE_SEM_MUTEX(clocks_sem);
 DEFINE_SPINLOCK(clockfw_lock);
 
 static struct clk_functions *arch_clock;
arch/arm26/kernel/traps.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/arm26/kernel/traps.c linux-2.6.15-rc5-mutex/arch/arm26/kernel/traps.c
@@ -207,7 +207,7 @@ void die_if_kernel(const char *str, stru
     	die(str, regs, err);
 }
 
-static DECLARE_MUTEX(undef_sem);
+static DECLARE_SEM_MUTEX(undef_sem);
 static int (*undef_hook)(struct pt_regs *);
 
 int request_undef_hook(int (*fn)(struct pt_regs *))
arch/i386/kernel/cpu/cpufreq/powernow-k8.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/i386/kernel/cpu/cpufreq/powernow-k8.c linux-2.6.15-rc5-mutex/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
@@ -49,7 +49,7 @@
 #include "powernow-k8.h"
 
 /* serialize freq changes  */
-static DECLARE_MUTEX(fidvid_sem);
+static DECLARE_SEM_MUTEX(fidvid_sem);
 
 static struct powernow_k8_data *powernow_data[NR_CPUS];
 
arch/i386/kernel/cpu/mtrr/main.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/i386/kernel/cpu/mtrr/main.c linux-2.6.15-rc5-mutex/arch/i386/kernel/cpu/mtrr/main.c
@@ -49,7 +49,7 @@
 u32 num_var_ranges = 0;
 
 unsigned int *usage_table;
-static DECLARE_MUTEX(main_lock);
+static DECLARE_SEM_MUTEX(main_lock);
 
 u32 size_or_mask, size_and_mask;
 
arch/i386/kernel/microcode.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/i386/kernel/microcode.c linux-2.6.15-rc5-mutex/arch/i386/kernel/microcode.c
@@ -112,7 +112,7 @@ MODULE_LICENSE("GPL");
 static DEFINE_SPINLOCK(microcode_update_lock);
 
 /* no concurrent ->write()s are allowed on /dev/cpu/microcode */
-static DECLARE_MUTEX(microcode_sem);
+static DECLARE_SEM_MUTEX(microcode_sem);
 
 static void __user *user_buffer;	/* user area microcode data buffer */
 static unsigned int user_buffer_size;	/* it's size */
arch/i386/mach-voyager/voyager_thread.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/i386/mach-voyager/voyager_thread.c linux-2.6.15-rc5-mutex/arch/i386/mach-voyager/voyager_thread.c
@@ -35,7 +35,7 @@
 
 /* external variables */
 int kvoyagerd_running = 0;
-DECLARE_MUTEX_LOCKED(kvoyagerd_sem);
+DECLARE_SEM_MUTEX_LOCKED(kvoyagerd_sem);
 
 static int thread(void *);
 
arch/ia64/hp/sim/simserial.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/ia64/hp/sim/simserial.c linux-2.6.15-rc5-mutex/arch/ia64/hp/sim/simserial.c
@@ -107,7 +107,7 @@ static struct async_struct *IRQ_ports[NR
 static struct console *console;
 
 static unsigned char *tmp_buf;
-static DECLARE_MUTEX(tmp_buf_sem);
+static DECLARE_SEM_MUTEX(tmp_buf_sem);
 
 extern struct console *console_drivers; /* from kernel/printk.c */
 
arch/ia64/ia32/sys_ia32.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/ia64/ia32/sys_ia32.c linux-2.6.15-rc5-mutex/arch/ia64/ia32/sys_ia32.c
@@ -85,7 +85,7 @@
  * while doing so.
  */
 /* XXX make per-mm: */
-static DECLARE_MUTEX(ia32_mmap_sem);
+static DECLARE_SEM_MUTEX(ia32_mmap_sem);
 
 asmlinkage long
 sys32_execve (char __user *name, compat_uptr_t __user *argv, compat_uptr_t __user *envp,
arch/ia64/sn/kernel/mca.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/ia64/sn/kernel/mca.c linux-2.6.15-rc5-mutex/arch/ia64/sn/kernel/mca.c
@@ -27,7 +27,7 @@ void sn_init_cpei_timer(void);
 /* Printing oemdata from mca uses data that is not passed through SAL, it is
  * global.  Only one user at a time.
  */
-static DECLARE_MUTEX(sn_oemdata_mutex);
+static DECLARE_SEM_MUTEX(sn_oemdata_mutex);
 static u8 **sn_oemdata;
 static u64 *sn_oemdata_size, sn_oemdata_bufsize;
 
arch/ia64/sn/kernel/sn2/sn_hwperf.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/ia64/sn/kernel/sn2/sn_hwperf.c linux-2.6.15-rc5-mutex/arch/ia64/sn/kernel/sn2/sn_hwperf.c
@@ -49,7 +49,7 @@ static void *sn_hwperf_salheap = NULL;
 static int sn_hwperf_obj_cnt = 0;
 static nasid_t sn_hwperf_master_nasid = INVALID_NASID;
 static int sn_hwperf_init(void);
-static DECLARE_MUTEX(sn_hwperf_init_mutex);
+static DECLARE_SEM_MUTEX(sn_hwperf_init_mutex);
 
 static int sn_hwperf_enum_objects(int *nobj, struct sn_hwperf_object_info **ret)
 {
arch/ia64/sn/kernel/xpc_main.c +2 -2
diff -uNrp linux-2.6.15-rc5/arch/ia64/sn/kernel/xpc_main.c linux-2.6.15-rc5-mutex/arch/ia64/sn/kernel/xpc_main.c
@@ -172,10 +172,10 @@ static DECLARE_WAIT_QUEUE_HEAD(xpc_act_I
 static unsigned long xpc_hb_check_timeout;
 
 /* notification that the xpc_hb_checker thread has exited */
-static DECLARE_MUTEX_LOCKED(xpc_hb_checker_exited);
+static DECLARE_SEM_MUTEX_LOCKED(xpc_hb_checker_exited);
 
 /* notification that the xpc_discovery thread has exited */
-static DECLARE_MUTEX_LOCKED(xpc_discovery_exited);
+static DECLARE_SEM_MUTEX_LOCKED(xpc_discovery_exited);
 
 
 static struct timer_list xpc_hb_timer;
arch/mips/lasat/picvue.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/mips/lasat/picvue.c linux-2.6.15-rc5-mutex/arch/mips/lasat/picvue.c
@@ -22,7 +22,7 @@
 
 struct pvc_defs *picvue = NULL;
 
-DECLARE_MUTEX(pvc_sem);
+DECLARE_SEM_MUTEX(pvc_sem);
 
 static void pvc_reg_write(u32 val)
 {
arch/mips/lasat/sysctl.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/mips/lasat/sysctl.c linux-2.6.15-rc5-mutex/arch/mips/lasat/sysctl.c
@@ -35,7 +35,7 @@
 #include "sysctl.h"
 #include "ds1603.h"
 
-static DECLARE_MUTEX(lasat_info_sem);
+static DECLARE_SEM_MUTEX(lasat_info_sem);
 
 /* Strategy function to write EEPROM after changing string entry */
 int sysctl_lasatstring(ctl_table *table, int *name, int nlen,
arch/powerpc/kernel/kprobes.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/powerpc/kernel/kprobes.c linux-2.6.15-rc5-mutex/arch/powerpc/kernel/kprobes.c
@@ -35,7 +35,7 @@
 #include <asm/kdebug.h>
 #include <asm/sstep.h>
 
-static DECLARE_MUTEX(kprobe_mutex);
+static DECLARE_SEM_MUTEX(kprobe_mutex);
 DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
 DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
 
arch/powerpc/mm/imalloc.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/powerpc/mm/imalloc.c linux-2.6.15-rc5-mutex/arch/powerpc/mm/imalloc.c
@@ -18,7 +18,7 @@
 
 #include "mmu_decl.h"
 
-static DECLARE_MUTEX(imlist_sem);
+static DECLARE_SEM_MUTEX(imlist_sem);
 struct vm_struct * imlist = NULL;
 
 static int get_free_im_addr(unsigned long size, unsigned long *im_addr)
arch/powerpc/platforms/iseries/viopath.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/powerpc/platforms/iseries/viopath.c linux-2.6.15-rc5-mutex/arch/powerpc/platforms/iseries/viopath.c
@@ -115,7 +115,7 @@ static int proc_viopath_show(struct seq_
 	u16 vlanMap;
 	dma_addr_t handle;
 	HvLpEvent_Rc hvrc;
-	DECLARE_MUTEX_LOCKED(Semaphore);
+	DECLARE_SEM_MUTEX_LOCKED(Semaphore);
 
 	buf = kmalloc(HW_PAGE_SIZE, GFP_KERNEL);
 	if (!buf)
arch/powerpc/platforms/powermac/cpufreq_64.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/powerpc/platforms/powermac/cpufreq_64.c linux-2.6.15-rc5-mutex/arch/powerpc/platforms/powermac/cpufreq_64.c
@@ -85,7 +85,7 @@ static u32 *g5_pmode_data;
 static int g5_pmode_max;
 static int g5_pmode_cur;
 
-static DECLARE_MUTEX(g5_switch_mutex);
+static DECLARE_SEM_MUTEX(g5_switch_mutex);
 
 
 static struct smu_sdbp_fvt *g5_fvt_table;	/* table of op. points */
arch/ppc/4xx_io/serial_sicc.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/ppc/4xx_io/serial_sicc.c linux-2.6.15-rc5-mutex/arch/ppc/4xx_io/serial_sicc.c
@@ -214,7 +214,7 @@ static struct tty_driver *siccnormal_dri
  * memory if large numbers of serial ports are open.
  */
 static u_char *tmp_buf;
-static DECLARE_MUTEX(tmp_buf_sem);
+static DECLARE_SEM_MUTEX(tmp_buf_sem);
 
 #define HIGH_BITS_OFFSET    ((sizeof(long)-sizeof(int))*8)
 
arch/ppc/syslib/mv64x60.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/ppc/syslib/mv64x60.c linux-2.6.15-rc5-mutex/arch/ppc/syslib/mv64x60.c
@@ -2355,7 +2355,7 @@ mv64460_chip_specific_init(struct mv64x6
 /* Export the hotswap register via sysfs for enum event monitoring */
 #define	VAL_LEN_MAX	11 /* 32-bit hex or dec stringified number + '\n' */
 
-DECLARE_MUTEX(mv64xxx_hs_lock);
+DECLARE_SEM_MUTEX(mv64xxx_hs_lock);
 
 static ssize_t
 mv64xxx_hs_reg_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
arch/s390/kernel/debug.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/s390/kernel/debug.c linux-2.6.15-rc5-mutex/arch/s390/kernel/debug.c
@@ -164,7 +164,7 @@ unsigned int debug_feature_version = __D
 
 static debug_info_t *debug_area_first = NULL;
 static debug_info_t *debug_area_last = NULL;
-DECLARE_MUTEX(debug_lock);
+DECLARE_SEM_MUTEX(debug_lock);
 
 static int initialized;
 
arch/um/drivers/port_kern.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/um/drivers/port_kern.c linux-2.6.15-rc5-mutex/arch/um/drivers/port_kern.c
@@ -129,7 +129,7 @@ static int port_accept(struct port_list 
 	return(ret);
 } 
 
-DECLARE_MUTEX(ports_sem);
+DECLARE_SEM_MUTEX(ports_sem);
 struct list_head ports = LIST_HEAD_INIT(ports);
 
 void port_work_proc(void *unused)
arch/x86_64/Kconfig +4 -0
diff -uNrp linux-2.6.15-rc5/arch/x86_64/Kconfig linux-2.6.15-rc5-mutex/arch/x86_64/Kconfig
@@ -28,6 +28,10 @@ config SEMAPHORE_SLEEPERS
 	bool
 	default y
 
+config ARCH_CMPXCHG_MUTEX
+	bool
+	default y
+
 config MMU
 	bool
 	default y
arch/x86_64/kernel/kprobes.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/x86_64/kernel/kprobes.c linux-2.6.15-rc5-mutex/arch/x86_64/kernel/kprobes.c
@@ -42,7 +42,7 @@
 #include <asm/pgtable.h>
 #include <asm/kdebug.h>
 
-static DECLARE_MUTEX(kprobe_mutex);
+static DECLARE_SEM_MUTEX(kprobe_mutex);
 void jprobe_return_end(void);
 
 DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
arch/x86_64/kernel/mce.c +1 -1
diff -uNrp linux-2.6.15-rc5/arch/x86_64/kernel/mce.c linux-2.6.15-rc5-mutex/arch/x86_64/kernel/mce.c
@@ -400,7 +400,7 @@ static void collect_tscs(void *data) 
 static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize, loff_t *off)
 {
 	unsigned long *cpu_tsc;
-	static DECLARE_MUTEX(mce_read_sem);
+	static DECLARE_SEM_MUTEX(mce_read_sem);
 	unsigned next;
 	char __user *buf = ubuf;
 	int i, err;
author maintainer
#28 lore raw

PATCH 4/12 : MUTEX: Rename DECLARE_MUTEX for drivers/ dir, A thru M

In reply to David Howells

The attached patch renames DECLARE_MUTEX*() to DECLARE_SEM_MUTEX*() for the drivers/ directory, subdirs A through M.

---
warthog>diffstat -p1 mutex-drivers-AtoM-2615rc5-2.diff

 drivers/acpi/pci_link.c                        |    2 +-
 drivers/acpi/processor_perflib.c               |    2 +-
 drivers/acpi/scan.c                            |    2 +-
 drivers/base/attribute_container.c             |    2 +-
 drivers/base/dmapool.c                         |    2 +-
 drivers/base/firmware_class.c                  |    2 +-
 drivers/base/power/main.c                      |    4 ++--
 drivers/base/sys.c                             |    2 +-
 drivers/block/floppy.c                         |    2 +-
 drivers/cdrom/cdu31a.c                         |    2 +-
 drivers/cdrom/sbpcd.c                          |    2 +-
 drivers/char/amiserial.c                       |    2 +-
 drivers/char/esp.c                             |    2 +-
 drivers/char/generic_serial.c                  |    2 +-
 drivers/char/ipmi/ipmi_watchdog.c              |    6 +++---
 drivers/char/isicom.c                          |    2 +-
 drivers/char/istallion.c                       |    2 +-
 drivers/char/misc.c                            |    2 +-
 drivers/char/nwflash.c                         |    2 +-
 drivers/char/raw.c                             |    2 +-
 drivers/char/riscom8.c                         |    2 +-
 drivers/char/serial167.c                       |    2 +-
 drivers/char/specialix.c                       |    2 +-
 drivers/char/stallion.c                        |    2 +-
 drivers/char/synclink.c                        |    2 +-
 drivers/char/tty_io.c                          |    4 ++--
 drivers/char/vt.c                              |    2 +-
 drivers/char/watchdog/pcwd_usb.c               |    2 +-
 drivers/char/watchdog/s3c2410_wdt.c            |    2 +-
 drivers/connector/connector.c                  |    2 +-
 drivers/cpufreq/cpufreq.c                      |    2 +-
 drivers/cpufreq/cpufreq_conservative.c         |    2 +-
 drivers/cpufreq/cpufreq_ondemand.c             |    2 +-
 drivers/cpufreq/cpufreq_userspace.c            |    2 +-
 drivers/fc4/fc.c                               |    2 +-
 drivers/firmware/dcdbas.c                      |    2 +-
 drivers/hwmon/hdaps.c                          |    2 +-
 drivers/i2c/busses/i2c-ali1535.c               |    2 +-
 drivers/i2c/chips/ds1374.c                     |    2 +-
 drivers/i2c/chips/m41t00.c                     |    2 +-
 drivers/i2c/i2c-core.c                         |    2 +-
 drivers/ide/ide-cd.c                           |    2 +-
 drivers/ide/ide-disk.c                         |    2 +-
 drivers/ide/ide-floppy.c                       |    2 +-
 drivers/ide/ide-tape.c                         |    2 +-
 drivers/ide/ide.c                              |    4 ++--
 drivers/ieee1394/hosts.c                       |    2 +-
 drivers/ieee1394/ieee1394_core.c               |    2 +-
 drivers/ieee1394/nodemgr.c                     |    2 +-
 drivers/infiniband/core/device.c               |    2 +-
 drivers/infiniband/core/ucm.c                  |    2 +-
 drivers/infiniband/core/uverbs_main.c          |    2 +-
 drivers/infiniband/ulp/ipoib/ipoib_ib.c        |    2 +-
 drivers/infiniband/ulp/ipoib/ipoib_multicast.c |    2 +-
 drivers/input/gameport/gameport.c              |    2 +-
 drivers/input/joystick/amijoy.c                |    2 +-
 drivers/input/mouse/psmouse-base.c             |    2 +-
 drivers/input/serio/serio.c                    |    2 +-
 drivers/input/serio/serio_raw.c                |    2 +-
 drivers/isdn/capi/kcapi.c                      |    2 +-
 drivers/macintosh/adb.c                        |    4 ++--
 drivers/macintosh/smu.c                        |    2 +-
 drivers/macintosh/therm_pm72.c                 |    2 +-
 drivers/macintosh/windfarm_core.c              |    2 +-
 drivers/md/dm-table.c                          |    2 +-
 drivers/md/dm.c                                |    2 +-
 drivers/md/kcopyd.c                            |    4 ++--
 drivers/md/md.c                                |    2 +-
 drivers/media/common/saa7146_core.c            |    2 +-
 drivers/media/dvb/dvb-core/dvb_frontend.c      |    2 +-
 drivers/media/dvb/dvb-core/dvbdev.c            |    2 +-
 drivers/media/video/cx88/cx88-core.c           |    2 +-
 drivers/media/video/em28xx/em28xx-video.c      |    2 +-
 drivers/media/video/saa7134/saa7134-core.c     |    2 +-
 drivers/media/video/saa7134/saa7134-tvaudio.c  |    2 +-
 drivers/media/video/videodev.c                 |    2 +-
 drivers/mfd/ucb1x00-core.c                     |    2 +-
 drivers/mmc/mmc_block.c                        |    2 +-
 drivers/mtd/devices/doc2000.c                  |    2 +-
 drivers/mtd/mtdcore.c                          |    2 +-
 80 files changed, 87 insertions(+), 87 deletions(-)
drivers/acpi/pci_link.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/acpi/pci_link.c linux-2.6.15-rc5-mutex/drivers/acpi/pci_link.c
@@ -91,7 +91,7 @@ static struct {
 	int count;
 	struct list_head entries;
 } acpi_link;
-DECLARE_MUTEX(acpi_link_lock);
+DECLARE_SEM_MUTEX(acpi_link_lock);
 
 /* --------------------------------------------------------------------------
                             PCI Link Device Management
drivers/acpi/processor_perflib.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/acpi/processor_perflib.c linux-2.6.15-rc5-mutex/drivers/acpi/processor_perflib.c
@@ -48,7 +48,7 @@
 #define _COMPONENT		ACPI_PROCESSOR_COMPONENT
 ACPI_MODULE_NAME("acpi_processor")
 
-static DECLARE_MUTEX(performance_sem);
+static DECLARE_SEM_MUTEX(performance_sem);
 
 /*
  * _PPC support is implemented as a CPUfreq policy notifier:
drivers/acpi/scan.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/acpi/scan.c linux-2.6.15-rc5-mutex/drivers/acpi/scan.c
@@ -472,7 +472,7 @@ static int acpi_bus_get_perf_flags(struc
    -------------------------------------------------------------------------- */
 
 static LIST_HEAD(acpi_bus_drivers);
-static DECLARE_MUTEX(acpi_bus_drivers_lock);
+static DECLARE_SEM_MUTEX(acpi_bus_drivers_lock);
 
 /**
  * acpi_bus_match 
drivers/base/attribute_container.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/base/attribute_container.c linux-2.6.15-rc5-mutex/drivers/base/attribute_container.c
@@ -62,7 +62,7 @@ EXPORT_SYMBOL_GPL(attribute_container_cl
 
 static struct list_head attribute_container_list;
 
-static DECLARE_MUTEX(attribute_container_mutex);
+static DECLARE_SEM_MUTEX(attribute_container_mutex);
 
 /**
  * attribute_container_register - register an attribute container
drivers/base/dmapool.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/base/dmapool.c linux-2.6.15-rc5-mutex/drivers/base/dmapool.c
@@ -38,7 +38,7 @@ struct dma_page {	/* cacheable header fo
 #define	POOL_POISON_FREED	0xa7	/* !inuse */
 #define	POOL_POISON_ALLOCATED	0xa9	/* !initted */
 
-static DECLARE_MUTEX (pools_lock);
+static DECLARE_SEM_MUTEX (pools_lock);
 
 static ssize_t
 show_pools (struct device *dev, struct device_attribute *attr, char *buf)
drivers/base/firmware_class.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/base/firmware_class.c linux-2.6.15-rc5-mutex/drivers/base/firmware_class.c
@@ -35,7 +35,7 @@ static int loading_timeout = 10;	/* In s
 
 /* fw_lock could be moved to 'struct firmware_priv' but since it is just
  * guarding for corner cases a global lock should be OK */
-static DECLARE_MUTEX(fw_lock);
+static DECLARE_SEM_MUTEX(fw_lock);
 
 struct firmware_priv {
 	char fw_id[FIRMWARE_NAME_MAX];
drivers/base/power/main.c +2 -2
diff -uNrp linux-2.6.15-rc5/drivers/base/power/main.c linux-2.6.15-rc5-mutex/drivers/base/power/main.c
@@ -27,8 +27,8 @@ LIST_HEAD(dpm_active);
 LIST_HEAD(dpm_off);
 LIST_HEAD(dpm_off_irq);
 
-DECLARE_MUTEX(dpm_sem);
-DECLARE_MUTEX(dpm_list_sem);
+DECLARE_SEM_MUTEX(dpm_sem);
+DECLARE_SEM_MUTEX(dpm_list_sem);
 
 /**
  *	device_pm_set_parent - Specify power dependency.
drivers/base/sys.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/base/sys.c linux-2.6.15-rc5-mutex/drivers/base/sys.c
@@ -104,7 +104,7 @@ EXPORT_SYMBOL_GPL(sysdev_class_unregiste
 
 
 static LIST_HEAD(sysdev_drivers);
-static DECLARE_MUTEX(sysdev_drivers_lock);
+static DECLARE_SEM_MUTEX(sysdev_drivers_lock);
 
 /**
  *	sysdev_driver_register - Register auxillary driver
drivers/block/floppy.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/block/floppy.c linux-2.6.15-rc5-mutex/drivers/block/floppy.c
@@ -414,7 +414,7 @@ static struct floppy_write_errors write_
 static struct timer_list motor_off_timer[N_DRIVE];
 static struct gendisk *disks[N_DRIVE];
 static struct block_device *opened_bdev[N_DRIVE];
-static DECLARE_MUTEX(open_lock);
+static DECLARE_SEM_MUTEX(open_lock);
 static struct floppy_raw_cmd *raw_cmd, default_raw_cmd;
 
 /*
drivers/cdrom/cdu31a.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/cdrom/cdu31a.c linux-2.6.15-rc5-mutex/drivers/cdrom/cdu31a.c
@@ -264,7 +264,7 @@ static int sony_toc_read = 0;	/* Has the
 static struct s_sony_subcode last_sony_subcode;	/* Points to the last
 						   subcode address read */
 
-static DECLARE_MUTEX(sony_sem);		/* Semaphore for drive hardware access */
+static DECLARE_SEM_MUTEX(sony_sem);		/* Semaphore for drive hardware access */
 
 static int is_double_speed = 0;	/* does the drive support double speed ? */
 
drivers/cdrom/sbpcd.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/cdrom/sbpcd.c linux-2.6.15-rc5-mutex/drivers/cdrom/sbpcd.c
@@ -598,7 +598,7 @@ static u_char xa_tail_buf[CD_XA_TAIL];
 static volatile u_char busy_data;
 static volatile u_char busy_audio; /* true semaphores would be safer */
 #endif /* OLD_BUSY */ 
-static DECLARE_MUTEX(ioctl_read_sem);
+static DECLARE_SEM_MUTEX(ioctl_read_sem);
 static u_long timeout;
 static volatile u_char timed_out_delay;
 static volatile u_char timed_out_data;
drivers/char/amiserial.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/amiserial.c linux-2.6.15-rc5-mutex/drivers/char/amiserial.c
@@ -128,7 +128,7 @@ static struct serial_state rs_table[1];
  * memory if large numbers of serial ports are open.
  */
 static unsigned char *tmp_buf;
-static DECLARE_MUTEX(tmp_buf_sem);
+static DECLARE_SEM_MUTEX(tmp_buf_sem);
 
 #include <asm/uaccess.h>
 
drivers/char/esp.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/esp.c linux-2.6.15-rc5-mutex/drivers/char/esp.c
@@ -160,7 +160,7 @@ static void rs_wait_until_sent(struct tt
  * memory if large numbers of serial ports are open.
  */
 static unsigned char *tmp_buf;
-static DECLARE_MUTEX(tmp_buf_sem);
+static DECLARE_SEM_MUTEX(tmp_buf_sem);
 
 static inline int serial_paranoia_check(struct esp_struct *info,
 					char *name, const char *routine)
drivers/char/generic_serial.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/generic_serial.c linux-2.6.15-rc5-mutex/drivers/char/generic_serial.c
@@ -34,7 +34,7 @@
 #define DEBUG 
 
 static char *                  tmp_buf; 
-static DECLARE_MUTEX(tmp_buf_sem);
+static DECLARE_SEM_MUTEX(tmp_buf_sem);
 
 static int gs_debug;
 
drivers/char/ipmi/ipmi_watchdog.c +3 -3
diff -uNrp linux-2.6.15-rc5/drivers/char/ipmi/ipmi_watchdog.c linux-2.6.15-rc5-mutex/drivers/char/ipmi/ipmi_watchdog.c
@@ -308,7 +308,7 @@ static void panic_halt_ipmi_heartbeat(vo
    The semaphore is claimed when the set_timeout is sent and freed
    when both messages are free. */
 static atomic_t set_timeout_tofree = ATOMIC_INIT(0);
-static DECLARE_MUTEX(set_timeout_lock);
+static DECLARE_SEM_MUTEX(set_timeout_lock);
 static void set_timeout_free_smi(struct ipmi_smi_msg *msg)
 {
     if (atomic_dec_and_test(&set_timeout_tofree))
@@ -458,8 +458,8 @@ static void panic_halt_ipmi_set_timeout(
    The semaphore is claimed when the set_timeout is sent and freed
    when both messages are free. */
 static atomic_t heartbeat_tofree = ATOMIC_INIT(0);
-static DECLARE_MUTEX(heartbeat_lock);
-static DECLARE_MUTEX_LOCKED(heartbeat_wait_lock);
+static DECLARE_SEM_MUTEX(heartbeat_lock);
+static DECLARE_SEM_MUTEX_LOCKED(heartbeat_wait_lock);
 static void heartbeat_free_smi(struct ipmi_smi_msg *msg)
 {
     if (atomic_dec_and_test(&heartbeat_tofree))
drivers/char/isicom.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/isicom.c linux-2.6.15-rc5-mutex/drivers/char/isicom.c
@@ -163,7 +163,7 @@ static void isicom_tx(unsigned long _dat
 static void isicom_start(struct tty_struct * tty);
 
 static unsigned char * tmp_buf;
-static DECLARE_MUTEX(tmp_buf_sem);
+static DECLARE_SEM_MUTEX(tmp_buf_sem);
 
 /*   baud index mappings from linux defns to isi */
 
drivers/char/istallion.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/istallion.c linux-2.6.15-rc5-mutex/drivers/char/istallion.c
@@ -181,7 +181,7 @@ static struct tty_driver	*stli_serial;
  *	is already swapping a shared buffer won't make things any worse.
  */
 static char			*stli_tmpwritebuf;
-static DECLARE_MUTEX(stli_tmpwritesem);
+static DECLARE_SEM_MUTEX(stli_tmpwritesem);
 
 #define	STLI_TXBUFSIZE		4096
 
drivers/char/misc.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/misc.c linux-2.6.15-rc5-mutex/drivers/char/misc.c
@@ -55,7 +55,7 @@
  * Head entry for the doubly linked miscdevice list
  */
 static LIST_HEAD(misc_list);
-static DECLARE_MUTEX(misc_sem);
+static DECLARE_SEM_MUTEX(misc_sem);
 
 /*
  * Assigned numbers, used for dynamic minors
drivers/char/nwflash.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/nwflash.c linux-2.6.15-rc5-mutex/drivers/char/nwflash.c
@@ -56,7 +56,7 @@ static int gbWriteEnable;
 static int gbWriteBase64Enable;
 static volatile unsigned char *FLASH_BASE;
 static int gbFlashSize = KFLASH_SIZE;
-static DECLARE_MUTEX(nwflash_sem);
+static DECLARE_SEM_MUTEX(nwflash_sem);
 
 extern spinlock_t gpio_lock;
 
drivers/char/raw.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/raw.c linux-2.6.15-rc5-mutex/drivers/char/raw.c
@@ -29,7 +29,7 @@ struct raw_device_data {
 
 static struct class *raw_class;
 static struct raw_device_data raw_devices[MAX_RAW_MINORS];
-static DECLARE_MUTEX(raw_mutex);
+static DECLARE_SEM_MUTEX(raw_mutex);
 static struct file_operations raw_ctl_fops;	     /* forward declaration */
 
 /*
drivers/char/riscom8.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/riscom8.c linux-2.6.15-rc5-mutex/drivers/char/riscom8.c
@@ -81,7 +81,7 @@
 static struct riscom_board * IRQ_to_board[16];
 static struct tty_driver *riscom_driver;
 static unsigned char * tmp_buf;
-static DECLARE_MUTEX(tmp_buf_sem);
+static DECLARE_SEM_MUTEX(tmp_buf_sem);
 
 static unsigned long baud_table[] =  {
 	0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
drivers/char/serial167.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/serial167.c linux-2.6.15-rc5-mutex/drivers/char/serial167.c
@@ -129,7 +129,7 @@ struct cyclades_port cy_port[] = {
  * memory if large numbers of serial ports are open.
  */
 static unsigned char *tmp_buf = 0;
-DECLARE_MUTEX(tmp_buf_sem);
+DECLARE_SEM_MUTEX(tmp_buf_sem);
 
 /*
  * This is used to look up the divisor speeds and the timeouts
drivers/char/specialix.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/specialix.c linux-2.6.15-rc5-mutex/drivers/char/specialix.c
@@ -183,7 +183,7 @@ static int sx_poll = HZ;
 
 static struct tty_driver *specialix_driver;
 static unsigned char * tmp_buf;
-static DECLARE_MUTEX(tmp_buf_sem);
+static DECLARE_SEM_MUTEX(tmp_buf_sem);
 
 static unsigned long baud_table[] =  {
 	0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
drivers/char/stallion.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/stallion.c linux-2.6.15-rc5-mutex/drivers/char/stallion.c
@@ -148,7 +148,7 @@ static struct tty_driver	*stl_serial;
  *	is already swapping a shared buffer won't make things any worse.
  */
 static char			*stl_tmpwritebuf;
-static DECLARE_MUTEX(stl_tmpwritesem);
+static DECLARE_SEM_MUTEX(stl_tmpwritesem);
 
 /*
  *	Define a local default termios struct. All ports will be created
drivers/char/synclink.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/synclink.c linux-2.6.15-rc5-mutex/drivers/char/synclink.c
@@ -951,7 +951,7 @@ static void* mgsl_get_text_ptr(void)
  * memory if large numbers of serial ports are open.
  */
 static unsigned char *tmp_buf;
-static DECLARE_MUTEX(tmp_buf_sem);
+static DECLARE_SEM_MUTEX(tmp_buf_sem);
 
 static inline int mgsl_paranoia_check(struct mgsl_struct *info,
 					char *name, const char *routine)
drivers/char/tty_io.c +2 -2
diff -uNrp linux-2.6.15-rc5/drivers/char/tty_io.c linux-2.6.15-rc5-mutex/drivers/char/tty_io.c
@@ -130,13 +130,13 @@ LIST_HEAD(tty_drivers);			/* linked list
 
 /* Semaphore to protect creating and releasing a tty. This is shared with
    vt.c for deeply disgusting hack reasons */
-DECLARE_MUTEX(tty_sem);
+DECLARE_SEM_MUTEX(tty_sem);
 
 #ifdef CONFIG_UNIX98_PTYS
 extern struct tty_driver *ptm_driver;	/* Unix98 pty masters; for /dev/ptmx */
 extern int pty_limit;		/* Config limit on Unix98 ptys */
 static DEFINE_IDR(allocated_ptys);
-static DECLARE_MUTEX(allocated_ptys_lock);
+static DECLARE_SEM_MUTEX(allocated_ptys_lock);
 static int ptmx_open(struct inode *, struct file *);
 #endif
 
drivers/char/vt.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/vt.c linux-2.6.15-rc5-mutex/drivers/char/vt.c
@@ -1907,7 +1907,7 @@ static void do_con_trol(struct tty_struc
  * kernel memory allocation is available.
  */
 char con_buf[CON_BUF_SIZE];
-DECLARE_MUTEX(con_buf_sem);
+DECLARE_SEM_MUTEX(con_buf_sem);
 
 /* acquires console_sem */
 static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count)
drivers/char/watchdog/pcwd_usb.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/watchdog/pcwd_usb.c linux-2.6.15-rc5-mutex/drivers/char/watchdog/pcwd_usb.c
@@ -143,7 +143,7 @@ struct usb_pcwd_private {
 static struct usb_pcwd_private *usb_pcwd_device;
 
 /* prevent races between open() and disconnect() */
-static DECLARE_MUTEX (disconnect_sem);
+static DECLARE_SEM_MUTEX (disconnect_sem);
 
 /* local function prototypes */
 static int usb_pcwd_probe	(struct usb_interface *interface, const struct usb_device_id *id);
drivers/char/watchdog/s3c2410_wdt.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/char/watchdog/s3c2410_wdt.c linux-2.6.15-rc5-mutex/drivers/char/watchdog/s3c2410_wdt.c
@@ -91,7 +91,7 @@ typedef enum close_state {
 	CLOSE_STATE_ALLOW=0x4021
 } close_state_t;
 
-static DECLARE_MUTEX(open_lock);
+static DECLARE_SEM_MUTEX(open_lock);
 
 static struct resource	*wdt_mem;
 static struct resource	*wdt_irq;
drivers/connector/connector.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/connector/connector.c linux-2.6.15-rc5-mutex/drivers/connector/connector.c
@@ -41,7 +41,7 @@ module_param(cn_val, uint, 0);
 MODULE_PARM_DESC(cn_idx, "Connector's main device idx.");
 MODULE_PARM_DESC(cn_val, "Connector's main device val.");
 
-static DECLARE_MUTEX(notify_lock);
+static DECLARE_SEM_MUTEX(notify_lock);
 static LIST_HEAD(notify_list);
 
 static struct cn_dev cdev;
drivers/cpufreq/cpufreq.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/cpufreq/cpufreq.c linux-2.6.15-rc5-mutex/drivers/cpufreq/cpufreq.c
@@ -56,7 +56,7 @@ static DECLARE_RWSEM		(cpufreq_notifier_
 
 
 static LIST_HEAD(cpufreq_governor_list);
-static DECLARE_MUTEX		(cpufreq_governor_sem);
+static DECLARE_SEM_MUTEX		(cpufreq_governor_sem);
 
 struct cpufreq_policy * cpufreq_cpu_get(unsigned int cpu)
 {
drivers/cpufreq/cpufreq_conservative.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/cpufreq/cpufreq_conservative.c linux-2.6.15-rc5-mutex/drivers/cpufreq/cpufreq_conservative.c
@@ -71,7 +71,7 @@ static DEFINE_PER_CPU(struct cpu_dbs_inf
 
 static unsigned int dbs_enable;	/* number of CPUs using this policy */
 
-static DECLARE_MUTEX 	(dbs_sem);
+static DECLARE_SEM_MUTEX 	(dbs_sem);
 static DECLARE_WORK	(dbs_work, do_dbs_timer, NULL);
 
 struct dbs_tuners {
drivers/cpufreq/cpufreq_ondemand.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/cpufreq/cpufreq_ondemand.c linux-2.6.15-rc5-mutex/drivers/cpufreq/cpufreq_ondemand.c
@@ -70,7 +70,7 @@ static DEFINE_PER_CPU(struct cpu_dbs_inf
 
 static unsigned int dbs_enable;	/* number of CPUs using this policy */
 
-static DECLARE_MUTEX 	(dbs_sem);
+static DECLARE_SEM_MUTEX 	(dbs_sem);
 static DECLARE_WORK	(dbs_work, do_dbs_timer, NULL);
 
 struct dbs_tuners {
drivers/cpufreq/cpufreq_userspace.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/cpufreq/cpufreq_userspace.c linux-2.6.15-rc5-mutex/drivers/cpufreq/cpufreq_userspace.c
@@ -35,7 +35,7 @@ static unsigned int	cpu_set_freq[NR_CPUS
 static unsigned int	cpu_is_managed[NR_CPUS];
 static struct cpufreq_policy current_policy[NR_CPUS];
 
-static DECLARE_MUTEX	(userspace_sem); 
+static DECLARE_SEM_MUTEX	(userspace_sem); 
 
 #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "userspace", msg)
 
drivers/fc4/fc.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/fc4/fc.c linux-2.6.15-rc5-mutex/drivers/fc4/fc.c
@@ -928,7 +928,7 @@ int fcp_scsi_dev_reset(Scsi_Cmnd *SCpnt)
 	fcp_cmd *cmd;
 	fcp_cmnd *fcmd;
 	fc_channel *fc = FC_SCMND(SCpnt);
-        DECLARE_MUTEX_LOCKED(sem);
+        DECLARE_SEM_MUTEX_LOCKED(sem);
 
 	if (!fc->rst_pkt) {
 		fc->rst_pkt = (Scsi_Cmnd *) kmalloc(sizeof(SCpnt), GFP_KERNEL);
drivers/firmware/dcdbas.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/firmware/dcdbas.c linux-2.6.15-rc5-mutex/drivers/firmware/dcdbas.c
@@ -48,7 +48,7 @@ static u8 *smi_data_buf;
 static dma_addr_t smi_data_buf_handle;
 static unsigned long smi_data_buf_size;
 static u32 smi_data_buf_phys_addr;
-static DECLARE_MUTEX(smi_data_lock);
+static DECLARE_SEM_MUTEX(smi_data_lock);
 
 static unsigned int host_control_action;
 static unsigned int host_control_smi_type;
drivers/hwmon/hdaps.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/hwmon/hdaps.c linux-2.6.15-rc5-mutex/drivers/hwmon/hdaps.c
@@ -70,7 +70,7 @@ static u8 km_activity;
 static int rest_x;
 static int rest_y;
 
-static DECLARE_MUTEX(hdaps_sem);
+static DECLARE_SEM_MUTEX(hdaps_sem);
 
 /*
  * __get_latch - Get the value from a given port.  Callers must hold hdaps_sem.
drivers/i2c/busses/i2c-ali1535.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/i2c/busses/i2c-ali1535.c linux-2.6.15-rc5-mutex/drivers/i2c/busses/i2c-ali1535.c
@@ -136,7 +136,7 @@
 
 static struct pci_driver ali1535_driver;
 static unsigned short ali1535_smba;
-static DECLARE_MUTEX(i2c_ali1535_sem);
+static DECLARE_SEM_MUTEX(i2c_ali1535_sem);
 
 /* Detect whether a ALI1535 can be found, and initialize it, where necessary.
    Note the differences between kernels with the old PCI BIOS interface and
drivers/i2c/chips/ds1374.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/i2c/chips/ds1374.c linux-2.6.15-rc5-mutex/drivers/i2c/chips/ds1374.c
@@ -41,7 +41,7 @@
 
 #define	DS1374_DRV_NAME		"ds1374"
 
-static DECLARE_MUTEX(ds1374_mutex);
+static DECLARE_SEM_MUTEX(ds1374_mutex);
 
 static struct i2c_driver ds1374_driver;
 static struct i2c_client *save_client;
drivers/i2c/chips/m41t00.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/i2c/chips/m41t00.c linux-2.6.15-rc5-mutex/drivers/i2c/chips/m41t00.c
@@ -30,7 +30,7 @@
 
 #define	M41T00_DRV_NAME		"m41t00"
 
-static DECLARE_MUTEX(m41t00_mutex);
+static DECLARE_SEM_MUTEX(m41t00_mutex);
 
 static struct i2c_driver m41t00_driver;
 static struct i2c_client *save_client;
drivers/i2c/i2c-core.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/i2c/i2c-core.c linux-2.6.15-rc5-mutex/drivers/i2c/i2c-core.c
@@ -36,7 +36,7 @@
 
 static LIST_HEAD(adapters);
 static LIST_HEAD(drivers);
-static DECLARE_MUTEX(core_lists);
+static DECLARE_SEM_MUTEX(core_lists);
 static DEFINE_IDR(i2c_adapter_idr);
 
 /* match always succeeds, as we want the probe() to tell if we really accept this match */
drivers/ide/ide-cd.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/ide/ide-cd.c linux-2.6.15-rc5-mutex/drivers/ide/ide-cd.c
@@ -324,7 +324,7 @@
 
 #include "ide-cd.h"
 
-static DECLARE_MUTEX(idecd_ref_sem);
+static DECLARE_SEM_MUTEX(idecd_ref_sem);
 
 #define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref) 
 
drivers/ide/ide-disk.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/ide/ide-disk.c linux-2.6.15-rc5-mutex/drivers/ide/ide-disk.c
@@ -78,7 +78,7 @@ struct ide_disk_obj {
 	struct kref	kref;
 };
 
-static DECLARE_MUTEX(idedisk_ref_sem);
+static DECLARE_SEM_MUTEX(idedisk_ref_sem);
 
 #define to_ide_disk(obj) container_of(obj, struct ide_disk_obj, kref)
 
drivers/ide/ide-floppy.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/ide/ide-floppy.c linux-2.6.15-rc5-mutex/drivers/ide/ide-floppy.c
@@ -517,7 +517,7 @@ typedef struct {
 	u8		reserved[4];
 } idefloppy_mode_parameter_header_t;
 
-static DECLARE_MUTEX(idefloppy_ref_sem);
+static DECLARE_SEM_MUTEX(idefloppy_ref_sem);
 
 #define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref)
 
drivers/ide/ide-tape.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/ide/ide-tape.c linux-2.6.15-rc5-mutex/drivers/ide/ide-tape.c
@@ -1011,7 +1011,7 @@ typedef struct ide_tape_obj {
          int debug_level; 
 } idetape_tape_t;
 
-static DECLARE_MUTEX(idetape_ref_sem);
+static DECLARE_SEM_MUTEX(idetape_ref_sem);
 
 static struct class *idetape_sysfs_class;
 
drivers/ide/ide.c +2 -2
diff -uNrp linux-2.6.15-rc5/drivers/ide/ide.c linux-2.6.15-rc5-mutex/drivers/ide/ide.c
@@ -174,7 +174,7 @@ static int idebus_parameter;	/* holds th
 static int system_bus_speed;	/* holds what we think is VESA/PCI bus speed */
 static int initializing;	/* set while initializing built-in drivers */
 
-DECLARE_MUTEX(ide_cfg_sem);
+DECLARE_SEM_MUTEX(ide_cfg_sem);
  __cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock);
 
 #ifdef CONFIG_BLK_DEV_IDEPCI
@@ -829,7 +829,7 @@ EXPORT_SYMBOL(ide_register_hw);
  *	Locks for IDE setting functionality
  */
 
-DECLARE_MUTEX(ide_setting_sem);
+DECLARE_SEM_MUTEX(ide_setting_sem);
 
 /**
  *	__ide_add_setting	-	add an ide setting option
drivers/ieee1394/hosts.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/ieee1394/hosts.c linux-2.6.15-rc5-mutex/drivers/ieee1394/hosts.c
@@ -105,7 +105,7 @@ static int alloc_hostnum_cb(struct hpsb_
  * Return Value: a pointer to the &hpsb_host if succesful, %NULL if
  * no memory was available.
  */
-static DECLARE_MUTEX(host_num_alloc);
+static DECLARE_SEM_MUTEX(host_num_alloc);
 
 struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
 				  struct device *dev)
drivers/ieee1394/ieee1394_core.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/ieee1394/ieee1394_core.c linux-2.6.15-rc5-mutex/drivers/ieee1394/ieee1394_core.c
@@ -1003,7 +1003,7 @@ void abort_timedouts(unsigned long __opa
 static int khpsbpkt_pid = -1, khpsbpkt_kill;
 static DECLARE_COMPLETION(khpsbpkt_complete);
 static struct sk_buff_head hpsbpkt_queue;
-static DECLARE_MUTEX_LOCKED(khpsbpkt_sig);
+static DECLARE_SEM_MUTEX_LOCKED(khpsbpkt_sig);
 
 
 static void queue_packet_complete(struct hpsb_packet *packet)
drivers/ieee1394/nodemgr.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/ieee1394/nodemgr.c linux-2.6.15-rc5-mutex/drivers/ieee1394/nodemgr.c
@@ -108,7 +108,7 @@ static struct csr1212_bus_ops nodemgr_cs
  * but now we are much simpler because of the LDM.
  */
 
-static DECLARE_MUTEX(nodemgr_serialize);
+static DECLARE_SEM_MUTEX(nodemgr_serialize);
 
 struct host_info {
 	struct hpsb_host *host;
drivers/infiniband/core/device.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/infiniband/core/device.c linux-2.6.15-rc5-mutex/drivers/infiniband/core/device.c
@@ -63,7 +63,7 @@ static LIST_HEAD(client_list);
  * modifying one list or the other list.  In any case this is not a
  * hot path so there's no point in trying to optimize.
  */
-static DECLARE_MUTEX(device_sem);
+static DECLARE_SEM_MUTEX(device_sem);
 
 static int ib_device_check_mandatory(struct ib_device *device)
 {
drivers/infiniband/core/ucm.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/infiniband/core/ucm.c linux-2.6.15-rc5-mutex/drivers/infiniband/core/ucm.c
@@ -113,7 +113,7 @@ static struct ib_client ucm_client = {
 	.remove = ib_ucm_remove_one
 };
 
-static DECLARE_MUTEX(ctx_id_mutex);
+static DECLARE_SEM_MUTEX(ctx_id_mutex);
 static DEFINE_IDR(ctx_id_table);
 static DECLARE_BITMAP(dev_map, IB_UCM_MAX_DEVICES);
 
drivers/infiniband/core/uverbs_main.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/infiniband/core/uverbs_main.c linux-2.6.15-rc5-mutex/drivers/infiniband/core/uverbs_main.c
@@ -66,7 +66,7 @@ enum {
 
 static struct class *uverbs_class;
 
-DECLARE_MUTEX(ib_uverbs_idr_mutex);
+DECLARE_SEM_MUTEX(ib_uverbs_idr_mutex);
 DEFINE_IDR(ib_uverbs_pd_idr);
 DEFINE_IDR(ib_uverbs_mr_idr);
 DEFINE_IDR(ib_uverbs_mw_idr);
drivers/infiniband/ulp/ipoib/ipoib_ib.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/infiniband/ulp/ipoib/ipoib_ib.c linux-2.6.15-rc5-mutex/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -52,7 +52,7 @@ MODULE_PARM_DESC(data_debug_level,
 
 #define	IPOIB_OP_RECV	(1ul << 31)
 
-static DECLARE_MUTEX(pkey_sem);
+static DECLARE_SEM_MUTEX(pkey_sem);
 
 struct ipoib_ah *ipoib_create_ah(struct net_device *dev,
 				 struct ib_pd *pd, struct ib_ah_attr *attr)
drivers/infiniband/ulp/ipoib/ipoib_multicast.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/infiniband/ulp/ipoib/ipoib_multicast.c linux-2.6.15-rc5-mutex/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -53,7 +53,7 @@ MODULE_PARM_DESC(mcast_debug_level,
 		 "Enable multicast debug tracing if > 0");
 #endif
 
-static DECLARE_MUTEX(mcast_mutex);
+static DECLARE_SEM_MUTEX(mcast_mutex);
 
 /* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */
 struct ipoib_mcast {
drivers/input/gameport/gameport.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/input/gameport/gameport.c linux-2.6.15-rc5-mutex/drivers/input/gameport/gameport.c
@@ -46,7 +46,7 @@ EXPORT_SYMBOL(gameport_stop_polling);
  * gameport_sem protects entire gameport subsystem and is taken
  * every time gameport port or driver registrered or unregistered.
  */
-static DECLARE_MUTEX(gameport_sem);
+static DECLARE_SEM_MUTEX(gameport_sem);
 
 static LIST_HEAD(gameport_list);
 
drivers/input/joystick/amijoy.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/input/joystick/amijoy.c linux-2.6.15-rc5-mutex/drivers/input/joystick/amijoy.c
@@ -52,7 +52,7 @@ MODULE_PARM_DESC(map, "Map of attached j
 __obsolete_setup("amijoy=");
 
 static int amijoy_used;
-static DECLARE_MUTEX(amijoy_sem);
+static DECLARE_SEM_MUTEX(amijoy_sem);
 static struct input_dev *amijoy_dev[2];
 static char *amijoy_phys[2] = { "amijoy/input0", "amijoy/input1" };
 
drivers/input/mouse/psmouse-base.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/input/mouse/psmouse-base.c linux-2.6.15-rc5-mutex/drivers/input/mouse/psmouse-base.c
@@ -96,7 +96,7 @@ __obsolete_setup("psmouse_rate=");
  * rarely more than one PS/2 mouse connected and since semaphore
  * is taken in "slow" paths it is not worth it.
  */
-static DECLARE_MUTEX(psmouse_sem);
+static DECLARE_SEM_MUTEX(psmouse_sem);
 
 struct psmouse_protocol {
 	enum psmouse_type type;
drivers/input/serio/serio.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/input/serio/serio.c linux-2.6.15-rc5-mutex/drivers/input/serio/serio.c
@@ -55,7 +55,7 @@ EXPORT_SYMBOL(serio_reconnect);
  * serio_sem protects entire serio subsystem and is taken every time
  * serio port or driver registrered or unregistered.
  */
-static DECLARE_MUTEX(serio_sem);
+static DECLARE_SEM_MUTEX(serio_sem);
 
 static LIST_HEAD(serio_list);
 
drivers/input/serio/serio_raw.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/input/serio/serio_raw.c linux-2.6.15-rc5-mutex/drivers/input/serio/serio_raw.c
@@ -46,7 +46,7 @@ struct serio_raw_list {
 	struct list_head node;
 };
 
-static DECLARE_MUTEX(serio_raw_sem);
+static DECLARE_SEM_MUTEX(serio_raw_sem);
 static LIST_HEAD(serio_raw_list);
 static unsigned int serio_raw_no;
 
drivers/isdn/capi/kcapi.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/isdn/capi/kcapi.c linux-2.6.15-rc5-mutex/drivers/isdn/capi/kcapi.c
@@ -66,7 +66,7 @@ LIST_HEAD(capi_drivers);
 DEFINE_RWLOCK(capi_drivers_list_lock);
 
 static DEFINE_RWLOCK(application_lock);
-static DECLARE_MUTEX(controller_sem);
+static DECLARE_SEM_MUTEX(controller_sem);
 
 struct capi20_appl *capi_applications[CAPI_MAXAPPL];
 struct capi_ctr *capi_cards[CAPI_MAXCONTR];
drivers/macintosh/adb.c +2 -2
diff -uNrp linux-2.6.15-rc5/drivers/macintosh/adb.c linux-2.6.15-rc5-mutex/drivers/macintosh/adb.c
@@ -84,7 +84,7 @@ struct notifier_block *adb_client_list =
 static int adb_got_sleep;
 static int adb_inited;
 static pid_t adb_probe_task_pid;
-static DECLARE_MUTEX(adb_probe_mutex);
+static DECLARE_SEM_MUTEX(adb_probe_mutex);
 static struct completion adb_probe_task_comp;
 static int sleepy_trackpad;
 static int autopoll_devs;
@@ -119,7 +119,7 @@ static struct adb_handler {
  * time adb_unregister returns, we know that the old handler isn't being
  * called.
  */
-static DECLARE_MUTEX(adb_handler_sem);
+static DECLARE_SEM_MUTEX(adb_handler_sem);
 static DEFINE_RWLOCK(adb_handler_lock);
 
 #if 0
drivers/macintosh/smu.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/macintosh/smu.c linux-2.6.15-rc5-mutex/drivers/macintosh/smu.c
@@ -92,7 +92,7 @@ struct smu_device {
  * for now, just hard code that
  */
 static struct smu_device	*smu;
-static DECLARE_MUTEX(smu_part_access);
+static DECLARE_SEM_MUTEX(smu_part_access);
 
 /*
  * SMU driver low level stuff
drivers/macintosh/therm_pm72.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/macintosh/therm_pm72.c linux-2.6.15-rc5-mutex/drivers/macintosh/therm_pm72.c
@@ -158,7 +158,7 @@ static int				critical_state;
 static int				rackmac;
 static s32				dimm_output_clamp;
 
-static DECLARE_MUTEX(driver_lock);
+static DECLARE_SEM_MUTEX(driver_lock);
 
 /*
  * We have 3 types of CPU PID control. One is "split" old style control
drivers/macintosh/windfarm_core.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/macintosh/windfarm_core.c linux-2.6.15-rc5-mutex/drivers/macintosh/windfarm_core.c
@@ -48,7 +48,7 @@
 
 static LIST_HEAD(wf_controls);
 static LIST_HEAD(wf_sensors);
-static DECLARE_MUTEX(wf_lock);
+static DECLARE_SEM_MUTEX(wf_lock);
 static struct notifier_block *wf_client_list;
 static int wf_client_count;
 static unsigned int wf_overtemp;
drivers/md/dm-table.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/md/dm-table.c linux-2.6.15-rc5-mutex/drivers/md/dm-table.c
@@ -765,7 +765,7 @@ int dm_table_complete(struct dm_table *t
 	return r;
 }
 
-static DECLARE_MUTEX(_event_lock);
+static DECLARE_SEM_MUTEX(_event_lock);
 void dm_table_event_callback(struct dm_table *t,
 			     void (*fn)(void *), void *context)
 {
drivers/md/dm.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/md/dm.c linux-2.6.15-rc5-mutex/drivers/md/dm.c
@@ -652,7 +652,7 @@ static int dm_any_congested(void *conges
 /*-----------------------------------------------------------------
  * An IDR is used to keep track of allocated minor numbers.
  *---------------------------------------------------------------*/
-static DECLARE_MUTEX(_minor_lock);
+static DECLARE_SEM_MUTEX(_minor_lock);
 static DEFINE_IDR(_minor_idr);
 
 static void free_minor(unsigned int minor)
drivers/md/kcopyd.c +2 -2
diff -uNrp linux-2.6.15-rc5/drivers/md/kcopyd.c linux-2.6.15-rc5-mutex/drivers/md/kcopyd.c
@@ -570,7 +570,7 @@ int kcopyd_cancel(struct kcopyd_job *job
 /*-----------------------------------------------------------------
  * Unit setup
  *---------------------------------------------------------------*/
-static DECLARE_MUTEX(_client_lock);
+static DECLARE_SEM_MUTEX(_client_lock);
 static LIST_HEAD(_clients);
 
 static void client_add(struct kcopyd_client *kc)
@@ -587,7 +587,7 @@ static void client_del(struct kcopyd_cli
 	up(&_client_lock);
 }
 
-static DECLARE_MUTEX(kcopyd_init_lock);
+static DECLARE_SEM_MUTEX(kcopyd_init_lock);
 static int kcopyd_clients = 0;
 
 static int kcopyd_init(void)
drivers/md/md.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/md/md.c linux-2.6.15-rc5-mutex/drivers/md/md.c
@@ -1882,7 +1882,7 @@ int mdp_major = 0;
 
 static struct kobject *md_probe(dev_t dev, int *part, void *data)
 {
-	static DECLARE_MUTEX(disks_sem);
+	static DECLARE_SEM_MUTEX(disks_sem);
 	mddev_t *mddev = mddev_find(dev);
 	struct gendisk *disk;
 	int partitioned = (MAJOR(dev) != MD_MAJOR);
drivers/media/common/saa7146_core.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/media/common/saa7146_core.c linux-2.6.15-rc5-mutex/drivers/media/common/saa7146_core.c
@@ -21,7 +21,7 @@
 #include <media/saa7146.h>
 
 LIST_HEAD(saa7146_devices);
-DECLARE_MUTEX(saa7146_devices_lock);
+DECLARE_SEM_MUTEX(saa7146_devices_lock);
 
 static int saa7146_num;
 
drivers/media/dvb/dvb-core/dvb_frontend.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/media/dvb/dvb-core/dvb_frontend.c linux-2.6.15-rc5-mutex/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -88,7 +88,7 @@ MODULE_PARM_DESC(dvb_powerdown_on_sleep,
  * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again.
  */
 
-static DECLARE_MUTEX(frontend_mutex);
+static DECLARE_SEM_MUTEX(frontend_mutex);
 
 struct dvb_frontend_private {
 
drivers/media/dvb/dvb-core/dvbdev.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/media/dvb/dvb-core/dvbdev.c linux-2.6.15-rc5-mutex/drivers/media/dvb/dvb-core/dvbdev.c
@@ -44,7 +44,7 @@ MODULE_PARM_DESC(dvbdev_debug, "Turn on/
 #define dprintk if (dvbdev_debug) printk
 
 static LIST_HEAD(dvb_adapter_list);
-static DECLARE_MUTEX(dvbdev_register_lock);
+static DECLARE_SEM_MUTEX(dvbdev_register_lock);
 
 static const char * const dnames[] = {
         "video", "audio", "sec", "frontend", "demux", "dvr", "ca",
drivers/media/video/cx88/cx88-core.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/media/video/cx88/cx88-core.c linux-2.6.15-rc5-mutex/drivers/media/video/cx88/cx88-core.c
@@ -74,7 +74,7 @@ MODULE_PARM_DESC(nocomb,"disable comb fi
 
 static unsigned int cx88_devcount;
 static LIST_HEAD(cx88_devlist);
-static DECLARE_MUTEX(devlist);
+static DECLARE_SEM_MUTEX(devlist);
 
 /* ------------------------------------------------------------------ */
 /* debug help functions                                               */
drivers/media/video/em28xx/em28xx-video.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/media/video/em28xx/em28xx-video.c linux-2.6.15-rc5-mutex/drivers/media/video/em28xx/em28xx-video.c
@@ -184,7 +184,7 @@ static struct v4l2_queryctrl em28xx_qctr
 
 static struct usb_driver em28xx_usb_driver;
 
-static DECLARE_MUTEX(em28xx_sysfs_lock);
+static DECLARE_SEM_MUTEX(em28xx_sysfs_lock);
 static DECLARE_RWSEM(em28xx_disconnect);
 
 /*********************  v4l2 interface  ******************************************/
drivers/media/video/saa7134/saa7134-core.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/media/video/saa7134/saa7134-core.c linux-2.6.15-rc5-mutex/drivers/media/video/saa7134/saa7134-core.c
@@ -83,7 +83,7 @@ MODULE_PARM_DESC(radio_nr, "radio device
 MODULE_PARM_DESC(tuner,    "tuner type");
 MODULE_PARM_DESC(card,     "card type");
 
-static DECLARE_MUTEX(devlist_lock);
+static DECLARE_SEM_MUTEX(devlist_lock);
 LIST_HEAD(saa7134_devlist);
 static LIST_HEAD(mops_list);
 static unsigned int saa7134_devcount;
drivers/media/video/saa7134/saa7134-tvaudio.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/media/video/saa7134/saa7134-tvaudio.c linux-2.6.15-rc5-mutex/drivers/media/video/saa7134/saa7134-tvaudio.c
@@ -970,7 +970,7 @@ int saa7134_tvaudio_getstereo(struct saa
 
 int saa7134_tvaudio_init2(struct saa7134_dev *dev)
 {
-	DECLARE_MUTEX_LOCKED(sem);
+	DECLARE_SEM_MUTEX_LOCKED(sem);
 	int (*my_thread)(void *data) = NULL;
 
 	switch (dev->pci->device) {
drivers/media/video/videodev.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/media/video/videodev.c linux-2.6.15-rc5-mutex/drivers/media/video/videodev.c
@@ -85,7 +85,7 @@ static struct class video_class = {
  */
 
 static struct video_device *video_device[VIDEO_NUM_DEVICES];
-static DECLARE_MUTEX(videodev_lock);
+static DECLARE_SEM_MUTEX(videodev_lock);
 
 struct video_device* video_devdata(struct file *file)
 {
drivers/mfd/ucb1x00-core.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/mfd/ucb1x00-core.c linux-2.6.15-rc5-mutex/drivers/mfd/ucb1x00-core.c
@@ -31,7 +31,7 @@
 
 #include "ucb1x00.h"
 
-static DECLARE_MUTEX(ucb1x00_sem);
+static DECLARE_SEM_MUTEX(ucb1x00_sem);
 static LIST_HEAD(ucb1x00_drivers);
 static LIST_HEAD(ucb1x00_devices);
 
drivers/mmc/mmc_block.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/mmc/mmc_block.c linux-2.6.15-rc5-mutex/drivers/mmc/mmc_block.c
@@ -56,7 +56,7 @@ struct mmc_blk_data {
 	unsigned int	block_bits;
 };
 
-static DECLARE_MUTEX(open_lock);
+static DECLARE_SEM_MUTEX(open_lock);
 
 static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk)
 {
drivers/mtd/devices/doc2000.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/mtd/devices/doc2000.c linux-2.6.15-rc5-mutex/drivers/mtd/devices/doc2000.c
@@ -975,7 +975,7 @@ static int doc_writev_ecc(struct mtd_inf
 			  u_char *eccbuf, struct nand_oobinfo *oobsel)
 {
 	static char static_buf[512];
-	static DECLARE_MUTEX(writev_buf_sem);
+	static DECLARE_SEM_MUTEX(writev_buf_sem);
 
 	size_t totretlen = 0;
 	size_t thisvecofs = 0;
drivers/mtd/mtdcore.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/mtd/mtdcore.c linux-2.6.15-rc5-mutex/drivers/mtd/mtdcore.c
@@ -27,7 +27,7 @@
 
 /* These are exported solely for the purpose of mtd_blkdevs.c. You
    should not use them for _anything_ else */
-DECLARE_MUTEX(mtd_table_mutex);
+DECLARE_SEM_MUTEX(mtd_table_mutex);
 struct mtd_info *mtd_table[MAX_MTD_DEVICES];
 
 EXPORT_SYMBOL_GPL(mtd_table_mutex);
author maintainer
#29 lore raw

PATCH 5/12 : MUTEX: Rename DECLARE_MUTEX for drivers/ dir, N thru Z

In reply to David Howells

The attached patch renames DECLARE_MUTEX*() to DECLARE_SEM_MUTEX*() for the drivers/ directory, subdirs N through Z.

---
warthog>diffstat -p1 mutex-drivers-NtoZ-2615rc5-2.diff

 drivers/net/irda/irtty-sir.c         |    2 +-
 drivers/net/irda/sir_dongle.c        |    2 +-
 drivers/net/ppp_generic.c            |    2 +-
 drivers/net/wan/dscc4.c              |    2 +-
 drivers/oprofile/event_buffer.c      |    2 +-
 drivers/oprofile/oprof.c             |    2 +-
 drivers/parport/share.c              |    2 +-
 drivers/pci/hotplug/rpadlpar_core.c  |    2 +-
 drivers/pci/hotplug/sgi_hotplug.c    |    2 +-
 drivers/pcmcia/au1000_generic.c      |    2 +-
 drivers/pcmcia/ds.c                  |    2 +-
 drivers/pcmcia/rsrc_nonstatic.c      |    2 +-
 drivers/pcmcia/soc_common.c          |    2 +-
 drivers/pnp/isapnp/core.c            |    2 +-
 drivers/pnp/manager.c                |    2 +-
 drivers/s390/char/raw3270.c          |    4 ++--
 drivers/sbus/char/aurora.c           |    2 +-
 drivers/scsi/aha152x.c               |    2 +-
 drivers/scsi/dpt/dpti_i2o.h          |    2 +-
 drivers/scsi/dpt_i2o.c               |    2 +-
 drivers/scsi/ide-scsi.c              |    2 +-
 drivers/scsi/megaraid/megaraid_sas.c |    2 +-
 drivers/scsi/pluto.c                 |    2 +-
 drivers/scsi/qla2xxx/qla_os.c        |    2 +-
 drivers/scsi/scsi.c                  |    2 +-
 drivers/scsi/scsi_proc.c             |    2 +-
 drivers/scsi/scsi_transport_iscsi.c  |    2 +-
 drivers/scsi/sd.c                    |    2 +-
 drivers/scsi/sr.c                    |    2 +-
 drivers/scsi/st.c                    |    2 +-
 drivers/serial/68328serial.c         |    2 +-
 drivers/serial/8250.c                |    2 +-
 drivers/serial/crisv10.c             |    4 ++--
 drivers/serial/pmac_zilog.c          |    2 +-
 drivers/serial/serial_core.c         |    2 +-
 drivers/serial/serial_txx9.c         |    2 +-
 drivers/telephony/phonedev.c         |    2 +-
 drivers/usb/class/audio.c            |    2 +-
 drivers/usb/class/cdc-acm.c          |    2 +-
 drivers/usb/class/usb-midi.c         |    2 +-
 drivers/usb/class/usblp.c            |    2 +-
 drivers/usb/core/hcd.c               |    2 +-
 drivers/usb/core/hub.c               |    2 +-
 drivers/usb/core/notify.c            |    2 +-
 drivers/usb/input/ati_remote.c       |    2 +-
 drivers/usb/media/sn9c102.h          |    2 +-
 drivers/usb/media/w9968cf.h          |    4 ++--
 drivers/usb/misc/idmouse.c           |    2 +-
 drivers/usb/misc/ldusb.c             |    2 +-
 drivers/usb/misc/legousbtower.c      |    2 +-
 drivers/usb/misc/sisusbvga/sisusb.c  |    2 +-
 drivers/usb/mon/mon_main.c           |    2 +-
 drivers/usb/serial/pl2303.c          |    2 +-
 53 files changed, 56 insertions(+), 56 deletions(-)
drivers/net/irda/irtty-sir.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/net/irda/irtty-sir.c linux-2.6.15-rc5-mutex/drivers/net/irda/irtty-sir.c
@@ -354,7 +354,7 @@ static inline void irtty_stop_receiver(s
 /*****************************************************************/
 
 /* serialize ldisc open/close with sir_dev */
-static DECLARE_MUTEX(irtty_sem);
+static DECLARE_SEM_MUTEX(irtty_sem);
 
 /* notifier from sir_dev when irda% device gets opened (ifup) */
 
drivers/net/irda/sir_dongle.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/net/irda/sir_dongle.c linux-2.6.15-rc5-mutex/drivers/net/irda/sir_dongle.c
@@ -28,7 +28,7 @@
  */
 
 static LIST_HEAD(dongle_list);			/* list of registered dongle drivers */
-static DECLARE_MUTEX(dongle_list_lock);		/* protects the list */
+static DECLARE_SEM_MUTEX(dongle_list_lock);		/* protects the list */
 
 int irda_register_dongle(struct dongle_driver *new)
 {
drivers/net/ppp_generic.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/net/ppp_generic.c linux-2.6.15-rc5-mutex/drivers/net/ppp_generic.c
@@ -202,7 +202,7 @@ static void cardmap_destroy(struct cardm
  * It also ensures that finding a ppp unit in the all_ppp_units map
  * and updating its file.refcnt field is atomic.
  */
-static DECLARE_MUTEX(all_ppp_sem);
+static DECLARE_SEM_MUTEX(all_ppp_sem);
 static struct cardmap *all_ppp_units;
 static atomic_t ppp_unit_count = ATOMIC_INIT(0);
 
drivers/net/wan/dscc4.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/net/wan/dscc4.c linux-2.6.15-rc5-mutex/drivers/net/wan/dscc4.c
@@ -112,7 +112,7 @@ static int debug;
 static int quartz;
 
 #ifdef CONFIG_DSCC4_PCI_RST
-static DECLARE_MUTEX(dscc4_sem);
+static DECLARE_SEM_MUTEX(dscc4_sem);
 static u32 dscc4_pci_config_store[16];
 #endif
 
drivers/oprofile/event_buffer.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/oprofile/event_buffer.c linux-2.6.15-rc5-mutex/drivers/oprofile/event_buffer.c
@@ -23,7 +23,7 @@
 #include "event_buffer.h"
 #include "oprofile_stats.h"
 
-DECLARE_MUTEX(buffer_sem);
+DECLARE_SEM_MUTEX(buffer_sem);
  
 static unsigned long buffer_opened;
 static DECLARE_WAIT_QUEUE_HEAD(buffer_wait);
drivers/oprofile/oprof.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/oprofile/oprof.c linux-2.6.15-rc5-mutex/drivers/oprofile/oprof.c
@@ -25,7 +25,7 @@ struct oprofile_operations oprofile_ops;
 unsigned long oprofile_started;
 unsigned long backtrace_depth;
 static unsigned long is_setup;
-static DECLARE_MUTEX(start_sem);
+static DECLARE_SEM_MUTEX(start_sem);
 
 /* timer
    0 - use performance monitoring hardware if available
drivers/parport/share.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/parport/share.c linux-2.6.15-rc5-mutex/drivers/parport/share.c
@@ -50,7 +50,7 @@ static DEFINE_SPINLOCK(full_list_lock);
 
 static LIST_HEAD(drivers);
 
-static DECLARE_MUTEX(registration_lock);
+static DECLARE_SEM_MUTEX(registration_lock);
 
 /* What you can do to a port that's gone away.. */
 static void dead_write_lines (struct parport *p, unsigned char b){}
drivers/pci/hotplug/rpadlpar_core.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/pci/hotplug/rpadlpar_core.c linux-2.6.15-rc5-mutex/drivers/pci/hotplug/rpadlpar_core.c
@@ -27,7 +27,7 @@
 #include "rpaphp.h"
 #include "rpadlpar.h"
 
-static DECLARE_MUTEX(rpadlpar_sem);
+static DECLARE_SEM_MUTEX(rpadlpar_sem);
 
 #define DLPAR_MODULE_NAME "rpadlpar_io"
 
drivers/pci/hotplug/sgi_hotplug.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/pci/hotplug/sgi_hotplug.c linux-2.6.15-rc5-mutex/drivers/pci/hotplug/sgi_hotplug.c
@@ -81,7 +81,7 @@ static struct hotplug_slot_ops sn_hotplu
 	.get_power_status       = get_power_status,
 };
 
-static DECLARE_MUTEX(sn_hotplug_sem);
+static DECLARE_SEM_MUTEX(sn_hotplug_sem);
 
 static ssize_t path_show (struct hotplug_slot *bss_hotplug_slot,
 	       		  char *buf)
drivers/pcmcia/au1000_generic.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/pcmcia/au1000_generic.c linux-2.6.15-rc5-mutex/drivers/pcmcia/au1000_generic.c
@@ -72,7 +72,7 @@ extern struct au1000_pcmcia_socket au100
 u32 *pcmcia_base_vaddrs[2];
 extern const unsigned long mips_io_port_base;
 
-DECLARE_MUTEX(pcmcia_sockets_lock);
+DECLARE_SEM_MUTEX(pcmcia_sockets_lock);
 
 static int (*au1x00_pcmcia_hw_init[])(struct device *dev) = {
 	au1x_board_init,
drivers/pcmcia/ds.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/pcmcia/ds.c linux-2.6.15-rc5-mutex/drivers/pcmcia/ds.c
@@ -499,7 +499,7 @@ static int pcmcia_device_query(struct pc
  * won't work, this doesn't matter much at the moment: the driver core doesn't
  * support it either.
  */
-static DECLARE_MUTEX(device_add_lock);
+static DECLARE_SEM_MUTEX(device_add_lock);
 
 struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int function)
 {
drivers/pcmcia/rsrc_nonstatic.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/pcmcia/rsrc_nonstatic.c linux-2.6.15-rc5-mutex/drivers/pcmcia/rsrc_nonstatic.c
@@ -61,7 +61,7 @@ struct socket_data {
 	unsigned int			rsrc_mem_probe;
 };
 
-static DECLARE_MUTEX(rsrc_sem);
+static DECLARE_SEM_MUTEX(rsrc_sem);
 #define MEM_PROBE_LOW	(1 << 0)
 #define MEM_PROBE_HIGH	(1 << 1)
 
drivers/pcmcia/soc_common.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/pcmcia/soc_common.c linux-2.6.15-rc5-mutex/drivers/pcmcia/soc_common.c
@@ -599,7 +599,7 @@ EXPORT_SYMBOL(soc_pcmcia_enable_irqs);
 
 
 LIST_HEAD(soc_pcmcia_sockets);
-DECLARE_MUTEX(soc_pcmcia_sockets_lock);
+DECLARE_SEM_MUTEX(soc_pcmcia_sockets_lock);
 
 static const char *skt_names[] = {
 	"PCMCIA socket 0",
drivers/pnp/isapnp/core.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/pnp/isapnp/core.c linux-2.6.15-rc5-mutex/drivers/pnp/isapnp/core.c
@@ -92,7 +92,7 @@ MODULE_LICENSE("GPL");
 #define _LTAG_FIXEDMEM32RANGE	0x86
 
 static unsigned char isapnp_checksum_value;
-static DECLARE_MUTEX(isapnp_cfg_mutex);
+static DECLARE_SEM_MUTEX(isapnp_cfg_mutex);
 static int isapnp_detected;
 static int isapnp_csn_count;
 
drivers/pnp/manager.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/pnp/manager.c linux-2.6.15-rc5-mutex/drivers/pnp/manager.c
@@ -16,7 +16,7 @@
 #include <linux/bitmap.h>
 #include "base.h"
 
-DECLARE_MUTEX(pnp_res_mutex);
+DECLARE_SEM_MUTEX(pnp_res_mutex);
 
 static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)
 {
drivers/s390/char/raw3270.c +2 -2
diff -uNrp linux-2.6.15-rc5/drivers/s390/char/raw3270.c linux-2.6.15-rc5-mutex/drivers/s390/char/raw3270.c
@@ -59,7 +59,7 @@ struct raw3270 {
 #define RAW3270_FLAGS_CONSOLE	8	/* Device is the console. */
 
 /* Semaphore to protect global data of raw3270 (devices, views, etc). */
-static DECLARE_MUTEX(raw3270_sem);
+static DECLARE_SEM_MUTEX(raw3270_sem);
 
 /* List of 3270 devices. */
 static struct list_head raw3270_devices = LIST_HEAD_INIT(raw3270_devices);
@@ -487,7 +487,7 @@ struct raw3270_ua {	/* Query Reply struc
 static unsigned char raw3270_init_data[256];
 static struct raw3270_request raw3270_init_request;
 static struct diag210 raw3270_init_diag210;
-static DECLARE_MUTEX(raw3270_init_sem);
+static DECLARE_SEM_MUTEX(raw3270_init_sem);
 
 static int
 raw3270_init_irq(struct raw3270_view *view, struct raw3270_request *rq,
drivers/sbus/char/aurora.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/sbus/char/aurora.c linux-2.6.15-rc5-mutex/drivers/sbus/char/aurora.c
@@ -92,7 +92,7 @@ static struct Aurora_port aurora_port[AU
 
 /* no longer used. static struct Aurora_board * IRQ_to_board[16] = { NULL, } ;*/
 static unsigned char * tmp_buf = NULL;
-static DECLARE_MUTEX(tmp_buf_sem);
+static DECLARE_SEM_MUTEX(tmp_buf_sem);
 
 DECLARE_TASK_QUEUE(tq_aurora);
 
drivers/scsi/aha152x.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/scsi/aha152x.c linux-2.6.15-rc5-mutex/drivers/scsi/aha152x.c
@@ -1161,7 +1161,7 @@ static void timer_expired(unsigned long 
 static int aha152x_device_reset(Scsi_Cmnd * SCpnt)
 {
 	struct Scsi_Host *shpnt = SCpnt->device->host;
-	DECLARE_MUTEX_LOCKED(sem);
+	DECLARE_SEM_MUTEX_LOCKED(sem);
 	struct timer_list timer;
 	int ret, issued, disconnected;
 	unsigned long flags;
drivers/scsi/dpt/dpti_i2o.h +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/scsi/dpt/dpti_i2o.h linux-2.6.15-rc5-mutex/drivers/scsi/dpt/dpti_i2o.h
@@ -50,7 +50,7 @@
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
 
-#define DECLARE_MUTEX(name) struct semaphore name=MUTEX
+#define DECLARE_SEM_MUTEX(name) struct semaphore name=MUTEX
 
 typedef struct wait_queue *adpt_wait_queue_head_t;
 #define ADPT_DECLARE_WAIT_QUEUE_HEAD(wait) adpt_wait_queue_head_t wait = NULL
drivers/scsi/dpt_i2o.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/scsi/dpt_i2o.c linux-2.6.15-rc5-mutex/drivers/scsi/dpt_i2o.c
@@ -106,7 +106,7 @@ static dpt_sig_S DPTI_sig = {
  *============================================================================
  */
 
-static DECLARE_MUTEX(adpt_configuration_lock);
+static DECLARE_SEM_MUTEX(adpt_configuration_lock);
 
 static struct i2o_sys_tbl *sys_tbl = NULL;
 static int sys_tbl_ind = 0;
drivers/scsi/ide-scsi.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/scsi/ide-scsi.c linux-2.6.15-rc5-mutex/drivers/scsi/ide-scsi.c
@@ -109,7 +109,7 @@ typedef struct ide_scsi_obj {
 	unsigned long log;			/* log flags */
 } idescsi_scsi_t;
 
-static DECLARE_MUTEX(idescsi_ref_sem);
+static DECLARE_SEM_MUTEX(idescsi_ref_sem);
 
 #define ide_scsi_g(disk) \
 	container_of((disk)->private_data, struct ide_scsi_obj, driver)
drivers/scsi/megaraid/megaraid_sas.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/scsi/megaraid/megaraid_sas.c linux-2.6.15-rc5-mutex/drivers/scsi/megaraid/megaraid_sas.c
@@ -72,7 +72,7 @@ MODULE_DEVICE_TABLE(pci, megasas_pci_tab
 static int megasas_mgmt_majorno;
 static struct megasas_mgmt_info megasas_mgmt_info;
 static struct fasync_struct *megasas_async_queue;
-static DECLARE_MUTEX(megasas_async_queue_mutex);
+static DECLARE_SEM_MUTEX(megasas_async_queue_mutex);
 
 /**
  * megasas_get_cmd -	Get a command from the free pool
drivers/scsi/pluto.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/scsi/pluto.c linux-2.6.15-rc5-mutex/drivers/scsi/pluto.c
@@ -48,7 +48,7 @@ static struct ctrl_inquiry {
 } *fcs __initdata;
 static int fcscount __initdata = 0;
 static atomic_t fcss __initdata = ATOMIC_INIT(0);
-DECLARE_MUTEX_LOCKED(fc_sem);
+DECLARE_SEM_MUTEX_LOCKED(fc_sem);
 
 static int pluto_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmnd *fcmd);
 
drivers/scsi/qla2xxx/qla_os.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/scsi/qla2xxx/qla_os.c linux-2.6.15-rc5-mutex/drivers/scsi/qla2xxx/qla_os.c
@@ -2082,7 +2082,7 @@ qla2x00_free_sp_pool( scsi_qla_host_t *h
 static int
 qla2x00_do_dpc(void *data)
 {
-	DECLARE_MUTEX_LOCKED(sem);
+	DECLARE_SEM_MUTEX_LOCKED(sem);
 	scsi_qla_host_t *ha;
 	fc_port_t	*fcport;
 	uint8_t		status;
drivers/scsi/scsi.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/scsi/scsi.c linux-2.6.15-rc5-mutex/drivers/scsi/scsi.c
@@ -210,7 +210,7 @@ static struct scsi_host_cmd_pool scsi_cm
 	.gfp_mask	= __GFP_DMA,
 };
 
-static DECLARE_MUTEX(host_cmd_pool_mutex);
+static DECLARE_SEM_MUTEX(host_cmd_pool_mutex);
 
 static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost,
 					    gfp_t gfp_mask)
drivers/scsi/scsi_proc.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/scsi/scsi_proc.c linux-2.6.15-rc5-mutex/drivers/scsi/scsi_proc.c
@@ -41,7 +41,7 @@
 static struct proc_dir_entry *proc_scsi;
 
 /* Protect sht->present and sht->proc_dir */
-static DECLARE_MUTEX(global_host_template_sem);
+static DECLARE_SEM_MUTEX(global_host_template_sem);
 
 static int proc_scsi_read(char *buffer, char **start, off_t offset,
 			  int length, int *eof, void *data)
drivers/scsi/scsi_transport_iscsi.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/scsi/scsi_transport_iscsi.c linux-2.6.15-rc5-mutex/drivers/scsi/scsi_transport_iscsi.c
@@ -145,7 +145,7 @@ static DECLARE_TRANSPORT_CLASS(iscsi_con
 
 static struct sock *nls;
 static int daemon_pid;
-static DECLARE_MUTEX(rx_queue_sema);
+static DECLARE_SEM_MUTEX(rx_queue_sema);
 
 struct mempool_zone {
 	mempool_t *pool;
drivers/scsi/sd.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/scsi/sd.c linux-2.6.15-rc5-mutex/drivers/scsi/sd.c
@@ -110,7 +110,7 @@ static DEFINE_SPINLOCK(sd_index_lock);
 /* This semaphore is used to mediate the 0->1 reference get in the
  * face of object destruction (i.e. we can't allow a get on an
  * object after last put) */
-static DECLARE_MUTEX(sd_ref_sem);
+static DECLARE_SEM_MUTEX(sd_ref_sem);
 
 static int sd_revalidate_disk(struct gendisk *disk);
 static void sd_rw_intr(struct scsi_cmnd * SCpnt);
drivers/scsi/sr.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/scsi/sr.c linux-2.6.15-rc5-mutex/drivers/scsi/sr.c
@@ -90,7 +90,7 @@ static DEFINE_SPINLOCK(sr_index_lock);
 /* This semaphore is used to mediate the 0->1 reference get in the
  * face of object destruction (i.e. we can't allow a get on an
  * object after last put) */
-static DECLARE_MUTEX(sr_ref_sem);
+static DECLARE_SEM_MUTEX(sr_ref_sem);
 
 static int sr_open(struct cdrom_device_info *, int);
 static void sr_release(struct cdrom_device_info *);
drivers/scsi/st.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/scsi/st.c linux-2.6.15-rc5-mutex/drivers/scsi/st.c
@@ -223,7 +223,7 @@ static void scsi_tape_release(struct kre
 
 #define to_scsi_tape(obj) container_of(obj, struct scsi_tape, kref)
 
-static DECLARE_MUTEX(st_ref_sem);
+static DECLARE_SEM_MUTEX(st_ref_sem);
 
 
 #include "osst_detect.h"
drivers/serial/68328serial.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/serial/68328serial.c linux-2.6.15-rc5-mutex/drivers/serial/68328serial.c
@@ -143,7 +143,7 @@ static int m68328_console_cbaud   = DEFA
  * memory if large numbers of serial ports are open.
  */
 static unsigned char tmp_buf[SERIAL_XMIT_SIZE]; /* This is cheating */
-DECLARE_MUTEX(tmp_buf_sem);
+DECLARE_SEM_MUTEX(tmp_buf_sem);
 
 static inline int serial_paranoia_check(struct m68k_serial *info,
 					char *name, const char *routine)
drivers/serial/8250.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/serial/8250.c linux-2.6.15-rc5-mutex/drivers/serial/8250.c
@@ -2480,7 +2480,7 @@ static struct platform_device *serial825
  * 16x50 serial ports to be configured at run-time, to support PCMCIA
  * modems and PCI multiport cards.
  */
-static DECLARE_MUTEX(serial_sem);
+static DECLARE_SEM_MUTEX(serial_sem);
 
 static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *port)
 {
drivers/serial/crisv10.c +2 -2
diff -uNrp linux-2.6.15-rc5/drivers/serial/crisv10.c linux-2.6.15-rc5-mutex/drivers/serial/crisv10.c
@@ -1315,8 +1315,8 @@ static const struct control_pins e100_mo
  * memory if large numbers of serial ports are open.
  */
 static unsigned char *tmp_buf;
-#ifdef DECLARE_MUTEX
-static DECLARE_MUTEX(tmp_buf_sem);
+#ifdef DECLARE_SEM_MUTEX
+static DECLARE_SEM_MUTEX(tmp_buf_sem);
 #else
 static struct semaphore tmp_buf_sem = MUTEX;
 #endif
drivers/serial/pmac_zilog.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/serial/pmac_zilog.c linux-2.6.15-rc5-mutex/drivers/serial/pmac_zilog.c
@@ -96,7 +96,7 @@ MODULE_LICENSE("GPL");
  */
 static struct uart_pmac_port	pmz_ports[MAX_ZS_PORTS];
 static int			pmz_ports_count;
-static DECLARE_MUTEX(pmz_irq_sem);
+static DECLARE_SEM_MUTEX(pmz_irq_sem);
 
 static struct uart_driver pmz_uart_reg = {
 	.owner		=	THIS_MODULE,
drivers/serial/serial_core.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/serial/serial_core.c linux-2.6.15-rc5-mutex/drivers/serial/serial_core.c
@@ -47,7 +47,7 @@
 /*
  * This is used to lock changes in serial line configuration.
  */
-static DECLARE_MUTEX(port_sem);
+static DECLARE_SEM_MUTEX(port_sem);
 
 #define HIGH_BITS_OFFSET	((sizeof(long)-sizeof(int))*8)
 
drivers/serial/serial_txx9.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/serial/serial_txx9.c linux-2.6.15-rc5-mutex/drivers/serial/serial_txx9.c
@@ -1029,7 +1029,7 @@ static void serial_txx9_resume_port(int 
 	uart_resume_port(&serial_txx9_reg, &serial_txx9_ports[line].port);
 }
 
-static DECLARE_MUTEX(serial_txx9_sem);
+static DECLARE_SEM_MUTEX(serial_txx9_sem);
 
 /**
  *	serial_txx9_register_port - register a serial port
drivers/telephony/phonedev.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/telephony/phonedev.c linux-2.6.15-rc5-mutex/drivers/telephony/phonedev.c
@@ -37,7 +37,7 @@
  */
 
 static struct phone_device *phone_device[PHONE_NUM_DEVICES];
-static DECLARE_MUTEX(phone_lock);
+static DECLARE_SEM_MUTEX(phone_lock);
 
 /*
  *    Open a phone device.
drivers/usb/class/audio.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/usb/class/audio.c linux-2.6.15-rc5-mutex/drivers/usb/class/audio.c
@@ -218,7 +218,7 @@
  * Linked list of all audio devices...
  */
 static struct list_head audiodevs = LIST_HEAD_INIT(audiodevs);
-static DECLARE_MUTEX(open_sem);
+static DECLARE_SEM_MUTEX(open_sem);
 
 /*
  * wait queue for processes wanting to open an USB audio device
drivers/usb/class/cdc-acm.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/usb/class/cdc-acm.c linux-2.6.15-rc5-mutex/drivers/usb/class/cdc-acm.c
@@ -77,7 +77,7 @@ static struct usb_driver acm_driver;
 static struct tty_driver *acm_tty_driver;
 static struct acm *acm_table[ACM_TTY_MINORS];
 
-static DECLARE_MUTEX(open_sem);
+static DECLARE_SEM_MUTEX(open_sem);
 
 #define ACM_READY(acm)	(acm && acm->dev && acm->used)
 
drivers/usb/class/usb-midi.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/usb/class/usb-midi.c linux-2.6.15-rc5-mutex/drivers/usb/class/usb-midi.c
@@ -296,7 +296,7 @@ static int cin_to_len[] = {
 
 static struct list_head mididevs = LIST_HEAD_INIT(mididevs);
 
-static DECLARE_MUTEX(open_sem);
+static DECLARE_SEM_MUTEX(open_sem);
 static DECLARE_WAIT_QUEUE_HEAD(open_wait);
 
 
drivers/usb/class/usblp.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/usb/class/usblp.c linux-2.6.15-rc5-mutex/drivers/usb/class/usblp.c
@@ -222,7 +222,7 @@ static int usblp_cache_device_id_string(
 
 /* forward reference to make our lives easier */
 static struct usb_driver usblp_driver;
-static DECLARE_MUTEX(usblp_sem);	/* locks the existence of usblp's */
+static DECLARE_SEM_MUTEX(usblp_sem);	/* locks the existence of usblp's */
 
 /*
  * Functions for usblp control messages.
drivers/usb/core/hcd.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/usb/core/hcd.c linux-2.6.15-rc5-mutex/drivers/usb/core/hcd.c
@@ -93,7 +93,7 @@ struct usb_busmap {
 static struct usb_busmap busmap;
 
 /* used when updating list of hcds */
-DECLARE_MUTEX (usb_bus_list_lock);	/* exported only for usbfs */
+DECLARE_SEM_MUTEX (usb_bus_list_lock);	/* exported only for usbfs */
 EXPORT_SYMBOL_GPL (usb_bus_list_lock);
 
 /* used for controlling access to virtual root hubs */
drivers/usb/core/hub.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/usb/core/hub.c linux-2.6.15-rc5-mutex/drivers/usb/core/hub.c
@@ -2107,7 +2107,7 @@ static int
 hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
 		int retry_counter)
 {
-	static DECLARE_MUTEX(usb_address0_sem);
+	static DECLARE_SEM_MUTEX(usb_address0_sem);
 
 	struct usb_device	*hdev = hub->hdev;
 	int			i, j, retval;
drivers/usb/core/notify.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/usb/core/notify.c linux-2.6.15-rc5-mutex/drivers/usb/core/notify.c
@@ -17,7 +17,7 @@
 
 
 static struct notifier_block *usb_notifier_list;
-static DECLARE_MUTEX(usb_notifier_lock);
+static DECLARE_SEM_MUTEX(usb_notifier_lock);
 
 static void usb_notifier_chain_register(struct notifier_block **list,
 					struct notifier_block *n)
drivers/usb/input/ati_remote.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/usb/input/ati_remote.c linux-2.6.15-rc5-mutex/drivers/usb/input/ati_remote.c
@@ -158,7 +158,7 @@ static char accel[] = { 1, 2, 4, 6, 9, 1
  */
 #define FILTER_TIME (HZ / 20)
 
-static DECLARE_MUTEX(disconnect_sem);
+static DECLARE_SEM_MUTEX(disconnect_sem);
 
 struct ati_remote {
 	struct input_dev *idev;
drivers/usb/media/sn9c102.h +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/usb/media/sn9c102.h linux-2.6.15-rc5-mutex/drivers/usb/media/sn9c102.h
@@ -114,7 +114,7 @@ struct sn9c102_module_param {
 	u8 force_munmap;
 };
 
-static DECLARE_MUTEX(sn9c102_sysfs_lock);
+static DECLARE_SEM_MUTEX(sn9c102_sysfs_lock);
 static DECLARE_RWSEM(sn9c102_disconnect);
 
 struct sn9c102_device {
drivers/usb/media/w9968cf.h +2 -2
diff -uNrp linux-2.6.15-rc5/drivers/usb/media/w9968cf.h linux-2.6.15-rc5-mutex/drivers/usb/media/w9968cf.h
@@ -195,11 +195,11 @@ enum w9968cf_vpp_flag {
 };
 
 static struct w9968cf_vpp_t* w9968cf_vpp;
-static DECLARE_MUTEX(w9968cf_vppmod_lock);
+static DECLARE_SEM_MUTEX(w9968cf_vppmod_lock);
 static DECLARE_WAIT_QUEUE_HEAD(w9968cf_vppmod_wait);
 
 static LIST_HEAD(w9968cf_dev_list); /* head of V4L registered cameras list */
-static DECLARE_MUTEX(w9968cf_devlist_sem); /* semaphore for list traversal */
+static DECLARE_SEM_MUTEX(w9968cf_devlist_sem); /* semaphore for list traversal */
 
 static DECLARE_RWSEM(w9968cf_disconnect); /* prevent races with open() */
 
drivers/usb/misc/idmouse.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/usb/misc/idmouse.c linux-2.6.15-rc5-mutex/drivers/usb/misc/idmouse.c
@@ -122,7 +122,7 @@ static struct usb_driver idmouse_driver 
 };
 
 /* prevent races between open() and disconnect() */
-static DECLARE_MUTEX(disconnect_sem);
+static DECLARE_SEM_MUTEX(disconnect_sem);
 
 static int idmouse_create_image(struct usb_idmouse *dev)
 {
drivers/usb/misc/ldusb.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/usb/misc/ldusb.c linux-2.6.15-rc5-mutex/drivers/usb/misc/ldusb.c
@@ -165,7 +165,7 @@ struct ld_usb {
 };
 
 /* prevent races between open() and disconnect() */
-static DECLARE_MUTEX(disconnect_sem);
+static DECLARE_SEM_MUTEX(disconnect_sem);
 
 static struct usb_driver ld_usb_driver;
 
drivers/usb/misc/legousbtower.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/usb/misc/legousbtower.c linux-2.6.15-rc5-mutex/drivers/usb/misc/legousbtower.c
@@ -256,7 +256,7 @@ static void tower_disconnect	(struct usb
 
 
 /* prevent races between open() and disconnect */
-static DECLARE_MUTEX (disconnect_sem);
+static DECLARE_SEM_MUTEX (disconnect_sem);
 
 /* file operations needed when we register this driver */
 static struct file_operations tower_fops = {
drivers/usb/misc/sisusbvga/sisusb.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/usb/misc/sisusbvga/sisusb.c linux-2.6.15-rc5-mutex/drivers/usb/misc/sisusbvga/sisusb.c
@@ -102,7 +102,7 @@ MODULE_PARM_DESC(last, "Number of last c
 
 static struct usb_driver sisusb_driver;
 
-DECLARE_MUTEX(disconnect_sem);
+DECLARE_SEM_MUTEX(disconnect_sem);
 
 static void
 sisusb_free_buffers(struct sisusb_usb_data *sisusb)
drivers/usb/mon/mon_main.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/usb/mon/mon_main.c linux-2.6.15-rc5-mutex/drivers/usb/mon/mon_main.c
@@ -23,7 +23,7 @@ static void mon_dissolve(struct mon_bus 
 static void mon_bus_drop(struct kref *r);
 static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus);
 
-DECLARE_MUTEX(mon_lock);
+DECLARE_SEM_MUTEX(mon_lock);
 
 static struct dentry *mon_dir;		/* /dbg/usbmon */
 static LIST_HEAD(mon_buses);		/* All buses we know: struct mon_bus */
drivers/usb/serial/pl2303.c +1 -1
diff -uNrp linux-2.6.15-rc5/drivers/usb/serial/pl2303.c linux-2.6.15-rc5-mutex/drivers/usb/serial/pl2303.c
@@ -43,7 +43,7 @@ static int debug;
 #define PL2303_BUF_SIZE		1024
 #define PL2303_TMP_BUF_SIZE	1024
 
-static DECLARE_MUTEX(pl2303_tmp_buf_sem);
+static DECLARE_SEM_MUTEX(pl2303_tmp_buf_sem);
 
 struct pl2303_buf {
 	unsigned int	buf_size;
author maintainer
#30 lore raw

PATCH 6/12 : MUTEX: Rename DECLARE_MUTEX for fs/ dir

In reply to David Howells

The attached patch renames DECLARE_MUTEX*() to DECLARE_SEM_MUTEX*() for the fs/ directory.

---
warthog>diffstat -p1 mutex-fs-2615rc5-2.diff

 fs/char_dev.c         |    2 +-
 fs/cramfs/inode.c     |    2 +-
 fs/dcookies.c         |    2 +-
 fs/inode.c            |    2 +-
 fs/jffs2/compr_zlib.c |    4 ++--
 fs/jfs/jfs_logmgr.c   |    2 +-
 fs/lockd/host.c       |    2 +-
 fs/lockd/svc.c        |    4 ++--
 fs/lockd/svcsubs.c    |    2 +-
 fs/nfs/callback.c     |    2 +-
 fs/nfsd/nfs4state.c   |    2 +-
 fs/ntfs/super.c       |    2 +-
 fs/partitions/devfs.c |    2 +-
 fs/super.c            |    2 +-
 14 files changed, 16 insertions(+), 16 deletions(-)
fs/char_dev.c +1 -1
diff -uNrp linux-2.6.15-rc5/fs/char_dev.c linux-2.6.15-rc5-mutex/fs/char_dev.c
@@ -28,7 +28,7 @@ static struct kobj_map *cdev_map;
 
 #define MAX_PROBE_HASH 255	/* random */
 
-static DECLARE_MUTEX(chrdevs_lock);
+static DECLARE_SEM_MUTEX(chrdevs_lock);
 
 static struct char_device_struct {
 	struct char_device_struct *next;
fs/cramfs/inode.c +1 -1
diff -uNrp linux-2.6.15-rc5/fs/cramfs/inode.c linux-2.6.15-rc5-mutex/fs/cramfs/inode.c
@@ -31,7 +31,7 @@ static struct inode_operations cramfs_di
 static struct file_operations cramfs_directory_operations;
 static struct address_space_operations cramfs_aops;
 
-static DECLARE_MUTEX(read_mutex);
+static DECLARE_SEM_MUTEX(read_mutex);
 
 
 /* These two macros may change in future, to provide better st_ino
fs/dcookies.c +1 -1
diff -uNrp linux-2.6.15-rc5/fs/dcookies.c linux-2.6.15-rc5-mutex/fs/dcookies.c
@@ -35,7 +35,7 @@ struct dcookie_struct {
 };
 
 static LIST_HEAD(dcookie_users);
-static DECLARE_MUTEX(dcookie_sem);
+static DECLARE_SEM_MUTEX(dcookie_sem);
 static kmem_cache_t * dcookie_cache;
 static struct list_head * dcookie_hashtable;
 static size_t hash_size;
fs/inode.c +1 -1
diff -uNrp linux-2.6.15-rc5/fs/inode.c linux-2.6.15-rc5-mutex/fs/inode.c
@@ -90,7 +90,7 @@ DEFINE_SPINLOCK(inode_lock);
  * from its final dispose_list, the struct super_block they refer to
  * (for inode->i_sb->s_op) may already have been freed and reused.
  */
-DECLARE_MUTEX(iprune_sem);
+DECLARE_SEM_MUTEX(iprune_sem);
 
 /*
  * Statistics gathering..
fs/jffs2/compr_zlib.c +2 -2
diff -uNrp linux-2.6.15-rc5/fs/jffs2/compr_zlib.c linux-2.6.15-rc5-mutex/fs/jffs2/compr_zlib.c
@@ -33,8 +33,8 @@
 	*/
 #define STREAM_END_SPACE 12
 
-static DECLARE_MUTEX(deflate_sem);
-static DECLARE_MUTEX(inflate_sem);
+static DECLARE_SEM_MUTEX(deflate_sem);
+static DECLARE_SEM_MUTEX(inflate_sem);
 static z_stream inf_strm, def_strm;
 
 #ifdef __KERNEL__ /* Linux-only */
fs/jfs/jfs_logmgr.c +1 -1
diff -uNrp linux-2.6.15-rc5/fs/jfs/jfs_logmgr.c linux-2.6.15-rc5-mutex/fs/jfs/jfs_logmgr.c
@@ -165,7 +165,7 @@ do {						\
  */
 static LIST_HEAD(jfs_external_logs);
 static struct jfs_log *dummy_log = NULL;
-static DECLARE_MUTEX(jfs_log_sem);
+static DECLARE_SEM_MUTEX(jfs_log_sem);
 
 /*
  * forward references
fs/lockd/host.c +1 -1
diff -uNrp linux-2.6.15-rc5/fs/lockd/host.c linux-2.6.15-rc5-mutex/fs/lockd/host.c
@@ -30,7 +30,7 @@
 static struct nlm_host *	nlm_hosts[NLM_HOST_NRHASH];
 static unsigned long		next_gc;
 static int			nrhosts;
-static DECLARE_MUTEX(nlm_host_sema);
+static DECLARE_SEM_MUTEX(nlm_host_sema);
 
 
 static void			nlm_gc_hosts(void);
fs/lockd/svc.c +2 -2
diff -uNrp linux-2.6.15-rc5/fs/lockd/svc.c linux-2.6.15-rc5-mutex/fs/lockd/svc.c
@@ -43,13 +43,13 @@ static struct svc_program	nlmsvc_program
 struct nlmsvc_binding *		nlmsvc_ops;
 EXPORT_SYMBOL(nlmsvc_ops);
 
-static DECLARE_MUTEX(nlmsvc_sema);
+static DECLARE_SEM_MUTEX(nlmsvc_sema);
 static unsigned int		nlmsvc_users;
 static pid_t			nlmsvc_pid;
 int				nlmsvc_grace_period;
 unsigned long			nlmsvc_timeout;
 
-static DECLARE_MUTEX_LOCKED(lockd_start);
+static DECLARE_SEM_MUTEX_LOCKED(lockd_start);
 static DECLARE_WAIT_QUEUE_HEAD(lockd_exit);
 
 /*
fs/lockd/svcsubs.c +1 -1
diff -uNrp linux-2.6.15-rc5/fs/lockd/svcsubs.c linux-2.6.15-rc5-mutex/fs/lockd/svcsubs.c
@@ -28,7 +28,7 @@
 #define FILE_HASH_BITS		5
 #define FILE_NRHASH		(1<<FILE_HASH_BITS)
 static struct nlm_file *	nlm_files[FILE_NRHASH];
-static DECLARE_MUTEX(nlm_file_sema);
+static DECLARE_SEM_MUTEX(nlm_file_sema);
 
 #ifdef NFSD_DEBUG
 static inline void nlm_debug_print_fh(char *msg, struct nfs_fh *f)
fs/nfs/callback.c +1 -1
diff -uNrp linux-2.6.15-rc5/fs/nfs/callback.c linux-2.6.15-rc5-mutex/fs/nfs/callback.c
@@ -28,7 +28,7 @@ struct nfs_callback_data {
 };
 
 static struct nfs_callback_data nfs_callback_info;
-static DECLARE_MUTEX(nfs_callback_sema);
+static DECLARE_SEM_MUTEX(nfs_callback_sema);
 static struct svc_program nfs4_callback_program;
 
 unsigned short nfs_callback_tcpport;
fs/nfsd/nfs4state.c +1 -1
diff -uNrp linux-2.6.15-rc5/fs/nfsd/nfs4state.c linux-2.6.15-rc5-mutex/fs/nfsd/nfs4state.c
@@ -81,7 +81,7 @@ static void nfs4_set_recdir(char *recdir
  * 	protects clientid_hashtbl[], clientstr_hashtbl[],
  * 	unconfstr_hashtbl[], uncofid_hashtbl[].
  */
-static DECLARE_MUTEX(client_sema);
+static DECLARE_SEM_MUTEX(client_sema);
 
 static kmem_cache_t *stateowner_slab = NULL;
 static kmem_cache_t *file_slab = NULL;
fs/ntfs/super.c +1 -1
diff -uNrp linux-2.6.15-rc5/fs/ntfs/super.c linux-2.6.15-rc5-mutex/fs/ntfs/super.c
@@ -3012,7 +3012,7 @@ kmem_cache_t *ntfs_attr_ctx_cache;
 kmem_cache_t *ntfs_index_ctx_cache;
 
 /* Driver wide semaphore. */
-DECLARE_MUTEX(ntfs_lock);
+DECLARE_SEM_MUTEX(ntfs_lock);
 
 static struct super_block *ntfs_get_sb(struct file_system_type *fs_type,
 	int flags, const char *dev_name, void *data)
fs/partitions/devfs.c +1 -1
diff -uNrp linux-2.6.15-rc5/fs/partitions/devfs.c linux-2.6.15-rc5-mutex/fs/partitions/devfs.c
@@ -16,7 +16,7 @@ struct unique_numspace {
 	struct semaphore  mutex;
 };
 
-static DECLARE_MUTEX(numspace_mutex);
+static DECLARE_SEM_MUTEX(numspace_mutex);
 
 static int expand_numspace(struct unique_numspace *s)
 {
fs/super.c +1 -1
diff -uNrp linux-2.6.15-rc5/fs/super.c linux-2.6.15-rc5-mutex/fs/super.c
@@ -380,7 +380,7 @@ restart:
 void sync_filesystems(int wait)
 {
 	struct super_block *sb;
-	static DECLARE_MUTEX(mutex);
+	static DECLARE_SEM_MUTEX(mutex);
 
 	down(&mutex);		/* Could be down_interruptible */
 	spin_lock(&sb_lock);
author maintainer
#31 lore raw

PATCH 7/12 : MUTEX: Rename DECLARE_MUTEX for include/asm-*/ dirs

In reply to David Howells

The attached patch renames DECLARE_MUTEX*() to DECLARE_SEM_MUTEX*() for the include/asm-*/ directories.

Additionally, for the i386 arch it also implements sem_is_locked().

---
warthog>diffstat -p1 mutex-incasm-2615rc5-2.diff

 include/asm-alpha/semaphore.h     |    4 ++--
 include/asm-arm/semaphore.h       |    4 ++--
 include/asm-arm26/semaphore.h     |    4 ++--
 include/asm-cris/semaphore.h      |    4 ++--
 include/asm-frv/semaphore.h       |    4 ++--
 include/asm-h8300/semaphore.h     |    4 ++--
 include/asm-i386/semaphore.h      |    5 +++--
 include/asm-ia64/semaphore.h      |    4 ++--
 include/asm-m32r/semaphore.h      |    4 ++--
 include/asm-m68k/semaphore.h      |    4 ++--
 include/asm-m68knommu/semaphore.h |    4 ++--
 include/asm-mips/semaphore.h      |    4 ++--
 include/asm-parisc/semaphore.h    |    4 ++--
 include/asm-powerpc/semaphore.h   |    4 ++--
 include/asm-s390/semaphore.h      |    4 ++--
 include/asm-sh/semaphore.h        |    4 ++--
 include/asm-sh64/semaphore.h      |    4 ++--
 include/asm-sparc/semaphore.h     |    4 ++--
 include/asm-sparc64/semaphore.h   |    4 ++--
 include/asm-v850/semaphore.h      |    4 ++--
 include/asm-x86_64/semaphore.h    |    4 ++--
 include/asm-xtensa/semaphore.h    |    4 ++--
 22 files changed, 45 insertions(+), 44 deletions(-)
include/asm-alpha/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-alpha/semaphore.h linux-2.6.15-rc5-mutex/include/asm-alpha/semaphore.h
@@ -29,8 +29,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count)		\
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init(struct semaphore *sem, int val)
 {
include/asm-arm/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-arm/semaphore.h linux-2.6.15-rc5-mutex/include/asm-arm/semaphore.h
@@ -27,8 +27,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count)	\
 	struct semaphore name = __SEMAPHORE_INIT(name,count)
 
-#define DECLARE_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init(struct semaphore *sem, int val)
 {
include/asm-arm26/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-arm26/semaphore.h linux-2.6.15-rc5-mutex/include/asm-arm26/semaphore.h
@@ -28,8 +28,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count)	\
 	struct semaphore name = __SEMAPHORE_INIT(name,count)
 
-#define DECLARE_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init(struct semaphore *sem, int val)
 {
include/asm-cris/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-cris/semaphore.h linux-2.6.15-rc5-mutex/include/asm-cris/semaphore.h
@@ -34,8 +34,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count) \
         struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init(struct semaphore *sem, int val)
 {
include/asm-frv/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-frv/semaphore.h linux-2.6.15-rc5-mutex/include/asm-frv/semaphore.h
@@ -50,8 +50,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count) \
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init (struct semaphore *sem, int val)
 {
include/asm-h8300/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-h8300/semaphore.h linux-2.6.15-rc5-mutex/include/asm-h8300/semaphore.h
@@ -38,8 +38,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count) \
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init (struct semaphore *sem, int val)
 {
include/asm-i386/semaphore.h +3 -2
diff -uNrp linux-2.6.15-rc5/include/asm-i386/semaphore.h linux-2.6.15-rc5-mutex/include/asm-i386/semaphore.h
@@ -47,6 +47,7 @@ struct semaphore {
 	wait_queue_head_t wait;
 };
 
+#define sem_is_locked(s) (atomic_read(&(s)->count) <= 0)
 
 #define __SEMAPHORE_INITIALIZER(name, n)				\
 {									\
@@ -58,8 +59,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count) \
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init (struct semaphore *sem, int val)
 {
include/asm-ia64/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-ia64/semaphore.h linux-2.6.15-rc5-mutex/include/asm-ia64/semaphore.h
@@ -27,8 +27,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count)					\
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name, count)
 
-#define DECLARE_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC(name, 1)
-#define DECLARE_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC(name, 0)
+#define DECLARE_SEM_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC(name, 1)
+#define DECLARE_SEM_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC(name, 0)
 
 static inline void
 sema_init (struct semaphore *sem, int val)
include/asm-m32r/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-m32r/semaphore.h linux-2.6.15-rc5-mutex/include/asm-m32r/semaphore.h
@@ -35,8 +35,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count) \
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init (struct semaphore *sem, int val)
 {
include/asm-m68k/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-m68k/semaphore.h linux-2.6.15-rc5-mutex/include/asm-m68k/semaphore.h
@@ -39,8 +39,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count) \
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init(struct semaphore *sem, int val)
 {
include/asm-m68knommu/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-m68knommu/semaphore.h linux-2.6.15-rc5-mutex/include/asm-m68knommu/semaphore.h
@@ -38,8 +38,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count) \
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init (struct semaphore *sem, int val)
 {
include/asm-mips/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-mips/semaphore.h linux-2.6.15-rc5-mutex/include/asm-mips/semaphore.h
@@ -48,8 +48,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name, count) \
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC(name, 1)
-#define DECLARE_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC(name, 0)
+#define DECLARE_SEM_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC(name, 1)
+#define DECLARE_SEM_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC(name, 0)
 
 static inline void sema_init (struct semaphore *sem, int val)
 {
include/asm-parisc/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-parisc/semaphore.h linux-2.6.15-rc5-mutex/include/asm-parisc/semaphore.h
@@ -52,8 +52,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count) \
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
 extern inline void sema_init (struct semaphore *sem, int val)
 {
include/asm-powerpc/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-powerpc/semaphore.h linux-2.6.15-rc5-mutex/include/asm-powerpc/semaphore.h
@@ -34,8 +34,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name, count) \
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC(name, 1)
-#define DECLARE_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC(name, 0)
+#define DECLARE_SEM_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC(name, 1)
+#define DECLARE_SEM_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC(name, 0)
 
 static inline void sema_init (struct semaphore *sem, int val)
 {
include/asm-s390/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-s390/semaphore.h linux-2.6.15-rc5-mutex/include/asm-s390/semaphore.h
@@ -32,8 +32,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count) \
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init (struct semaphore *sem, int val)
 {
include/asm-sh/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-sh/semaphore.h linux-2.6.15-rc5-mutex/include/asm-sh/semaphore.h
@@ -36,8 +36,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count) \
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init (struct semaphore *sem, int val)
 {
include/asm-sh64/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-sh64/semaphore.h linux-2.6.15-rc5-mutex/include/asm-sh64/semaphore.h
@@ -43,8 +43,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count) \
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init (struct semaphore *sem, int val)
 {
include/asm-sparc/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-sparc/semaphore.h linux-2.6.15-rc5-mutex/include/asm-sparc/semaphore.h
@@ -25,8 +25,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count) \
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init (struct semaphore *sem, int val)
 {
include/asm-sparc64/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-sparc64/semaphore.h linux-2.6.15-rc5-mutex/include/asm-sparc64/semaphore.h
@@ -25,8 +25,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name, count) \
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC(name, 1)
-#define DECLARE_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC(name, 0)
+#define DECLARE_SEM_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC(name, 1)
+#define DECLARE_SEM_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC(name, 0)
 
 static inline void sema_init (struct semaphore *sem, int val)
 {
include/asm-v850/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-v850/semaphore.h linux-2.6.15-rc5-mutex/include/asm-v850/semaphore.h
@@ -21,8 +21,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count)	\
 	struct semaphore name = __SEMAPHORE_INITIALIZER (name,count)
 
-#define DECLARE_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC (name,1)
-#define DECLARE_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC (name,0)
+#define DECLARE_SEM_MUTEX(name)		__DECLARE_SEMAPHORE_GENERIC (name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name)	__DECLARE_SEMAPHORE_GENERIC (name,0)
 
 static inline void sema_init (struct semaphore *sem, int val)
 {
include/asm-x86_64/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-x86_64/semaphore.h linux-2.6.15-rc5-mutex/include/asm-x86_64/semaphore.h
@@ -59,8 +59,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count) \
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init (struct semaphore *sem, int val)
 {
include/asm-xtensa/semaphore.h +2 -2
diff -uNrp linux-2.6.15-rc5/include/asm-xtensa/semaphore.h linux-2.6.15-rc5-mutex/include/asm-xtensa/semaphore.h
@@ -32,8 +32,8 @@ struct semaphore {
 #define __DECLARE_SEMAPHORE_GENERIC(name,count) 			\
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
 
-#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
-#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+#define DECLARE_SEM_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_SEM_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
 static inline void sema_init (struct semaphore *sem, int val)
 {
author maintainer
#32 lore raw

PATCH 8/12 : MUTEX: Rename DECLARE_MUTEX for kernel/ dir

In reply to David Howells

The attached patch renames DECLARE_MUTEX*() to DECLARE_SEM_MUTEX*() for the kernel/ directory.

---
warthog>diffstat -p1 mutex-kernel-2615rc5-2.diff

 kernel/Makefile        |    3 
 kernel/audit.c         |    2 
 kernel/cpu.c           |    2 
 kernel/cpuset.c        |    4 
 kernel/irq/autoprobe.c |    2 
 kernel/kthread.c       |    2 
 kernel/module.c        |    4 
 kernel/mutex-cmpxchg.c |  298 +++++++++++++++++++++++++++++++++++++++++++++++++
 kernel/mutex-xchg.c    |  220 ++++++++++++++++++++++++++++++++++++
 kernel/posix-timers.c  |    2 
 kernel/power/main.c    |    2 
 kernel/power/pm.c      |    2 
 kernel/printk.c        |    2 
 kernel/profile.c       |    2 
 kernel/stop_machine.c  |    2 
 15 files changed, 535 insertions(+), 14 deletions(-)
kernel/Makefile +3 -0
diff -uNrp linux-2.6.15-rc5/kernel/Makefile linux-2.6.15-rc5-mutex/kernel/Makefile
@@ -33,6 +33,9 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
 obj-$(CONFIG_SECCOMP) += seccomp.o
 obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
 
+obj-$(CONFIG_ARCH_CMPXCHG_MUTEX) += mutex-cmpxchg.o
+obj-$(CONFIG_ARCH_XCHG_MUTEX) += mutex-xchg.o
+
 ifneq ($(CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER),y)
 # According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is
 # needed for x86 only.  Why this used to be enabled for all architectures is beyond
kernel/audit.c +1 -1
diff -uNrp linux-2.6.15-rc5/kernel/audit.c linux-2.6.15-rc5-mutex/kernel/audit.c
@@ -113,7 +113,7 @@ static DECLARE_WAIT_QUEUE_HEAD(audit_bac
 /* The netlink socket is only to be read by 1 CPU, which lets us assume
  * that list additions and deletions never happen simultaneously in
  * auditsc.c */
-DECLARE_MUTEX(audit_netlink_sem);
+DECLARE_SEM_MUTEX(audit_netlink_sem);
 
 /* AUDIT_BUFSIZ is the size of the temporary buffer used for formatting
  * audit records.  Since printk uses a 1024 byte buffer, this buffer
kernel/cpu.c +1 -1
diff -uNrp linux-2.6.15-rc5/kernel/cpu.c linux-2.6.15-rc5-mutex/kernel/cpu.c
@@ -16,7 +16,7 @@
 #include <asm/semaphore.h>
 
 /* This protects CPUs going up and down... */
-static DECLARE_MUTEX(cpucontrol);
+static DECLARE_SEM_MUTEX(cpucontrol);
 
 static struct notifier_block *cpu_chain;
 
kernel/cpuset.c +2 -2
diff -uNrp linux-2.6.15-rc5/kernel/cpuset.c linux-2.6.15-rc5-mutex/kernel/cpuset.c
@@ -229,8 +229,8 @@ static struct super_block *cpuset_sb = N
  * such matters.
  */
 
-static DECLARE_MUTEX(manage_sem);
-static DECLARE_MUTEX(callback_sem);
+static DECLARE_SEM_MUTEX(manage_sem);
+static DECLARE_SEM_MUTEX(callback_sem);
 
 /*
  * A couple of forward declarations required, due to cyclic reference loop:
kernel/irq/autoprobe.c +1 -1
diff -uNrp linux-2.6.15-rc5/kernel/irq/autoprobe.c linux-2.6.15-rc5-mutex/kernel/irq/autoprobe.c
@@ -16,7 +16,7 @@
  * comes in on to an unassigned handler will get stuck with
  * "IRQ_WAITING" cleared and the interrupt disabled.
  */
-static DECLARE_MUTEX(probe_sem);
+static DECLARE_SEM_MUTEX(probe_sem);
 
 /**
  *	probe_irq_on	- begin an interrupt autodetect
kernel/kthread.c +1 -1
diff -uNrp linux-2.6.15-rc5/kernel/kthread.c linux-2.6.15-rc5-mutex/kernel/kthread.c
@@ -41,7 +41,7 @@ struct kthread_stop_info
 
 /* Thread stopping is done by setthing this var: lock serializes
  * multiple kthread_stop calls. */
-static DECLARE_MUTEX(kthread_stop_lock);
+static DECLARE_SEM_MUTEX(kthread_stop_lock);
 static struct kthread_stop_info kthread_stop_info;
 
 int kthread_should_stop(void)
kernel/module.c +2 -2
diff -uNrp linux-2.6.15-rc5/kernel/module.c linux-2.6.15-rc5-mutex/kernel/module.c
@@ -59,10 +59,10 @@
 static DEFINE_SPINLOCK(modlist_lock);
 
 /* List of modules, protected by module_mutex AND modlist_lock */
-static DECLARE_MUTEX(module_mutex);
+static DECLARE_SEM_MUTEX(module_mutex);
 static LIST_HEAD(modules);
 
-static DECLARE_MUTEX(notify_mutex);
+static DECLARE_SEM_MUTEX(notify_mutex);
 static struct notifier_block * module_notify_list;
 
 int register_module_notifier(struct notifier_block * nb)
kernel/mutex-cmpxchg.c +298 -0

298 lines not on this page · raw message

kernel/mutex-xchg.c +220 -0

220 lines not on this page · raw message

kernel/posix-timers.c +1 -1
diff -uNrp linux-2.6.15-rc5/kernel/posix-timers.c linux-2.6.15-rc5-mutex/kernel/posix-timers.c
@@ -1312,7 +1312,7 @@ sys_clock_getres(clockid_t which_clock, 
 static DECLARE_WAIT_QUEUE_HEAD(nanosleep_abs_wqueue);
 static DECLARE_WORK(clock_was_set_work, (void(*)(void*))clock_was_set, NULL);
 
-static DECLARE_MUTEX(clock_was_set_lock);
+static DECLARE_SEM_MUTEX(clock_was_set_lock);
 
 void clock_was_set(void)
 {
kernel/power/main.c +1 -1
diff -uNrp linux-2.6.15-rc5/kernel/power/main.c linux-2.6.15-rc5-mutex/kernel/power/main.c
@@ -22,7 +22,7 @@
 /*This is just an arbitrary number */
 #define FREE_PAGE_NUMBER (100)
 
-DECLARE_MUTEX(pm_sem);
+DECLARE_SEM_MUTEX(pm_sem);
 
 struct pm_ops *pm_ops;
 suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;
kernel/power/pm.c +1 -1
diff -uNrp linux-2.6.15-rc5/kernel/power/pm.c linux-2.6.15-rc5-mutex/kernel/power/pm.c
@@ -40,7 +40,7 @@ int pm_active;
  *	until a resume but that will be fine.
  */
  
-static DECLARE_MUTEX(pm_devs_lock);
+static DECLARE_SEM_MUTEX(pm_devs_lock);
 static LIST_HEAD(pm_devs);
 
 /**
kernel/printk.c +1 -1
diff -uNrp linux-2.6.15-rc5/kernel/printk.c linux-2.6.15-rc5-mutex/kernel/printk.c
@@ -66,7 +66,7 @@ EXPORT_SYMBOL(oops_in_progress);
  * provides serialisation for access to the entire console
  * driver system.
  */
-static DECLARE_MUTEX(console_sem);
+static DECLARE_SEM_MUTEX(console_sem);
 struct console *console_drivers;
 /*
  * This is used for debugging the mess that is the VT code by
kernel/profile.c +1 -1
diff -uNrp linux-2.6.15-rc5/kernel/profile.c linux-2.6.15-rc5-mutex/kernel/profile.c
@@ -44,7 +44,7 @@ static cpumask_t prof_cpu_mask = CPU_MAS
 #ifdef CONFIG_SMP
 static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits);
 static DEFINE_PER_CPU(int, cpu_profile_flip);
-static DECLARE_MUTEX(profile_flip_mutex);
+static DECLARE_SEM_MUTEX(profile_flip_mutex);
 #endif /* CONFIG_SMP */
 
 static int __init profile_setup(char * str)
kernel/stop_machine.c +1 -1
diff -uNrp linux-2.6.15-rc5/kernel/stop_machine.c linux-2.6.15-rc5-mutex/kernel/stop_machine.c
@@ -23,7 +23,7 @@ enum stopmachine_state {
 static enum stopmachine_state stopmachine_state;
 static unsigned int stopmachine_num_threads;
 static atomic_t stopmachine_thread_ack;
-static DECLARE_MUTEX(stopmachine_mutex);
+static DECLARE_SEM_MUTEX(stopmachine_mutex);
 
 static int stopmachine(void *cpu)
 {
author maintainer
#33 lore raw

PATCH 9/12 : MUTEX: Rename DECLARE_MUTEX for net/ dir

In reply to David Howells

The attached patch renames DECLARE_MUTEX*() to DECLARE_SEM_MUTEX*() for the net/ directory.

---
warthog>diffstat -p1 mutex-net-2615rc5-2.diff

 net/atm/ioctl.c                    |    2 +-
 net/atm/resources.c                |    2 +-
 net/bluetooth/rfcomm/core.c        |    2 +-
 net/bridge/netfilter/ebtables.c    |    2 +-
 net/core/dev.c                     |    2 +-
 net/core/flow.c                    |    2 +-
 net/core/pktgen.c                  |    2 +-
 net/core/rtnetlink.c               |    2 +-
 net/ipv4/ipcomp.c                  |    2 +-
 net/ipv4/ipvs/ip_vs_app.c          |    2 +-
 net/ipv4/ipvs/ip_vs_ctl.c          |    2 +-
 net/ipv4/netfilter/arp_tables.c    |    2 +-
 net/ipv4/netfilter/ip_queue.c      |    2 +-
 net/ipv4/netfilter/ip_tables.c     |    2 +-
 net/ipv4/netfilter/ipt_hashlimit.c |    2 +-
 net/ipv4/xfrm4_tunnel.c            |    2 +-
 net/ipv6/ipcomp6.c                 |    2 +-
 net/ipv6/netfilter/ip6_queue.c     |    2 +-
 net/ipv6/netfilter/ip6_tables.c    |    2 +-
 net/ipv6/xfrm6_tunnel.c            |    2 +-
 net/netfilter/nf_conntrack_core.c  |    2 +-
 net/netfilter/nf_sockopt.c         |    2 +-
 net/netfilter/nfnetlink.c          |    2 +-
 net/netlink/genetlink.c            |    2 +-
 net/socket.c                       |    6 +++---
 net/sunrpc/cache.c                 |    2 +-
 net/sunrpc/sched.c                 |    4 ++--
 net/unix/garbage.c                 |    2 +-
 net/xfrm/xfrm_policy.c             |    2 +-
 29 files changed, 32 insertions(+), 32 deletions(-)
net/atm/ioctl.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/atm/ioctl.c linux-2.6.15-rc5-mutex/net/atm/ioctl.c
@@ -24,7 +24,7 @@
 #include "common.h"
 
 
-static DECLARE_MUTEX(ioctl_mutex);
+static DECLARE_SEM_MUTEX(ioctl_mutex);
 static LIST_HEAD(ioctl_list);
 
 
net/atm/resources.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/atm/resources.c linux-2.6.15-rc5-mutex/net/atm/resources.c
@@ -25,7 +25,7 @@
 
 
 LIST_HEAD(atm_devs);
-DECLARE_MUTEX(atm_dev_mutex);
+DECLARE_SEM_MUTEX(atm_dev_mutex);
 
 static struct atm_dev *__alloc_atm_dev(const char *type)
 {
net/bluetooth/rfcomm/core.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/bluetooth/rfcomm/core.c linux-2.6.15-rc5-mutex/net/bluetooth/rfcomm/core.c
@@ -55,7 +55,7 @@
 
 static struct task_struct *rfcomm_thread;
 
-static DECLARE_MUTEX(rfcomm_sem);
+static DECLARE_SEM_MUTEX(rfcomm_sem);
 #define rfcomm_lock()	down(&rfcomm_sem);
 #define rfcomm_unlock()	up(&rfcomm_sem);
 
net/bridge/netfilter/ebtables.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/bridge/netfilter/ebtables.c linux-2.6.15-rc5-mutex/net/bridge/netfilter/ebtables.c
@@ -81,7 +81,7 @@ static void print_string(char *str)
 
 
 
-static DECLARE_MUTEX(ebt_mutex);
+static DECLARE_SEM_MUTEX(ebt_mutex);
 static LIST_HEAD(ebt_tables);
 static LIST_HEAD(ebt_targets);
 static LIST_HEAD(ebt_matches);
net/core/dev.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/core/dev.c linux-2.6.15-rc5-mutex/net/core/dev.c
@@ -2902,7 +2902,7 @@ static void netdev_wait_allrefs(struct n
  * 2) Since we run with the RTNL semaphore not held, we can sleep
  *    safely in order to wait for the netdev refcnt to drop to zero.
  */
-static DECLARE_MUTEX(net_todo_run_mutex);
+static DECLARE_SEM_MUTEX(net_todo_run_mutex);
 void netdev_run_todo(void)
 {
 	struct list_head list = LIST_HEAD_INIT(list);
net/core/flow.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/core/flow.c linux-2.6.15-rc5-mutex/net/core/flow.c
@@ -283,7 +283,7 @@ static void flow_cache_flush_per_cpu(voi
 void flow_cache_flush(void)
 {
 	struct flow_flush_info info;
-	static DECLARE_MUTEX(flow_flush_sem);
+	static DECLARE_SEM_MUTEX(flow_flush_sem);
 
 	/* Don't want cpus going down or up during this. */
 	lock_cpu_hotplug();
net/core/pktgen.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/core/pktgen.c linux-2.6.15-rc5-mutex/net/core/pktgen.c
@@ -491,7 +491,7 @@ static int pg_delay_d = 0;
 static int pg_clone_skb_d = 0;
 static int debug = 0;
 
-static DECLARE_MUTEX(pktgen_sem);
+static DECLARE_SEM_MUTEX(pktgen_sem);
 static struct pktgen_thread *pktgen_threads = NULL;
 
 static struct notifier_block pktgen_notifier_block = {
net/core/rtnetlink.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/core/rtnetlink.c linux-2.6.15-rc5-mutex/net/core/rtnetlink.c
@@ -51,7 +51,7 @@
 #include <net/pkt_sched.h>
 #include <net/netlink.h>
 
-DECLARE_MUTEX(rtnl_sem);
+DECLARE_SEM_MUTEX(rtnl_sem);
 
 void rtnl_lock(void)
 {
net/ipv4/ipcomp.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/ipv4/ipcomp.c linux-2.6.15-rc5-mutex/net/ipv4/ipcomp.c
@@ -35,7 +35,7 @@ struct ipcomp_tfms {
 	int users;
 };
 
-static DECLARE_MUTEX(ipcomp_resource_sem);
+static DECLARE_SEM_MUTEX(ipcomp_resource_sem);
 static void **ipcomp_scratches;
 static int ipcomp_scratch_users;
 static LIST_HEAD(ipcomp_tfms_list);
net/ipv4/ipvs/ip_vs_app.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/ipv4/ipvs/ip_vs_app.c linux-2.6.15-rc5-mutex/net/ipv4/ipvs/ip_vs_app.c
@@ -40,7 +40,7 @@ EXPORT_SYMBOL(register_ip_vs_app_inc);
 
 /* ipvs application list head */
 static LIST_HEAD(ip_vs_app_list);
-static DECLARE_MUTEX(__ip_vs_app_mutex);
+static DECLARE_SEM_MUTEX(__ip_vs_app_mutex);
 
 
 /*
net/ipv4/ipvs/ip_vs_ctl.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/ipv4/ipvs/ip_vs_ctl.c linux-2.6.15-rc5-mutex/net/ipv4/ipvs/ip_vs_ctl.c
@@ -42,7 +42,7 @@
 #include <net/ip_vs.h>
 
 /* semaphore for IPVS sockopts. And, [gs]etsockopt may sleep. */
-static DECLARE_MUTEX(__ip_vs_mutex);
+static DECLARE_SEM_MUTEX(__ip_vs_mutex);
 
 /* lock for service table */
 static DEFINE_RWLOCK(__ip_vs_svc_lock);
net/ipv4/netfilter/arp_tables.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/ipv4/netfilter/arp_tables.c linux-2.6.15-rc5-mutex/net/ipv4/netfilter/arp_tables.c
@@ -56,7 +56,7 @@ do {								\
 #endif
 #define SMP_ALIGN(x) (((x) + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1))
 
-static DECLARE_MUTEX(arpt_mutex);
+static DECLARE_SEM_MUTEX(arpt_mutex);
 
 #define ASSERT_READ_LOCK(x) ARP_NF_ASSERT(down_trylock(&arpt_mutex) != 0)
 #define ASSERT_WRITE_LOCK(x) ARP_NF_ASSERT(down_trylock(&arpt_mutex) != 0)
net/ipv4/netfilter/ip_queue.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/ipv4/netfilter/ip_queue.c linux-2.6.15-rc5-mutex/net/ipv4/netfilter/ip_queue.c
@@ -61,7 +61,7 @@ static unsigned int queue_dropped = 0;
 static unsigned int queue_user_dropped = 0;
 static struct sock *ipqnl;
 static LIST_HEAD(queue_list);
-static DECLARE_MUTEX(ipqnl_sem);
+static DECLARE_SEM_MUTEX(ipqnl_sem);
 
 static void
 ipq_issue_verdict(struct ipq_queue_entry *entry, int verdict)
net/ipv4/netfilter/ip_tables.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/ipv4/netfilter/ip_tables.c linux-2.6.15-rc5-mutex/net/ipv4/netfilter/ip_tables.c
@@ -63,7 +63,7 @@ do {								\
 #endif
 #define SMP_ALIGN(x) (((x) + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1))
 
-static DECLARE_MUTEX(ipt_mutex);
+static DECLARE_SEM_MUTEX(ipt_mutex);
 
 /* Must have mutex */
 #define ASSERT_READ_LOCK(x) IP_NF_ASSERT(down_trylock(&ipt_mutex) != 0)
net/ipv4/netfilter/ipt_hashlimit.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/ipv4/netfilter/ipt_hashlimit.c linux-2.6.15-rc5-mutex/net/ipv4/netfilter/ipt_hashlimit.c
@@ -92,7 +92,7 @@ struct ipt_hashlimit_htable {
 };
 
 static DEFINE_SPINLOCK(hashlimit_lock);	/* protects htables list */
-static DECLARE_MUTEX(hlimit_mutex);	/* additional checkentry protection */
+static DECLARE_SEM_MUTEX(hlimit_mutex);	/* additional checkentry protection */
 static HLIST_HEAD(hashlimit_htables);
 static kmem_cache_t *hashlimit_cachep __read_mostly;
 
net/ipv4/xfrm4_tunnel.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/ipv4/xfrm4_tunnel.c linux-2.6.15-rc5-mutex/net/ipv4/xfrm4_tunnel.c
@@ -26,7 +26,7 @@ static int ipip_xfrm_rcv(struct xfrm_sta
 }
 
 static struct xfrm_tunnel *ipip_handler;
-static DECLARE_MUTEX(xfrm4_tunnel_sem);
+static DECLARE_SEM_MUTEX(xfrm4_tunnel_sem);
 
 int xfrm4_tunnel_register(struct xfrm_tunnel *handler)
 {
net/ipv6/ipcomp6.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/ipv6/ipcomp6.c linux-2.6.15-rc5-mutex/net/ipv6/ipcomp6.c
@@ -56,7 +56,7 @@ struct ipcomp6_tfms {
 	int users;
 };
 
-static DECLARE_MUTEX(ipcomp6_resource_sem);
+static DECLARE_SEM_MUTEX(ipcomp6_resource_sem);
 static void **ipcomp6_scratches;
 static int ipcomp6_scratch_users;
 static LIST_HEAD(ipcomp6_tfms_list);
net/ipv6/netfilter/ip6_queue.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/ipv6/netfilter/ip6_queue.c linux-2.6.15-rc5-mutex/net/ipv6/netfilter/ip6_queue.c
@@ -65,7 +65,7 @@ static unsigned int queue_dropped = 0;
 static unsigned int queue_user_dropped = 0;
 static struct sock *ipqnl;
 static LIST_HEAD(queue_list);
-static DECLARE_MUTEX(ipqnl_sem);
+static DECLARE_SEM_MUTEX(ipqnl_sem);
 
 static void
 ipq_issue_verdict(struct ipq_queue_entry *entry, int verdict)
net/ipv6/netfilter/ip6_tables.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/ipv6/netfilter/ip6_tables.c linux-2.6.15-rc5-mutex/net/ipv6/netfilter/ip6_tables.c
@@ -66,7 +66,7 @@ do {								\
 #endif
 #define SMP_ALIGN(x) (((x) + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1))
 
-static DECLARE_MUTEX(ip6t_mutex);
+static DECLARE_SEM_MUTEX(ip6t_mutex);
 
 /* Must have mutex */
 #define ASSERT_READ_LOCK(x) IP_NF_ASSERT(down_trylock(&ip6t_mutex) != 0)
net/ipv6/xfrm6_tunnel.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/ipv6/xfrm6_tunnel.c linux-2.6.15-rc5-mutex/net/ipv6/xfrm6_tunnel.c
@@ -359,7 +359,7 @@ static int xfrm6_tunnel_input(struct xfr
 }
 
 static struct xfrm6_tunnel *xfrm6_tunnel_handler;
-static DECLARE_MUTEX(xfrm6_tunnel_sem);
+static DECLARE_SEM_MUTEX(xfrm6_tunnel_sem);
 
 int xfrm6_tunnel_register(struct xfrm6_tunnel *handler)
 {
net/netfilter/nf_conntrack_core.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/netfilter/nf_conntrack_core.c linux-2.6.15-rc5-mutex/net/netfilter/nf_conntrack_core.c
@@ -180,7 +180,7 @@ static struct {
 DEFINE_RWLOCK(nf_ct_cache_lock);
 
 /* This avoids calling kmem_cache_create() with same name simultaneously */
-DECLARE_MUTEX(nf_ct_cache_mutex);
+DECLARE_SEM_MUTEX(nf_ct_cache_mutex);
 
 extern struct nf_conntrack_protocol nf_conntrack_generic_protocol;
 struct nf_conntrack_protocol *
net/netfilter/nf_sockopt.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/netfilter/nf_sockopt.c linux-2.6.15-rc5-mutex/net/netfilter/nf_sockopt.c
@@ -11,7 +11,7 @@
 /* Sockopts only registered and called from user context, so
    net locking would be overkill.  Also, [gs]etsockopt calls may
    sleep. */
-static DECLARE_MUTEX(nf_sockopt_mutex);
+static DECLARE_SEM_MUTEX(nf_sockopt_mutex);
 static LIST_HEAD(nf_sockopts);
 
 /* Do exclusive ranges overlap? */
net/netfilter/nfnetlink.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/netfilter/nfnetlink.c linux-2.6.15-rc5-mutex/net/netfilter/nfnetlink.c
@@ -53,7 +53,7 @@ static char __initdata nfversion[] = "0.
 
 static struct sock *nfnl = NULL;
 static struct nfnetlink_subsystem *subsys_table[NFNL_SUBSYS_COUNT];
-DECLARE_MUTEX(nfnl_sem);
+DECLARE_SEM_MUTEX(nfnl_sem);
 
 void nfnl_lock(void)
 {
net/netlink/genetlink.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/netlink/genetlink.c linux-2.6.15-rc5-mutex/net/netlink/genetlink.c
@@ -18,7 +18,7 @@
 
 struct sock *genl_sock = NULL;
 
-static DECLARE_MUTEX(genl_sem); /* serialization of message processing */
+static DECLARE_SEM_MUTEX(genl_sem); /* serialization of message processing */
 
 static void genl_lock(void)
 {
net/socket.c +3 -3
diff -uNrp linux-2.6.15-rc5/net/socket.c linux-2.6.15-rc5-mutex/net/socket.c
@@ -796,7 +796,7 @@ static ssize_t sock_writev(struct file *
  * with module unload.
  */
 
-static DECLARE_MUTEX(br_ioctl_mutex);
+static DECLARE_SEM_MUTEX(br_ioctl_mutex);
 static int (*br_ioctl_hook)(unsigned int cmd, void __user *arg) = NULL;
 
 void brioctl_set(int (*hook)(unsigned int, void __user *))
@@ -807,7 +807,7 @@ void brioctl_set(int (*hook)(unsigned in
 }
 EXPORT_SYMBOL(brioctl_set);
 
-static DECLARE_MUTEX(vlan_ioctl_mutex);
+static DECLARE_SEM_MUTEX(vlan_ioctl_mutex);
 static int (*vlan_ioctl_hook)(void __user *arg);
 
 void vlan_ioctl_set(int (*hook)(void __user *))
@@ -818,7 +818,7 @@ void vlan_ioctl_set(int (*hook)(void __u
 }
 EXPORT_SYMBOL(vlan_ioctl_set);
 
-static DECLARE_MUTEX(dlci_ioctl_mutex);
+static DECLARE_SEM_MUTEX(dlci_ioctl_mutex);
 static int (*dlci_ioctl_hook)(unsigned int, void __user *);
 
 void dlci_ioctl_set(int (*hook)(unsigned int, void __user *))
net/sunrpc/cache.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/sunrpc/cache.c linux-2.6.15-rc5-mutex/net/sunrpc/cache.c
@@ -532,7 +532,7 @@ void cache_clean_deferred(void *owner)
  */
 
 static DEFINE_SPINLOCK(queue_lock);
-static DECLARE_MUTEX(queue_io_sem);
+static DECLARE_SEM_MUTEX(queue_io_sem);
 
 struct cache_queue {
 	struct list_head	list;
net/sunrpc/sched.c +2 -2
diff -uNrp linux-2.6.15-rc5/net/sunrpc/sched.c linux-2.6.15-rc5-mutex/net/sunrpc/sched.c
@@ -64,7 +64,7 @@ static LIST_HEAD(all_tasks);
 /*
  * rpciod-related stuff
  */
-static DECLARE_MUTEX(rpciod_sema);
+static DECLARE_SEM_MUTEX(rpciod_sema);
 static unsigned int		rpciod_users;
 static struct workqueue_struct *rpciod_workqueue;
 
@@ -971,7 +971,7 @@ void rpc_killall_tasks(struct rpc_clnt *
 	spin_unlock(&rpc_sched_lock);
 }
 
-static DECLARE_MUTEX_LOCKED(rpciod_running);
+static DECLARE_SEM_MUTEX_LOCKED(rpciod_running);
 
 static void rpciod_killall(void)
 {
net/unix/garbage.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/unix/garbage.c linux-2.6.15-rc5-mutex/net/unix/garbage.c
@@ -169,7 +169,7 @@ static void maybe_unmark_and_push(struct
 
 void unix_gc(void)
 {
-	static DECLARE_MUTEX(unix_gc_sem);
+	static DECLARE_SEM_MUTEX(unix_gc_sem);
 	int i;
 	struct sock *s;
 	struct sk_buff_head hitlist;
net/xfrm/xfrm_policy.c +1 -1
diff -uNrp linux-2.6.15-rc5/net/xfrm/xfrm_policy.c linux-2.6.15-rc5-mutex/net/xfrm/xfrm_policy.c
@@ -26,7 +26,7 @@
 #include <net/xfrm.h>
 #include <net/ip.h>
 
-DECLARE_MUTEX(xfrm_cfg_sem);
+DECLARE_SEM_MUTEX(xfrm_cfg_sem);
 EXPORT_SYMBOL(xfrm_cfg_sem);
 
 static DEFINE_RWLOCK(xfrm_policy_lock);
author maintainer
#34 lore raw

PATCH 10/12 : MUTEX: Rename DECLARE_MUTEX for sound/ dir

In reply to David Howells

The attached patch renames DECLARE_MUTEX*() to DECLARE_SEM_MUTEX*() for the sound/ directory.

---
warthog>diffstat -p1 mutex-sound-2615rc5-2.diff

 sound/arm/pxa2xx-ac97.c             |    2 +-
 sound/core/hwdep.c                  |    2 +-
 sound/core/info.c                   |    2 +-
 sound/core/info_oss.c               |    2 +-
 sound/core/memalloc.c               |    2 +-
 sound/core/pcm.c                    |    2 +-
 sound/core/rawmidi.c                |    2 +-
 sound/core/seq/oss/seq_oss.c        |    2 +-
 sound/core/seq/seq_clientmgr.c      |    2 +-
 sound/core/seq/seq_device.c         |    2 +-
 sound/core/seq/seq_midi.c           |    2 +-
 sound/core/sound.c                  |    2 +-
 sound/core/sound_oss.c              |    2 +-
 sound/core/timer.c                  |    2 +-
 sound/oss/ac97_codec.c              |    2 +-
 sound/oss/dmasound/dmasound_awacs.c |    2 +-
 sound/usb/usbaudio.c                |    2 +-
 17 files changed, 17 insertions(+), 17 deletions(-)
sound/arm/pxa2xx-ac97.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/arm/pxa2xx-ac97.c linux-2.6.15-rc5-mutex/sound/arm/pxa2xx-ac97.c
@@ -33,7 +33,7 @@
 #include "pxa2xx-pcm.h"
 
 
-static DECLARE_MUTEX(car_mutex);
+static DECLARE_SEM_MUTEX(car_mutex);
 static DECLARE_WAIT_QUEUE_HEAD(gsr_wq);
 static volatile long gsr_bits;
 
sound/core/hwdep.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/core/hwdep.c linux-2.6.15-rc5-mutex/sound/core/hwdep.c
@@ -37,7 +37,7 @@ MODULE_LICENSE("GPL");
 
 static snd_hwdep_t *snd_hwdep_devices[SNDRV_CARDS * SNDRV_MINOR_HWDEPS];
 
-static DECLARE_MUTEX(register_mutex);
+static DECLARE_SEM_MUTEX(register_mutex);
 
 static int snd_hwdep_free(snd_hwdep_t *hwdep);
 static int snd_hwdep_dev_free(snd_device_t *device);
sound/core/info.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/core/info.c linux-2.6.15-rc5-mutex/sound/core/info.c
@@ -68,7 +68,7 @@ int snd_info_check_reserved_words(const 
 
 #ifdef CONFIG_PROC_FS
 
-static DECLARE_MUTEX(info_mutex);
+static DECLARE_SEM_MUTEX(info_mutex);
 
 typedef struct _snd_info_private_data {
 	snd_info_buffer_t *rbuffer;
sound/core/info_oss.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/core/info_oss.c linux-2.6.15-rc5-mutex/sound/core/info_oss.c
@@ -35,7 +35,7 @@
  *  OSS compatible part
  */
 
-static DECLARE_MUTEX(strings);
+static DECLARE_SEM_MUTEX(strings);
 static char *snd_sndstat_strings[SNDRV_CARDS][SNDRV_OSS_INFO_DEV_COUNT];
 static snd_info_entry_t *snd_sndstat_proc_entry;
 
sound/core/memalloc.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/core/memalloc.c linux-2.6.15-rc5-mutex/sound/core/memalloc.c
@@ -58,7 +58,7 @@ int snd_free_sgbuf_pages(struct snd_dma_
 /*
  */
 
-static DECLARE_MUTEX(list_mutex);
+static DECLARE_SEM_MUTEX(list_mutex);
 static LIST_HEAD(mem_list_head);
 
 /* buffer preservation list */
sound/core/pcm.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/core/pcm.c linux-2.6.15-rc5-mutex/sound/core/pcm.c
@@ -35,7 +35,7 @@ MODULE_LICENSE("GPL");
 
 snd_pcm_t *snd_pcm_devices[SNDRV_CARDS * SNDRV_PCM_DEVICES];
 static LIST_HEAD(snd_pcm_notify_list);
-static DECLARE_MUTEX(register_mutex);
+static DECLARE_SEM_MUTEX(register_mutex);
 
 static int snd_pcm_free(snd_pcm_t *pcm);
 static int snd_pcm_dev_free(snd_device_t *device);
sound/core/rawmidi.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/core/rawmidi.c linux-2.6.15-rc5-mutex/sound/core/rawmidi.c
@@ -58,7 +58,7 @@ static int snd_rawmidi_dev_unregister(sn
 
 static snd_rawmidi_t *snd_rawmidi_devices[SNDRV_CARDS * SNDRV_RAWMIDI_DEVICES];
 
-static DECLARE_MUTEX(register_mutex);
+static DECLARE_SEM_MUTEX(register_mutex);
 
 static inline unsigned short snd_rawmidi_file_flags(struct file *file)
 {
sound/core/seq/oss/seq_oss.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/core/seq/oss/seq_oss.c linux-2.6.15-rc5-mutex/sound/core/seq/oss/seq_oss.c
@@ -122,7 +122,7 @@ module_exit(alsa_seq_oss_exit)
  * ALSA minor device interface
  */
 
-static DECLARE_MUTEX(register_mutex);
+static DECLARE_SEM_MUTEX(register_mutex);
 
 static int
 odev_open(struct inode *inode, struct file *file)
sound/core/seq/seq_clientmgr.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/core/seq/seq_clientmgr.c linux-2.6.15-rc5-mutex/sound/core/seq/seq_clientmgr.c
@@ -52,7 +52,7 @@
 #define SNDRV_SEQ_LFLG_OPEN	(SNDRV_SEQ_LFLG_INPUT|SNDRV_SEQ_LFLG_OUTPUT)
 
 static DEFINE_SPINLOCK(clients_lock);
-static DECLARE_MUTEX(register_mutex);
+static DECLARE_SEM_MUTEX(register_mutex);
 
 /*
  * client table
sound/core/seq/seq_device.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/core/seq/seq_device.c linux-2.6.15-rc5-mutex/sound/core/seq/seq_device.c
@@ -82,7 +82,7 @@ struct ops_list {
 
 static LIST_HEAD(opslist);
 static int num_ops;
-static DECLARE_MUTEX(ops_mutex);
+static DECLARE_SEM_MUTEX(ops_mutex);
 static snd_info_entry_t *info_entry = NULL;
 
 /*
sound/core/seq/seq_midi.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/core/seq/seq_midi.c linux-2.6.15-rc5-mutex/sound/core/seq/seq_midi.c
@@ -70,7 +70,7 @@ typedef struct {
 } seq_midisynth_client_t;
 
 static seq_midisynth_client_t *synths[SNDRV_CARDS];
-static DECLARE_MUTEX(register_mutex);
+static DECLARE_SEM_MUTEX(register_mutex);
 
 /* handle rawmidi input event (MIDI v1.0 stream) */
 static void snd_midi_input_event(snd_rawmidi_substream_t * substream)
sound/core/sound.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/core/sound.c linux-2.6.15-rc5-mutex/sound/core/sound.c
@@ -62,7 +62,7 @@ int snd_ecards_limit;
 
 static struct list_head snd_minors_hash[SNDRV_CARDS];
 
-static DECLARE_MUTEX(sound_mutex);
+static DECLARE_SEM_MUTEX(sound_mutex);
 
 extern struct class *sound_class;
 
sound/core/sound_oss.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/core/sound_oss.c linux-2.6.15-rc5-mutex/sound/core/sound_oss.c
@@ -39,7 +39,7 @@
 
 static struct list_head snd_oss_minors_hash[SNDRV_CARDS];
 
-static DECLARE_MUTEX(sound_oss_mutex);
+static DECLARE_SEM_MUTEX(sound_oss_mutex);
 
 static snd_minor_t *snd_oss_minor_search(int minor)
 {
sound/core/timer.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/core/timer.c linux-2.6.15-rc5-mutex/sound/core/timer.c
@@ -82,7 +82,7 @@ static LIST_HEAD(snd_timer_slave_list);
 /* lock for slave active lists */
 static DEFINE_SPINLOCK(slave_active_lock);
 
-static DECLARE_MUTEX(register_mutex);
+static DECLARE_SEM_MUTEX(register_mutex);
 
 static int snd_timer_free(snd_timer_t *timer);
 static int snd_timer_dev_free(snd_device_t *device);
sound/oss/ac97_codec.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/oss/ac97_codec.c linux-2.6.15-rc5-mutex/sound/oss/ac97_codec.c
@@ -304,7 +304,7 @@ static const unsigned int ac97_oss_rm[] 
 
 static LIST_HEAD(codecs);
 static LIST_HEAD(codec_drivers);
-static DECLARE_MUTEX(codec_sem);
+static DECLARE_SEM_MUTEX(codec_sem);
 
 /* reads the given OSS mixer from the ac97 the caller must have insured that the ac97 knows
    about that given mixer, and should be holding a spinlock for the card */
sound/oss/dmasound/dmasound_awacs.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/oss/dmasound/dmasound_awacs.c linux-2.6.15-rc5-mutex/sound/oss/dmasound/dmasound_awacs.c
@@ -129,7 +129,7 @@ static struct device_node* i2s_node;
 static char awacs_name[64];
 static int awacs_revision;
 static int awacs_sleeping;
-static DECLARE_MUTEX(dmasound_sem);
+static DECLARE_SEM_MUTEX(dmasound_sem);
 
 static int sound_device_id;		/* exists after iMac revA */
 static int hw_can_byteswap = 1 ;	/* most pmac sound h/w can */
sound/usb/usbaudio.c +1 -1
diff -uNrp linux-2.6.15-rc5/sound/usb/usbaudio.c linux-2.6.15-rc5-mutex/sound/usb/usbaudio.c
@@ -204,7 +204,7 @@ struct snd_usb_stream {
  * the all interfaces on the same card as one sound device.
  */
 
-static DECLARE_MUTEX(register_mutex);
+static DECLARE_SEM_MUTEX(register_mutex);
 static snd_usb_audio_t *usb_chip[SNDRV_CARDS];
 
 
author maintainer
#35 lore raw

PATCH 11/12 : MUTEX: Rename DECLARE_MUTEX for miscellaneous directories

In reply to David Howells

The attached patch renames DECLARE_MUTEX*() to DECLARE_SEM_MUTEX*() for the remaining directories.

---
warthog>diffstat -p1 mutex-misc-2615rc5-2.diff

 Documentation/DocBook/kernel-locking.tmpl |    4 ++--
 Documentation/kref.txt                    |    2 +-
 block/genhd.c                             |    2 +-
 lib/kernel_lock.c                         |    2 +-
 lib/reed_solomon/reed_solomon.c           |    2 +-
 mm/swapfile.c                             |    2 +-
 security/keys/process_keys.c              |    2 +-
 security/selinux/selinuxfs.c              |    2 +-
 security/selinux/ss/services.c            |    2 +-
 9 files changed, 10 insertions(+), 10 deletions(-)
Documentation/DocBook/kernel-locking.tmpl +2 -2
diff -uNrp linux-2.6.15-rc5/Documentation/DocBook/kernel-locking.tmpl linux-2.6.15-rc5-mutex/Documentation/DocBook/kernel-locking.tmpl
@@ -698,7 +698,7 @@ struct object
 };
 
 /* Protects the cache, cache_num, and the objects within it */
-static DECLARE_MUTEX(cache_lock);
+static DECLARE_SEM_MUTEX(cache_lock);
 static LIST_HEAD(cache);
 static unsigned int cache_num = 0;
 #define MAX_CACHE_SIZE 10
@@ -814,7 +814,7 @@ The change is shown below, in standard p
          int popularity;
  };
 
--static DECLARE_MUTEX(cache_lock);
+-static DECLARE_SEM_MUTEX(cache_lock);
 +static spinlock_t cache_lock = SPIN_LOCK_UNLOCKED;
  static LIST_HEAD(cache);
  static unsigned int cache_num = 0;
Documentation/kref.txt +1 -1
diff -uNrp linux-2.6.15-rc5/Documentation/kref.txt linux-2.6.15-rc5-mutex/Documentation/kref.txt
@@ -144,7 +144,7 @@ and kref_get() it.  That violates rule 3
 holding a valid pointer.  You must add locks or semaphores.  For
 instance:
 
-static DECLARE_MUTEX(sem);
+static DECLARE_SEM_MUTEX(sem);
 static LIST_HEAD(q);
 struct my_data
 {
block/genhd.c +1 -1
diff -uNrp linux-2.6.15-rc5/block/genhd.c linux-2.6.15-rc5-mutex/block/genhd.c
@@ -20,7 +20,7 @@
 
 static struct subsystem block_subsys;
 
-static DECLARE_MUTEX(block_subsys_sem);
+static DECLARE_SEM_MUTEX(block_subsys_sem);
 
 /*
  * Can be deleted altogether. Later.
lib/kernel_lock.c +1 -1
diff -uNrp linux-2.6.15-rc5/lib/kernel_lock.c linux-2.6.15-rc5-mutex/lib/kernel_lock.c
@@ -24,7 +24,7 @@
  *
  * Don't use in new code.
  */
-static DECLARE_MUTEX(kernel_sem);
+static DECLARE_SEM_MUTEX(kernel_sem);
 
 /*
  * Re-acquire the kernel semaphore.
lib/reed_solomon/reed_solomon.c +1 -1
diff -uNrp linux-2.6.15-rc5/lib/reed_solomon/reed_solomon.c linux-2.6.15-rc5-mutex/lib/reed_solomon/reed_solomon.c
@@ -49,7 +49,7 @@
 /* This list holds all currently allocated rs control structures */
 static LIST_HEAD (rslist);
 /* Protection for the list */
-static DECLARE_MUTEX(rslistlock);
+static DECLARE_SEM_MUTEX(rslistlock);
 
 /**
  * rs_init - Initialize a Reed-Solomon codec
mm/swapfile.c +1 -1
diff -uNrp linux-2.6.15-rc5/mm/swapfile.c linux-2.6.15-rc5-mutex/mm/swapfile.c
@@ -45,7 +45,7 @@ struct swap_list_t swap_list = {-1, -1};
 
 struct swap_info_struct swap_info[MAX_SWAPFILES];
 
-static DECLARE_MUTEX(swapon_sem);
+static DECLARE_SEM_MUTEX(swapon_sem);
 
 /*
  * We need this because the bdev->unplug_fn can sleep and we cannot
security/keys/process_keys.c +1 -1
diff -uNrp linux-2.6.15-rc5/security/keys/process_keys.c linux-2.6.15-rc5-mutex/security/keys/process_keys.c
@@ -20,7 +20,7 @@
 #include "internal.h"
 
 /* session keyring create vs join semaphore */
-static DECLARE_MUTEX(key_session_sem);
+static DECLARE_SEM_MUTEX(key_session_sem);
 
 /* the root user's tracking struct */
 struct key_user root_key_user = {
security/selinux/selinuxfs.c +1 -1
diff -uNrp linux-2.6.15-rc5/security/selinux/selinuxfs.c linux-2.6.15-rc5-mutex/security/selinux/selinuxfs.c
@@ -44,7 +44,7 @@ static int __init checkreqprot_setup(cha
 __setup("checkreqprot=", checkreqprot_setup);
 
 
-static DECLARE_MUTEX(sel_sem);
+static DECLARE_SEM_MUTEX(sel_sem);
 
 /* global data for booleans */
 static struct dentry *bool_dir = NULL;
security/selinux/ss/services.c +1 -1
diff -uNrp linux-2.6.15-rc5/security/selinux/ss/services.c linux-2.6.15-rc5-mutex/security/selinux/ss/services.c
@@ -48,7 +48,7 @@ static DEFINE_RWLOCK(policy_rwlock);
 #define POLICY_RDUNLOCK read_unlock(&policy_rwlock)
 #define POLICY_WRUNLOCK write_unlock_irq(&policy_rwlock)
 
-static DECLARE_MUTEX(load_sem);
+static DECLARE_SEM_MUTEX(load_sem);
 #define LOAD_LOCK down(&load_sem)
 #define LOAD_UNLOCK up(&load_sem)
 
author maintainer
#36 lore raw

PATCH 12/12 : MUTEX: Provide synchronisation primitive testing module

In reply to David Howells

The attached patch adds a module for testing and benchmarking mutexes, semaphores and R/W semaphores.

Using it is simple:

insmod synchro-test.ko <args>

It will exit with error ENOANO after running the tests and printing the results to the kernel console log.

The available arguments are:

(*) mx=N

Start up to N mutex thrashing threads, where N is at most 20. All will try and thrash the same mutex.

(*) sm=N

Start up to N counting semaphore thrashing threads, where N is at most
20. All will try and thrash the same semaphore.

(*) ism=M

Initialise the counting semaphore with M, where M is any positive integer greater than zero. The default is 4.

(*) rd=N
(*) wr=O
(*) dg=P

Start up to N reader thrashing threads, O writer thrashing threads and P downgrader thrashing threads, where N, O and P are at most 20 apiece. All will try and thrash the same read/write semaphore.

(*) elapse=N

Run the tests for N seconds. The default is 5.

(*) load=N

Each thread delays for N uS whilst holding the lock. The dfault is 0.

(*) do_sched=1

Each thread will call schedule if required after each iteration.

(*) v=1

Print more verbose information, including a thread iteration distribution list.

---
warthog>diffstat -p1 mutex-testing-2615rc5-2.diff

 Makefile             |    2 
 tests/Makefile       |    7 
 tests/synchro-test.c |  486 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 494 insertions(+), 1 deletion(-)
Makefile +1 -1
diff -uNrp linux-2.6.15-rc5/Makefile linux-2.6.15-rc5-mutex/Makefile
@@ -470,7 +470,7 @@ scripts_basic: include/linux/autoconf.h
 
 # Objects we will link into vmlinux / subdirs we need to visit
 init-y		:= init/
-drivers-y	:= drivers/ sound/
+drivers-y	:= drivers/ sound/ tests/
 net-y		:= net/
 libs-y		:= lib/
 core-y		:= usr/
tests/Makefile +7 -0
diff -uNrp linux-2.6.15-rc5/tests/Makefile linux-2.6.15-rc5-mutex/tests/Makefile
@@ -0,0 +1,7 @@
+#
+# Makefile for the tests
+#
+
+ifeq ($(CONFIG_MODULES),y)
+obj-m += synchro-test.o
+endif
tests/synchro-test.c +486 -0

486 lines not on this page · raw message