[PATCH 3/5] iio: humidity: hts221: Allow unknown whoami for DT fallback

Adi Nata <[email protected]>
Newsgroups org.kernel.vger.linux-iio,dev.linux.lists.linux-kernel-mentees,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
The WHOAMI check currently returns -ENODEV when the chip ID is not
0xbc. That rejects Device Tree fallback compatibles.

Keep failing if the WHOAMI register cannot be read. On an unexpected
ID, log it and continue so OF fallback matching can work.

Use dev_err_probe() for the read-failure path.

Signed-off-by: Adi Nata <[email protected]>
---
 drivers/iio/humidity/hts221_core.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
index 76a391f421f5..da773d2edc80 100644
--- a/drivers/iio/humidity/hts221_core.c
+++ b/drivers/iio/humidity/hts221_core.c
@@ -139,16 +139,13 @@ static int hts221_check_whoami(struct hts221_hw *hw)
 	int err, data;
 
 	err = regmap_read(hw->regmap, HTS221_REG_WHOAMI_ADDR, &data);
-	if (err < 0) {
-		dev_err(hw->dev, "failed to read whoami register\n");
-		return err;
-	}
+	if (err < 0)
+		return dev_err_probe(hw->dev, err,
+				     "failed to read whoami register\n");
 
-	if (data != HTS221_REG_WHOAMI_VAL) {
-		dev_err(hw->dev, "wrong whoami {%02x vs %02x}\n",
-			data, HTS221_REG_WHOAMI_VAL);
-		return -ENODEV;
-	}
+	if (data != HTS221_REG_WHOAMI_VAL)
+		dev_info(hw->dev,
+			 "unexpected whoami 0x%02x, continuing\n", data);
 
 	return 0;
 }
-- 
2.47.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.