Commit 65d70e79cdb96b208c72a30b34525a850ee640cb
Merge tag 'hwmon-for-linus-v4.4-rc6' of git://git.kernel.org/pub/scm/linux/kerne…
…l/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
Showing 2 changed files Side-by-side Diff
drivers/hwmon/Kconfig
... | ... | @@ -1217,6 +1217,7 @@ |
1217 | 1217 | config SENSORS_SHT15 |
1218 | 1218 | tristate "Sensiron humidity and temperature sensors. SHT15 and compat." |
1219 | 1219 | depends on GPIOLIB || COMPILE_TEST |
1220 | + select BITREVERSE | |
1220 | 1221 | help |
1221 | 1222 | If you say yes here you get support for the Sensiron SHT10, SHT11, |
1222 | 1223 | SHT15, SHT71, SHT75 humidity and temperature sensors. |
drivers/hwmon/tmp102.c
... | ... | @@ -58,6 +58,7 @@ |
58 | 58 | u16 config_orig; |
59 | 59 | unsigned long last_update; |
60 | 60 | int temp[3]; |
61 | + bool first_time; | |
61 | 62 | }; |
62 | 63 | |
63 | 64 | /* convert left adjusted 13-bit TMP102 register value to milliCelsius */ |
... | ... | @@ -93,6 +94,7 @@ |
93 | 94 | tmp102->temp[i] = tmp102_reg_to_mC(status); |
94 | 95 | } |
95 | 96 | tmp102->last_update = jiffies; |
97 | + tmp102->first_time = false; | |
96 | 98 | } |
97 | 99 | mutex_unlock(&tmp102->lock); |
98 | 100 | return tmp102; |
... | ... | @@ -102,6 +104,12 @@ |
102 | 104 | { |
103 | 105 | struct tmp102 *tmp102 = tmp102_update_device(dev); |
104 | 106 | |
107 | + /* Is it too early even to return a conversion? */ | |
108 | + if (tmp102->first_time) { | |
109 | + dev_dbg(dev, "%s: Conversion not ready yet..\n", __func__); | |
110 | + return -EAGAIN; | |
111 | + } | |
112 | + | |
105 | 113 | *temp = tmp102->temp[0]; |
106 | 114 | |
107 | 115 | return 0; |
... | ... | @@ -114,6 +122,10 @@ |
114 | 122 | struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); |
115 | 123 | struct tmp102 *tmp102 = tmp102_update_device(dev); |
116 | 124 | |
125 | + /* Is it too early even to return a read? */ | |
126 | + if (tmp102->first_time) | |
127 | + return -EAGAIN; | |
128 | + | |
117 | 129 | return sprintf(buf, "%d\n", tmp102->temp[sda->index]); |
118 | 130 | } |
119 | 131 | |
... | ... | @@ -207,7 +219,9 @@ |
207 | 219 | status = -ENODEV; |
208 | 220 | goto fail_restore_config; |
209 | 221 | } |
210 | - tmp102->last_update = jiffies - HZ; | |
222 | + tmp102->last_update = jiffies; | |
223 | + /* Mark that we are not ready with data until conversion is complete */ | |
224 | + tmp102->first_time = true; | |
211 | 225 | mutex_init(&tmp102->lock); |
212 | 226 | |
213 | 227 | hwmon_dev = hwmon_device_register_with_groups(dev, client->name, |