[PATCH lora-next 01/11] net: lora: sx125x: Abort on wrong version
From: Andreas FÃrber
Date: Sun Jan 06 2019 - 03:39:28 EST
This helps detect issues such as the concentrator being in reset.
Enhance error output while at it.
Signed-off-by: Andreas FÃrber <afaerber@xxxxxxx>
---
drivers/net/lora/sx125x.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/lora/sx125x.c b/drivers/net/lora/sx125x.c
index 90e7cdb9d1a8..0228d1f887a0 100644
--- a/drivers/net/lora/sx125x.c
+++ b/drivers/net/lora/sx125x.c
@@ -195,9 +195,13 @@ static int __maybe_unused sx125x_regmap_probe(struct device *dev, struct regmap
if (true) {
ret = regmap_read(priv->regmap, SX1255_VERSION, &val);
if (ret) {
- dev_err(dev, "version read failed\n");
+ dev_err(dev, "version read failed (%d)\n", ret);
return ret;
}
+ if (val != 0x21) {
+ dev_err(dev, "unexpected version: %u\n", val);
+ return -EINVAL;
+ }
dev_info(dev, "SX125x version: %02x\n", val);
}
--
2.16.4