lkml.org 
[lkml]   [2019]   [Jan]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH lora-next 04/11] net: lora: sx130x: Fix soft reset
Date
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
\
 
 \ /
  Last update: 2019-01-06 09:39    [W:0.073 / U:0.956 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site