Skip to contentSkip to conversation

semaphore cleanup

PATCH Applied Thomas Gleixner 10 participants 71 messages Sep 7, 2010 – Oct 30, 2010

Subsystems (23)
lore
Share & tools
lore
#0 lore raw

cover semaphore cleanup

init_MUTEX[_LOCKED] and DECLARE_MUTEX are deprecated for quite some time. Cleanup the remaining users and remove the cruft.

Thanks,

tglx

#1 lore raw

PATCH 1/30 semaphore: Add DEFINE_SEMAPHORE

The full cleanup of init_MUTEX[_LOCKED] and DECLARE_MUTEX has not been done. Some of the users are real semaphores and we should name them as such instead of confusing everyone with "MUTEX".

Provide the infrastructure to get finally rid of init_MUTEX[_LOCKED] and DECLARE_MUTEX.

---
 include/linux/semaphore.h |    3 +++
 1 file changed, 3 insertions(+)
include/linux/semaphore.h +3 -0
Index: linux-2.6/include/linux/semaphore.h
===================================================================
@@ -26,6 +26,9 @@ struct semaphore {
 	.wait_list	= LIST_HEAD_INIT((name).wait_list),		\
 }
 
+#define DEFINE_SEMAPHORE(name)	\
+	struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
+
 #define DECLARE_MUTEX(name)	\
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
 
#2 lore raw

PATCH 2/30 input: misc/hp_sdc_rtc: semaphore cleanup

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/input/misc/hp_sdc_rtc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/input/misc/hp_sdc_rtc.c +2 -2
Index: linux-2.6/drivers/input/misc/hp_sdc_rtc.c
===================================================================
@@ -104,7 +104,7 @@ static int hp_sdc_rtc_do_read_bbrtc (str
 	t.endidx =		91;
 	t.seq =			tseq;
 	t.act.semaphore =	&tsem;
-	init_MUTEX_LOCKED(&tsem);
+	sema_init(&tsem, 0);
 	
 	if (hp_sdc_enqueue_transaction(&t)) return -1;
 	
@@ -698,7 +698,7 @@ static int __init hp_sdc_rtc_init(void)
 		return -ENODEV;
 #endif
 
-	init_MUTEX(&i8042tregs);
+	sema_init(&i8042tregs, 1);
 
 	if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr)))
 		return ret;
maintainer
#3 lore raw

Re: [patch 02/30] input: misc/hp_sdc_rtc: semaphore cleanup

Quoted 4 lines · Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

All 3 look good to me Thomas, please merge with the rest of the patch series.

Quoted 29 lines
---
 drivers/input/misc/hp_sdc_rtc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: linux-2.6/drivers/input/misc/hp_sdc_rtc.c
===================================================================

drivers/input/misc/hp_sdc_rtc.c +2 -2
@@ -104,7 +104,7 @@ static int hp_sdc_rtc_do_read_bbrtc (str
 	t.endidx =		91;
 	t.seq =			tseq;
 	t.act.semaphore =	&tsem;
-	init_MUTEX_LOCKED(&tsem);
+	sema_init(&tsem, 0);
 
 	if (hp_sdc_enqueue_transaction(&t)) return -1;
 
@@ -698,7 +698,7 @@ static int __init hp_sdc_rtc_init(void)
 		return -ENODEV;
 #endif
 
-	init_MUTEX(&i8042tregs);
+	sema_init(&i8042tregs, 1);
 
 	if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr)))
 		return ret;
Signature · 1 line
Dmitry
#4 lore raw

[tip:core/locking] input: Misc/hp_sdc_rtc: semaphore cleanup

In reply to Thomas Gleixner
Commit-ID:  10d0ff83078d5ef99aaf94a2aaceb740f5ced923
Gitweb:     http://git.kernel.org/tip/10d0ff83078d5ef99aaf94a2aaceb740f5ced923
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:31:58 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 12 Oct 2010 17:36:07 +0200

input: Misc/hp_sdc_rtc: semaphore cleanup

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

LKML-Reference: <[email protected]>

---
 drivers/input/misc/hp_sdc_rtc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/input/misc/hp_sdc_rtc.c +2 -2
index c190664..7e2c12a 100644
@@ -104,7 +104,7 @@ static int hp_sdc_rtc_do_read_bbrtc (struct rtc_time *rtctm)
 	t.endidx =		91;
 	t.seq =			tseq;
 	t.act.semaphore =	&tsem;
-	init_MUTEX_LOCKED(&tsem);
+	sema_init(&tsem, 0);
 	
 	if (hp_sdc_enqueue_transaction(&t)) return -1;
 	
@@ -698,7 +698,7 @@ static int __init hp_sdc_rtc_init(void)
 		return -ENODEV;
 #endif
 
-	init_MUTEX(&i8042tregs);
+	sema_init(&i8042tregs, 1);
 
 	if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr)))
 		return ret;
#5 lore raw

PATCH 3/30 input: serio/hil_mlc: semaphore cleanup

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/input/serio/hil_mlc.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/input/serio/hil_mlc.c +3 -3
Index: linux-2.6/drivers/input/serio/hil_mlc.c
===================================================================
@@ -915,15 +915,15 @@ int hil_mlc_register(hil_mlc *mlc)
 	mlc->ostarted = 0;
 
 	rwlock_init(&mlc->lock);
-	init_MUTEX(&mlc->osem);
+	sema_init(&mlc->osem, 1);
 
-	init_MUTEX(&mlc->isem);
+	sema_init(&mlc->isem, 1);
 	mlc->icount = -1;
 	mlc->imatch = 0;
 
 	mlc->opercnt = 0;
 
-	init_MUTEX_LOCKED(&(mlc->csem));
+	sema_init(&(mlc->csem), 0);
 
 	hil_mlc_clear_di_scratch(mlc);
 	hil_mlc_clear_di_map(mlc, 0);
#6 lore raw

[tip:core/locking] input: Serio/hil_mlc: semaphore cleanup

Commit-ID:  45e8492f594dcb17e8cbb26edb2dd3018a68dada
Gitweb:     http://git.kernel.org/tip/45e8492f594dcb17e8cbb26edb2dd3018a68dada
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:32:01 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 12 Oct 2010 17:36:08 +0200

input: Serio/hil_mlc: semaphore cleanup

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

LKML-Reference: <[email protected]>

---
 drivers/input/serio/hil_mlc.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/input/serio/hil_mlc.c +3 -3
index c92f4ed..e5624d8 100644
@@ -915,15 +915,15 @@ int hil_mlc_register(hil_mlc *mlc)
 	mlc->ostarted = 0;
 
 	rwlock_init(&mlc->lock);
-	init_MUTEX(&mlc->osem);
+	sema_init(&mlc->osem, 1);
 
-	init_MUTEX(&mlc->isem);
+	sema_init(&mlc->isem, 1);
 	mlc->icount = -1;
 	mlc->imatch = 0;
 
 	mlc->opercnt = 0;
 
-	init_MUTEX_LOCKED(&(mlc->csem));
+	sema_init(&(mlc->csem), 0);
 
 	hil_mlc_clear_di_scratch(mlc);
 	hil_mlc_clear_di_map(mlc, 0);
#7 lore raw

PATCH 4/30 input: serio/hp_sdc: semaphore cleanup

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/input/serio/hp_sdc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/input/serio/hp_sdc.c +2 -2
Index: linux-2.6/drivers/input/serio/hp_sdc.c
===================================================================
@@ -905,7 +905,7 @@ static int __init hp_sdc_init(void)
 	ts_sync[1]	= 0x0f;
 	ts_sync[2] = ts_sync[3]	= ts_sync[4] = ts_sync[5] = 0;
 	t_sync.act.semaphore = &s_sync;
-	init_MUTEX_LOCKED(&s_sync);
+	sema_init(&s_sync, 0);
 	hp_sdc_enqueue_transaction(&t_sync);
 	down(&s_sync); /* Wait for t_sync to complete */
 
@@ -1039,7 +1039,7 @@ static int __init hp_sdc_register(void)
 		return hp_sdc.dev_err;
 	}
 
-	init_MUTEX_LOCKED(&tq_init_sem);
+	sema_init(&tq_init_sem, 0);
 
 	tq_init.actidx		= 0;
 	tq_init.idx		= 1;
#8 lore raw

[tip:core/locking] input: Serio/hp_sdc: semaphore cleanup

Commit-ID:  4a4a506f81eebe63fb1b8e9e99f4bcd1fd9aac66
Gitweb:     http://git.kernel.org/tip/4a4a506f81eebe63fb1b8e9e99f4bcd1fd9aac66
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:32:06 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 12 Oct 2010 17:36:08 +0200

input: Serio/hp_sdc: semaphore cleanup

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

LKML-Reference: <[email protected]>

---
 drivers/input/serio/hp_sdc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/input/serio/hp_sdc.c +2 -2
index bcc2d30..8c0b51c 100644
@@ -905,7 +905,7 @@ static int __init hp_sdc_init(void)
 	ts_sync[1]	= 0x0f;
 	ts_sync[2] = ts_sync[3]	= ts_sync[4] = ts_sync[5] = 0;
 	t_sync.act.semaphore = &s_sync;
-	init_MUTEX_LOCKED(&s_sync);
+	sema_init(&s_sync, 0);
 	hp_sdc_enqueue_transaction(&t_sync);
 	down(&s_sync); /* Wait for t_sync to complete */
 
@@ -1039,7 +1039,7 @@ static int __init hp_sdc_register(void)
 		return hp_sdc.dev_err;
 	}
 
-	init_MUTEX_LOCKED(&tq_init_sem);
+	sema_init(&tq_init_sem, 0);
 
 	tq_init.actidx		= 0;
 	tq_init.idx		= 1;
#9 lore raw

