258 "supported. Choose one of 1, 2, 4 or 8!\n", val);
259 mutex_unlock(&data->update_lock);
260 return -EINVAL;
261 }
262
263 reg = (lm80_read_value(client, LM80_REG_FANDIV) & ~(3 << (2 * (nr + 1))))
264 | (data->fan_div[nr] << (2 * (nr + 1)));
265 lm80_write_value(client, LM80_REG_FANDIV, reg);
266
267
268 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
269 lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]);
270 mutex_unlock(&data->update_lock);
271
272 return count;
273}
274
275static ssize_t show_temp_input1(struct device *dev, struct device_attribute *attr, char *buf)
276{
277 struct lm80_data *data = lm80_update_device(dev);
278 return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp));
279}
280
281#define show_temp(suffix, value) \
282static ssize_t show_temp_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \
283{ \
284 struct lm80_data *data = lm80_update_device(dev); \
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); \