linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] can: c_can: use regmap_update_bits() to modify RAMINIT register
@ 2015-01-07 14:32 Roger Quadros
  2015-01-09 13:50 ` Tomi Valkeinen
  2015-01-13 14:23 ` [PATCH v2] " Roger Quadros
  0 siblings, 2 replies; 9+ messages in thread
From: Roger Quadros @ 2015-01-07 14:32 UTC (permalink / raw)
  To: mkl; +Cc: tomi.valkeinen, linux-can, wsa, kernel, linux-omap, Roger Quadros

use of regmap_read() and regmap_write() in c_can_hw_raminit_syscon()
is not safe as the RAMINIT register can be shared between different drivers
at least for TI SoCs.

To make the modification atomic we switch to using regmap_update_bits().

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/net/can/c_can/c_can_platform.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
index f363972..364209a 100644
--- a/drivers/net/can/c_can/c_can_platform.c
+++ b/drivers/net/can/c_can/c_can_platform.c
@@ -110,6 +110,10 @@ static void c_can_hw_raminit_syscon(const struct c_can_priv *priv, bool enable)
 	 */
 	ctrl &= ~(1 << raminit->bits.start);
 	ctrl |= 1 << raminit->bits.done;
+
+	/* we can't use regmap_update_bits here as it will bypass the write
+	 * if START is already 0 and DONE is already 1.
+	 */
 	regmap_write(raminit->syscon, raminit->reg, ctrl);
 
 	ctrl &= ~(1 << raminit->bits.done);
@@ -118,12 +122,13 @@ static void c_can_hw_raminit_syscon(const struct c_can_priv *priv, bool enable)
 	if (enable) {
 		/* Set start bit and wait for the done bit. */
 		ctrl |= 1 << raminit->bits.start;
-		regmap_write(raminit->syscon, raminit->reg, ctrl);
+		regmap_update_bits(raminit->syscon, raminit->reg, mask, ctrl);
 
 		/* clear START bit if start pulse is needed */
 		if (raminit->needs_pulse) {
 			ctrl &= ~(1 << raminit->bits.start);
-			regmap_write(raminit->syscon, raminit->reg, ctrl);
+			regmap_update_bits(raminit->syscon, raminit->reg,
+					   mask, ctrl);
 		}
 
 		ctrl |= 1 << raminit->bits.done;
-- 
2.1.0


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

end of thread, other threads:[~2015-01-15 14:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-07 14:32 [PATCH] can: c_can: use regmap_update_bits() to modify RAMINIT register Roger Quadros
2015-01-09 13:50 ` Tomi Valkeinen
2015-01-12  9:57   ` Roger Quadros
2015-01-12 10:02     ` Roger Quadros
2015-01-12 12:05       ` Mark Brown
2015-01-12 12:37         ` Roger Quadros
2015-01-12 12:43           ` Mark Brown
2015-01-13 14:23 ` [PATCH v2] " Roger Quadros
2015-01-15 14:37   ` Marc Kleine-Budde

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).