netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, linux-can@vger.kernel.org,
	kernel@pengutronix.de, Thomas Gleixner <tglx@linutronix.de>,
	Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH 15/26] can: c_can: Cleanup setup of receive buffers
Date: Fri, 25 Apr 2014 00:00:18 +0200	[thread overview]
Message-ID: <1398376829-6771-16-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1398376829-6771-1-git-send-email-mkl@pengutronix.de>

From: Thomas Gleixner <tglx@linutronix.de>

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/c_can/c_can.c | 38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index d0daef8..e4eaa84 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -125,6 +125,10 @@
 /* For the high buffers we clear the interrupt bit and newdat */
 #define IF_COMM_RCV_HIGH	(IF_COMM_RCV_LOW | IF_COMM_CLR_NEWDAT)
 
+
+/* Receive setup of message objects */
+#define IF_COMM_RCV_SETUP	(IF_COMM_MASK | IF_COMM_ARB | IF_COMM_CONTROL)
+
 /* IFx arbitration */
 #define IF_ARB_MSGVAL		BIT(15)
 #define IF_ARB_MSGXTD		BIT(14)
@@ -142,6 +146,9 @@
 #define IF_MCONT_EOB		BIT(7)
 #define IF_MCONT_DLC_MASK	0xf
 
+#define IF_MCONT_RCV		(IF_MCONT_RXIE | IF_MCONT_UMASK)
+#define IF_MCONT_RCV_EOB	(IF_MCONT_RCV | IF_MCONT_EOB)
+
 /*
  * Use IF1 for RX and IF2 for TX
  */
@@ -424,30 +431,20 @@ static int c_can_read_msg_object(struct net_device *dev, int iface, u32 ctrl)
 }
 
 static void c_can_setup_receive_object(struct net_device *dev, int iface,
-					int objno, unsigned int mask,
-					unsigned int id, unsigned int mcont)
+				       u32 obj, u32 mask, u32 id, u32 mcont)
 {
 	struct c_can_priv *priv = netdev_priv(dev);
 
-	priv->write_reg(priv, C_CAN_IFACE(MASK1_REG, iface),
-			IFX_WRITE_LOW_16BIT(mask));
-
-	/* According to C_CAN documentation, the reserved bit
-	 * in IFx_MASK2 register is fixed 1
-	 */
-	priv->write_reg(priv, C_CAN_IFACE(MASK2_REG, iface),
-			IFX_WRITE_HIGH_16BIT(mask) | BIT(13));
+	mask |= BIT(29);
+	priv->write_reg(priv, C_CAN_IFACE(MASK1_REG, iface), mask);
+	priv->write_reg(priv, C_CAN_IFACE(MASK2_REG, iface), mask >> 16);
 
-	priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface),
-			IFX_WRITE_LOW_16BIT(id));
-	priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface),
-			(IF_ARB_MSGVAL | IFX_WRITE_HIGH_16BIT(id)));
+	id |= IF_ARB_MSGVAL << 16;
+	priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface), id);
+	priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface), id >> 16);
 
 	priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface), mcont);
-	c_can_object_put(dev, iface, objno, IF_COMM_ALL & ~IF_COMM_TXRQST);
-
-	netdev_dbg(dev, "obj no:%d, msgval:0x%08x\n", objno,
-			c_can_read_reg32(priv, C_CAN_MSGVAL1_REG));
+	c_can_object_put(dev, iface, obj, IF_COMM_RCV_SETUP);
 }
 
 static void c_can_inval_msg_object(struct net_device *dev, int iface, int objno)
@@ -581,11 +578,10 @@ static void c_can_configure_msg_objects(struct net_device *dev)
 
 	/* setup receive message objects */
 	for (i = C_CAN_MSG_OBJ_RX_FIRST; i < C_CAN_MSG_OBJ_RX_LAST; i++)
-		c_can_setup_receive_object(dev, IF_RX, i, 0, 0,
-					   IF_MCONT_RXIE | IF_MCONT_UMASK);
+		c_can_setup_receive_object(dev, IF_RX, i, 0, 0, IF_MCONT_RCV);
 
 	c_can_setup_receive_object(dev, IF_RX, C_CAN_MSG_OBJ_RX_LAST, 0, 0,
-			IF_MCONT_EOB | IF_MCONT_RXIE | IF_MCONT_UMASK);
+				   IF_MCONT_RCV_EOB);
 }
 
 /*
-- 
1.9.0.279.gdc9e3eb


  parent reply	other threads:[~2014-04-24 22:00 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-24 22:00 pull-request: can 2014-04-24 Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 01/26] can: c_can_pci: Set the type of the IP core Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 02/26] can: c_can: Fix startup logic Marc Kleine-Budde
2014-04-29  7:29   ` Yegor Yefremov
2014-05-02 12:37     ` Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 03/26] can: c_can: Make bus off interrupt disable logic work Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 04/26] can: c_can: Do not access skb after net_receive_skb() Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 05/26] can: c_can: Handle state change correctly Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 06/26] can: c_can: Fix berr reporting Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 07/26] can: c_can: Always update error stats Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 08/26] can: c_can: Simplify buffer reenabling Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 09/26] can: c_can: Avoid status register update for D_CAN Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 10/26] can: c_can: Get rid of pointless interrupts Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 11/26] can: c_can: Disable rx split as workaround Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 12/26] can: c_can: Work around C_CAN RX wreckage Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 13/26] can: c_can: Cleanup irq enable/disable Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 14/26] can: c_can: Cleanup c_can_read_msg_object() Marc Kleine-Budde
2014-04-24 22:00 ` Marc Kleine-Budde [this message]
2014-04-24 22:00 ` [PATCH 16/26] can: c_can: Cleanup c_can_inval_msg_object() Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 17/26] can: c_can: Cleanup c_can_msg_obj_put/get() Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 18/26] can: c_can: Cleanup c_can_write_msg_object() Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 19/26] can: c_can: Use proper u32 variables in c_can_write_msg_object() Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 20/26] can: c_can: Remove tx locking Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 21/26] can: c_can: Speed up tx buffer invalidation Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 22/26] can: c_can: use proper type for 'instance' Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 23/26] can: c_can_pci: enable PCI bus master only for MSI Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 24/26] can: sja1000_isa: add locking for indirect register access mode Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 25/26] can: fix return value from can_get_bittiming() Marc Kleine-Budde
2014-04-24 22:00 ` [PATCH 26/26] can: slcan: Fix spinlock variant Marc Kleine-Budde
2014-04-24 22:04 ` pull-request: can 2014-04-24 Marc Kleine-Budde
2014-04-26 16:31 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1398376829-6771-16-git-send-email-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=davem@davemloft.net \
    --cc=kernel@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).