The previous patch introduced per channel subnodes in DT that let us
specify some channel specific properties. This built a ground for easily
disabling individual channels of the sensor that may not be connected to
any external diode and thus are not returning any meaningful data.
This patch adds support for parsing the "status" property of channels DT
subnodes and makes sure the -ENODATA is returned when disabled channels
value is read.
Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Link: https://lore.kernel.org/r/a85d623f0792b862870933a875bdf802f4c017f1.1634206677.git.krzysztof.adamski@nokia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
struct tmp421_channel {
const char *label;
+ bool enabled;
s16 temp;
};
if (ret)
return ret;
+ if (!tmp421->channel[channel].enabled)
+ return -ENODATA;
+
switch (attr) {
case hwmon_temp_input:
*val = temp_from_raw(tmp421->channel[channel].temp,
if (data->channel[i].label)
data->temp_config[i] |= HWMON_T_LABEL;
+ data->channel[i].enabled = of_device_is_available(child);
+
return 0;
}
if (err)
return err;
- for (i = 0; i < data->channels; i++)
+ for (i = 0; i < data->channels; i++) {
data->temp_config[i] = HWMON_T_INPUT | HWMON_T_FAULT;
+ data->channel[i].enabled = true;
+ }
err = tmp421_probe_from_dt(client, data);
if (err)