Commit b3e8d6f3 authored by Toshihiro Kobayashi's avatar Toshihiro Kobayashi Committed by Tony Lindgren

ARM: OMAP: fix for mailbox queue status detection

detect 'full' and 'empty' correctly and simply.
Signed-off-by: default avatarToshihiro Kobayashi <toshihiro.kobayashi@nokia.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent d5010964
...@@ -21,6 +21,7 @@ struct omap_mbq { ...@@ -21,6 +21,7 @@ struct omap_mbq {
rwlock_t lock; rwlock_t lock;
mbox_msg_t msg[MBQ_DEPTH]; mbox_msg_t msg[MBQ_DEPTH];
mbox_msg_t *rp, *wp; mbox_msg_t *rp, *wp;
int cnt;
}; };
static inline int mbq_init(struct omap_mbq **addr) static inline int mbq_init(struct omap_mbq **addr)
...@@ -33,6 +34,7 @@ static inline int mbq_init(struct omap_mbq **addr) ...@@ -33,6 +34,7 @@ static inline int mbq_init(struct omap_mbq **addr)
write_lock_irq(&m->lock); write_lock_irq(&m->lock);
m->rp = m->wp = &m->msg[0]; m->rp = m->wp = &m->msg[0];
m->cnt = 0;
write_unlock_irq(&m->lock); write_unlock_irq(&m->lock);
*addr = m; *addr = m;
...@@ -45,7 +47,7 @@ static inline int mbq_empty(struct omap_mbq *mbq) ...@@ -45,7 +47,7 @@ static inline int mbq_empty(struct omap_mbq *mbq)
int ret; int ret;
read_lock_irq(&mbq->lock); read_lock_irq(&mbq->lock);
ret = (mbq->rp == mbq->wp); ret = (mbq->cnt == 0);
read_unlock_irq(&mbq->lock); read_unlock_irq(&mbq->lock);
return ret; return ret;
...@@ -54,16 +56,9 @@ static inline int mbq_empty(struct omap_mbq *mbq) ...@@ -54,16 +56,9 @@ static inline int mbq_empty(struct omap_mbq *mbq)
static inline int mbq_full(struct omap_mbq *mbq) static inline int mbq_full(struct omap_mbq *mbq)
{ {
int ret; int ret;
mbox_msg_t *p;
read_lock_irq(&mbq->lock); read_lock_irq(&mbq->lock);
p = mbq->wp; ret = (mbq->cnt == MBQ_DEPTH);
if (++p == &mbq->msg[MBQ_DEPTH])
p = &mbq->msg[0];
ret = (p == mbq->rp);
read_unlock_irq(&mbq->lock); read_unlock_irq(&mbq->lock);
return ret; return ret;
...@@ -79,8 +74,8 @@ static inline int mbq_add(struct omap_mbq *mbq, mbox_msg_t msg) ...@@ -79,8 +74,8 @@ static inline int mbq_add(struct omap_mbq *mbq, mbox_msg_t msg)
if (++mbq->wp == &mbq->msg[MBQ_DEPTH]) if (++mbq->wp == &mbq->msg[MBQ_DEPTH])
mbq->wp = &mbq->msg[0]; mbq->wp = &mbq->msg[0];
if (mbq->wp == mbq->rp) /* full */ if (++mbq->cnt == MBQ_DEPTH) /* full */
ret = -1;; ret = -1;
write_unlock_irq(&mbq->lock); write_unlock_irq(&mbq->lock);
...@@ -97,6 +92,7 @@ static inline mbox_msg_t mbq_get(struct omap_mbq *mbq) ...@@ -97,6 +92,7 @@ static inline mbox_msg_t mbq_get(struct omap_mbq *mbq)
if (++mbq->rp == &mbq->msg[MBQ_DEPTH]) if (++mbq->rp == &mbq->msg[MBQ_DEPTH])
mbq->rp = &mbq->msg[0]; mbq->rp = &mbq->msg[0];
mbq->cnt--;
write_unlock_irq(&mbq->lock); write_unlock_irq(&mbq->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment