aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/tmp102.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2016-01-12 05:01:12 -0500
committerThomas Gleixner <tglx@linutronix.de>2016-01-12 05:01:12 -0500
commit1f16f116b01c110db20ab808562c8b8bc3ee3d6e (patch)
tree44db563f64cf5f8d62af8f99a61e2b248c44ea3a /drivers/hwmon/tmp102.c
parent03724ac3d48f8f0e3caf1d30fa134f8fd96c94e2 (diff)
parentf9eccf24615672896dc13251410c3f2f33a14f95 (diff)
Merge branches 'clockevents/4.4-fixes' and 'clockevents/4.5-fixes' of http://git.linaro.org/people/daniel.lezcano/linux into timers/urgent
Pull in fixes from Daniel Lezcano: - Fix the vt8500 timer leading to a system lock up when dealing with too small delta (Roman Volkov) - Select the CLKSRC_MMIO when the fsl_ftm_timer is enabled with COMPILE_TEST (Daniel Lezcano) - Prevent to compile timers using the 'iomem' API when the architecture has not HAS_IOMEM set (Richard Weinberger)
Diffstat (limited to 'drivers/hwmon/tmp102.c')
-rw-r--r--drivers/hwmon/tmp102.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
index 65482624ea2c..5289aa0980a8 100644
--- a/drivers/hwmon/tmp102.c
+++ b/drivers/hwmon/tmp102.c
@@ -58,6 +58,7 @@ struct tmp102 {
58 u16 config_orig; 58 u16 config_orig;
59 unsigned long last_update; 59 unsigned long last_update;
60 int temp[3]; 60 int temp[3];
61 bool first_time;
61}; 62};
62 63
63/* convert left adjusted 13-bit TMP102 register value to milliCelsius */ 64/* convert left adjusted 13-bit TMP102 register value to milliCelsius */
@@ -93,6 +94,7 @@ static struct tmp102 *tmp102_update_device(struct device *dev)
93 tmp102->temp[i] = tmp102_reg_to_mC(status); 94 tmp102->temp[i] = tmp102_reg_to_mC(status);
94 } 95 }
95 tmp102->last_update = jiffies; 96 tmp102->last_update = jiffies;
97 tmp102->first_time = false;
96 } 98 }
97 mutex_unlock(&tmp102->lock); 99 mutex_unlock(&tmp102->lock);
98 return tmp102; 100 return tmp102;
@@ -102,6 +104,12 @@ static int tmp102_read_temp(void *dev, int *temp)
102{ 104{
103 struct tmp102 *tmp102 = tmp102_update_device(dev); 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 *temp = tmp102->temp[0]; 113 *temp = tmp102->temp[0];
106 114
107 return 0; 115 return 0;
@@ -114,6 +122,10 @@ static ssize_t tmp102_show_temp(struct device *dev,
114 struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); 122 struct sensor_device_attribute *sda = to_sensor_dev_attr(attr);
115 struct tmp102 *tmp102 = tmp102_update_device(dev); 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 return sprintf(buf, "%d\n", tmp102->temp[sda->index]); 129 return sprintf(buf, "%d\n", tmp102->temp[sda->index]);
118} 130}
119 131
@@ -207,7 +219,9 @@ static int tmp102_probe(struct i2c_client *client,
207 status = -ENODEV; 219 status = -ENODEV;
208 goto fail_restore_config; 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 mutex_init(&tmp102->lock); 225 mutex_init(&tmp102->lock);
212 226
213 hwmon_dev = hwmon_device_register_with_groups(dev, client->name, 227 hwmon_dev = hwmon_device_register_with_groups(dev, client->name,