All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/4] can: m_can: move Message RAM initialization to function
@ 2017-05-05 13:50 Quentin Schulz
  2017-05-05 13:50 ` [PATCH v4 2/4] can: m_can: make m_can_start and m_can_stop symmetric Quentin Schulz
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Quentin Schulz @ 2017-05-05 13:50 UTC (permalink / raw)
  To: wg, mkl, mario.huettel, socketcan
  Cc: Quentin Schulz, linux-can, netdev, linux-kernel,
	alexandre.belloni, thomas.petazzoni

To avoid possible ECC/parity checksum errors when reading an
uninitialized buffer, the entire Message RAM is initialized when probing
the driver. This initialization is done in the same function reading the
Device Tree properties.

This patch moves the RAM initialization to a separate function so it can
be called separately from device initialization from Device Tree.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

v4:
  - remove unused variables from m_can_of_parse_mram,

 drivers/net/can/m_can/m_can.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index bf8fdaeb955e..5da1bdb202a3 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1489,11 +1489,23 @@ static int register_m_can_dev(struct net_device *dev)
 	return register_candev(dev);
 }
 
+static void m_can_init_ram(struct m_can_priv *priv)
+{
+	int end, i, start;
+
+	/* initialize the entire Message RAM in use to avoid possible
+	 * ECC/parity checksum errors when reading an uninitialized buffer
+	 */
+	start = priv->mcfg[MRAM_SIDF].off;
+	end = priv->mcfg[MRAM_TXB].off +
+		priv->mcfg[MRAM_TXB].num * TXB_ELEMENT_SIZE;
+	for (i = start; i < end; i += 4)
+		writel(0x0, priv->mram_base + i);
+}
+
 static void m_can_of_parse_mram(struct m_can_priv *priv,
 				const u32 *mram_config_vals)
 {
-	int i, start, end;
-
 	priv->mcfg[MRAM_SIDF].off = mram_config_vals[0];
 	priv->mcfg[MRAM_SIDF].num = mram_config_vals[1];
 	priv->mcfg[MRAM_XIDF].off = priv->mcfg[MRAM_SIDF].off +
@@ -1529,15 +1541,7 @@ static void m_can_of_parse_mram(struct m_can_priv *priv,
 		priv->mcfg[MRAM_TXE].off, priv->mcfg[MRAM_TXE].num,
 		priv->mcfg[MRAM_TXB].off, priv->mcfg[MRAM_TXB].num);
 
-	/* initialize the entire Message RAM in use to avoid possible
-	 * ECC/parity checksum errors when reading an uninitialized buffer
-	 */
-	start = priv->mcfg[MRAM_SIDF].off;
-	end = priv->mcfg[MRAM_TXB].off +
-		priv->mcfg[MRAM_TXB].num * TXB_ELEMENT_SIZE;
-	for (i = start; i < end; i += 4)
-		writel(0x0, priv->mram_base + i);
-
+	m_can_init_ram(priv);
 }
 
 static int m_can_plat_probe(struct platform_device *pdev)
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-05-16 13:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-05 13:50 [PATCH v4 1/4] can: m_can: move Message RAM initialization to function Quentin Schulz
2017-05-05 13:50 ` [PATCH v4 2/4] can: m_can: make m_can_start and m_can_stop symmetric Quentin Schulz
2017-05-05 13:50 ` [PATCH v4 3/4] can: m_can: factorize clock gating and ungating Quentin Schulz
2017-05-05 13:50 ` [PATCH v4 4/4] can: m_can: add deep Suspend/Resume support Quentin Schulz
2017-05-12  6:37 ` [PATCH v4 1/4] can: m_can: move Message RAM initialization to function Quentin Schulz
2017-05-15 13:50   ` Marc Kleine-Budde
2017-05-16  3:51     ` Oliver Hartkopp
2017-05-16  8:00       ` Alexandre Belloni
2017-05-16 13:16         ` Oliver Hartkopp

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.