From: Marcin Slusarz <marcin.slusarz@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Matthew Wilcox <willy@linux.intel.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Rename DECLARE_MUTEX to DEFINE_SEMAPHORE
Date: Sun, 26 Oct 2008 16:23:10 +0100 [thread overview]
Message-ID: <20081026152306.GA29017@joi> (raw)
In-Reply-To: <1225028346.32713.11.camel@twins>
On Sun, Oct 26, 2008 at 02:39:06PM +0100, Peter Zijlstra wrote:
> On Sun, 2008-10-26 at 13:06 +0100, Marcin Slusarz wrote:
> > DECLARE_MUTEX is doubly misleading name (it actually _defines_ struct
> > _semaphore_ initialized to 1) and it can be confused with DEFINE_MUTEX
> > (which defines real struct mutex). Rename it.
>
> I'd prefer DEFINE_BINARY_SEM or somesuch
Sounds better.
---
Subject: [PATCH] Rename DECLARE_MUTEX to DEFINE_BINARY_SEM
DECLARE_MUTEX is doubly misleading name (it actually _defines_ struct
_semaphore_ initialized to 1) and it can be confused with DEFINE_MUTEX
(which defines real struct mutex). Rename it.
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Matthew Wilcox <willy@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
arch/arm/mach-lh7a40x/clocks.c | 2 +-
drivers/macintosh/adb.c | 2 +-
drivers/staging/go7007/go7007-i2c.c | 4 ++--
include/linux/semaphore.h | 5 +++--
kernel/printk.c | 4 ++--
lib/dynamic_printk.c | 2 +-
scripts/checkpatch.pl | 2 +-
sound/soc/s3c24xx/s3c2443-ac97.c | 2 +-
8 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/arch/arm/mach-lh7a40x/clocks.c b/arch/arm/mach-lh7a40x/clocks.c
index 4fb23ac..de27e81 100644
--- a/arch/arm/mach-lh7a40x/clocks.c
+++ b/arch/arm/mach-lh7a40x/clocks.c
@@ -80,7 +80,7 @@ unsigned int pclkfreq_get (void)
/* ----- */
static LIST_HEAD(clocks);
-static DECLARE_MUTEX(clocks_sem);
+static DEFINE_BINARY_SEM(clocks_sem);
struct clk *clk_get (struct device *dev, const char *id)
{
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 23741ce..7cf07c2 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -83,7 +83,7 @@ static struct adb_driver *adb_controller;
BLOCKING_NOTIFIER_HEAD(adb_client_list);
static int adb_got_sleep;
static int adb_inited;
-static DECLARE_MUTEX(adb_probe_mutex);
+static DEFINE_BINARY_SEM(adb_probe_mutex);
static int sleepy_trackpad;
static int autopoll_devs;
int __adb_probe_sync;
diff --git a/drivers/staging/go7007/go7007-i2c.c b/drivers/staging/go7007/go7007-i2c.c
index cd55b76..6f698af 100644
--- a/drivers/staging/go7007/go7007-i2c.c
+++ b/drivers/staging/go7007/go7007-i2c.c
@@ -56,7 +56,7 @@ struct wis_i2c_client_driver {
};
static LIST_HEAD(i2c_client_drivers);
-static DECLARE_MUTEX(i2c_client_driver_list_lock);
+static DEFINE_BINARY_SEM(i2c_client_driver_list_lock);
/* Client drivers register here by their I2C driver ID */
int wis_i2c_add_driver(unsigned int id, found_proc found_proc)
@@ -129,7 +129,7 @@ int wis_i2c_probe_device(struct i2c_adapter *adapter,
/* There is only one I2C port on the TW2804 that feeds all four GO7007 VIPs
* on the Adlink PCI-MPG24, so access is shared between all of them. */
-static DECLARE_MUTEX(adlink_mpg24_i2c_lock);
+static DEFINE_BINARY_SEM(adlink_mpg24_i2c_lock);
static int go7007_i2c_xfer(struct go7007 *go, u16 addr, int read,
u16 command, int flags, u8 *data)
diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
index 7415839..824b423 100644
--- a/include/linux/semaphore.h
+++ b/include/linux/semaphore.h
@@ -26,8 +26,9 @@ struct semaphore {
.wait_list = LIST_HEAD_INIT((name).wait_list), \
}
-#define DECLARE_MUTEX(name) \
- struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
+#define DEFINE_SEMAPHORE(name, init) \
+ struct semaphore name = __SEMAPHORE_INITIALIZER(name, init)
+#define DEFINE_BINARY_SEM(name) DEFINE_SEMAPHORE(name, 1)
static inline void sema_init(struct semaphore *sem, int val)
{
diff --git a/kernel/printk.c b/kernel/printk.c
index 6341af7..2a2281b 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -72,8 +72,8 @@ EXPORT_SYMBOL(oops_in_progress);
* provides serialisation for access to the entire console
* driver system.
*/
-static DECLARE_MUTEX(console_sem);
-static DECLARE_MUTEX(secondary_console_sem);
+static DEFINE_BINARY_SEM(console_sem);
+static DEFINE_BINARY_SEM(secondary_console_sem);
struct console *console_drivers;
EXPORT_SYMBOL_GPL(console_drivers);
diff --git a/lib/dynamic_printk.c b/lib/dynamic_printk.c
index d640f87..0b3dbdb 100644
--- a/lib/dynamic_printk.c
+++ b/lib/dynamic_printk.c
@@ -34,7 +34,7 @@ static struct hlist_head module_table[DEBUG_HASH_TABLE_SIZE] =
{ [0 ... DEBUG_HASH_TABLE_SIZE-1] = HLIST_HEAD_INIT };
static struct hlist_head module_table2[DEBUG_HASH_TABLE_SIZE] =
{ [0 ... DEBUG_HASH_TABLE_SIZE-1] = HLIST_HEAD_INIT };
-static DECLARE_MUTEX(debug_list_mutex);
+static DEFINE_BINARY_SEM(debug_list_mutex);
/* dynamic_printk_enabled, and dynamic_printk_enabled2 are bitmasks in which
* bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f88bb3e..91462b0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2428,7 +2428,7 @@ sub process {
}
# check for semaphores used as mutexes
- if ($line =~ /^.\s*(DECLARE_MUTEX|init_MUTEX)\s*\(/) {
+ if ($line =~ /^.\s*(DEFINE_BINARY_SEM|init_MUTEX)\s*\(/) {
WARN("mutexes are preferred for single holder semaphores\n" . $herecurr);
}
# check for semaphores used as mutexes
diff --git a/sound/soc/s3c24xx/s3c2443-ac97.c b/sound/soc/s3c24xx/s3c2443-ac97.c
index 19c5c3c..8980111 100644
--- a/sound/soc/s3c24xx/s3c2443-ac97.c
+++ b/sound/soc/s3c24xx/s3c2443-ac97.c
@@ -46,7 +46,7 @@ static struct s3c24xx_ac97_info s3c24xx_ac97;
static DECLARE_COMPLETION(ac97_completion);
static u32 codec_ready;
-static DECLARE_MUTEX(ac97_mutex);
+static DEFINE_BINARY_SEM(ac97_mutex);
static unsigned short s3c2443_ac97_read(struct snd_ac97 *ac97,
unsigned short reg)
--
1.5.6.4
next prev parent reply other threads:[~2008-10-26 15:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-26 12:06 [PATCH] Rename DECLARE_MUTEX to DEFINE_SEMAPHORE Marcin Slusarz
2008-10-26 13:39 ` Peter Zijlstra
2008-10-26 14:11 ` Leon Woestenberg
2008-10-26 14:41 ` Peter Zijlstra
2008-10-26 15:20 ` Leon Woestenberg
2008-10-26 15:23 ` Marcin Slusarz [this message]
2008-10-26 16:41 ` Christoph Hellwig
2008-10-29 21:16 ` Marcin Slusarz
2008-10-29 21:22 ` Christoph Hellwig
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=20081026152306.GA29017@joi \
--to=marcin.slusarz@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
--cc=willy@linux.intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.