Skip to content

Commit 04a07a3

Browse files
glneoJassi Brar
authored andcommitted
mailbox: omap: Reverse FIFO busy check logic
It is much more clear to check if the hardware FIFO is full and return EBUSY if true. This allows us to also remove one level of indention from the core of this function. It also makes the similarities between omap_mbox_chan_send_noirq() and omap_mbox_chan_send() more obvious. Signed-off-by: Andrew Davis <[email protected]> Signed-off-by: Jassi Brar <[email protected]>
1 parent 5aa00b6 commit 04a07a3

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

drivers/mailbox/omap-mailbox.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -375,34 +375,33 @@ static void omap_mbox_chan_shutdown(struct mbox_chan *chan)
375375

376376
static int omap_mbox_chan_send_noirq(struct omap_mbox *mbox, u32 msg)
377377
{
378-
int ret = -EBUSY;
378+
if (mbox_fifo_full(mbox))
379+
return -EBUSY;
379380

380-
if (!mbox_fifo_full(mbox)) {
381-
omap_mbox_enable_irq(mbox, IRQ_RX);
382-
mbox_fifo_write(mbox, msg);
383-
ret = 0;
384-
omap_mbox_disable_irq(mbox, IRQ_RX);
381+
omap_mbox_enable_irq(mbox, IRQ_RX);
382+
mbox_fifo_write(mbox, msg);
383+
omap_mbox_disable_irq(mbox, IRQ_RX);
385384

386-
/* we must read and ack the interrupt directly from here */
387-
mbox_fifo_read(mbox);
388-
ack_mbox_irq(mbox, IRQ_RX);
389-
}
385+
/* we must read and ack the interrupt directly from here */
386+
mbox_fifo_read(mbox);
387+
ack_mbox_irq(mbox, IRQ_RX);
390388

391-
return ret;
389+
return 0;
392390
}
393391

394392
static int omap_mbox_chan_send(struct omap_mbox *mbox, u32 msg)
395393
{
396-
int ret = -EBUSY;
397-
398-
if (!mbox_fifo_full(mbox)) {
399-
mbox_fifo_write(mbox, msg);
400-
ret = 0;
394+
if (mbox_fifo_full(mbox)) {
395+
/* always enable the interrupt */
396+
omap_mbox_enable_irq(mbox, IRQ_TX);
397+
return -EBUSY;
401398
}
402399

400+
mbox_fifo_write(mbox, msg);
401+
403402
/* always enable the interrupt */
404403
omap_mbox_enable_irq(mbox, IRQ_TX);
405-
return ret;
404+
return 0;
406405
}
407406

408407
static int omap_mbox_chan_send_data(struct mbox_chan *chan, void *data)

0 commit comments

Comments
 (0)