mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Robert P. J. Day" <rpjday@mindspring.com>
To: Linux kernel mailing list <linux-kernel@vger.kernel.org>
Subject: [PATCH] standardize definition of sema_init()
Date: Mon, 9 Oct 2006 15:30:26 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0610091527310.27241@localhost.localdomain> (raw)

Signed off by: Robert P. J. Day <rpjday@mindspring.com>
---
  There doesn't *appear* to be any reason for the various definitions
of sema_init() not to be in the standard form, but I'm willing to be
convinced otherwise.

diff --git a/include/asm-alpha/semaphore.h b/include/asm-alpha/semaphore.h
index 1a6295f..8c3c6dd 100644
--- a/include/asm-alpha/semaphore.h
+++ b/include/asm-alpha/semaphore.h
@@ -34,14 +34,7 @@ #define DECLARE_MUTEX_LOCKED(name)	__DEC

 static inline void sema_init(struct semaphore *sem, int val)
 {
-	/*
-	 * Logically,
-	 *   *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
-	 * except that gcc produces better initializing by parts yet.
-	 */
-
-	atomic_set(&sem->count, val);
-	init_waitqueue_head(&sem->wait);
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 }

 static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-arm/semaphore.h b/include/asm-arm/semaphore.h
index d5dc624..7394cb1 100644
--- a/include/asm-arm/semaphore.h
+++ b/include/asm-arm/semaphore.h
@@ -32,9 +32,7 @@ #define DECLARE_MUTEX_LOCKED(name)	__DEC

 static inline void sema_init(struct semaphore *sem, int val)
 {
-	atomic_set(&sem->count, val);
-	sem->sleepers = 0;
-	init_waitqueue_head(&sem->wait);
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 }

 static inline void init_MUTEX(struct semaphore *sem)
diff --git a/include/asm-arm26/semaphore.h b/include/asm-arm26/semaphore.h
index 1fda543..84ad0e3 100644
--- a/include/asm-arm26/semaphore.h
+++ b/include/asm-arm26/semaphore.h
@@ -18,7 +18,7 @@ struct semaphore {
 	wait_queue_head_t wait;
 };

-#define __SEMAPHORE_INIT(name, n)					\
+#define __SEMAPHORE_INITIALIZER(name, n)					\
 {									\
 	.count		= ATOMIC_INIT(n),				\
 	.sleepers	= 0,						\
@@ -33,9 +33,7 @@ #define DECLARE_MUTEX_LOCKED(name)	__DEC

 static inline void sema_init(struct semaphore *sem, int val)
 {
-	atomic_set(&sem->count, val);
-	sem->sleepers = 0;
-	init_waitqueue_head(&sem->wait);
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 }

 static inline void init_MUTEX(struct semaphore *sem)
diff --git a/include/asm-avr32/semaphore.h b/include/asm-avr32/semaphore.h
index ef99ddc..7391408 100644
--- a/include/asm-avr32/semaphore.h
+++ b/include/asm-avr32/semaphore.h
@@ -40,9 +40,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC

 static inline void sema_init (struct semaphore *sem, int val)
 {
-	atomic_set(&sem->count, val);
-	sem->sleepers = 0;
-	init_waitqueue_head(&sem->wait);
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 }

 static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-i386/semaphore.h b/include/asm-i386/semaphore.h
index 4e34a46..0945d0f 100644
--- a/include/asm-i386/semaphore.h
+++ b/include/asm-i386/semaphore.h
@@ -63,15 +63,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC

 static inline void sema_init (struct semaphore *sem, int val)
 {
-/*
- *	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
- *
- * i'd rather use the more flexible initialization above, but sadly
- * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well.
- */
-	atomic_set(&sem->count, val);
-	sem->sleepers = 0;
-	init_waitqueue_head(&sem->wait);
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 }

 static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-m32r/semaphore.h b/include/asm-m32r/semaphore.h
index 41e45d7..d114364 100644
--- a/include/asm-m32r/semaphore.h
+++ b/include/asm-m32r/semaphore.h
@@ -39,15 +39,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC

 static inline void sema_init (struct semaphore *sem, int val)
 {
-/*
- *	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
- *
- * i'd rather use the more flexible initialization above, but sadly
- * GCC 2.7.2.3 emits a bogus warning. EGCS doesnt. Oh well.
- */
-	atomic_set(&sem->count, val);
-	sem->sleepers = 0;
-	init_waitqueue_head(&sem->wait);
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 }

 static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-mips/semaphore.h b/include/asm-mips/semaphore.h
index 3d6aa7c..cba043a 100644
--- a/include/asm-mips/semaphore.h
+++ b/include/asm-mips/semaphore.h
@@ -53,8 +53,7 @@ #define DECLARE_MUTEX_LOCKED(name)	__DEC

 static inline void sema_init (struct semaphore *sem, int val)
 {
-	atomic_set(&sem->count, val);
-	init_waitqueue_head(&sem->wait);
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 }

 static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-powerpc/semaphore.h b/include/asm-powerpc/semaphore.h
index 57369d2..ca3ea7d 100644
--- a/include/asm-powerpc/semaphore.h
+++ b/include/asm-powerpc/semaphore.h
@@ -39,8 +39,7 @@ #define DECLARE_MUTEX_LOCKED(name)	__DEC

 static inline void sema_init (struct semaphore *sem, int val)
 {
-	atomic_set(&sem->count, val);
-	init_waitqueue_head(&sem->wait);
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 }

 static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-s390/semaphore.h b/include/asm-s390/semaphore.h
index dbce058..ad8c949 100644
--- a/include/asm-s390/semaphore.h
+++ b/include/asm-s390/semaphore.h
@@ -37,8 +37,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC

 static inline void sema_init (struct semaphore *sem, int val)
 {
-	atomic_set(&sem->count, val);
-	init_waitqueue_head(&sem->wait);
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 }

 static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-sh/semaphore.h b/include/asm-sh/semaphore.h
index 489f784..209103d 100644
--- a/include/asm-sh/semaphore.h
+++ b/include/asm-sh/semaphore.h
@@ -41,15 +41,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC

 static inline void sema_init (struct semaphore *sem, int val)
 {
-/*
- *	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
- *
- * i'd rather use the more flexible initialization above, but sadly
- * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well.
- */
-	atomic_set(&sem->count, val);
-	sem->sleepers = 0;
-	init_waitqueue_head(&sem->wait);
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 }

 static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-sh64/semaphore.h b/include/asm-sh64/semaphore.h
index 4695264..b2f3f57 100644
--- a/include/asm-sh64/semaphore.h
+++ b/include/asm-sh64/semaphore.h
@@ -48,15 +48,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC

 static inline void sema_init (struct semaphore *sem, int val)
 {
-/*
- *	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
- *
- * i'd rather use the more flexible initialization above, but sadly
- * GCC 2.7.2.3 emits a bogus warning. EGCS doesnt. Oh well.
- */
-	atomic_set(&sem->count, val);
-	sem->sleepers = 0;
-	init_waitqueue_head(&sem->wait);
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 }

 static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-sparc/semaphore.h b/include/asm-sparc/semaphore.h
index f74ba31..79d4121 100644
--- a/include/asm-sparc/semaphore.h
+++ b/include/asm-sparc/semaphore.h
@@ -30,9 +30,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC

 static inline void sema_init (struct semaphore *sem, int val)
 {
-	atomic24_set(&sem->count, val);
-	sem->sleepers = 0;
-	init_waitqueue_head(&sem->wait);
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 }

 static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-sparc64/semaphore.h b/include/asm-sparc64/semaphore.h
index 093dcc6..8a7c201 100644
--- a/include/asm-sparc64/semaphore.h
+++ b/include/asm-sparc64/semaphore.h
@@ -30,8 +30,7 @@ #define DECLARE_MUTEX_LOCKED(name)	__DEC

 static inline void sema_init (struct semaphore *sem, int val)
 {
-	atomic_set(&sem->count, val);
-	init_waitqueue_head(&sem->wait);
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 }

 static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-x86_64/semaphore.h b/include/asm-x86_64/semaphore.h
index 1194888..504a3ac 100644
--- a/include/asm-x86_64/semaphore.h
+++ b/include/asm-x86_64/semaphore.h
@@ -64,15 +64,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC

 static inline void sema_init (struct semaphore *sem, int val)
 {
-/*
- *	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
- *
- * i'd rather use the more flexible initialization above, but sadly
- * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well.
- */
-	atomic_set(&sem->count, val);
-	sem->sleepers = 0;
-	init_waitqueue_head(&sem->wait);
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 }

 static inline void init_MUTEX (struct semaphore *sem)
diff --git a/include/asm-xtensa/semaphore.h b/include/asm-xtensa/semaphore.h
index f10c348..017d892 100644
--- a/include/asm-xtensa/semaphore.h
+++ b/include/asm-xtensa/semaphore.h
@@ -37,9 +37,7 @@ #define DECLARE_MUTEX_LOCKED(name) __DEC

 static inline void sema_init (struct semaphore *sem, int val)
 {
-	atomic_set(&sem->count, val);
-	sem->sleepers = 0;
-	init_waitqueue_head(&sem->wait);
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
 }

 static inline void init_MUTEX (struct semaphore *sem)



                 reply	other threads:[~2006-10-09 19:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0610091527310.27241@localhost.localdomain \
    --to=rpjday@mindspring.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®