static ssize_t sht15_show_temp(struct device *dev, struct device_attribute *attr, char *buf) { int ret; struct sht15_data *data = dev_get_drvdata(dev); /* Technically no need to read humidity as well */ ret = sht15_update_vals(data); return ret ? ret : sprintf(buf, "%d\n", sht15_calc_temp(data)); }
static ssize_t sht15_show_temp(struct device *dev, struct device_attribute *attr, char *buf) { int ret; struct sht15_data *data = dev_get_drvdata(dev); ret = sht15_update_vals(data); return ret ? ret : sprintf(buf, "%d\n", sht15_calc_temp(data)); }
/** * sht15_calc_humid() - using last temperature convert raw to humid * @data: device state * * This is the temperature compensated version as per section 4.2 of * the data sheet. **/ static inline int sht15_calc_humid(struct sht15_data *data) { int RHlinear; /* milli percent */ int temp = sht15_calc_temp(data); const int c1 = -4; const int c2 = 40500; /* x 10 ^ -6 */ const int c3 = -28; /* x 10 ^ -7 */ RHlinear = c1*1000 + c2 * data->val_humid/1000 + (data->val_humid * data->val_humid * c3) / 10000; return (temp - 25000) * (10000 + 80 * data->val_humid) / 1000000 + RHlinear; }
static inline int sht15_calc_humid(struct sht15_data *data) { int RHlinear; int temp = sht15_calc_temp(data); const int c1 = -4; const int c2 = 40500; const int c3 = -2800; RHlinear = c1*1000 + c2 * data->val_humid/1000 + (data->val_humid * data->val_humid * c3)/1000000; return (temp - 25000) * (10000 + 80 * data->val_humid) / 1000000 + RHlinear; }