diff mbox series

[6/8] hwmon: (lm90) enable the extended temperature range

Message ID 20220520093243.2523749-7-sst@poczta.fm (mailing list archive)
State Changes Requested
Headers show
Series Add support for ADT7481 in lm90 | expand

Commit Message

Slawomir Stepien May 20, 2022, 9:32 a.m. UTC
From: Slawomir Stepien <slawomir.stepien@nokia.com>

Enable the extended temperature range if it was requested from
device-tree node.

Signed-off-by: Slawomir Stepien <slawomir.stepien@nokia.com>
---
 drivers/hwmon/lm90.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index f642c6fd1641..67d48707a8d6 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -1914,6 +1914,7 @@  static const struct hwmon_ops lm90_ops = {
 static int lm90_probe(struct i2c_client *client)
 {
 	struct device *dev = &client->dev;
+	const struct device_node *np = dev->of_node;
 	struct i2c_adapter *adapter = client->adapter;
 	struct hwmon_channel_info *info;
 	struct regulator *regulator;
@@ -2017,6 +2018,17 @@  static int lm90_probe(struct i2c_client *client)
 	/* Set maximum conversion rate */
 	data->max_convrate = lm90_params[data->kind].max_convrate;
 
+	/* Parse device-tree information */
+	if (np) {
+		if (data->flags & LM90_HAVE_EXTENDED_TEMP) {
+			if (of_property_read_bool(np, "extended-range-enable")) {
+				err = lm90_update_confreg(data, data->config | 0x04);
+				if (err)
+					return err;
+			}
+		}
+	}
+
 	/* Initialize the LM90 chip */
 	err = lm90_init_client(client, data);
 	if (err < 0) {