public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: OMAP: fix for mailbox queue status detection
@ 2006-11-30 11:09 Toshihiro.Kobayashi
  2006-11-30 23:28 ` Tony Lindgren
  0 siblings, 1 reply; 2+ messages in thread
From: Toshihiro.Kobayashi @ 2006-11-30 11:09 UTC (permalink / raw)
  To: linux-omap-open-source, hiroshi.doyu

detect 'full' and 'empty' correctly and simply.

Signed-off-by: Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com>

---

 arch/arm/plat-omap/mailbox.h |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

927a857c6e44fd508562d9d8c5654b9159449abc
diff --git a/arch/arm/plat-omap/mailbox.h b/arch/arm/plat-omap/mailbox.h
index f8b87a1..c3f8f2c 100644
--- a/arch/arm/plat-omap/mailbox.h
+++ b/arch/arm/plat-omap/mailbox.h
@@ -21,6 +21,7 @@ struct omap_mbq {
 	rwlock_t lock;
 	mbox_msg_t msg[MBQ_DEPTH];
 	mbox_msg_t *rp, *wp;
+	int cnt;
 };
 
 static inline int mbq_init(struct omap_mbq **addr)
@@ -33,6 +34,7 @@ static inline int mbq_init(struct omap_m
 
 	write_lock_irq(&m->lock);
 	m->rp = m->wp = &m->msg[0];
+	m->cnt = 0;
 	write_unlock_irq(&m->lock);
 
 	*addr = m;
@@ -45,7 +47,7 @@ static inline int mbq_empty(struct omap_
 	int ret;
 
 	read_lock_irq(&mbq->lock);
-	ret = (mbq->rp == mbq->wp);
+	ret = (mbq->cnt == 0);
 	read_unlock_irq(&mbq->lock);
 
 	return ret;
@@ -54,16 +56,9 @@ static inline int mbq_empty(struct omap_
 static inline int mbq_full(struct omap_mbq *mbq)
 {
 	int ret;
-	mbox_msg_t *p;
 
 	read_lock_irq(&mbq->lock);
-	p = mbq->wp;
-
-	if (++p == &mbq->msg[MBQ_DEPTH])
-		p = &mbq->msg[0];
-
-	ret = (p == mbq->rp);
-
+	ret = (mbq->cnt == MBQ_DEPTH);
 	read_unlock_irq(&mbq->lock);
 
 	return ret;
@@ -79,8 +74,8 @@ static inline int mbq_add(struct omap_mb
 	if (++mbq->wp == &mbq->msg[MBQ_DEPTH])
 		mbq->wp = &mbq->msg[0];
 
-	if (mbq->wp == mbq->rp)	/* full */
-		ret = -1;;
+	if (++mbq->cnt == MBQ_DEPTH)	/* full */
+		ret = -1;
 
 	write_unlock_irq(&mbq->lock);
 
@@ -97,6 +92,7 @@ static inline mbox_msg_t mbq_get(struct 
 
 	if (++mbq->rp == &mbq->msg[MBQ_DEPTH])
 		mbq->rp = &mbq->msg[0];
+	mbq->cnt--;
 
 	write_unlock_irq(&mbq->lock);
 
-- 
1.3.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-11-30 23:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-30 11:09 [PATCH] ARM: OMAP: fix for mailbox queue status detection Toshihiro.Kobayashi
2006-11-30 23:28 ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox