mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: linux-lpwan@lists.infradead.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Andreas Färber" <afaerber@suse.de>,
	"Ben Whitten" <ben.whitten@gmail.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH lora-next 04/11] net: lora: sx130x: Fix soft reset
Date: Sun,  6 Jan 2019 09:37:47 +0100	[thread overview]
Message-ID: <20190106083754.6004-5-afaerber@suse.de> (raw)
In-Reply-To: <20190106083754.6004-1-afaerber@suse.de>

The soft reset bit is volatile. As it lives in the frequently accessed
page register, refrain from marking the register as volatile and
instead bypass the cache for this one write.

Mark the cache as dirty afterwards. This does not appear to clear it,
so manually drop the whole cache. If we don't have a cache configured,
this may return -EINVAL, so guard it appropriately to aid in testing.

Cc: Ben Whitten <ben.whitten@gmail.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 drivers/net/lora/sx130x.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/lora/sx130x.c b/drivers/net/lora/sx130x.c
index 7a387d9a75a0..4ba02836a35d 100644
--- a/drivers/net/lora/sx130x.c
+++ b/drivers/net/lora/sx130x.c
@@ -182,7 +182,19 @@ static int sx130x_field_write(struct sx130x_priv *priv,
 
 static int sx130x_soft_reset(struct sx130x_priv *priv)
 {
-	return sx130x_field_write(priv, F_SOFT_RESET, 1);
+	int ret;
+
+	regcache_cache_bypass(priv->regmap, true);
+	ret = sx130x_field_write(priv, F_SOFT_RESET, 1);
+	regcache_cache_bypass(priv->regmap, false);
+	if (ret)
+		return ret;
+
+	regcache_mark_dirty(priv->regmap);
+	if (sx130x_regmap_config.cache_type != REGCACHE_NONE)
+		return regcache_drop_region(priv->regmap,
+			0, sx130x_regmap_config.max_register);
+	return 0;
 }
 
 static int sx130x_agc_ram_read(struct sx130x_priv *priv, u8 addr, unsigned int *val)
-- 
2.16.4


  parent reply	other threads:[~2019-01-06  8:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-06  8:37 [PATCH lora-next 00/11] net: lora: sx130x: Fixes for enabling regcache Andreas Färber
2019-01-06  8:37 ` [PATCH lora-next 01/11] net: lora: sx125x: Abort on wrong version Andreas Färber
2019-01-06  8:37 ` [PATCH lora-next 02/11] net: lora: sx130x: Fix error codes Andreas Färber
2019-01-06  8:37 ` [PATCH lora-next 03/11] net: lora: sx130x: Revert drop of sx1301_soft_reset() Andreas Färber
2019-01-06  8:37 ` Andreas Färber [this message]
2019-01-06  8:37 ` [PATCH lora-next 05/11] net: lora: sx130x: Fix regmap field toggles Andreas Färber
2019-01-06  8:37 ` [PATCH lora-next 06/11] net: lora: sx130x: Force regmap field write before sleep Andreas Färber
2019-01-06  8:37 ` [PATCH lora-next 07/11] net: lora: sx130x: Force regmap field writes before function boundaries Andreas Färber
2019-01-06  8:37 ` [PATCH lora-next 08/11] net: lora: sx130x: Force regmap field write before reading status Andreas Färber
2019-01-06  8:37 ` [PATCH lora-next 09/11] net: lora: sx130x: Mark AGCSTS register as volatile Andreas Färber
2019-01-06  8:37 ` [PATCH lora-next 10/11] net: lora: sx130x: Mark MCU_CTRL " Andreas Färber
2019-01-06  8:37 ` [PATCH lora-next 11/11] net: lora: sx130x: Enable regmap caching Andreas Färber

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=20190106083754.6004-5-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=ben.whitten@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-lpwan@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®