From patchwork Tue Aug 6 21:40:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 2839676 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5AE6CBF535 for ; Tue, 6 Aug 2013 21:49:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 461322011D for ; Tue, 6 Aug 2013 21:49:27 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D347D20201 for ; Tue, 6 Aug 2013 21:49:25 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6p6y-0006qK-Tu; Tue, 06 Aug 2013 21:48:13 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6p6S-00033v-Be; Tue, 06 Aug 2013 21:47:40 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6p63-0002zI-UB for linux-arm-kernel@lists.infradead.org; Tue, 06 Aug 2013 21:47:19 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r76LkrEl021200; Tue, 6 Aug 2013 16:46:53 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r76Lkrhk017218; Tue, 6 Aug 2013 16:46:53 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Tue, 6 Aug 2013 16:46:52 -0500 Received: from localhost (irmo.am.dhcp.ti.com [128.247.74.241]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r76LkrmZ024241; Tue, 6 Aug 2013 16:46:53 -0500 From: Suman Anna To: Tony Lindgren , Benoit Cousson Subject: [PATCHv3 6/8] mailbox/omap: remove omap_mbox_type_t from mailbox ops Date: Tue, 6 Aug 2013 16:40:35 -0500 Message-ID: <1375825235-18263-1-git-send-email-s-anna@ti.com> X-Mailer: git-send-email 1.8.3.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130806_174716_164964_2F9F19A8 X-CRM114-Status: GOOD ( 13.68 ) X-Spam-Score: -6.9 (------) Cc: Ohad Ben-Cohen , devicetree@vger.kernel.org, Paul Walmsley , Suman Anna , Loic Pallardy , Jassi Brar , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The type definition omap_mbox_type_t used for distinguishing OMAP1 from OMAP2+ mailboxes does not really belong to the ops, and has been cleaned up. Signed-off-by: Loic Pallardy Signed-off-by: Suman Anna --- drivers/mailbox/mailbox-omap1.c | 27 ++++++++++++++++++++++++--- drivers/mailbox/mailbox-omap2.c | 11 +++++++++-- drivers/mailbox/omap-mailbox.c | 26 ++++---------------------- drivers/mailbox/omap-mbox.h | 7 +------ 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/drivers/mailbox/mailbox-omap1.c b/drivers/mailbox/mailbox-omap1.c index 5e38ffc..0f874e0 100644 --- a/drivers/mailbox/mailbox-omap1.c +++ b/drivers/mailbox/mailbox-omap1.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "omap-mbox.h" @@ -37,6 +38,7 @@ struct omap_mbox1_fifo { struct omap_mbox1_priv { struct omap_mbox1_fifo tx_fifo; struct omap_mbox1_fifo rx_fifo; + bool empty_flag; }; static inline int mbox_read_reg(size_t ofs) @@ -59,6 +61,7 @@ static mbox_msg_t omap1_mbox_fifo_read(struct omap_mbox *mbox) msg = mbox_read_reg(fifo->data); msg |= ((mbox_msg_t) mbox_read_reg(fifo->cmd)) << 16; + (struct omap_mbox1_priv *)(mbox->priv)->empty_flag = false; return msg; } @@ -74,7 +77,9 @@ omap1_mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg) static int omap1_mbox_fifo_empty(struct omap_mbox *mbox) { - return 0; + struct omap_mbox1_priv *priv = (struct omap_mbox1_priv *)mbox->priv; + + return priv->empty_flag ? 0 : 1; } static int omap1_mbox_fifo_full(struct omap_mbox *mbox) @@ -85,6 +90,18 @@ static int omap1_mbox_fifo_full(struct omap_mbox *mbox) return mbox_read_reg(fifo->flag); } +static int omap1_mbox_poll_for_space(struct omap_mbox *mbox) +{ + int i = 1000; + + while (omap1_mbox_fifo_full(mbox)) { + if (--i == 0) + return -1; + udelay(1); + } + return 0; +} + /* irq */ static void omap1_mbox_enable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) @@ -103,17 +120,21 @@ omap1_mbox_disable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) static int omap1_mbox_is_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) { + struct omap_mbox1_priv *priv = (struct omap_mbox1_priv *)mbox->priv; + if (irq == IRQ_TX) return 0; + if (irq == IRQ_RX) + priv->empty_flag = true; + return 1; } static struct omap_mbox_ops omap1_mbox_ops = { - .type = OMAP_MBOX_TYPE1, .fifo_read = omap1_mbox_fifo_read, .fifo_write = omap1_mbox_fifo_write, .fifo_empty = omap1_mbox_fifo_empty, - .fifo_full = omap1_mbox_fifo_full, + .poll_for_space = omap1_mbox_poll_for_space, .enable_irq = omap1_mbox_enable_irq, .disable_irq = omap1_mbox_disable_irq, .is_irq = omap1_mbox_is_irq, diff --git a/drivers/mailbox/mailbox-omap2.c b/drivers/mailbox/mailbox-omap2.c index 759f72c..fef18f4 100644 --- a/drivers/mailbox/mailbox-omap2.c +++ b/drivers/mailbox/mailbox-omap2.c @@ -124,6 +124,14 @@ static int omap2_mbox_fifo_full(struct omap_mbox *mbox) return mbox_read_reg(mbox->parent, fifo->fifo_stat); } +static int omap2_mbox_poll_for_space(struct omap_mbox *mbox) +{ + if (omap2_mbox_fifo_full(mbox)) + return -1; + + return 0; +} + /* Mailbox IRQ handle functions */ static void omap2_mbox_enable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) { @@ -208,13 +216,12 @@ static void omap2_mbox_restore_ctx(struct omap_mbox *mbox) } static struct omap_mbox_ops omap2_mbox_ops = { - .type = OMAP_MBOX_TYPE2, .startup = omap2_mbox_startup, .shutdown = omap2_mbox_shutdown, .fifo_read = omap2_mbox_fifo_read, .fifo_write = omap2_mbox_fifo_write, .fifo_empty = omap2_mbox_fifo_empty, - .fifo_full = omap2_mbox_fifo_full, + .poll_for_space = omap2_mbox_poll_for_space, .enable_irq = omap2_mbox_enable_irq, .disable_irq = omap2_mbox_disable_irq, .ack_irq = omap2_mbox_ack_irq, diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c index 25a2da7..8329c8a 100644 --- a/drivers/mailbox/omap-mailbox.c +++ b/drivers/mailbox/omap-mailbox.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -52,9 +51,9 @@ static inline int mbox_fifo_empty(struct omap_mbox *mbox) { return mbox->ops->fifo_empty(mbox); } -static inline int mbox_fifo_full(struct omap_mbox *mbox) +static inline int mbox_poll_for_space(struct omap_mbox *mbox) { - return mbox->ops->fifo_full(mbox); + return mbox->ops->poll_for_space(mbox); } /* Mailbox IRQ handle functions */ @@ -71,20 +70,6 @@ static inline int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) /* * message sender */ -static int __mbox_poll_for_space(struct omap_mbox *mbox) -{ - 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); - } - return ret; -} - int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg) { struct omap_mbox_queue *mq = mbox->txq; @@ -97,7 +82,7 @@ int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg) goto out; } - if (kfifo_is_empty(&mq->fifo) && !__mbox_poll_for_space(mbox)) { + if (kfifo_is_empty(&mq->fifo) && !mbox_poll_for_space(mbox)) { mbox_fifo_write(mbox, msg); goto out; } @@ -155,7 +140,7 @@ static void mbox_tx_tasklet(unsigned long tx_data) int ret; while (kfifo_len(&mq->fifo)) { - if (__mbox_poll_for_space(mbox)) { + if (mbox_poll_for_space(mbox)) { omap_mbox_enable_irq(mbox, IRQ_TX); break; } @@ -220,9 +205,6 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox) len = kfifo_in(&mq->fifo, (unsigned char *)&msg, sizeof(msg)); WARN_ON(len != sizeof(msg)); - - if (mbox->ops->type == OMAP_MBOX_TYPE1) - break; } /* no more messages in the fifo. clear IRQ source. */ diff --git a/drivers/mailbox/omap-mbox.h b/drivers/mailbox/omap-mbox.h index 6df528a..2d3cdb4 100644 --- a/drivers/mailbox/omap-mbox.h +++ b/drivers/mailbox/omap-mbox.h @@ -16,19 +16,14 @@ #include #include -typedef int __bitwise omap_mbox_type_t; -#define OMAP_MBOX_TYPE1 ((__force omap_mbox_type_t) 1) -#define OMAP_MBOX_TYPE2 ((__force omap_mbox_type_t) 2) - struct omap_mbox_ops { - omap_mbox_type_t type; int (*startup)(struct omap_mbox *mbox); void (*shutdown)(struct omap_mbox *mbox); /* fifo */ mbox_msg_t (*fifo_read)(struct omap_mbox *mbox); void (*fifo_write)(struct omap_mbox *mbox, mbox_msg_t msg); int (*fifo_empty)(struct omap_mbox *mbox); - int (*fifo_full)(struct omap_mbox *mbox); + int (*poll_for_space)(struct omap_mbox *mbox); /* irq */ void (*enable_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);