hwmon: (lm77) Add individual alarm files

The new libsensors needs this. As the old library never had support for
the lm77 driver, I even dropped the legacy "alarms" file.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Hans de Goede <j.w.r.degoede@hhs.nl>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>

authored by Jean Delvare and committed by Mark M. Hoffman 1f52af0f 7b501b1f

+15 -5
+15 -5
drivers/hwmon/lm77.c
··· 31 31 #include <linux/jiffies.h> 32 32 #include <linux/i2c.h> 33 33 #include <linux/hwmon.h> 34 + #include <linux/hwmon-sysfs.h> 34 35 #include <linux/err.h> 35 36 #include <linux/mutex.h> 36 37 ··· 114 113 show(temp_crit); 115 114 show(temp_min); 116 115 show(temp_max); 117 - show(alarms); 118 116 119 117 /* read routines for hysteresis values */ 120 118 static ssize_t show_temp_crit_hyst(struct device *dev, struct device_attribute *attr, char *buf) ··· 186 186 return count; 187 187 } 188 188 189 + static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, 190 + char *buf) 191 + { 192 + int bitnr = to_sensor_dev_attr(attr)->index; 193 + struct lm77_data *data = lm77_update_device(dev); 194 + return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); 195 + } 196 + 189 197 static DEVICE_ATTR(temp1_input, S_IRUGO, 190 198 show_temp_input, NULL); 191 199 static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, ··· 210 202 static DEVICE_ATTR(temp1_max_hyst, S_IRUGO, 211 203 show_temp_max_hyst, NULL); 212 204 213 - static DEVICE_ATTR(alarms, S_IRUGO, 214 - show_alarms, NULL); 205 + static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 2); 206 + static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 0); 207 + static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 1); 215 208 216 209 static int lm77_attach_adapter(struct i2c_adapter *adapter) 217 210 { ··· 229 220 &dev_attr_temp1_crit_hyst.attr, 230 221 &dev_attr_temp1_min_hyst.attr, 231 222 &dev_attr_temp1_max_hyst.attr, 232 - &dev_attr_alarms.attr, 233 - 223 + &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr, 224 + &sensor_dev_attr_temp1_min_alarm.dev_attr.attr, 225 + &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, 234 226 NULL 235 227 }; 236 228