Commit 65d70e79 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'hwmon-for-linus-v4.4-rc6' of...

Merge tag 'hwmon-for-linus-v4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon fixes from Guenter Roeck:

 - Select CONFIG_BITREVERSE for sht15 driver to avoid build failure if
   it is not configured.

 - Force wait for conversion time for the first valid data in tmp102
   driver to avoid reporting erroneous data to the thermal subsystem.

* tag 'hwmon-for-linus-v4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  hwmon: (sht15) Select CONFIG_BITREVERSE
  hwmon: (tmp102) Force wait for conversion time for the first valid data
parents ccdd96be a3a316cf
...@@ -1217,6 +1217,7 @@ config SENSORS_PWM_FAN ...@@ -1217,6 +1217,7 @@ config SENSORS_PWM_FAN
config SENSORS_SHT15 config SENSORS_SHT15
tristate "Sensiron humidity and temperature sensors. SHT15 and compat." tristate "Sensiron humidity and temperature sensors. SHT15 and compat."
depends on GPIOLIB || COMPILE_TEST depends on GPIOLIB || COMPILE_TEST
select BITREVERSE
help help
If you say yes here you get support for the Sensiron SHT10, SHT11, If you say yes here you get support for the Sensiron SHT10, SHT11,
SHT15, SHT71, SHT75 humidity and temperature sensors. SHT15, SHT71, SHT75 humidity and temperature sensors.
......
...@@ -58,6 +58,7 @@ struct tmp102 { ...@@ -58,6 +58,7 @@ struct tmp102 {
u16 config_orig; u16 config_orig;
unsigned long last_update; unsigned long last_update;
int temp[3]; int temp[3];
bool first_time;
}; };
/* convert left adjusted 13-bit TMP102 register value to milliCelsius */ /* convert left adjusted 13-bit TMP102 register value to milliCelsius */
...@@ -93,6 +94,7 @@ static struct tmp102 *tmp102_update_device(struct device *dev) ...@@ -93,6 +94,7 @@ static struct tmp102 *tmp102_update_device(struct device *dev)
tmp102->temp[i] = tmp102_reg_to_mC(status); tmp102->temp[i] = tmp102_reg_to_mC(status);
} }
tmp102->last_update = jiffies; tmp102->last_update = jiffies;
tmp102->first_time = false;
} }
mutex_unlock(&tmp102->lock); mutex_unlock(&tmp102->lock);
return tmp102; return tmp102;
...@@ -102,6 +104,12 @@ static int tmp102_read_temp(void *dev, int *temp) ...@@ -102,6 +104,12 @@ static int tmp102_read_temp(void *dev, int *temp)
{ {
struct tmp102 *tmp102 = tmp102_update_device(dev); struct tmp102 *tmp102 = tmp102_update_device(dev);
/* Is it too early even to return a conversion? */
if (tmp102->first_time) {
dev_dbg(dev, "%s: Conversion not ready yet..\n", __func__);
return -EAGAIN;
}
*temp = tmp102->temp[0]; *temp = tmp102->temp[0];
return 0; return 0;
...@@ -114,6 +122,10 @@ static ssize_t tmp102_show_temp(struct device *dev, ...@@ -114,6 +122,10 @@ static ssize_t tmp102_show_temp(struct device *dev,
struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); struct sensor_device_attribute *sda = to_sensor_dev_attr(attr);
struct tmp102 *tmp102 = tmp102_update_device(dev); struct tmp102 *tmp102 = tmp102_update_device(dev);
/* Is it too early even to return a read? */
if (tmp102->first_time)
return -EAGAIN;
return sprintf(buf, "%d\n", tmp102->temp[sda->index]); return sprintf(buf, "%d\n", tmp102->temp[sda->index]);
} }
...@@ -207,7 +219,9 @@ static int tmp102_probe(struct i2c_client *client, ...@@ -207,7 +219,9 @@ static int tmp102_probe(struct i2c_client *client,
status = -ENODEV; status = -ENODEV;
goto fail_restore_config; goto fail_restore_config;
} }
tmp102->last_update = jiffies - HZ; tmp102->last_update = jiffies;
/* Mark that we are not ready with data until conversion is complete */
tmp102->first_time = true;
mutex_init(&tmp102->lock); mutex_init(&tmp102->lock);
hwmon_dev = hwmon_device_register_with_groups(dev, client->name, hwmon_dev = hwmon_device_register_with_groups(dev, client->name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment