diff options
author | Guenter Roeck <linux@roeck-us.net> | 2014-05-12 14:35:06 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2014-05-21 19:02:24 -0400 |
commit | 54392ce4446e31b4f8a98961ef30bf6397c15266 (patch) | |
tree | 7d682cf734f3604a4019f3db095cc431a210e4b7 /drivers/hwmon | |
parent | a9a74006867e23ad310c6a0dd5cb8fdec5ae3520 (diff) |
hwmon: (emc1403) Add support for min_hyst attributes
The hysteresis value applies to all limits, so add support for
tempX_min_hyst.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/emc1403.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c index 9ee057776f96..bc96eefe2894 100644 --- a/drivers/hwmon/emc1403.c +++ b/drivers/hwmon/emc1403.c | |||
@@ -106,8 +106,9 @@ static ssize_t store_bit(struct device *dev, | |||
106 | return count; | 106 | return count; |
107 | } | 107 | } |
108 | 108 | ||
109 | static ssize_t show_hyst(struct device *dev, | 109 | static ssize_t show_hyst_common(struct device *dev, |
110 | struct device_attribute *attr, char *buf) | 110 | struct device_attribute *attr, char *buf, |
111 | bool is_min) | ||
111 | { | 112 | { |
112 | struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); | 113 | struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); |
113 | struct thermal_data *data = dev_get_drvdata(dev); | 114 | struct thermal_data *data = dev_get_drvdata(dev); |
@@ -124,7 +125,19 @@ static ssize_t show_hyst(struct device *dev, | |||
124 | if (retval < 0) | 125 | if (retval < 0) |
125 | return retval; | 126 | return retval; |
126 | 127 | ||
127 | return sprintf(buf, "%d000\n", limit - hyst); | 128 | return sprintf(buf, "%d000\n", is_min ? limit + hyst : limit - hyst); |
129 | } | ||
130 | |||
131 | static ssize_t show_hyst(struct device *dev, | ||
132 | struct device_attribute *attr, char *buf) | ||
133 | { | ||
134 | return show_hyst_common(dev, attr, buf, false); | ||
135 | } | ||
136 | |||
137 | static ssize_t show_min_hyst(struct device *dev, | ||
138 | struct device_attribute *attr, char *buf) | ||
139 | { | ||
140 | return show_hyst_common(dev, attr, buf, true); | ||
128 | } | 141 | } |
129 | 142 | ||
130 | static ssize_t store_hyst(struct device *dev, | 143 | static ssize_t store_hyst(struct device *dev, |
@@ -173,6 +186,7 @@ static SENSOR_DEVICE_ATTR_2(temp1_max_alarm, S_IRUGO, | |||
173 | show_bit, NULL, 0x35, 0x01); | 186 | show_bit, NULL, 0x35, 0x01); |
174 | static SENSOR_DEVICE_ATTR_2(temp1_crit_alarm, S_IRUGO, | 187 | static SENSOR_DEVICE_ATTR_2(temp1_crit_alarm, S_IRUGO, |
175 | show_bit, NULL, 0x37, 0x01); | 188 | show_bit, NULL, 0x37, 0x01); |
189 | static SENSOR_DEVICE_ATTR(temp1_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x06); | ||
176 | static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO, show_hyst, NULL, 0x05); | 190 | static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO, show_hyst, NULL, 0x05); |
177 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO | S_IWUSR, | 191 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO | S_IWUSR, |
178 | show_hyst, store_hyst, 0x20); | 192 | show_hyst, store_hyst, 0x20); |
@@ -191,6 +205,7 @@ static SENSOR_DEVICE_ATTR_2(temp2_max_alarm, S_IRUGO, | |||
191 | show_bit, NULL, 0x35, 0x02); | 205 | show_bit, NULL, 0x35, 0x02); |
192 | static SENSOR_DEVICE_ATTR_2(temp2_crit_alarm, S_IRUGO, | 206 | static SENSOR_DEVICE_ATTR_2(temp2_crit_alarm, S_IRUGO, |
193 | show_bit, NULL, 0x37, 0x02); | 207 | show_bit, NULL, 0x37, 0x02); |
208 | static SENSOR_DEVICE_ATTR(temp2_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x08); | ||
194 | static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IRUGO, show_hyst, NULL, 0x07); | 209 | static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IRUGO, show_hyst, NULL, 0x07); |
195 | static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_hyst, NULL, 0x19); | 210 | static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_hyst, NULL, 0x19); |
196 | 211 | ||
@@ -208,6 +223,7 @@ static SENSOR_DEVICE_ATTR_2(temp3_max_alarm, S_IRUGO, | |||
208 | show_bit, NULL, 0x35, 0x04); | 223 | show_bit, NULL, 0x35, 0x04); |
209 | static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO, | 224 | static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO, |
210 | show_bit, NULL, 0x37, 0x04); | 225 | show_bit, NULL, 0x37, 0x04); |
226 | static SENSOR_DEVICE_ATTR(temp3_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x16); | ||
211 | static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO, show_hyst, NULL, 0x15); | 227 | static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO, show_hyst, NULL, 0x15); |
212 | static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO, show_hyst, NULL, 0x1A); | 228 | static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO, show_hyst, NULL, 0x1A); |
213 | 229 | ||
@@ -225,6 +241,7 @@ static SENSOR_DEVICE_ATTR_2(temp4_max_alarm, S_IRUGO, | |||
225 | show_bit, NULL, 0x35, 0x08); | 241 | show_bit, NULL, 0x35, 0x08); |
226 | static SENSOR_DEVICE_ATTR_2(temp4_crit_alarm, S_IRUGO, | 242 | static SENSOR_DEVICE_ATTR_2(temp4_crit_alarm, S_IRUGO, |
227 | show_bit, NULL, 0x37, 0x08); | 243 | show_bit, NULL, 0x37, 0x08); |
244 | static SENSOR_DEVICE_ATTR(temp4_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x2D); | ||
228 | static SENSOR_DEVICE_ATTR(temp4_max_hyst, S_IRUGO, show_hyst, NULL, 0x2C); | 245 | static SENSOR_DEVICE_ATTR(temp4_max_hyst, S_IRUGO, show_hyst, NULL, 0x2C); |
229 | static SENSOR_DEVICE_ATTR(temp4_crit_hyst, S_IRUGO, show_hyst, NULL, 0x30); | 246 | static SENSOR_DEVICE_ATTR(temp4_crit_hyst, S_IRUGO, show_hyst, NULL, 0x30); |
230 | 247 | ||
@@ -236,6 +253,7 @@ static struct attribute *emc1402_attrs[] = { | |||
236 | &sensor_dev_attr_temp1_max.dev_attr.attr, | 253 | &sensor_dev_attr_temp1_max.dev_attr.attr, |
237 | &sensor_dev_attr_temp1_crit.dev_attr.attr, | 254 | &sensor_dev_attr_temp1_crit.dev_attr.attr, |
238 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 255 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
256 | &sensor_dev_attr_temp1_min_hyst.dev_attr.attr, | ||
239 | &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, | 257 | &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, |
240 | &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, | 258 | &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, |
241 | 259 | ||
@@ -243,6 +261,7 @@ static struct attribute *emc1402_attrs[] = { | |||
243 | &sensor_dev_attr_temp2_max.dev_attr.attr, | 261 | &sensor_dev_attr_temp2_max.dev_attr.attr, |
244 | &sensor_dev_attr_temp2_crit.dev_attr.attr, | 262 | &sensor_dev_attr_temp2_crit.dev_attr.attr, |
245 | &sensor_dev_attr_temp2_input.dev_attr.attr, | 263 | &sensor_dev_attr_temp2_input.dev_attr.attr, |
264 | &sensor_dev_attr_temp2_min_hyst.dev_attr.attr, | ||
246 | &sensor_dev_attr_temp2_max_hyst.dev_attr.attr, | 265 | &sensor_dev_attr_temp2_max_hyst.dev_attr.attr, |
247 | &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr, | 266 | &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr, |
248 | 267 | ||
@@ -272,6 +291,7 @@ static struct attribute *emc1403_attrs[] = { | |||
272 | &sensor_dev_attr_temp3_min_alarm.dev_attr.attr, | 291 | &sensor_dev_attr_temp3_min_alarm.dev_attr.attr, |
273 | &sensor_dev_attr_temp3_max_alarm.dev_attr.attr, | 292 | &sensor_dev_attr_temp3_max_alarm.dev_attr.attr, |
274 | &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr, | 293 | &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr, |
294 | &sensor_dev_attr_temp3_min_hyst.dev_attr.attr, | ||
275 | &sensor_dev_attr_temp3_max_hyst.dev_attr.attr, | 295 | &sensor_dev_attr_temp3_max_hyst.dev_attr.attr, |
276 | &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr, | 296 | &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr, |
277 | NULL | 297 | NULL |
@@ -290,6 +310,7 @@ static struct attribute *emc1404_attrs[] = { | |||
290 | &sensor_dev_attr_temp4_min_alarm.dev_attr.attr, | 310 | &sensor_dev_attr_temp4_min_alarm.dev_attr.attr, |
291 | &sensor_dev_attr_temp4_max_alarm.dev_attr.attr, | 311 | &sensor_dev_attr_temp4_max_alarm.dev_attr.attr, |
292 | &sensor_dev_attr_temp4_crit_alarm.dev_attr.attr, | 312 | &sensor_dev_attr_temp4_crit_alarm.dev_attr.attr, |
313 | &sensor_dev_attr_temp4_min_hyst.dev_attr.attr, | ||
293 | &sensor_dev_attr_temp4_max_hyst.dev_attr.attr, | 314 | &sensor_dev_attr_temp4_max_hyst.dev_attr.attr, |
294 | &sensor_dev_attr_temp4_crit_hyst.dev_attr.attr, | 315 | &sensor_dev_attr_temp4_crit_hyst.dev_attr.attr, |
295 | NULL | 316 | NULL |