Skip to content
Permalink
Browse files

sensors: ti_hdc simplified ti_hdc_channel_get

Removed unneeded second temporary variable, used for humidity conversion

Signed-off-by: Nikos Oikonomou <nikoikonomou92@gmail.com>
  • Loading branch information...
nikooiko authored and MaureenHelm committed Jun 5, 2019
1 parent e7dbc1d commit 8617df1e64fb36323d541e1b3e7a3a2cee41b10a
Showing with 3 additions and 4 deletions.
  1. +3 −4 drivers/sensor/ti_hdc/ti_hdc.c
@@ -88,11 +88,10 @@ static int ti_hdc_channel_get(struct device *dev,
val->val2 = ((tmp & 0xFFFF) * 1000000U) >> 16;
} else if (chan == SENSOR_CHAN_HUMIDITY) {
/* val = 100 * sample / 2^16 */
u32_t tmp2;
tmp2 = (u32_t)drv_data->rh_sample * 100U;
val->val1 = tmp2 >> 16;
tmp = (u64_t)drv_data->rh_sample * 100U;
val->val1 = tmp >> 16;
/* x * 1000000 / 65536 == x * 15625 / 1024 */
val->val2 = ((tmp2 & 0xFFFF) * 15625U) >> 10;
val->val2 = ((tmp & 0xFFFF) * 15625U) >> 10;
} else {
return -ENOTSUP;
}

0 comments on commit 8617df1

Please sign in to comment.
You can’t perform that action at this time.