PATCH 5/30 net: 3c527: semaphore cleanup

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/net/3c527.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/3c527.c +1 -1
Index: linux-2.6/drivers/net/3c527.c
===================================================================
@@ -522,7 +522,7 @@ static int __init mc32_probe1(struct net
 	lp->tx_len 		= lp->exec_box->data[9];   /* Transmit list count */
 	lp->rx_len 		= lp->exec_box->data[11];  /* Receive list count */
 
-	init_MUTEX_LOCKED(&lp->cmd_mutex);
+	sema_init(&lp->cmd_mutex, 0);
 	init_completion(&lp->execution_cmd);
 	init_completion(&lp->xceiver_cmd);
 
#11 lore raw

[tip:core/locking] net: 3c527: semaphore cleanup

In reply to Thomas Gleixner
Commit-ID:  50948ee8124c2125d833e8889002aa12a948b4e9
Gitweb:     http://git.kernel.org/tip/50948ee8124c2125d833e8889002aa12a948b4e9
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:32:10 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 12 Oct 2010 17:36:08 +0200

net: 3c527: semaphore cleanup

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

LKML-Reference: <[email protected]>

---
 drivers/net/3c527.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/3c527.c +1 -1
index 70705d1..eca55c5 100644
@@ -522,7 +522,7 @@ static int __init mc32_probe1(struct net_device *dev, int slot)
 	lp->tx_len 		= lp->exec_box->data[9];   /* Transmit list count */
 	lp->rx_len 		= lp->exec_box->data[11];  /* Receive list count */
 
-	init_MUTEX_LOCKED(&lp->cmd_mutex);
+	sema_init(&lp->cmd_mutex, 0);
 	init_completion(&lp->execution_cmd);
 	init_completion(&lp->xceiver_cmd);
 
#12 lore raw

PATCH 6/30 hamradio: 6pack: semaphore cleanup

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/net/hamradio/6pack.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/hamradio/6pack.c +1 -1
Index: linux-2.6/drivers/net/hamradio/6pack.c
===================================================================
@@ -608,7 +608,7 @@ static int sixpack_open(struct tty_struc
 
 	spin_lock_init(&sp->lock);
 	atomic_set(&sp->refcnt, 1);
-	init_MUTEX_LOCKED(&sp->dead_sem);
+	sema_init(&sp->dead_sem, 0);
 
 	/* !!! length of the buffers. MTU is IP MTU, not PACLEN!  */
 
#14 lore raw

[tip:core/locking] hamradio: 6pack: semaphore cleanup

In reply to Thomas Gleixner
Commit-ID:  89d9f10d0b21268d3dba33db984ab03092861700
Gitweb:     http://git.kernel.org/tip/89d9f10d0b21268d3dba33db984ab03092861700
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:32:14 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 12 Oct 2010 17:36:08 +0200

hamradio: 6pack: semaphore cleanup

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

LKML-Reference: <[email protected]>

---
 drivers/net/hamradio/6pack.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/hamradio/6pack.c +1 -1
index 4b52c76..3e5d0b6 100644
@@ -608,7 +608,7 @@ static int sixpack_open(struct tty_struct *tty)
 
 	spin_lock_init(&sp->lock);
 	atomic_set(&sp->refcnt, 1);
-	init_MUTEX_LOCKED(&sp->dead_sem);
+	sema_init(&sp->dead_sem, 0);
 
 	/* !!! length of the buffers. MTU is IP MTU, not PACLEN!  */
 
#15 lore raw

PATCH 7/30 hamradio: mkiss: semaphore cleanup

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/net/hamradio/mkiss.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/hamradio/mkiss.c +1 -1
Index: linux-2.6/drivers/net/hamradio/mkiss.c
===================================================================
@@ -747,7 +747,7 @@ static int mkiss_open(struct tty_struct 
 
 	spin_lock_init(&ax->buflock);
 	atomic_set(&ax->refcnt, 1);
-	init_MUTEX_LOCKED(&ax->dead_sem);
+	sema_init(&ax->dead_sem, 0);
 
 	ax->tty = tty;
 	tty->disc_data = ax;
#17 lore raw

[tip:core/locking] hamradio: Mkiss: semaphore cleanup

In reply to Thomas Gleixner
Commit-ID:  495e64bddeb9349395ed346177057fff7d52857e
Gitweb:     http://git.kernel.org/tip/495e64bddeb9349395ed346177057fff7d52857e
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:32:18 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 12 Oct 2010 17:36:09 +0200

hamradio: Mkiss: semaphore cleanup

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

LKML-Reference: <[email protected]>

---
 drivers/net/hamradio/mkiss.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/hamradio/mkiss.c +1 -1
index 66e88bd..4c62839 100644
@@ -747,7 +747,7 @@ static int mkiss_open(struct tty_struct *tty)
 
 	spin_lock_init(&ax->buflock);
 	atomic_set(&ax->refcnt, 1);
-	init_MUTEX_LOCKED(&ax->dead_sem);
+	sema_init(&ax->dead_sem, 0);
 
 	ax->tty = tty;
 	tty->disc_data = ax;
#18 lore raw

PATCH 8/30 net: ppp_async: semaphore cleanup

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/net/ppp_async.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ppp_async.c +1 -1
Index: linux-2.6/drivers/net/ppp_async.c
===================================================================
@@ -184,7 +184,7 @@ ppp_asynctty_open(struct tty_struct *tty
 	tasklet_init(&ap->tsk, ppp_async_process, (unsigned long) ap);
 
 	atomic_set(&ap->refcnt, 1);
-	init_MUTEX_LOCKED(&ap->dead_sem);
+	sema_init(&ap->dead_sem, 0);
 
 	ap->chan.private = ap;
 	ap->chan.ops = &async_ops;
#20 lore raw

[tip:core/locking] net: Ppp_async: semaphore cleanup

In reply to Thomas Gleixner
Commit-ID:  0bce198b7688911e072bd65032ab9278b577ee93
Gitweb:     http://git.kernel.org/tip/0bce198b7688911e072bd65032ab9278b577ee93
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:32:22 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 12 Oct 2010 17:36:09 +0200

net: Ppp_async: semaphore cleanup

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

LKML-Reference: <[email protected]>

---
 drivers/net/ppp_async.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/ppp_async.c +1 -1
index af50a53..78d70a6 100644
@@ -184,7 +184,7 @@ ppp_asynctty_open(struct tty_struct *tty)
 	tasklet_init(&ap->tsk, ppp_async_process, (unsigned long) ap);
 
 	atomic_set(&ap->refcnt, 1);
-	init_MUTEX_LOCKED(&ap->dead_sem);
+	sema_init(&ap->dead_sem, 0);
 
 	ap->chan.private = ap;
 	ap->chan.ops = &async_ops;
#21 lore raw

PATCH 9/30 net: wan/cosa.c: Convert "mutex" to semaphore

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/net/wan/cosa.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wan/cosa.c +1 -1
Index: linux-2.6/drivers/net/wan/cosa.c
===================================================================
@@ -575,7 +575,7 @@ static int cosa_probe(int base, int irq,
 
 		/* Initialize the chardev data structures */
 		mutex_init(&chan->rlock);
-		init_MUTEX(&chan->wsem);
+		sema_init(&chan->wsem, 1);
 
 		/* Register the network interface */
 		if (!(chan->netdev = alloc_hdlcdev(chan))) {
#23 lore raw

[tip:core/locking] net: Wan/cosa.c: Convert "mutex" to semaphore

In reply to Thomas Gleixner
Commit-ID:  d1985508320ad40a68375bdbafa8a5d6c56d2114
Gitweb:     http://git.kernel.org/tip/d1985508320ad40a68375bdbafa8a5d6c56d2114
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:32:25 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 12 Oct 2010 17:36:09 +0200

net: Wan/cosa.c: Convert "mutex" to semaphore

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

LKML-Reference: <[email protected]>

---
 drivers/net/wan/cosa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wan/cosa.c +1 -1
index 04c6cd4..10bafd5 100644
@@ -575,7 +575,7 @@ static int cosa_probe(int base, int irq, int dma)
 
 		/* Initialize the chardev data structures */
 		mutex_init(&chan->rlock);
-		init_MUTEX(&chan->wsem);
+		sema_init(&chan->wsem, 1);
 
 		/* Register the network interface */
 		if (!(chan->netdev = alloc_hdlcdev(chan))) {
#24 lore raw

PATCH 10/30 irda: semaphore cleanup

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/net/irda/sir_dev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/irda/sir_dev.c +1 -1
Index: linux-2.6/drivers/net/irda/sir_dev.c
===================================================================
@@ -909,7 +909,7 @@ struct sir_dev * sirdev_get_instance(con
 	dev->tx_skb = NULL;
 
 	spin_lock_init(&dev->tx_lock);
-	init_MUTEX(&dev->fsm.sem);
+	sema_init(&dev->fsm.sem, 1);
 
 	dev->drv = drv;
 	dev->netdev = ndev;
#26 lore raw

[tip:core/locking] irda: Semaphore cleanup

In reply to Thomas Gleixner
Commit-ID:  db7f859ec53c0bfaf3520afe2feafd18a27e48fb
Gitweb:     http://git.kernel.org/tip/db7f859ec53c0bfaf3520afe2feafd18a27e48fb
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:32:30 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 12 Oct 2010 17:36:09 +0200

irda: Semaphore cleanup

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

LKML-Reference: <[email protected]>

---
 drivers/net/irda/sir_dev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/irda/sir_dev.c +1 -1
index 1b051da..51d7444 100644
@@ -909,7 +909,7 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n
 	dev->tx_skb = NULL;
 
 	spin_lock_init(&dev->tx_lock);
-	init_MUTEX(&dev->fsm.sem);
+	sema_init(&dev->fsm.sem, 1);
 
 	dev->drv = drv;
 	dev->netdev = ndev;
#27 lore raw

PATCH 11/30 parport: semaphore cleanup

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/parport/share.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/parport/share.c +1 -1
Index: linux-2.6/drivers/parport/share.c
===================================================================
@@ -306,7 +306,7 @@ struct parport *parport_register_port(un
 	spin_lock_init(&tmp->pardevice_lock);
 	tmp->ieee1284.mode = IEEE1284_MODE_COMPAT;
 	tmp->ieee1284.phase = IEEE1284_PH_FWD_IDLE;
-	init_MUTEX_LOCKED (&tmp->ieee1284.irq); /* actually a semaphore at 0 */
+	sema_init(&tmp->ieee1284.irq, 0);
 	tmp->spintime = parport_default_spintime;
 	atomic_set (&tmp->ref_count, 1);
 	INIT_LIST_HEAD(&tmp->full_list);
#28 lore raw

[tip:core/locking] parport: Semaphore cleanup

Commit-ID:  a529f1505b6facfd0078dcb18a444976c1985962
Gitweb:     http://git.kernel.org/tip/a529f1505b6facfd0078dcb18a444976c1985962
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:32:34 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 12 Oct 2010 17:36:10 +0200

parport: Semaphore cleanup

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

Cc Peter Zijlstra <[email protected]>
Cc Alan Cox <[email protected]>
Cc Christoph Hellwig <[email protected]>

LKML-Reference: <[email protected]>

---
 drivers/parport/share.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/parport/share.c +1 -1
index dffa5d4..a2d9d1e 100644
@@ -306,7 +306,7 @@ struct parport *parport_register_port(unsigned long base, int irq, int dma,
 	spin_lock_init(&tmp->pardevice_lock);
 	tmp->ieee1284.mode = IEEE1284_MODE_COMPAT;
 	tmp->ieee1284.phase = IEEE1284_PH_FWD_IDLE;
-	init_MUTEX_LOCKED (&tmp->ieee1284.irq); /* actually a semaphore at 0 */
+	sema_init(&tmp->ieee1284.irq, 0);
 	tmp->spintime = parport_default_spintime;
 	atomic_set (&tmp->ref_count, 1);
 	INIT_LIST_HEAD(&tmp->full_list);
#29 lore raw

PATCH 12/30 ibmphp-hpc: semaphore cleanup

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/pci/hotplug/ibmphp_hpc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/hotplug/ibmphp_hpc.c +2 -2
Index: linux-2.6/drivers/pci/hotplug/ibmphp_hpc.c
===================================================================
@@ -133,8 +133,8 @@ void __init ibmphp_hpc_initvars (void)
 	debug ("%s - Entry\n", __func__);
 
 	mutex_init(&sem_hpcaccess);
-	init_MUTEX (&semOperations);
-	init_MUTEX_LOCKED (&sem_exit);
+	sema_init(&semOperations, 1);
+	sema_init(&sem_exit, 0);
 	to_debug = 0;
 
 	debug ("%s - Exit\n", __func__);
Applied
#30 lore raw

Re: [patch 12/30] ibmphp-hpc: semaphore cleanup

Quoted 18 lines · On Tue, 07 Sep 2010 14:32:38 -0000 Thomas Gleixner <[email protected]> wrote:

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/pci/hotplug/ibmphp_hpc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: linux-2.6/drivers/pci/hotplug/ibmphp_hpc.c
===================================================================

drivers/pci/hotplug/ibmphp_hpc.c void __init ibmphp_hpc_initvars (void) · line 140

Quoted 10 lines
drivers/pci/hotplug/ibmphp_hpc.c +2 -2
@@ -133,8 +133,8 @@ void __init ibmphp_hpc_initvars (void)
 	debug ("%s - Entry\n", __func__);
 
 	mutex_init(&sem_hpcaccess);
-	init_MUTEX (&semOperations);
-	init_MUTEX_LOCKED (&sem_exit);
+	sema_init(&semOperations, 1);
+	sema_init(&sem_exit, 0);
 	to_debug = 0;
 
 	debug ("%s - Exit\n", __func__);

Applied to my linux-next branch, thanks.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#31 lore raw

PATCH 13/30 usb: ftdi-elan: Convert "mutex" to semaphore

In reply to Thomas Gleixner

The "mutex" ftdi->sw_lock is used as a lock and a completion. Convert it to a real semaphore which allows both.

---
 drivers/usb/misc/ftdi-elan.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/misc/ftdi-elan.c +1 -1
Index: linux-2.6/drivers/usb/misc/ftdi-elan.c
===================================================================
@@ -2769,7 +2769,7 @@ static int ftdi_elan_probe(struct usb_in
         ftdi->sequence_num = ++ftdi_instances;
         mutex_unlock(&ftdi_module_lock);
         ftdi_elan_init_kref(ftdi);
-        init_MUTEX(&ftdi->sw_lock);
+	sema_init(&ftdi->sw_lock, 1);
         ftdi->udev = usb_get_dev(interface_to_usbdev(interface));
         ftdi->interface = interface;
         mutex_init(&ftdi->u132_lock);
#32 lore raw

PATCH 14/30 scsi: aacraid semaphore cleanup

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/scsi/aacraid/commctrl.c |    2 +-
 drivers/scsi/aacraid/commsup.c  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/aacraid/commctrl.c +1 -1
Index: linux-2.6/drivers/scsi/aacraid/commctrl.c
===================================================================
@@ -190,7 +190,7 @@ static int open_getadapter_fib(struct aa
 		/*
 		 *	Initialize the mutex used to wait for the next AIF.
 		 */
-		init_MUTEX_LOCKED(&fibctx->wait_sem);
+		sema_init(&fibctx->wait_sem, 0);
 		fibctx->wait = 0;
 		/*
 		 *	Initialize the fibs and set the count of fibs on
drivers/scsi/aacraid/commsup.c +1 -1
Index: linux-2.6/drivers/scsi/aacraid/commsup.c
===================================================================
@@ -124,7 +124,7 @@ int aac_fib_setup(struct aac_dev * dev)
 		fibptr->hw_fib_va = hw_fib;
 		fibptr->data = (void *) fibptr->hw_fib_va->data;
 		fibptr->next = fibptr+1;	/* Forward chain the fibs */
-		init_MUTEX_LOCKED(&fibptr->event_wait);
+		sema_init(&fibptr->event_wait, 0);
 		spin_lock_init(&fibptr->event_lock);
 		hw_fib->header.XferState = cpu_to_le32(0xffffffff);
 		hw_fib->header.SenderSize = cpu_to_le16(dev->max_fib_size);
#33 lore raw

PATCH 15/30 smbfs: Convert server->sem to mutex

In reply to Thomas Gleixner

server->sem is used as mutex so make it a mutex.

---
 fs/smbfs/inode.c          |    2 +-
 include/linux/smb_fs_sb.h |    8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
fs/smbfs/inode.c +1 -1
Index: linux-2.6/fs/smbfs/inode.c
===================================================================
@@ -536,7 +536,7 @@ static int smb_fill_super(struct super_b
 	server->mnt = NULL;
 	server->sock_file = NULL;
 	init_waitqueue_head(&server->conn_wq);
-	init_MUTEX(&server->sem);
+	mutex_init(&server->mutex);
 	INIT_LIST_HEAD(&server->entry);
 	INIT_LIST_HEAD(&server->xmitq);
 	INIT_LIST_HEAD(&server->recvq);
include/linux/smb_fs_sb.h +4 -4
Index: linux-2.6/include/linux/smb_fs_sb.h
===================================================================
@@ -58,7 +58,7 @@ struct smb_sb_info {
 	struct smb_conn_opt opt;
 	wait_queue_head_t conn_wq;
 	int conn_complete;
-	struct semaphore sem;
+	struct mutex mutex;
 
 	unsigned char      header[SMB_HEADER_LEN + 20*2 + 2];
 	u32                header_len;
@@ -82,19 +82,19 @@ struct smb_sb_info {
 static inline int
 smb_lock_server_interruptible(struct smb_sb_info *server)
 {
-	return down_interruptible(&(server->sem));
+	return mutex_lock_interruptible(&server->mutex);
 }
 
 static inline void
 smb_lock_server(struct smb_sb_info *server)
 {
-	down(&(server->sem));
+	mutex_lock(&server->mutex);
 }
 
 static inline void
 smb_unlock_server(struct smb_sb_info *server)
 {
-	up(&(server->sem));
+	mutex_unlock(&server->mutex);
 }
 
 #endif
Acked-by on v1 15/30
#34 lore raw

Re: [patch 15/30] smbfs: Convert server->sem to mutex

Quoted 63 lines · On Tue, 07 Sep 2010 14:32:52 -0000 Thomas Gleixner <[email protected]> wrote:

server->sem is used as mutex so make it a mutex.

---
 fs/smbfs/inode.c          |    2 +-
 include/linux/smb_fs_sb.h |    8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

Index: linux-2.6/fs/smbfs/inode.c
===================================================================

fs/smbfs/inode.c +1 -1
@@ -536,7 +536,7 @@ static int smb_fill_super(struct super_b
 	server->mnt = NULL;
 	server->sock_file = NULL;
 	init_waitqueue_head(&server->conn_wq);
-	init_MUTEX(&server->sem);
+	mutex_init(&server->mutex);
 	INIT_LIST_HEAD(&server->entry);
 	INIT_LIST_HEAD(&server->xmitq);
 	INIT_LIST_HEAD(&server->recvq);

Index: linux-2.6/include/linux/smb_fs_sb.h
===================================================================

include/linux/smb_fs_sb.h +4 -5
@@ -58,7 +58,7 @@ struct smb_sb_info {
 	struct smb_conn_opt opt;
 	wait_queue_head_t conn_wq;
 	int conn_complete;
-	struct semaphore sem;
+	struct mutex mutex;
 
 	unsigned char      header[SMB_HEADER_LEN + 20*2 + 2];
 	u32                header_len;
@@ -82,19 +82,19 @@ struct smb_sb_info {
 static inline int
 smb_lock_server_interruptible(struct smb_sb_info *server)
 {
-	return down_interruptible(&(server->sem));
+	return mutex_lock_interruptible(&server->mutex);
 }
 
 static inline void
 smb_lock_server(struct smb_sb_info *server)
 {
-	down(&(server->sem));
+	mutex_lock(&server->mutex);
 }
 
 static inline void
 smb_unlock_server(struct smb_sb_info *server)
 {
-	up(&(server->sem));
+	mutex_unlock(&server->mutex);
 }
 
 #endif
 
 
--
Quoted 5 lines

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Seems harmless...

#35 lore raw

PATCH 16/30 hpfs: Convert sbi->hpfs_creation_de to mutex

In reply to Thomas Gleixner

sbi->hpfs_creation_de is used as mutex so make it a mutex.

---
 fs/hpfs/buffer.c  |    4 ++--
 fs/hpfs/hpfs_fn.h |    2 +-
 fs/hpfs/super.c   |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
fs/hpfs/buffer.c +2 -2
Index: linux-2.6/fs/hpfs/buffer.c
===================================================================
@@ -14,7 +14,7 @@ void hpfs_lock_creation(struct super_blo
 #ifdef DEBUG_LOCKS
 	printk("lock creation\n");
 #endif
-	down(&hpfs_sb(s)->hpfs_creation_de);
+	mutex_lock(&hpfs_sb(s)->hpfs_creation_de);
 }
 
 void hpfs_unlock_creation(struct super_block *s)
@@ -22,7 +22,7 @@ void hpfs_unlock_creation(struct super_b
 #ifdef DEBUG_LOCKS
 	printk("unlock creation\n");
 #endif
-	up(&hpfs_sb(s)->hpfs_creation_de);
+	mutex_unlock(&hpfs_sb(s)->hpfs_creation_de);
 }
 
 /* Map a sector into a buffer and return pointers to it and to the buffer. */
fs/hpfs/hpfs_fn.h +1 -1
Index: linux-2.6/fs/hpfs/hpfs_fn.h
===================================================================
@@ -87,7 +87,7 @@ struct hpfs_sb_info {
 	unsigned *sb_bmp_dir;		/* main bitmap directory */
 	unsigned sb_c_bitmap;		/* current bitmap */
 	unsigned sb_max_fwd_alloc;	/* max forwad allocation */
-	struct semaphore hpfs_creation_de; /* when creating dirents, nobody else
+	struct mutex hpfs_creation_de;	/* when creating dirents, nobody else
 					   can alloc blocks */
 	/*unsigned sb_mounting : 1;*/
 	int sb_timeshift;
fs/hpfs/super.c +1 -1
Index: linux-2.6/fs/hpfs/super.c
===================================================================
@@ -487,7 +487,7 @@ static int hpfs_fill_super(struct super_
 	sbi->sb_bmp_dir = NULL;
 	sbi->sb_cp_table = NULL;
 
-	init_MUTEX(&sbi->hpfs_creation_de);
+	mutex_init(&sbi->hpfs_creation_de);
 
 	uid = current_uid();
 	gid = current_gid();
#36 lore raw

[tip:core/locking] hpfs: Convert sbi->hpfs_creation_de to mutex

Commit-ID:  117bf5fbdbdc7a5394e5718b3354238961c83067
Gitweb:     http://git.kernel.org/tip/117bf5fbdbdc7a5394e5718b3354238961c83067
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:32:56 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Sat, 30 Oct 2010 10:12:03 +0200

hpfs: Convert sbi->hpfs_creation_de to mutex

sbi->hpfs_creation_de is used as mutex so make it a mutex.

LKML-Reference: <[email protected]>

---
 fs/hpfs/buffer.c  |    4 ++--
 fs/hpfs/hpfs_fn.h |    2 +-
 fs/hpfs/super.c   |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
fs/hpfs/buffer.c +2 -2
index eac5f96..793cb9d 100644
@@ -14,7 +14,7 @@ void hpfs_lock_creation(struct super_block *s)
 #ifdef DEBUG_LOCKS
 	printk("lock creation\n");
 #endif
-	down(&hpfs_sb(s)->hpfs_creation_de);
+	mutex_lock(&hpfs_sb(s)->hpfs_creation_de);
 }
 
 void hpfs_unlock_creation(struct super_block *s)
@@ -22,7 +22,7 @@ void hpfs_unlock_creation(struct super_block *s)
 #ifdef DEBUG_LOCKS
 	printk("unlock creation\n");
 #endif
-	up(&hpfs_sb(s)->hpfs_creation_de);
+	mutex_unlock(&hpfs_sb(s)->hpfs_creation_de);
 }
 
 /* Map a sector into a buffer and return pointers to it and to the buffer. */
fs/hpfs/hpfs_fn.h +1 -1
index b59eac0..2fee17d 100644
@@ -87,7 +87,7 @@ struct hpfs_sb_info {
 	unsigned *sb_bmp_dir;		/* main bitmap directory */
 	unsigned sb_c_bitmap;		/* current bitmap */
 	unsigned sb_max_fwd_alloc;	/* max forwad allocation */
-	struct semaphore hpfs_creation_de; /* when creating dirents, nobody else
+	struct mutex hpfs_creation_de;	/* when creating dirents, nobody else
 					   can alloc blocks */
 	/*unsigned sb_mounting : 1;*/
 	int sb_timeshift;
fs/hpfs/super.c +1 -1
index c969a1a..18e1d45 100644
@@ -491,7 +491,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
 	sbi->sb_bmp_dir = NULL;
 	sbi->sb_cp_table = NULL;
 
-	init_MUTEX(&sbi->hpfs_creation_de);
+	mutex_init(&sbi->hpfs_creation_de);
 
 	uid = current_uid();
 	gid = current_gid();
#37 lore raw

PATCH 17/30 hpfsplus: Convert tree_lock to mutex

In reply to Thomas Gleixner

tree_lock is used as mutex so make it a mutex.

---
 fs/hfsplus/bfind.c      |    4 ++--
 fs/hfsplus/btree.c      |    2 +-
 fs/hfsplus/hfsplus_fs.h |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
fs/hfsplus/bfind.c +2 -2
Index: linux-2.6/fs/hfsplus/bfind.c
===================================================================
@@ -23,7 +23,7 @@ int hfs_find_init(struct hfs_btree *tree
 	fd->search_key = ptr;
 	fd->key = ptr + tree->max_key_len + 2;
 	dprint(DBG_BNODE_REFS, "find_init: %d (%p)\n", tree->cnid, __builtin_return_address(0));
-	down(&tree->tree_lock);
+	mutex_lock(&tree->tree_lock);
 	return 0;
 }
 
@@ -32,7 +32,7 @@ void hfs_find_exit(struct hfs_find_data 
 	hfs_bnode_put(fd->bnode);
 	kfree(fd->search_key);
 	dprint(DBG_BNODE_REFS, "find_exit: %d (%p)\n", fd->tree->cnid, __builtin_return_address(0));
-	up(&fd->tree->tree_lock);
+	mutex_unlock(&fd->tree->tree_lock);
 	fd->tree = NULL;
 }
 
fs/hfsplus/btree.c +1 -1
Index: linux-2.6/fs/hfsplus/btree.c
===================================================================
@@ -30,7 +30,7 @@ struct hfs_btree *hfs_btree_open(struct 
 	if (!tree)
 		return NULL;
 
-	init_MUTEX(&tree->tree_lock);
+	mutex_init(&tree->tree_lock);
 	spin_lock_init(&tree->hash_lock);
 	tree->sb = sb;
 	tree->cnid = id;
fs/hfsplus/hfsplus_fs.h +1 -1
Index: linux-2.6/fs/hfsplus/hfsplus_fs.h
===================================================================
@@ -62,7 +62,7 @@ struct hfs_btree {
 	unsigned int depth;
 
 	//unsigned int map1_size, map_size;
-	struct semaphore tree_lock;
+	struct mutex tree_lock;
 
 	unsigned int pages_per_bnode;
 	spinlock_t hash_lock;
#38 lore raw

PATCH 18/30 hfs: Convert tree_lock to mutex

In reply to Thomas Gleixner

tree_lock is used as mutex so make it a mutex.

---
 fs/hfs/bfind.c |    4 ++--
 fs/hfs/btree.c |    2 +-
 fs/hfs/btree.h |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
fs/hfs/bfind.c +2 -2
Index: linux-2.6/fs/hfs/bfind.c
===================================================================
@@ -23,7 +23,7 @@ int hfs_find_init(struct hfs_btree *tree
 	fd->search_key = ptr;
 	fd->key = ptr + tree->max_key_len + 2;
 	dprint(DBG_BNODE_REFS, "find_init: %d (%p)\n", tree->cnid, __builtin_return_address(0));
-	down(&tree->tree_lock);
+	mutex_lock(&tree->tree_lock);
 	return 0;
 }
 
@@ -32,7 +32,7 @@ void hfs_find_exit(struct hfs_find_data 
 	hfs_bnode_put(fd->bnode);
 	kfree(fd->search_key);
 	dprint(DBG_BNODE_REFS, "find_exit: %d (%p)\n", fd->tree->cnid, __builtin_return_address(0));
-	up(&fd->tree->tree_lock);
+	mutex_unlock(&fd->tree->tree_lock);
 	fd->tree = NULL;
 }
 
fs/hfs/btree.c +1 -1
Index: linux-2.6/fs/hfs/btree.c
===================================================================
@@ -27,7 +27,7 @@ struct hfs_btree *hfs_btree_open(struct 
 	if (!tree)
 		return NULL;
 
-	init_MUTEX(&tree->tree_lock);
+	mutex_init(&tree->tree_lock);
 	spin_lock_init(&tree->hash_lock);
 	/* Set the correct compare function */
 	tree->sb = sb;
fs/hfs/btree.h +1 -1
Index: linux-2.6/fs/hfs/btree.h
===================================================================
@@ -33,7 +33,7 @@ struct hfs_btree {
 	unsigned int depth;
 
 	//unsigned int map1_size, map_size;
-	struct semaphore tree_lock;
+	struct mutex tree_lock;
 
 	unsigned int pages_per_bnode;
 	spinlock_t hash_lock;
#39 lore raw

[tip:core/locking] hfs: Convert tree_lock to mutex

Commit-ID:  4a9410355406c31695eab9daeba694d7d9714e9b
Gitweb:     http://git.kernel.org/tip/4a9410355406c31695eab9daeba694d7d9714e9b
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:33:08 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 12 Oct 2010 17:36:11 +0200

hfs: Convert tree_lock to mutex

tree_lock is used as mutex so make it a mutex.

LKML-Reference: <[email protected]>

---
 fs/hfs/bfind.c |    4 ++--
 fs/hfs/btree.c |    2 +-
 fs/hfs/btree.h |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
fs/hfs/bfind.c +2 -2
index 4129cdb..571abe9 100644
@@ -23,7 +23,7 @@ int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd)
 	fd->search_key = ptr;
 	fd->key = ptr + tree->max_key_len + 2;
 	dprint(DBG_BNODE_REFS, "find_init: %d (%p)\n", tree->cnid, __builtin_return_address(0));
-	down(&tree->tree_lock);
+	mutex_lock(&tree->tree_lock);
 	return 0;
 }
 
@@ -32,7 +32,7 @@ void hfs_find_exit(struct hfs_find_data *fd)
 	hfs_bnode_put(fd->bnode);
 	kfree(fd->search_key);
 	dprint(DBG_BNODE_REFS, "find_exit: %d (%p)\n", fd->tree->cnid, __builtin_return_address(0));
-	up(&fd->tree->tree_lock);
+	mutex_unlock(&fd->tree->tree_lock);
 	fd->tree = NULL;
 }
 
fs/hfs/btree.c +1 -1
index 38a0a99..3ebc437 100644
@@ -27,7 +27,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
 	if (!tree)
 		return NULL;
 
-	init_MUTEX(&tree->tree_lock);
+	mutex_init(&tree->tree_lock);
 	spin_lock_init(&tree->hash_lock);
 	/* Set the correct compare function */
 	tree->sb = sb;
fs/hfs/btree.h +1 -1
index cc51905..2a1d712 100644
@@ -33,7 +33,7 @@ struct hfs_btree {
 	unsigned int depth;
 
 	//unsigned int map1_size, map_size;
-	struct semaphore tree_lock;
+	struct mutex tree_lock;
 
 	unsigned int pages_per_bnode;
 	spinlock_t hash_lock;
#40 lore raw

PATCH 19/30 affs: use sema_init instead of init_MUTEX

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 fs/affs/super.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/affs/super.c +2 -2
Index: linux-2.6/fs/affs/super.c
===================================================================
@@ -109,8 +109,8 @@ static void init_once(void *foo)
 {
 	struct affs_inode_info *ei = (struct affs_inode_info *) foo;
 
-	init_MUTEX(&ei->i_link_lock);
-	init_MUTEX(&ei->i_ext_lock);
+	sema_init(&ei->i_link_lock, 1);
+	sema_init(&ei->i_ext_lock, 1);
 	inode_init_once(&ei->vfs_inode);
 }
 
#41 lore raw

[tip:core/locking] affs: Use sema_init instead of init_MUTEX

Commit-ID:  756b0322e50aebc4b9afb4488a2d3f6c802b4e64
Gitweb:     http://git.kernel.org/tip/756b0322e50aebc4b9afb4488a2d3f6c802b4e64
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:33:11 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 12 Oct 2010 17:39:25 +0200

affs: Use sema_init instead of init_MUTEX

Get rid of init_MUTE() and use sema_init() instead.

Cc Peter Zijlstra <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Al Viro <[email protected]>

LKML-Reference: <[email protected]>

---
 fs/affs/super.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/affs/super.c +2 -2
index 33c4e7e..9581ea9 100644
@@ -109,8 +109,8 @@ static void init_once(void *foo)
 {
 	struct affs_inode_info *ei = (struct affs_inode_info *) foo;
 
-	init_MUTEX(&ei->i_link_lock);
-	init_MUTEX(&ei->i_ext_lock);
+	sema_init(&ei->i_link_lock, 1);
+	sema_init(&ei->i_ext_lock, 1);
 	inode_init_once(&ei->vfs_inode);
 }
 
#42 lore raw

PATCH 20/30 xfs: semaphore cleanup

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

Cc Christoph Hellwig <[email protected]>
Cc Dave Chinner <[email protected]>
---
 fs/xfs/linux-2.6/xfs_buf.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/linux-2.6/xfs_buf.c +1 -1
Index: linux-2.6/fs/xfs/linux-2.6/xfs_buf.c
===================================================================
@@ -189,7 +189,7 @@ _xfs_buf_initialize(
 	init_completion(&bp->b_iowait);
 	INIT_LIST_HEAD(&bp->b_list);
 	INIT_LIST_HEAD(&bp->b_hash_list);
-	init_MUTEX_LOCKED(&bp->b_sema); /* held, no waiters */
+	sema_init(&bp->b_sema, 0); /* held, no waiters */
 	XB_SET_OWNER(bp);
 	bp->b_target = target;
 	bp->b_file_offset = range_base;
#43 lore raw

PATCH 21/30 mmc: Convert "mutex" to semaphore

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/mmc/card/queue.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/card/queue.c +1 -1
Index: linux-2.6/drivers/mmc/card/queue.c
===================================================================
@@ -209,7 +209,7 @@ int mmc_init_queue(struct mmc_queue *mq,
 		sg_init_table(mq->sg, host->max_phys_segs);
 	}
 
-	init_MUTEX(&mq->thread_sem);
+	sema_init(&mq->thread_sem, 1);
 
 	mq->thread = kthread_run(mmc_queue_thread, mq, "mmcqd");
 	if (IS_ERR(mq->thread)) {
Applied
#44 lore raw

Re: [patch 21/30] mmc: Convert "mutex" to semaphore

Hi,

Quoted 16 lines · Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/mmc/card/queue.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/drivers/mmc/card/queue.c
===================================================================

drivers/mmc/card/queue.c int mmc_init_queue(struct mmc_queue *mq, · line 215

Quoted 8 lines
drivers/mmc/card/queue.c +1 -1
@@ -209,7 +209,7 @@ int mmc_init_queue(struct mmc_queue *mq,
 		sg_init_table(mq->sg, host->max_phys_segs);
 	}
 
-	init_MUTEX(&mq->thread_sem);
+	sema_init(&mq->thread_sem, 1);
 
 	mq->thread = kthread_run(mmc_queue_thread, mq, "mmcqd");
 	if (IS_ERR(mq->thread)) {

Thanks, applied to mmc-next.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#45 lore raw

PATCH 22/30 dvb: Convert "mutex" to semaphore

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/media/dvb/dvb-core/dvb_frontend.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/dvb/dvb-core/dvb_frontend.c +2 -2
Index: linux-2.6/drivers/media/dvb/dvb-core/dvb_frontend.c
===================================================================
@@ -702,7 +702,7 @@ static void dvb_frontend_stop(struct dvb
 
 	kthread_stop(fepriv->thread);
 
-	init_MUTEX (&fepriv->sem);
+	sema_init(&fepriv->sem, 1);
 	fepriv->state = FESTATE_IDLE;
 
 	/* paranoia check in case a signal arrived */
@@ -2061,7 +2061,7 @@ int dvb_register_frontend(struct dvb_ada
 	}
 	fepriv = fe->frontend_priv;
 
-	init_MUTEX (&fepriv->sem);
+	sema_init(&fepriv->sem, 1);
 	init_waitqueue_head (&fepriv->wait_queue);
 	init_waitqueue_head (&fepriv->events.wait_queue);
 	mutex_init(&fepriv->events.mtx);
#46 lore raw

PATCH 23/30 infiniband: Make user_mad semaphore a real one

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 drivers/infiniband/core/user_mad.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/user_mad.c +1 -1
Index: linux-2.6/drivers/infiniband/core/user_mad.c
===================================================================
@@ -1022,7 +1022,7 @@ static int ib_umad_init_port(struct ib_d
 
 	port->ib_dev   = device;
 	port->port_num = port_num;
-	init_MUTEX(&port->sm_sem);
+	sema_init(&port->sm_sem, 1);
 	mutex_init(&port->file_mutex);
 	INIT_LIST_HEAD(&port->file_list);
 
#47 lore raw

Re: [patch 23/30] infiniband: Make user_mad semaphore a real one

thanks, applied.

#48 lore raw

PATCH 24/30 ia64: salinfo: sema_init instead of init_MUTEX

In reply to Thomas Gleixner

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

---
 arch/ia64/kernel/salinfo.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/arch/ia64/kernel/salinfo.c =================================--- linux-2.6.orig/arch/ia64/kernel/salinfo.c +++ linux-2.6/arch/ia64/kernel/salinfo.c
@@ -642,7 +642,7 @@ salinfo_init(void)
for (i = 0; i < ARRAY_SIZE(salinfo_log_name); i++) {
data = salinfo_data + i;
data->type = i;
- init_MUTEX(&data->mutex);
+ sema_init(&data->mutex, 1);
dir = proc_mkdir(salinfo_log_name[i], salinfo_dir); if (!dir)
continue;

#49 lore raw

PATCH 25/30 drivers/macintosh/adb: Do not claim that the semaphore is a mutex

In reply to Thomas Gleixner

User DEFINE_SEMAPHORE() instead of DECLARE_MUTEX()

Cc Benjamin Herrenschmidt <[email protected]>
---
 drivers/macintosh/adb.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/macintosh/adb.c +1 -1
Index: linux-2.6/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_SEMAPHORE(adb_probe_mutex);
 static int sleepy_trackpad;
 static int autopoll_devs;
 int __adb_probe_sync;
#50 lore raw

[tip:core/locking] drivers/macintosh/adb: Do not claim that the semaphore is a mutex

Commit-ID:  8192b1f6b1a46b33213b993471356495a93ffc70
Gitweb:     http://git.kernel.org/tip/8192b1f6b1a46b33213b993471356495a93ffc70
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:33:40 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 12 Oct 2010 17:36:10 +0200

drivers/macintosh/adb: Do not claim that the semaphore is a mutex

User DEFINE_SEMAPHORE() instead of DECLARE_MUTEX()

Cc Peter Zijlstra <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>

LKML-Reference: <[email protected]>

---
 drivers/macintosh/adb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/macintosh/adb.c +1 -1
index 1c4ee6e..bf64e49 100644
@@ -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_SEMAPHORE(adb_probe_mutex);
 static int sleepy_trackpad;
 static int autopoll_devs;
 int __adb_probe_sync;
#51 lore raw

PATCH 26/30 printk: Make console_sem a semaphore not a pseudo mutex

In reply to Thomas Gleixner

It needs to be investigated whether it can be replaced by a real mutex, but that needs more thought.

---
 kernel/printk.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/printk.c +2 -2
Index: linux-2.6/kernel/printk.c
===================================================================
@@ -85,7 +85,7 @@ EXPORT_SYMBOL(oops_in_progress);
  * provides serialisation for access to the entire console
  * driver system.
  */
-static DECLARE_MUTEX(console_sem);
+static DEFINE_SEMAPHORE(console_sem);
 struct console *console_drivers;
 EXPORT_SYMBOL_GPL(console_drivers);
 
@@ -556,7 +556,7 @@ static void zap_locks(void)
 	/* If a crash is occurring, make sure we can't deadlock */
 	spin_lock_init(&logbuf_lock);
 	/* And make sure that we print immediately */
-	init_MUTEX(&console_sem);
+	sema_init(&console_sem, 1);
 }
 
 #if defined(CONFIG_PRINTK_TIME)
#52 lore raw

[tip:core/locking] printk: Make console_sem a semaphore not a pseudo mutex

Commit-ID:  5b8c4f23c54edda640a4850bc9b81dee70acb525
Gitweb:     http://git.kernel.org/tip/5b8c4f23c54edda640a4850bc9b81dee70acb525
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:33:43 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 12 Oct 2010 17:36:10 +0200

printk: Make console_sem a semaphore not a pseudo mutex

It needs to be investigated whether it can be replaced by a real mutex, but that needs more thought.

Cc Peter Zijlstra <[email protected]>
Cc Christoph Hellwig <[email protected]>

LKML-Reference: <[email protected]>

---
 kernel/printk.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/printk.c +2 -2
index 8fe465a..2531017 100644
@@ -85,7 +85,7 @@ EXPORT_SYMBOL(oops_in_progress);
  * provides serialisation for access to the entire console
  * driver system.
  */
-static DECLARE_MUTEX(console_sem);
+static DEFINE_SEMAPHORE(console_sem);
 struct console *console_drivers;
 EXPORT_SYMBOL_GPL(console_drivers);
 
@@ -556,7 +556,7 @@ static void zap_locks(void)
 	/* If a crash is occurring, make sure we can't deadlock */
 	spin_lock_init(&logbuf_lock);
 	/* And make sure that we print immediately */
-	init_MUTEX(&console_sem);
+	sema_init(&console_sem, 1);
 }
 
 #if defined(CONFIG_PRINTK_TIME)
#53 lore raw

PATCH 27/30 staging: Bulk convert the semaphore mess

In reply to Thomas Gleixner

init_MUTEX(_LOCKED) and DECLARE_MUTEX are going away. Bulk convert staging users.

Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/staging/comedi/drivers/dt9812.c     |    2 +-
 drivers/staging/comedi/drivers/usbdux.c     |    4 ++--
 drivers/staging/comedi/drivers/usbduxfast.c |    4 ++--
 drivers/staging/cxt1e1/functions.c          |    4 ++--
 drivers/staging/dream/pmem.c                |    2 +-
 drivers/staging/msm/mddihost.c              |    2 +-
 drivers/staging/msm/mdp.c                   |   10 +++++-----
 drivers/staging/msm/msm_fb.c                |    2 +-
 drivers/staging/otus/wwrap.c                |    2 +-
 drivers/staging/rt2860/common/rtmp_init.c   |    2 +-
 drivers/staging/solo6x10/solo6010-i2c.c     |    2 +-
 drivers/staging/solo6x10/solo6010-p2m.c     |    2 +-
 drivers/staging/vme/devices/vme_user.c      |    2 +-
 13 files changed, 20 insertions(+), 20 deletions(-)
drivers/staging/comedi/drivers/dt9812.c +1 -1
Index: linux-2.6/drivers/staging/comedi/drivers/dt9812.c
===================================================================
@@ -1128,7 +1128,7 @@ static int __init usb_dt9812_init(void)
 
 	/* Initialize all driver slots */
 	for (i = 0; i < DT9812_NUM_SLOTS; i++) {
-		init_MUTEX(&dt9812[i].mutex);
+		sema_init(&dt9812[i].mutex, 1);
 		dt9812[i].serial = 0;
 		dt9812[i].usb = NULL;
 		dt9812[i].comedi = NULL;
drivers/staging/comedi/drivers/usbdux.c +2 -2
Index: linux-2.6/drivers/staging/comedi/drivers/usbdux.c
===================================================================
@@ -315,7 +315,7 @@ struct usbduxsub {
  */
 static struct usbduxsub usbduxsub[NUMUSBDUX];
 
-static DECLARE_MUTEX(start_stop_sem);
+static DEFINE_SEMAPHORE(start_stop_sem);
 
 /*
  * Stops the data acquision
@@ -2367,7 +2367,7 @@ static int usbduxsub_probe(struct usb_in
 	dev_dbg(dev, "comedi_: usbdux: "
 		"usbduxsub[%d] is ready to connect to comedi.\n", index);
 
-	init_MUTEX(&(usbduxsub[index].sem));
+	sema_init(&(usbduxsub[index].sem), 1);
 	/* save a pointer to the usb device */
 	usbduxsub[index].usbdev = udev;
 
drivers/staging/comedi/drivers/usbduxfast.c +2 -2
Index: linux-2.6/drivers/staging/comedi/drivers/usbduxfast.c
===================================================================
@@ -199,7 +199,7 @@ struct usbduxfastsub_s {
  */
 static struct usbduxfastsub_s usbduxfastsub[NUMUSBDUXFAST];
 
-static DECLARE_MUTEX(start_stop_sem);
+static DEFINE_SEMAPHORE(start_stop_sem);
 
 /*
  * bulk transfers to usbduxfast
@@ -1504,7 +1504,7 @@ static int usbduxfastsub_probe(struct us
 	       "connect to comedi.\n", index);
 #endif
 
-	init_MUTEX(&(usbduxfastsub[index].sem));
+	sema_init(&(usbduxfastsub[index].sem), 1);
 	/* save a pointer to the usb device */
 	usbduxfastsub[index].usbdev = udev;
 
drivers/staging/cxt1e1/functions.c +2 -2
Index: linux-2.6/drivers/staging/cxt1e1/functions.c
===================================================================
@@ -184,10 +184,10 @@ OS_sem_init (void *sem, int state)
     switch (state)
     {
         case SEM_TAKEN:
-        init_MUTEX_LOCKED ((struct semaphore *) sem);
+		sema_init((struct semaphore *) sem, 0);
         break;
     case SEM_AVAILABLE:
-        init_MUTEX ((struct semaphore *) sem);
+	    sema_init((struct semaphore *) sem, 1);
         break;
     default:                        /* otherwise, set sem.count to state's
                                      * value */
drivers/staging/dream/pmem.c +1 -1
Index: linux-2.6/drivers/staging/dream/pmem.c
===================================================================
@@ -1231,7 +1231,7 @@ int pmem_setup(struct android_pmem_platf
 	pmem[id].ioctl = ioctl;
 	pmem[id].release = release;
 	init_rwsem(&pmem[id].bitmap_sem);
-	init_MUTEX(&pmem[id].data_list_sem);
+	sema_init(&pmem[id].data_list_sem, 1);
 	INIT_LIST_HEAD(&pmem[id].data_list);
 	pmem[id].dev.name = pdata->name;
 	pmem[id].dev.minor = id;
drivers/staging/msm/mddihost.c +1 -1
Index: linux-2.6/drivers/staging/msm/mddihost.c
===================================================================
@@ -67,7 +67,7 @@ void mddi_init(void)
 
 	mddi_host_initialized = TRUE;
 
-	init_MUTEX(&mddi_host_mutex);
+	sema_init(&mddi_host_mutex, 1);
 
 	if (!mddi_host_powered) {
 		down(&mddi_host_mutex);
drivers/staging/msm/mdp.c +5 -5
Index: linux-2.6/drivers/staging/msm/mdp.c
===================================================================
@@ -669,24 +669,24 @@ static void mdp_drv_init(void)
 
 	/* initialize semaphore */
 	init_completion(&mdp_ppp_comp);
-	init_MUTEX(&mdp_ppp_mutex);
-	init_MUTEX(&mdp_pipe_ctrl_mutex);
+	sema_init(&mdp_ppp_mutex, 1);
+	sema_init(&mdp_pipe_ctrl_mutex, 1);
 
 	dma2_data.busy = FALSE;
 	dma2_data.waiting = FALSE;
 	init_completion(&dma2_data.comp);
-	init_MUTEX(&dma2_data.mutex);
+	sema_init(&dma2_data.mutex, 1);
 	mutex_init(&dma2_data.ov_mutex);
 
 	dma3_data.busy = FALSE;
 	dma3_data.waiting = FALSE;
 	init_completion(&dma3_data.comp);
-	init_MUTEX(&dma3_data.mutex);
+	sema_init(&dma3_data.mutex, 1);
 
 	dma_s_data.busy = FALSE;
 	dma_s_data.waiting = FALSE;
 	init_completion(&dma_s_data.comp);
-	init_MUTEX(&dma_s_data.mutex);
+	sema_init(&dma_s_data.mutex, 1);
 
 	dma_e_data.busy = FALSE;
 	dma_e_data.waiting = FALSE;
drivers/staging/msm/msm_fb.c +1 -1
Index: linux-2.6/drivers/staging/msm/msm_fb.c
===================================================================
@@ -915,7 +915,7 @@ static int msm_fb_register(struct msm_fb
 	mfd->pan_waiting = FALSE;
 	init_completion(&mfd->pan_comp);
 	init_completion(&mfd->refresher_comp);
-	init_MUTEX(&mfd->sem);
+	sema_init(&mfd->sem, 1);
 
 	fbram_offset = PAGE_ALIGN((int)fbram)-(int)fbram;
 	fbram += fbram_offset;
drivers/staging/otus/wwrap.c +1 -1
Index: linux-2.6/drivers/staging/otus/wwrap.c
===================================================================
@@ -985,7 +985,7 @@ u8_t zfLnxCreateThread(zdev_t *dev)
 
     /* Create Mutex and keventd */
     INIT_WORK(&macp->kevent, kevent);
-    init_MUTEX(&macp->ioctl_sem);
+    sema_init(&macp->ioctl_sem, 1);
 
     return 0;
 }
drivers/staging/rt2860/common/rtmp_init.c +1 -1
Index: linux-2.6/drivers/staging/rt2860/common/rtmp_init.c
===================================================================
@@ -3509,7 +3509,7 @@ int RtmpRaDevCtrlInit(struct rt_rtmp_ada
 		 ("STA Driver version-%s\n", STA_DRIVER_VERSION));
 
 #ifdef RTMP_MAC_USB
-	init_MUTEX(&(pAd->UsbVendorReq_semaphore));
+	sema_init(&(pAd->UsbVendorReq_semaphore), 1);
 	os_alloc_mem(pAd, (u8 **) & pAd->UsbVendorReqBuf,
 		     MAX_PARAM_BUFFER_SIZE - 1);
 	if (pAd->UsbVendorReqBuf == NULL) {
drivers/staging/solo6x10/solo6010-i2c.c +1 -1
Index: linux-2.6/drivers/staging/solo6x10/solo6010-i2c.c
===================================================================
@@ -284,7 +284,7 @@ int solo_i2c_init(struct solo6010_dev *s
 	solo_dev->i2c_id = -1;
 	solo_dev->i2c_state = IIC_STATE_IDLE;
 	init_waitqueue_head(&solo_dev->i2c_wait);
-	init_MUTEX(&solo_dev->i2c_sem);
+	sema_init(&solo_dev->i2c_sem, 1);
 
 	for (i = 0; i < SOLO_I2C_ADAPTERS; i++) {
 		struct i2c_adapter *adap = &solo_dev->i2c_adap[i];
drivers/staging/solo6x10/solo6010-p2m.c +1 -1
Index: linux-2.6/drivers/staging/solo6x10/solo6010-p2m.c
===================================================================
@@ -188,7 +188,7 @@ int solo_p2m_init(struct solo6010_dev *s
 	for (i = 0; i < SOLO_NR_P2M; i++) {
 		p2m_dev = &solo_dev->p2m_dev[i];
 
-		init_MUTEX(&p2m_dev->sem);
+		sema_init(&p2m_dev->sem, 1);
 		init_completion(&p2m_dev->completion);
 
 		solo_reg_write(solo_dev, SOLO_P2M_DES_ADR(i),
drivers/staging/vme/devices/vme_user.c +1 -1
Index: linux-2.6/drivers/staging/vme/devices/vme_user.c
===================================================================
@@ -683,7 +683,7 @@ static int __init vme_user_probe(struct 
 	for (i = 0; i < VME_DEVS; i++) {
 		image[i].kern_buf = NULL;
 		image[i].pci_buf = 0;
-		init_MUTEX(&(image[i].sem));
+		sema_init(&(image[i].sem), 1);
 		image[i].device = NULL;
 		image[i].resource = NULL;
 		image[i].users = 0;
#54 lore raw

Re: [patch 27/30] staging: Bulk convert the semaphore mess

Quoted 2 lines · Thomas Gleixner

init_MUTEX(_LOCKED) and DECLARE_MUTEX are going away. Bulk convert staging users.

I don't think you actually built this change:

drivers/staging/comedi/drivers/usbdux.c struct usbduxsub { · line 321

Quoted 11 lines
drivers/staging/comedi/drivers/usbdux.c +1 -1
@@ -315,7 +315,7 @@ struct usbduxsub {
  */
 static struct usbduxsub usbduxsub[NUMUSBDUX];
 
-static DECLARE_MUTEX(start_stop_sem);
+static DEFINE_SEMAPHORE(start_stop_sem);
 
 /*
  * Stops the data acquision

I don't see DEFINE_SEMAPHORE() in Linus's tree, what should we use instead?

thanks,

greg k-h

#55 lore raw

Re: [patch 27/30] staging: Bulk convert the semaphore mess

Quoted 12 lines · Greg KH
Quoted 2 lines · Thomas Gleixner

init_MUTEX(_LOCKED) and DECLARE_MUTEX are going away. Bulk convert staging users.

I don't think you actually built this change:

Quoted 6 lines
drivers/staging/comedi/drivers/usbdux.c +0 -0
@@ -315,7 +315,7 @@ struct usbduxsub {
  */
 static struct usbduxsub usbduxsub[NUMUSBDUX];
 
Quoted 8 lines

drivers/staging/comedi/drivers/usbdux.c struct usbduxsub { · line 321

Quoted 5 lines
drivers/staging/comedi/drivers/usbdux.c +1 -1
-static DECLARE_MUTEX(start_stop_sem);
+static DEFINE_SEMAPHORE(start_stop_sem);
 
 /*
  * Stops the data acquision

I don't see DEFINE_SEMAPHORE() in Linus's tree, what should we use instead?

It's the first patch in the series, which I want to get Linus wards now, so this does not trip over.

Thanks,

tglx

#56 lore raw

Re: [patch 27/30] staging: Bulk convert the semaphore mess

Quoted 17 lines · Thomas Gleixner
Quoted 15 lines · Greg KH
Quoted 2 lines · Thomas Gleixner

init_MUTEX(_LOCKED) and DECLARE_MUTEX are going away. Bulk convert staging users.

I don't think you actually built this change:

Quoted 9 lines
drivers/staging/comedi/drivers/usbdux.c +1 -1
@@ -315,7 +315,7 @@ struct usbduxsub {
  */
 static struct usbduxsub usbduxsub[NUMUSBDUX];
 
-static DECLARE_MUTEX(start_stop_sem);
+static DEFINE_SEMAPHORE(start_stop_sem);
 
Quoted 8 lines
Quoted 5 lines

drivers/staging/comedi/drivers/usbdux.c struct usbduxsub { · line 321

Quoted 2 lines
drivers/staging/comedi/drivers/usbdux.c +0 -0
 /*
  * Stops the data acquision

I don't see DEFINE_SEMAPHORE() in Linus's tree, what should we use instead?

It's the first patch in the series, which I want to get Linus wards now, so this does not trip over.

Ah, that makes sense.

Well, it didn't hurt for me to take the other portions of this patch, right?

thanks,

greg k-h

#57 lore raw

Re: [patch 27/30] staging: Bulk convert the semaphore mess

Quoted 24 lines · Greg KH
Quoted 23 lines · Thomas Gleixner
Quoted 20 lines · Greg KH
Quoted 2 lines · Thomas Gleixner

init_MUTEX(_LOCKED) and DECLARE_MUTEX are going away. Bulk convert staging users.

I don't think you actually built this change:

drivers/staging/comedi/drivers/usbdux.c struct usbduxsub { · line 321

Quoted 11 lines
drivers/staging/comedi/drivers/usbdux.c +1 -1
@@ -315,7 +315,7 @@ struct usbduxsub {
  */
 static struct usbduxsub usbduxsub[NUMUSBDUX];
 
-static DECLARE_MUTEX(start_stop_sem);
+static DEFINE_SEMAPHORE(start_stop_sem);
 
 /*
  * Stops the data acquision

I don't see DEFINE_SEMAPHORE() in Linus's tree, what should we use instead?

Quoted 7 lines
Quoted 2 lines

It's the first patch in the series, which I want to get Linus wards now, so this does not trip over.

Ah, that makes sense.

Well, it didn't hurt for me to take the other portions of this patch, right?

Not at all. FYI, DEFINE_SEMAPHORE is now in Linus tree.

Thanks,

tglx

#58 lore raw

Re: [patch 27/30] staging: Bulk convert the semaphore mess

In reply to Thomas Gleixner
Quoted 6 lines · Thomas Gleixner

init_MUTEX(_LOCKED) and DECLARE_MUTEX are going away. Bulk convert staging users.

---
 drivers/staging/comedi/drivers/usbdux.c     |    4 ++--
 drivers/staging/comedi/drivers/usbduxfast.c |    4 ++--

I applied the patch with the exception of these two files, as they fail to build with the patch applied.

thanks,

greg k-h

#59 lore raw

[tip:core/locking] staging: Final semaphore cleanup

In reply to Thomas Gleixner
Commit-ID:  45f4d0243525b6bc747c946937ced437b135a84d
Gitweb:     http://git.kernel.org/tip/45f4d0243525b6bc747c946937ced437b135a84d
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Sat, 30 Oct 2010 11:06:57 +0200
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Sat, 30 Oct 2010 12:12:50 +0200

staging: Final semaphore cleanup

Fixup the last remaining users of DECLARE_MUTEX and init_MUTEX.

Scripted conversion, resulting code is binary equivalent.

Cc Greg Kroah-Hartman <[email protected]>

LKML-Reference: <[email protected]>

---
 drivers/staging/ath6kl/os/linux/ar6000_raw_if.c    |    4 ++--
 drivers/staging/brcm80211/brcmfmac/dhd_linux.c     |    4 ++--
 drivers/staging/brcm80211/sys/wl_mac80211.c        |    2 +-
 drivers/staging/comedi/drivers/dt9812.c            |    2 +-
 drivers/staging/comedi/drivers/usbdux.c            |    4 ++--
 drivers/staging/comedi/drivers/usbduxfast.c        |    4 ++--
 drivers/staging/dream/camera/mt9d112.c             |    2 +-
 drivers/staging/dream/camera/mt9p012_fox.c         |    2 +-
 drivers/staging/dream/camera/mt9t013.c             |    2 +-
 drivers/staging/dream/camera/s5k3e2fx.c            |    2 +-
 drivers/staging/msm/msm_fb.c                       |    4 ++--
 drivers/staging/rtl8712/osdep_service.h            |    2 +-
 drivers/staging/smbfs/inode.c                      |    2 +-
 .../westbridge/astoria/block/cyasblkdev_block.c    |    2 +-
 .../westbridge/astoria/block/cyasblkdev_queue.c    |    2 +-
 15 files changed, 20 insertions(+), 20 deletions(-)
drivers/staging/ath6kl/os/linux/ar6000_raw_if.c +2 -2
index c196098..6b8eeea 100644
@@ -198,8 +198,8 @@ int ar6000_htc_raw_open(AR_SOFTC_T *ar)
         
     for (streamID = HTC_RAW_STREAM_0; streamID < HTC_RAW_STREAM_NUM_MAX; streamID++) {
         /* Initialize the data structures */
-        init_MUTEX(&arRaw->raw_htc_read_sem[streamID]);
-        init_MUTEX(&arRaw->raw_htc_write_sem[streamID]);
+	sema_init(&arRaw->raw_htc_read_sem[streamID], 1);
+	sema_init(&arRaw->raw_htc_write_sem[streamID], 1);
         init_waitqueue_head(&arRaw->raw_htc_read_queue[streamID]);
         init_waitqueue_head(&arRaw->raw_htc_write_queue[streamID]);
 
drivers/staging/brcm80211/brcmfmac/dhd_linux.c +2 -2
index e535787..bbbe7c5 100644
@@ -1929,7 +1929,7 @@ dhd_pub_t *dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen)
 		goto fail;
 
 	net->netdev_ops = NULL;
-	init_MUTEX(&dhd->proto_sem);
+	sema_init(&dhd->proto_sem, 1);
 	/* Initialize other structure content */
 	init_waitqueue_head(&dhd->ioctl_resp_wait);
 	init_waitqueue_head(&dhd->ctrl_wait);
@@ -1977,7 +1977,7 @@ dhd_pub_t *dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen)
 	dhd->timer.function = dhd_watchdog;
 
 	/* Initialize thread based operation and lock */
-	init_MUTEX(&dhd->sdsem);
+	sema_init(&dhd->sdsem, 1);
 	if ((dhd_watchdog_prio >= 0) && (dhd_dpc_prio >= 0))
 		dhd->threads_only = true;
 	else
drivers/staging/brcm80211/sys/wl_mac80211.c +1 -1
index ad635ee..d060377 100644
@@ -866,7 +866,7 @@ static wl_info_t *wl_attach(u16 vendor, u16 device, unsigned long regs,
 	spin_lock_init(&wl->rpcq_lock);
 	spin_lock_init(&wl->txq_lock);
 
-	init_MUTEX(&wl->sem);
+	sema_init(&wl->sem, 1);
 #else
 	spin_lock_init(&wl->lock);
 	spin_lock_init(&wl->isr_lock);
drivers/staging/comedi/drivers/dt9812.c +1 -1
index 0560a74..0605985 100644
@@ -262,7 +262,7 @@ struct dt9812_usb_cmd {
 
 #define DT9812_NUM_SLOTS	16
 
-static DECLARE_MUTEX(dt9812_mutex);
+static DEFINE_SEMAPHORE(dt9812_mutex);
 
 static const struct usb_device_id dt9812_table[] = {
 	{USB_DEVICE(0x0867, 0x9812)},
drivers/staging/comedi/drivers/usbdux.c +2 -2
index 6131e2d..1f177a6 100644
@@ -315,7 +315,7 @@ struct usbduxsub {
  */
 static struct usbduxsub usbduxsub[NUMUSBDUX];
 
-static DECLARE_MUTEX(start_stop_sem);
+static DEFINE_SEMAPHORE(start_stop_sem);
 
 /*
  * Stops the data acquision
@@ -2367,7 +2367,7 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
 	dev_dbg(dev, "comedi_: usbdux: "
 		"usbduxsub[%d] is ready to connect to comedi.\n", index);
 
-	init_MUTEX(&(usbduxsub[index].sem));
+	sema_init(&(usbduxsub[index].sem), 1);
 	/* save a pointer to the usb device */
 	usbduxsub[index].usbdev = udev;
 
drivers/staging/comedi/drivers/usbduxfast.c +2 -2
index 0a164a9..5b15e6d 100644
@@ -199,7 +199,7 @@ struct usbduxfastsub_s {
  */
 static struct usbduxfastsub_s usbduxfastsub[NUMUSBDUXFAST];
 
-static DECLARE_MUTEX(start_stop_sem);
+static DEFINE_SEMAPHORE(start_stop_sem);
 
 /*
  * bulk transfers to usbduxfast
@@ -1504,7 +1504,7 @@ static int usbduxfastsub_probe(struct usb_interface *uinterf,
 	       "connect to comedi.\n", index);
 #endif
 
-	init_MUTEX(&(usbduxfastsub[index].sem));
+	sema_init(&(usbduxfastsub[index].sem), 1);
 	/* save a pointer to the usb device */
 	usbduxfastsub[index].usbdev = udev;
 
drivers/staging/dream/camera/mt9d112.c +1 -1
index e6f2d51..27c978f 100644
@@ -37,7 +37,7 @@ struct mt9d112_ctrl {
 static struct mt9d112_ctrl *mt9d112_ctrl;
 
 static DECLARE_WAIT_QUEUE_HEAD(mt9d112_wait_queue);
-DECLARE_MUTEX(mt9d112_sem);
+DEFINE_SEMAPHORE(mt9d112_sem);
 
 
 /*=============================================================
drivers/staging/dream/camera/mt9p012_fox.c +1 -1
index 791bd6c..544a973 100644
@@ -123,7 +123,7 @@ struct mt9p012_ctrl {
 
 static struct mt9p012_ctrl *mt9p012_ctrl;
 static DECLARE_WAIT_QUEUE_HEAD(mt9p012_wait_queue);
-DECLARE_MUTEX(mt9p012_sem);
+DEFINE_SEMAPHORE(mt9p012_sem);
 
 /*=============================================================
 	EXTERNAL DECLARATIONS
drivers/staging/dream/camera/mt9t013.c +1 -1
index 8fd7727..75e78aa 100644
@@ -123,7 +123,7 @@ struct mt9t013_ctrl {
 
 static struct mt9t013_ctrl *mt9t013_ctrl;
 static DECLARE_WAIT_QUEUE_HEAD(mt9t013_wait_queue);
-DECLARE_MUTEX(mt9t013_sem);
+DEFINE_SEMAPHORE(mt9t013_sem);
 
 extern struct mt9t013_reg mt9t013_regs; /* from mt9t013_reg.c */
 
drivers/staging/dream/camera/s5k3e2fx.c +1 -1
index 1459903..d66b453 100644
@@ -313,7 +313,7 @@ struct s5k3e2fx_i2c_reg_conf {
 
 static struct s5k3e2fx_ctrl *s5k3e2fx_ctrl;
 static DECLARE_WAIT_QUEUE_HEAD(s5k3e2fx_wait_queue);
-DECLARE_MUTEX(s5k3e2fx_sem);
+DEFINE_SEMAPHORE(s5k3e2fx_sem);
 
 static int s5k3e2fx_i2c_rxdata(unsigned short saddr, unsigned char *rxdata,
 	int length)
drivers/staging/msm/msm_fb.c +2 -2
index ea268ed..23fa049 100644
@@ -1158,7 +1158,7 @@ static int msm_fb_release(struct fb_info *info, int user)
 	return ret;
 }
 
-DECLARE_MUTEX(msm_fb_pan_sem);
+DEFINE_SEMAPHORE(msm_fb_pan_sem);
 
 static int msm_fb_pan_display(struct fb_var_screeninfo *var,
 			      struct fb_info *info)
@@ -1962,7 +1962,7 @@ static int msmfb_overlay_play(struct fb_info *info, unsigned long *argp)
 
 #endif
 
-DECLARE_MUTEX(msm_fb_ioctl_ppp_sem);
+DEFINE_SEMAPHORE(msm_fb_ioctl_ppp_sem);
 DEFINE_MUTEX(msm_fb_ioctl_lut_sem);
 DEFINE_MUTEX(msm_fb_ioctl_hist_sem);
 
drivers/staging/rtl8712/osdep_service.h +1 -1
index 7fca42c..d1674cd 100644
@@ -161,7 +161,7 @@ static inline u32 _down_sema(struct semaphore *sema)
 
 static inline void _rtl_rwlock_init(struct semaphore *prwlock)
 {
-	init_MUTEX(prwlock);
+	sema_init(prwlock, 1);
 }
 
 static inline void _init_listhead(struct list_head *list)
drivers/staging/smbfs/inode.c +1 -1
index 552951a..fa42f40 100644
@@ -537,7 +537,7 @@ static int smb_fill_super(struct super_block *sb, void *raw_data, int silent)
 	server->mnt = NULL;
 	server->sock_file = NULL;
 	init_waitqueue_head(&server->conn_wq);
-	init_MUTEX(&server->sem);
+	sema_init(&server->sem, 1);
 	INIT_LIST_HEAD(&server->entry);
 	INIT_LIST_HEAD(&server->xmitq);
 	INIT_LIST_HEAD(&server->recvq);
drivers/staging/westbridge/astoria/block/cyasblkdev_block.c +1 -1
index f428a7a..e1851f0 100644
@@ -157,7 +157,7 @@ struct cyasblkdev_blk_data {
 /* pointer to west bridge block data device superstructure */
 static struct cyasblkdev_blk_data *gl_bd;
 
-static DECLARE_MUTEX(open_lock);
+static DEFINE_SEMAPHORE(open_lock);
 
 /* local forwardd declarationss  */
 static cy_as_device_handle *cyas_dev_handle;
drivers/staging/westbridge/astoria/block/cyasblkdev_queue.c +1 -1
index 24e959e..0bbb8a3 100644
@@ -334,7 +334,7 @@ int cyasblkdev_init_queue(struct cyasblkdev_queue *bq, spinlock_t *lock)
 
 	init_completion(&bq->thread_complete);
 	init_waitqueue_head(&bq->thread_wq);
-	init_MUTEX(&bq->thread_sem);
+	sema_init(&bq->thread_sem, 1);
 
 	ret = kernel_thread(cyasblkdev_queue_thread, bq, CLONE_KERNEL);
 	if (ret >= 0) {
#61 lore raw

[tip:core/locking] arm: Bcmring: semaphore cleanup

Commit-ID:  5356d94872502e77317f82e8fcae2a0b162af07c
Gitweb:     http://git.kernel.org/tip/5356d94872502e77317f82e8fcae2a0b162af07c
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:33:52 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 12 Oct 2010 17:36:10 +0200

arm: Bcmring: semaphore cleanup

Cc Peter Zijlstra <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Leo Chen <[email protected]>

LKML-Reference: <[email protected]>

---
 arch/arm/mach-bcmring/dma.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-bcmring/dma.c +2 -2
index 29c0a91..77eb35c 100644
@@ -691,7 +691,7 @@ int dma_init(void)
 
 	memset(&gDMA, 0, sizeof(gDMA));
 
-	init_MUTEX_LOCKED(&gDMA.lock);
+	sema_init(&gDMA.lock, 0);
 	init_waitqueue_head(&gDMA.freeChannelQ);
 
 	/* Initialize the Hardware */
@@ -1574,7 +1574,7 @@ int dma_init_mem_map(DMA_MemMap_t *memMap)
 {
 	memset(memMap, 0, sizeof(*memMap));
 
-	init_MUTEX(&memMap->lock);
+	sema_init(&memMap->lock, 1);
 
 	return 0;
 }
#62 lore raw

PATCH 29/30 hwmon: s3c-hwmon: Use a real mutex

In reply to Thomas Gleixner

The semaphore which protects the ADC is semantically a mutex. Use a real mutex.

---
 drivers/hwmon/s3c-hwmon.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-2.6/drivers/hwmon/s3c-hwmon.c =================================--- linux-2.6.orig/drivers/hwmon/s3c-hwmon.c +++ linux-2.6/drivers/hwmon/s3c-hwmon.c
@@ -51,7 +51,7 @@ struct s3c_hwmon_attr {
* @attr: The holders for the channel attributes.
*/
struct s3c_hwmon {
- struct semaphore lock;
+ struct mutex lock;
struct s3c_adc_client *client;
struct device *hwmon_dev;

@@ -73,14 +73,14 @@ static int s3c_hwmon_read_ch(struct devi
{
int ret;

- ret = down_interruptible(&hwmon->lock);
+ ret = mutex_lock_interruptible(&hwmon->lock);
if (ret < 0)
return ret;

dev_dbg(dev, "reading channel %d\n", channel);

ret = s3c_adc_read(hwmon->client, channel);
- up(&hwmon->lock);
+ mutex_unlock(&hwmon->lock);

return ret;
}
@@ -296,7 +296,7 @@ static int __devinit s3c_hwmon_probe(str

platform_set_drvdata(dev, hwmon);

- init_MUTEX(&hwmon->lock);
+ mutex_init(&hwmon->lock);

/* Register with the core ADC driver. */

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

Applied
#63 lore raw

Re: [patch 29/30] hwmon: s3c-hwmon: Use a real mutex

Quoted 43 lines · Thomas Gleixner

The semaphore which protects the ADC is semantically a mutex. Use a real mutex.

---
 drivers/hwmon/s3c-hwmon.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-2.6/drivers/hwmon/s3c-hwmon.c =================================> --- linux-2.6.orig/drivers/hwmon/s3c-hwmon.c +++ linux-2.6/drivers/hwmon/s3c-hwmon.c

(quoted diff) +3 -3
@@ -51,7 +51,7 @@ struct s3c_hwmon_attr {
  * @attr: The holders for the channel attributes.
 */
 struct s3c_hwmon {
-	struct semaphore	lock;
+	struct mutex		lock;
 	struct s3c_adc_client	*client;
 	struct device		*hwmon_dev;
 
@@ -73,14 +73,14 @@ static int s3c_hwmon_read_ch(struct devi
 {
 	int ret;
 
-	ret = down_interruptible(&hwmon->lock);
+	ret = mutex_lock_interruptible(&hwmon->lock);
 	if (ret < 0)
 		return ret;
 
 	dev_dbg(dev, "reading channel %d\n", channel);
 
 	ret = s3c_adc_read(hwmon->client, channel);
-	up(&hwmon->lock);
+	mutex_unlock(&hwmon->lock);
 
 	return ret;
 }

Review static int __devinit s3c_hwmon_probe(str · line 302

Quoted 8 lines
(quoted diff) +1 -1
@@ -296,7 +296,7 @@ static int __devinit s3c_hwmon_probe(str
 
 	platform_set_drvdata(dev, hwmon);
 
-	init_MUTEX(&hwmon->lock);
+	mutex_init(&hwmon->lock);
 
 	/* Register with the core ADC driver. */
 

Applied, thanks.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#64 lore raw

PATCH 30/30 semaphore: Remove mutex emulation

In reply to Thomas Gleixner

Semaphores used as mutexes have been deprecated for years. Now that all users are either converted to real semaphores or to mutexes remove the cruft.

---
 include/linux/semaphore.h |    6 ------
 scripts/checkpatch.pl     |    8 ++------
 2 files changed, 2 insertions(+), 12 deletions(-)
include/linux/semaphore.h +0 -6
Index: linux-2.6/include/linux/semaphore.h
===================================================================
@@ -29,9 +29,6 @@ struct semaphore {
 #define DEFINE_SEMAPHORE(name)	\
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
 
-#define DECLARE_MUTEX(name)	\
-	struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
-
 static inline void sema_init(struct semaphore *sem, int val)
 {
 	static struct lock_class_key __key;
@@ -39,9 +36,6 @@ static inline void sema_init(struct sema
 	lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0);
 }
 
-#define init_MUTEX(sem)		sema_init(sem, 1)
-#define init_MUTEX_LOCKED(sem)	sema_init(sem, 0)
-
 extern void down(struct semaphore *sem);
 extern int __must_check down_interruptible(struct semaphore *sem);
 extern int __must_check down_killable(struct semaphore *sem);
scripts/checkpatch.pl +2 -6
Index: linux-2.6/scripts/checkpatch.pl
===================================================================
@@ -2701,12 +2701,8 @@ sub process {
 			WARN("__func__ should be used instead of gcc specific __FUNCTION__\n"  . $herecurr);
 		}
 
-# check for semaphores used as mutexes
-		if ($line =~ /^.\s*(DECLARE_MUTEX|init_MUTEX)\s*\(/) {
-			WARN("mutexes are preferred for single holder semaphores\n" . $herecurr);
-		}
-# check for semaphores used as mutexes
-		if ($line =~ /^.\s*init_MUTEX_LOCKED\s*\(/) {
+# check for semaphores initialized locked
+		if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
 			WARN("consider using a completion\n" . $herecurr);
 
 		}
#65 lore raw

[tip:core/locking] semaphore: Remove mutex emulation

Commit-ID:  4882720b267b7b1d1b0ce08334b205f0329d4615
Gitweb:     http://git.kernel.org/tip/4882720b267b7b1d1b0ce08334b205f0329d4615
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 7 Sep 2010 14:34:01 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Sat, 30 Oct 2010 12:12:50 +0200

semaphore: Remove mutex emulation

Semaphores used as mutexes have been deprecated for years. Now that all users are either converted to real semaphores or to mutexes remove the cruft.

Cc Peter Zijlstra <[email protected]>
Cc Christoph Hellwig <[email protected]>

LKML-Reference: <[email protected]>

---
 include/linux/semaphore.h |    6 ------
 scripts/checkpatch.pl     |    8 ++------
 2 files changed, 2 insertions(+), 12 deletions(-)
include/linux/semaphore.h +0 -6
index 5310d27..39fa049 100644
@@ -29,9 +29,6 @@ struct semaphore {
 #define DEFINE_SEMAPHORE(name)	\
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
 
-#define DECLARE_MUTEX(name)	\
-	struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
-
 static inline void sema_init(struct semaphore *sem, int val)
 {
 	static struct lock_class_key __key;
@@ -39,9 +36,6 @@ static inline void sema_init(struct semaphore *sem, int val)
 	lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0);
 }
 
-#define init_MUTEX(sem)		sema_init(sem, 1)
-#define init_MUTEX_LOCKED(sem)	sema_init(sem, 0)
-
 extern void down(struct semaphore *sem);
 extern int __must_check down_interruptible(struct semaphore *sem);
 extern int __must_check down_killable(struct semaphore *sem);
scripts/checkpatch.pl +2 -6
index 90b54d4..e3c7fc0 100755
@@ -2794,12 +2794,8 @@ sub process {
 			WARN("__func__ should be used instead of gcc specific __FUNCTION__\n"  . $herecurr);
 		}
 
-# check for semaphores used as mutexes
-		if ($line =~ /^.\s*(DECLARE_MUTEX|init_MUTEX)\s*\(/) {
-			WARN("mutexes are preferred for single holder semaphores\n" . $herecurr);
-		}
-# check for semaphores used as mutexes
-		if ($line =~ /^.\s*init_MUTEX_LOCKED\s*\(/) {
+# check for semaphores initialized locked
+		if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
 			WARN("consider using a completion\n" . $herecurr);
 
 		}
#66 lore raw
In reply to Thomas Gleixner
Quoted 2 lines · Thomas Gleixner

init_MUTEX[_LOCKED] and DECLARE_MUTEX are deprecated for quite some time. Cleanup the remaining users and remove the cruft.

How many of these really need to be semaphores and can't be converted to mutex or completion? I thought that we wanted to send the classic semaphore the same way as the BKL eventually.

Arnd

#67 lore raw
Quoted 7 lines · Arnd Bergmann
Quoted 2 lines · Thomas Gleixner

init_MUTEX[_LOCKED] and DECLARE_MUTEX are deprecated for quite some time. Cleanup the remaining users and remove the cruft.

How many of these really need to be semaphores and can't be converted to mutex or completion? I thought that we wanted to send the classic semaphore the same way as the BKL eventually.

Some of those can be converted to completions, but most of them have utterly borked semantics. I'm not sure if its worth the trouble to actually change all this as most of that stuff is ancient. Real semaphores are not going away (at least not the counting type ones).

Thanks,

tglx

#68 lore raw
Quoted 4 lines · On Tuesday 07 September 2010 17:38:33 Thomas Gleixner wrote:

Some of those can be converted to completions, but most of them have utterly borked semantics. I'm not sure if its worth the trouble to actually change all this as most of that stuff is ancient. Real semaphores are not going away (at least not the counting type ones).

Ok. I thought I had seen a series from Ingo some time ago that actually converted all of them to something else, but maybe I was mistaken.

Not sure if there is anything to be gained (other than more work) from merging semaphore and rw_semaphore into a single implementation that is both counting and read-write.

One problem I see (not with your series, just with semaphores in general) is that they keep creeping in through drivers/staging: About half the users we currently have are in staging. Obviously they get removed from there in order for drivers to graduate from staging, but not exposing the interface to device drivers would reduce the number of bad choices for authors to make.

Arnd

#69 lore raw

Arnd,

Quoted 13 lines · Arnd Bergmann
Quoted 4 lines · On Tuesday 07 September 2010 17:38:33 Thomas Gleixner wrote:

Some of those can be converted to completions, but most of them have utterly borked semantics. I'm not sure if its worth the trouble to actually change all this as most of that stuff is ancient. Real semaphores are not going away (at least not the counting type ones).

Ok. I thought I had seen a series from Ingo some time ago that actually converted all of them to something else, but maybe I was mistaken.

Not sure if there is anything to be gained (other than more work) from merging semaphore and rw_semaphore into a single implementation that is both counting and read-write.

Quoted 6 lines

One problem I see (not with your series, just with semaphores in general) is that they keep creeping in through drivers/staging: About half the users we currently have are in staging. Obviously they get removed from there in order for drivers to graduate from staging, but not exposing the interface to device drivers would reduce the number of bad choices for authors to make.

sure, but most of them are really the init_MUTEX[_LOCKED] type which has been copied over and over again for almost a decade.

That's going away, so people are actually forced to look into the alternative solutions. And I do not worry too much about staging/*

Thanks,

tglx

#70 lore raw
Quoted 5 lines · On Tuesday 07 September 2010 22:23:06 Thomas Gleixner wrote:

sure, but most of them are really the init_MUTEX[_LOCKED] type which has been copied over and over again for almost a decade.

That's going away, so people are actually forced to look into the alternative solutions. And I do not worry too much about staging/*

Yes, good point.

Arnd