diff options
author | Slawomir Stepien <slawomir.stepien@nokia.com> | 2022-06-07 08:35:04 +0200 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2022-07-13 17:38:20 +0200 |
commit | 00dc6452bee557c7d34a6064472817f6f6b3f185 (patch) | |
tree | 94c224a1a18c80a6060f8551bc042dbbead572b4 /drivers/hwmon/lm90.c | |
parent | hwmon: (lm90) Add support for 2nd remote channel's offset register (diff) | |
download | linux-00dc6452bee557c7d34a6064472817f6f6b3f185.tar.xz linux-00dc6452bee557c7d34a6064472817f6f6b3f185.zip |
hwmon: (lm90) Read the channel's temperature offset from device-tree
Try to read the channel's temperature offset from device-tree. Having
offset in device-tree node is not mandatory. The offset can only be set
for remote channels.
Signed-off-by: Slawomir Stepien <slawomir.stepien@nokia.com>
Link: https://lore.kernel.org/r/20220607063504.1287855-3-sst@poczta.fm
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/lm90.c')
-rw-r--r-- | drivers/hwmon/lm90.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index ec885cb3ab92..9d878163a1f2 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -2666,6 +2666,7 @@ static int lm90_probe_channel_from_dt(struct i2c_client *client, struct lm90_data *data) { u32 id; + s32 val; int err; struct device *dev = &client->dev; @@ -2689,6 +2690,21 @@ static int lm90_probe_channel_from_dt(struct i2c_client *client, if (data->channel_label[id]) data->channel_config[id] |= HWMON_T_LABEL; + err = of_property_read_s32(child, "temperature-offset-millicelsius", &val); + if (!err) { + if (id == 0) { + dev_err(dev, "temperature-offset-millicelsius can't be set for internal channel\n"); + return -EINVAL; + } + + err = lm90_set_temp_offset(data, lm90_temp_offset_index[id], id, val); + if (err) { + dev_err(dev, "can't set temperature offset %d for channel %d (%d)\n", + val, id, err); + return err; + } + } + return 0; } |