int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg) { struct omap_mbox_queue *mq = mbox->txq; int ret = 0, len; spin_lock_bh(&mq->lock); if (kfifo_avail(&mq->fifo) < sizeof(msg)) { ret = -ENOMEM; goto out; } if (kfifo_is_empty(&mq->fifo) && !__mbox_poll_for_space(mbox)) { mbox_fifo_write(mbox, msg); goto out; } len = kfifo_in(&mq->fifo, (unsigned char *)&msg, sizeof(msg)); WARN_ON(len != sizeof(msg)); tasklet_schedule(&mbox->txq->tasklet); out: spin_unlock_bh(&mq->lock); return ret; }
/* * message sender */ int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg) { struct omap_mbox_queue *mq = mbox->txq; int ret = 0, len; spin_lock_bh(&mq->lock); if ((FIFO_SIZE - (__kfifo_len(mq->fifo))) < sizeof(msg)) { ret = -ENOMEM; goto out; } if (!__kfifo_len(mq->fifo)) { if (!mbox_fifo_full(mbox)) { if (mbox->txq->callback) ret = mbox->txq->callback(NULL); mbox_fifo_write(mbox, msg); goto out; } } len = __kfifo_put(mq->fifo, (unsigned char *)&msg, sizeof(msg)); if (unlikely(len != sizeof(msg))) { pr_err("%s: __kfifo_put anomaly detected\n", __func__); ret = -ENOMEM; } tasklet_schedule(&mbox->txq->tasklet); out: spin_unlock_bh(&mq->lock); return ret; }
/* * message sender */ static int __mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg) { int ret = 0, i = 1000; while (mbox_fifo_full(mbox)) { if (mbox->ops->type == OMAP_MBOX_TYPE2) return -1; if (--i == 0) return -1; udelay(1); } mbox_fifo_write(mbox, msg); return ret; }
static void mbox_tx_tasklet(unsigned long tx_data) { struct omap_mbox *mbox = (struct omap_mbox *)tx_data; struct omap_mbox_queue *mq = mbox->txq; mbox_msg_t msg; int ret; while (kfifo_len(&mq->fifo)) { if (__mbox_poll_for_space(mbox)) { omap_mbox_enable_irq(mbox, IRQ_TX); break; } ret = kfifo_out(&mq->fifo, (unsigned char *)&msg, sizeof(msg)); WARN_ON(ret != sizeof(msg)); mbox_fifo_write(mbox, msg); } }
/* * message sender */ static int __mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg, void *arg) { int ret = 0, i = 1000; while (mbox_fifo_full(mbox)) { if (mbox->ops->type == OMAP_MBOX_TYPE2) return -1; if (--i == 0) return -1; udelay(1); } if (arg && mbox->txq->callback) { ret = mbox->txq->callback(arg); if (ret) goto out; } mbox_seq_toggle(mbox, &msg); mbox_fifo_write(mbox, msg); out: return ret; }
static void mbox_tx_tasklet(unsigned long tx_data) { struct omap_mbox *mbox = (struct omap_mbox *)tx_data; struct omap_mbox_queue *mq = mbox->txq; mbox_msg_t msg; int ret; while (__kfifo_len(mq->fifo)) { if (mbox_fifo_full(mbox)) { omap_mbox_enable_irq(mbox, IRQ_TX); break; } ret = __kfifo_get(mq->fifo, (unsigned char *)&msg, sizeof(msg)); if (unlikely(ret != sizeof(msg))) pr_err("%s: __kfifo_get anomaly\n", __func__); if (mbox->txq->callback) ret = mbox->txq->callback(NULL); mbox_fifo_write(mbox, msg); } }