285 return sprintf(buf, "%d\n", TEMP_LIMIT_FROM_REG(data->value)); \
286}
287show_temp(hot_max, temp_hot_max);
288show_temp(hot_hyst, temp_hot_hyst);
289show_temp(os_max, temp_os_max);
290show_temp(os_hyst, temp_os_hyst);
291
292#define set_temp(suffix, value, reg) \
293static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \
294 size_t count) \
295{ \
296 struct i2c_client *client = to_i2c_client(dev); \
297 struct lm80_data *data = i2c_get_clientdata(client); \
298 long val = simple_strtoul(buf, NULL, 10); \
299 \
300 mutex_lock(&data->update_lock); \
301 data->value = TEMP_LIMIT_TO_REG(val); \
302 lm80_write_value(client, reg, data->value); \
303 mutex_unlock(&data->update_lock); \
304 return count; \
305}
306set_temp(hot_max, temp_hot_max, LM80_REG_TEMP_HOT_MAX);
307set_temp(hot_hyst, temp_hot_hyst, LM80_REG_TEMP_HOT_HYST);
308set_temp(os_max, temp_os_max, LM80_REG_TEMP_OS_MAX);
309set_temp(os_hyst, temp_os_hyst, LM80_REG_TEMP_OS_HYST);
310
311static ssize_t show_alarms(struct device *dev, struct device_attribute *attr,
312 char *buf)
313{
314 struct lm80_data *data = lm80_update_device(dev);
315 return sprintf(buf, "%u\n", data->alarms);
316}
317
318static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
319 char *buf)
320{
321 int bitnr = to_sensor_dev_attr(attr)->index;
322 struct lm80_data *data = lm80_update_device(dev);
323 return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1);
324}
325