drivers: sensor: th02: Handle unsupported channels

Fixed th02_channel_get() code to return -ENOTSUP when the channel is not
supported.
Fixes #55160.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit is contained in:
Benjamin Cabé 2023-02-24 12:44:59 +01:00 committed by Maureen Helm
commit ca90bdacf3

View file

@ -110,10 +110,12 @@ static int th02_channel_get(const struct device *dev,
/* val = sample / 32 - 50 */
val->val1 = drv_data->t_sample / 32U - 50;
val->val2 = (drv_data->t_sample % 32) * (1000000 / 32);
} else {
} else if (chan == SENSOR_CHAN_HUMIDITY) {
/* val = sample / 16 -24 */
val->val1 = drv_data->rh_sample / 16U - 24;
val->val2 = (drv_data->rh_sample % 16) * (1000000 / 16);
} else {
return -ENOTSUP;
}
return 0;