drivers: fix double promotion warnings
With -Wdouble-promotion added to the warning base, fix warnings given by the compiler. Signed-off-by: Ryan McClelland <ryanmcclelland@fb.com>
This commit is contained in:
parent
a6f932a194
commit
b7bedb5c1e
9 changed files with 45 additions and 45 deletions
|
@ -390,27 +390,27 @@ static int ptp_clock_e1000_rate_adjust(const struct device *dev, float ratio)
|
|||
float val;
|
||||
|
||||
/* No change needed. */
|
||||
if (ratio == 1.0) {
|
||||
if (ratio == 1.0f) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ratio *= context->clk_ratio;
|
||||
|
||||
/* Limit possible ratio. */
|
||||
if ((ratio > 1.0 + 1.0/(2 * hw_inc)) ||
|
||||
(ratio < 1.0 - 1.0/(2 * hw_inc))) {
|
||||
if ((ratio > 1.0f + 1.0f/(2 * hw_inc)) ||
|
||||
(ratio < 1.0f - 1.0f/(2 * hw_inc))) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Save new ratio. */
|
||||
context->clk_ratio = ratio;
|
||||
|
||||
if (ratio < 1.0) {
|
||||
if (ratio < 1.0f) {
|
||||
corr = hw_inc - 1;
|
||||
val = 1.0 / (hw_inc * (1.0 - ratio));
|
||||
} else if (ratio > 1.0) {
|
||||
val = 1.0f / (hw_inc * (1.0f - ratio));
|
||||
} else if (ratio > 1.0f) {
|
||||
corr = hw_inc + 1;
|
||||
val = 1.0 / (hw_inc * (ratio-1.0));
|
||||
val = 1.0f / (hw_inc * (ratio - 1.0f));
|
||||
} else {
|
||||
val = 0;
|
||||
corr = hw_inc;
|
||||
|
|
|
@ -1483,27 +1483,27 @@ static int ptp_clock_mcux_rate_adjust(const struct device *dev, float ratio)
|
|||
float val;
|
||||
|
||||
/* No change needed. */
|
||||
if (ratio == 1.0) {
|
||||
if (ratio == 1.0f) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ratio *= context->clk_ratio;
|
||||
|
||||
/* Limit possible ratio. */
|
||||
if ((ratio > 1.0 + 1.0/(2 * hw_inc)) ||
|
||||
(ratio < 1.0 - 1.0/(2 * hw_inc))) {
|
||||
if ((ratio > 1.0f + 1.0f/(2 * hw_inc)) ||
|
||||
(ratio < 1.0f - 1.0f/(2 * hw_inc))) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Save new ratio. */
|
||||
context->clk_ratio = ratio;
|
||||
|
||||
if (ratio < 1.0) {
|
||||
if (ratio < 1.0f) {
|
||||
corr = hw_inc - 1;
|
||||
val = 1.0 / (hw_inc * (1.0 - ratio));
|
||||
} else if (ratio > 1.0) {
|
||||
val = 1.0f / (hw_inc * (1.0f - ratio));
|
||||
} else if (ratio > 1.0f) {
|
||||
corr = hw_inc + 1;
|
||||
val = 1.0 / (hw_inc * (ratio-1.0));
|
||||
val = 1.0f / (hw_inc * (ratio - 1.0f));
|
||||
} else {
|
||||
val = 0;
|
||||
corr = hw_inc;
|
||||
|
|
|
@ -87,29 +87,29 @@ static uint8_t acc_odr_to_reg(const struct sensor_value *val)
|
|||
double odr = sensor_value_to_double((struct sensor_value *) val);
|
||||
uint8_t reg = 0;
|
||||
|
||||
if ((odr >= 0.78125f) && (odr < 1.5625f)) {
|
||||
if ((odr >= 0.78125) && (odr < 1.5625)) {
|
||||
reg = BMI270_ACC_ODR_25D32_HZ;
|
||||
} else if ((odr >= 1.5625f) && (odr < 3.125f)) {
|
||||
} else if ((odr >= 1.5625) && (odr < 3.125)) {
|
||||
reg = BMI270_ACC_ODR_25D16_HZ;
|
||||
} else if ((odr >= 3.125f) && (odr < 6.25f)) {
|
||||
} else if ((odr >= 3.125) && (odr < 6.25)) {
|
||||
reg = BMI270_ACC_ODR_25D8_HZ;
|
||||
} else if ((odr >= 6.25f) && (odr < 12.5f)) {
|
||||
} else if ((odr >= 6.25) && (odr < 12.5)) {
|
||||
reg = BMI270_ACC_ODR_25D4_HZ;
|
||||
} else if ((odr >= 12.5f) && (odr < 25.0f)) {
|
||||
} else if ((odr >= 12.5) && (odr < 25.0)) {
|
||||
reg = BMI270_ACC_ODR_25D2_HZ;
|
||||
} else if ((odr >= 25.0f) && (odr < 50.0f)) {
|
||||
} else if ((odr >= 25.0) && (odr < 50.0)) {
|
||||
reg = BMI270_ACC_ODR_25_HZ;
|
||||
} else if ((odr >= 50.0f) && (odr < 100.0f)) {
|
||||
} else if ((odr >= 50.0) && (odr < 100.0)) {
|
||||
reg = BMI270_ACC_ODR_50_HZ;
|
||||
} else if ((odr >= 100.0f) && (odr < 200.0f)) {
|
||||
} else if ((odr >= 100.0) && (odr < 200.0)) {
|
||||
reg = BMI270_ACC_ODR_100_HZ;
|
||||
} else if ((odr >= 200.0f) && (odr < 400.0f)) {
|
||||
} else if ((odr >= 200.0) && (odr < 400.0)) {
|
||||
reg = BMI270_ACC_ODR_200_HZ;
|
||||
} else if ((odr >= 400.0f) && (odr < 800.0f)) {
|
||||
} else if ((odr >= 400.0) && (odr < 800.0)) {
|
||||
reg = BMI270_ACC_ODR_400_HZ;
|
||||
} else if ((odr >= 800.0f) && (odr < 1600.0f)) {
|
||||
} else if ((odr >= 800.0) && (odr < 1600.0)) {
|
||||
reg = BMI270_ACC_ODR_800_HZ;
|
||||
} else if (odr >= 1600.0f) {
|
||||
} else if (odr >= 1600.0) {
|
||||
reg = BMI270_ACC_ODR_1600_HZ;
|
||||
}
|
||||
return reg;
|
||||
|
@ -280,21 +280,21 @@ static uint8_t gyr_odr_to_reg(const struct sensor_value *val)
|
|||
double odr = sensor_value_to_double((struct sensor_value *) val);
|
||||
uint8_t reg = 0;
|
||||
|
||||
if ((odr >= 25.0f) && (odr < 50.0f)) {
|
||||
if ((odr >= 25.0) && (odr < 50.0)) {
|
||||
reg = BMI270_GYR_ODR_25_HZ;
|
||||
} else if ((odr >= 50.0f) && (odr < 100.0f)) {
|
||||
} else if ((odr >= 50.0) && (odr < 100.0)) {
|
||||
reg = BMI270_GYR_ODR_50_HZ;
|
||||
} else if ((odr >= 100.0f) && (odr < 200.0f)) {
|
||||
} else if ((odr >= 100.0) && (odr < 200.0)) {
|
||||
reg = BMI270_GYR_ODR_100_HZ;
|
||||
} else if ((odr >= 200.0f) && (odr < 400.0f)) {
|
||||
} else if ((odr >= 200.0) && (odr < 400.0)) {
|
||||
reg = BMI270_GYR_ODR_200_HZ;
|
||||
} else if ((odr >= 400.0f) && (odr < 800.0f)) {
|
||||
} else if ((odr >= 400.0) && (odr < 800.0)) {
|
||||
reg = BMI270_GYR_ODR_400_HZ;
|
||||
} else if ((odr >= 800.0f) && (odr < 1600.0f)) {
|
||||
} else if ((odr >= 800.0) && (odr < 1600.0)) {
|
||||
reg = BMI270_GYR_ODR_800_HZ;
|
||||
} else if ((odr >= 1600.0f) && (odr < 3200.0f)) {
|
||||
} else if ((odr >= 1600.0) && (odr < 3200.0)) {
|
||||
reg = BMI270_GYR_ODR_1600_HZ;
|
||||
} else if (odr >= 3200.0f) {
|
||||
} else if (odr >= 3200.0) {
|
||||
reg = BMI270_GYR_ODR_3200_HZ;
|
||||
}
|
||||
|
||||
|
|
|
@ -168,8 +168,8 @@ static int bq274xx_channel_get(const struct device *dev,
|
|||
break;
|
||||
|
||||
case SENSOR_CHAN_GAUGE_TEMP:
|
||||
int_temp = (bq274xx->internal_temperature * 0.1);
|
||||
int_temp = int_temp - 273.15;
|
||||
int_temp = (bq274xx->internal_temperature * 0.1f);
|
||||
int_temp = int_temp - 273.15f;
|
||||
val->val1 = (int32_t)int_temp;
|
||||
val->val2 = (int_temp - (int32_t)int_temp) * 1000000;
|
||||
break;
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
|
||||
/* Others */
|
||||
#define INA219_SIGN_BIT(x) ((x) >> 15) & 0x1
|
||||
#define INA219_V_BUS_MUL 0.004f
|
||||
#define INA219_SI_MUL 0.00001f
|
||||
#define INA219_V_BUS_MUL 0.004
|
||||
#define INA219_SI_MUL 0.00001
|
||||
#define INA219_POWER_MUL 20
|
||||
#define INA219_WAIT_STARTUP 40
|
||||
#define INA219_WAIT_MSR_RETRY 100
|
||||
|
|
|
@ -251,7 +251,7 @@ static inline void lsm6ds0_accel_convert(struct sensor_value *val, int raw_val,
|
|||
{
|
||||
double dval;
|
||||
|
||||
dval = (double)(raw_val) * scale / 32767.0;
|
||||
dval = (double)(raw_val) * (double)scale / 32767.0;
|
||||
val->val1 = (int32_t)dval;
|
||||
val->val2 = ((int32_t)(dval * 1000000)) % 1000000;
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ static inline void lsm6ds0_gyro_convert(struct sensor_value *val, int raw_val,
|
|||
{
|
||||
double dval;
|
||||
|
||||
dval = (double)(raw_val) * numerator / 1000.0 * SENSOR_DEG2RAD_DOUBLE;
|
||||
dval = (double)(raw_val) * (double)numerator / 1000.0 * SENSOR_DEG2RAD_DOUBLE;
|
||||
val->val1 = (int32_t)dval;
|
||||
val->val2 = ((int32_t)(dval * 1000000)) % 1000000;
|
||||
}
|
||||
|
|
|
@ -473,7 +473,7 @@ static inline void lsm6dsl_accel_convert(struct sensor_value *val, int raw_val,
|
|||
|
||||
/* Sensitivity is exposed in mg/LSB */
|
||||
/* Convert to m/s^2 */
|
||||
dval = (double)(raw_val) * sensitivity * SENSOR_G_DOUBLE / 1000;
|
||||
dval = (double)(raw_val) * (double)sensitivity * SENSOR_G_DOUBLE / 1000;
|
||||
val->val1 = (int32_t)dval;
|
||||
val->val2 = (((int32_t)(dval * 1000)) % 1000) * 1000;
|
||||
|
||||
|
@ -523,7 +523,7 @@ static inline void lsm6dsl_gyro_convert(struct sensor_value *val, int raw_val,
|
|||
|
||||
/* Sensitivity is exposed in mdps/LSB */
|
||||
/* Convert to rad/s */
|
||||
dval = (double)(raw_val * sensitivity * SENSOR_DEG2RAD_DOUBLE / 1000);
|
||||
dval = (double)(raw_val * (double)sensitivity * SENSOR_DEG2RAD_DOUBLE / 1000);
|
||||
val->val1 = (int32_t)dval;
|
||||
val->val2 = (((int32_t)(dval * 1000)) % 1000) * 1000;
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ static inline void lsm9ds0_gyro_convert(struct sensor_value *val, int raw_val,
|
|||
{
|
||||
double dval;
|
||||
|
||||
dval = (double)(raw_val) * numerator / 1000.0 * DEG2RAD;
|
||||
dval = (double)(raw_val) * (double)numerator / 1000.0 * DEG2RAD;
|
||||
val->val1 = (int32_t)dval;
|
||||
val->val2 = ((int32_t)(dval * 1000000)) % 1000000;
|
||||
}
|
||||
|
|
|
@ -398,7 +398,7 @@ static inline void lsm9ds0_mfd_convert_accel(struct sensor_value *val,
|
|||
{
|
||||
double dval;
|
||||
|
||||
dval = (double)(raw_val) * scale;
|
||||
dval = (double)(raw_val) * (double)scale;
|
||||
val->val1 = (int32_t)dval;
|
||||
val->val2 = ((int32_t)(dval * 1000000)) % 1000000;
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ static inline void lsm9ds0_mfd_convert_magn(struct sensor_value *val,
|
|||
{
|
||||
double dval;
|
||||
|
||||
dval = (double)(raw_val) * scale;
|
||||
dval = (double)(raw_val) * (double)scale;
|
||||
val->val1 = (int32_t)dval;
|
||||
val->val2 = ((int32_t)(dval * 1000000)) % 1000000;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue