aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/emc1403.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/emc1403.c')
-rw-r--r--drivers/hwmon/emc1403.c27
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
109static ssize_t show_hyst(struct device *dev, 109static 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
131static 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
137static 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
130static ssize_t store_hyst(struct device *dev, 143static 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);
174static SENSOR_DEVICE_ATTR_2(temp1_crit_alarm, S_IRUGO, 187static SENSOR_DEVICE_ATTR_2(temp1_crit_alarm, S_IRUGO,
175 show_bit, NULL, 0x37, 0x01); 188 show_bit, NULL, 0x37, 0x01);
189static SENSOR_DEVICE_ATTR(temp1_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x06);
176static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO, show_hyst, NULL, 0x05); 190static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO, show_hyst, NULL, 0x05);
177static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO | S_IWUSR, 191static 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);
192static SENSOR_DEVICE_ATTR_2(temp2_crit_alarm, S_IRUGO, 206static SENSOR_DEVICE_ATTR_2(temp2_crit_alarm, S_IRUGO,
193 show_bit, NULL, 0x37, 0x02); 207 show_bit, NULL, 0x37, 0x02);
208static SENSOR_DEVICE_ATTR(temp2_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x08);
194static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IRUGO, show_hyst, NULL, 0x07); 209static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IRUGO, show_hyst, NULL, 0x07);
195static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_hyst, NULL, 0x19); 210static 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);
209static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO, 224static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO,
210 show_bit, NULL, 0x37, 0x04); 225 show_bit, NULL, 0x37, 0x04);
226static SENSOR_DEVICE_ATTR(temp3_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x16);
211static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO, show_hyst, NULL, 0x15); 227static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO, show_hyst, NULL, 0x15);
212static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO, show_hyst, NULL, 0x1A); 228static 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);
226static SENSOR_DEVICE_ATTR_2(temp4_crit_alarm, S_IRUGO, 242static SENSOR_DEVICE_ATTR_2(temp4_crit_alarm, S_IRUGO,
227 show_bit, NULL, 0x37, 0x08); 243 show_bit, NULL, 0x37, 0x08);
244static SENSOR_DEVICE_ATTR(temp4_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x2D);
228static SENSOR_DEVICE_ATTR(temp4_max_hyst, S_IRUGO, show_hyst, NULL, 0x2C); 245static SENSOR_DEVICE_ATTR(temp4_max_hyst, S_IRUGO, show_hyst, NULL, 0x2C);
229static SENSOR_DEVICE_ATTR(temp4_crit_hyst, S_IRUGO, show_hyst, NULL, 0x30); 246static 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