diff options
-rw-r--r-- | drivers/hwmon/tmp102.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c index d7b47abf37fe..6748b4583e7b 100644 --- a/drivers/hwmon/tmp102.c +++ b/drivers/hwmon/tmp102.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #include <linux/mutex.h> | 27 | #include <linux/mutex.h> |
28 | #include <linux/device.h> | 28 | #include <linux/device.h> |
29 | #include <linux/jiffies.h> | 29 | #include <linux/jiffies.h> |
30 | #include <linux/thermal.h> | ||
31 | #include <linux/of.h> | ||
30 | 32 | ||
31 | #define DRIVER_NAME "tmp102" | 33 | #define DRIVER_NAME "tmp102" |
32 | 34 | ||
@@ -50,6 +52,7 @@ | |||
50 | 52 | ||
51 | struct tmp102 { | 53 | struct tmp102 { |
52 | struct device *hwmon_dev; | 54 | struct device *hwmon_dev; |
55 | struct thermal_zone_device *tz; | ||
53 | struct mutex lock; | 56 | struct mutex lock; |
54 | u16 config_orig; | 57 | u16 config_orig; |
55 | unsigned long last_update; | 58 | unsigned long last_update; |
@@ -93,6 +96,15 @@ static struct tmp102 *tmp102_update_device(struct i2c_client *client) | |||
93 | return tmp102; | 96 | return tmp102; |
94 | } | 97 | } |
95 | 98 | ||
99 | static int tmp102_read_temp(void *dev, long *temp) | ||
100 | { | ||
101 | struct tmp102 *tmp102 = tmp102_update_device(to_i2c_client(dev)); | ||
102 | |||
103 | *temp = tmp102->temp[0]; | ||
104 | |||
105 | return 0; | ||
106 | } | ||
107 | |||
96 | static ssize_t tmp102_show_temp(struct device *dev, | 108 | static ssize_t tmp102_show_temp(struct device *dev, |
97 | struct device_attribute *attr, | 109 | struct device_attribute *attr, |
98 | char *buf) | 110 | char *buf) |
@@ -204,6 +216,12 @@ static int tmp102_probe(struct i2c_client *client, | |||
204 | goto fail_remove_sysfs; | 216 | goto fail_remove_sysfs; |
205 | } | 217 | } |
206 | 218 | ||
219 | tmp102->tz = thermal_zone_of_sensor_register(&client->dev, 0, | ||
220 | &client->dev, | ||
221 | tmp102_read_temp, NULL); | ||
222 | if (IS_ERR(tmp102->tz)) | ||
223 | tmp102->tz = NULL; | ||
224 | |||
207 | dev_info(&client->dev, "initialized\n"); | 225 | dev_info(&client->dev, "initialized\n"); |
208 | 226 | ||
209 | return 0; | 227 | return 0; |
@@ -220,6 +238,7 @@ static int tmp102_remove(struct i2c_client *client) | |||
220 | { | 238 | { |
221 | struct tmp102 *tmp102 = i2c_get_clientdata(client); | 239 | struct tmp102 *tmp102 = i2c_get_clientdata(client); |
222 | 240 | ||
241 | thermal_zone_of_sensor_unregister(&client->dev, tmp102->tz); | ||
223 | hwmon_device_unregister(tmp102->hwmon_dev); | 242 | hwmon_device_unregister(tmp102->hwmon_dev); |
224 | sysfs_remove_group(&client->dev.kobj, &tmp102_attr_group); | 243 | sysfs_remove_group(&client->dev.kobj, &tmp102_attr_group); |
225 | 244 | ||