1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/tmp00x: cleanup return codes

This also fixes a scan-build warning about a potential use of uninitialized parameter to the call of tmp0xx_read function
This commit is contained in:
Alexandre Abadie 2019-10-27 16:49:30 +01:00
parent e4f1b67612
commit c062d74b84
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
2 changed files with 21 additions and 5 deletions

View File

@ -257,6 +257,10 @@ void tmp00x_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj);
* @param[in] dev device descriptor of sensor
* @param[out] ta converted ambient temperature
* @param[out] to converted object temperature
*
* @return TMP00X_OK on success
* @return -TMP00X_ERROR if data read not ready
* @return -TMP00X_ERROR_BUS on I2C error
*/
int tmp00x_read_temperature(const tmp00x_t *dev, int16_t *ta, int16_t *to);

View File

@ -214,18 +214,30 @@ int tmp00x_read_temperature(const tmp00x_t *dev, int16_t *ta, int16_t *to)
xtimer_usleep(TMP00X_CONVERSION_TIME);
#endif
int ret;
#if TMP00X_USE_RAW_VALUES
tmp00x_read(dev, to, ta, &drdy);
if ((ret = tmp00x_read(dev, to, ta, &drdy)) < 0) {
return ret;
}
if (!drdy) {
return TMP00X_ERROR;
#if TMP00X_USE_LOW_POWER
tmp00x_set_standby(dev);
#endif
return -TMP00X_ERROR;
}
#else
tmp00x_read(dev, &rawvolt, &rawtemp, &drdy);
if ((ret = tmp00x_read(dev, &rawvolt, &rawtemp, &drdy)) < 0) {
return ret;
}
if (!drdy) {
return TMP00X_ERROR;
#if TMP00X_USE_LOW_POWER
tmp00x_set_standby(dev);
#endif
return -TMP00X_ERROR;
}
tmp00x_convert(rawvolt, rawtemp, &tamb, &tobj);
*ta = (int16_t)(tamb*100);
*to = (int16_t)(tobj*100);
@ -233,7 +245,7 @@ int tmp00x_read_temperature(const tmp00x_t *dev, int16_t *ta, int16_t *to)
#if TMP00X_USE_LOW_POWER
if (tmp00x_set_standby(dev)) {
return TMP00X_ERROR;
return -TMP00X_ERROR;
}
#endif