1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * lm80.c - From lm_sensors, Linux kernel modules for hardware
5 * Copyright (C) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
6 * and Philip Edelbrock <phil@netroedge.com>
8 * Ported to Linux 2.6 by Tiago Sousa <mirage@kaotik.org>
11 #include <linux/module.h>
12 #include <linux/init.h>
13 #include <linux/slab.h>
14 #include <linux/jiffies.h>
15 #include <linux/i2c.h>
16 #include <linux/hwmon.h>
17 #include <linux/hwmon-sysfs.h>
18 #include <linux/err.h>
19 #include <linux/mutex.h>
21 /* Addresses to scan */
22 static const unsigned short normal_i2c
[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
23 0x2e, 0x2f, I2C_CLIENT_END
};
25 /* Many LM80 constants specified below */
27 /* The LM80 registers */
28 #define LM80_REG_IN_MAX(nr) (0x2a + (nr) * 2)
29 #define LM80_REG_IN_MIN(nr) (0x2b + (nr) * 2)
30 #define LM80_REG_IN(nr) (0x20 + (nr))
32 #define LM80_REG_FAN1 0x28
33 #define LM80_REG_FAN2 0x29
34 #define LM80_REG_FAN_MIN(nr) (0x3b + (nr))
36 #define LM80_REG_TEMP 0x27
37 #define LM80_REG_TEMP_HOT_MAX 0x38
38 #define LM80_REG_TEMP_HOT_HYST 0x39
39 #define LM80_REG_TEMP_OS_MAX 0x3a
40 #define LM80_REG_TEMP_OS_HYST 0x3b
42 #define LM80_REG_CONFIG 0x00
43 #define LM80_REG_ALARM1 0x01
44 #define LM80_REG_ALARM2 0x02
45 #define LM80_REG_MASK1 0x03
46 #define LM80_REG_MASK2 0x04
47 #define LM80_REG_FANDIV 0x05
48 #define LM80_REG_RES 0x06
50 #define LM96080_REG_CONV_RATE 0x07
51 #define LM96080_REG_MAN_ID 0x3e
52 #define LM96080_REG_DEV_ID 0x3f
56 * Conversions. Rounding and limit checking is only done on the TO_REG
57 * variants. Note that you should be a bit careful with which arguments
58 * these macros are called: arguments may be evaluated more than once.
59 * Fixing this is just not worth it.
62 #define IN_TO_REG(val) (clamp_val(((val) + 5) / 10, 0, 255))
63 #define IN_FROM_REG(val) ((val) * 10)
65 static inline unsigned char FAN_TO_REG(unsigned rpm
, unsigned div
)
69 rpm
= clamp_val(rpm
, 1, 1000000);
70 return clamp_val((1350000 + rpm
* div
/ 2) / (rpm
* div
), 1, 254);
73 #define FAN_FROM_REG(val, div) ((val) == 0 ? -1 : \
74 (val) == 255 ? 0 : 1350000/((div) * (val)))
76 #define TEMP_FROM_REG(reg) ((reg) * 125 / 32)
77 #define TEMP_TO_REG(temp) (DIV_ROUND_CLOSEST(clamp_val((temp), \
78 -128000, 127000), 1000) << 8)
80 #define DIV_FROM_REG(val) (1 << (val))
91 static const u8 temp_regs
[t_num_temp
] = {
92 [t_input
] = LM80_REG_TEMP
,
93 [t_hot_max
] = LM80_REG_TEMP_HOT_MAX
,
94 [t_hot_hyst
] = LM80_REG_TEMP_HOT_HYST
,
95 [t_os_max
] = LM80_REG_TEMP_OS_MAX
,
96 [t_os_hyst
] = LM80_REG_TEMP_OS_HYST
,
113 * Client data (each client gets its own)
117 struct i2c_client
*client
;
118 struct mutex update_lock
;
119 char error
; /* !=0 if error occurred during last update */
120 char valid
; /* !=0 if following fields are valid */
121 unsigned long last_updated
; /* In jiffies */
123 u8 in
[i_num_in
][7]; /* Register value, 1st index is enum in_index */
124 u8 fan
[f_num_fan
][2]; /* Register value, 1st index enum fan_index */
125 u8 fan_div
[2]; /* Register encoding, shifted right */
126 s16 temp
[t_num_temp
]; /* Register values, normalized to 16 bit */
127 u16 alarms
; /* Register encoding, combined */
130 static int lm80_read_value(struct i2c_client
*client
, u8 reg
)
132 return i2c_smbus_read_byte_data(client
, reg
);
135 static int lm80_write_value(struct i2c_client
*client
, u8 reg
, u8 value
)
137 return i2c_smbus_write_byte_data(client
, reg
, value
);
140 /* Called when we have found a new LM80 and after read errors */
141 static void lm80_init_client(struct i2c_client
*client
)
144 * Reset all except Watchdog values and last conversion values
145 * This sets fan-divs to 2, among others. This makes most other
146 * initializations unnecessary
148 lm80_write_value(client
, LM80_REG_CONFIG
, 0x80);
149 /* Set 11-bit temperature resolution */
150 lm80_write_value(client
, LM80_REG_RES
, 0x08);
152 /* Start monitoring */
153 lm80_write_value(client
, LM80_REG_CONFIG
, 0x01);
156 static struct lm80_data
*lm80_update_device(struct device
*dev
)
158 struct lm80_data
*data
= dev_get_drvdata(dev
);
159 struct i2c_client
*client
= data
->client
;
163 struct lm80_data
*ret
= data
;
165 mutex_lock(&data
->update_lock
);
168 lm80_init_client(client
);
170 if (time_after(jiffies
, data
->last_updated
+ 2 * HZ
) || !data
->valid
) {
171 dev_dbg(dev
, "Starting lm80 update\n");
172 for (i
= 0; i
<= 6; i
++) {
173 rv
= lm80_read_value(client
, LM80_REG_IN(i
));
176 data
->in
[i_input
][i
] = rv
;
178 rv
= lm80_read_value(client
, LM80_REG_IN_MIN(i
));
181 data
->in
[i_min
][i
] = rv
;
183 rv
= lm80_read_value(client
, LM80_REG_IN_MAX(i
));
186 data
->in
[i_max
][i
] = rv
;
189 rv
= lm80_read_value(client
, LM80_REG_FAN1
);
192 data
->fan
[f_input
][0] = rv
;
194 rv
= lm80_read_value(client
, LM80_REG_FAN_MIN(1));
197 data
->fan
[f_min
][0] = rv
;
199 rv
= lm80_read_value(client
, LM80_REG_FAN2
);
202 data
->fan
[f_input
][1] = rv
;
204 rv
= lm80_read_value(client
, LM80_REG_FAN_MIN(2));
207 data
->fan
[f_min
][1] = rv
;
209 prev_rv
= rv
= lm80_read_value(client
, LM80_REG_TEMP
);
212 rv
= lm80_read_value(client
, LM80_REG_RES
);
215 data
->temp
[t_input
] = (prev_rv
<< 8) | (rv
& 0xf0);
217 for (i
= t_input
+ 1; i
< t_num_temp
; i
++) {
218 rv
= lm80_read_value(client
, temp_regs
[i
]);
221 data
->temp
[i
] = rv
<< 8;
224 rv
= lm80_read_value(client
, LM80_REG_FANDIV
);
227 data
->fan_div
[0] = (rv
>> 2) & 0x03;
228 data
->fan_div
[1] = (rv
>> 4) & 0x03;
230 prev_rv
= rv
= lm80_read_value(client
, LM80_REG_ALARM1
);
233 rv
= lm80_read_value(client
, LM80_REG_ALARM2
);
236 data
->alarms
= prev_rv
+ (rv
<< 8);
238 data
->last_updated
= jiffies
;
250 mutex_unlock(&data
->update_lock
);
259 static ssize_t
in_show(struct device
*dev
, struct device_attribute
*attr
,
262 struct lm80_data
*data
= lm80_update_device(dev
);
263 int index
= to_sensor_dev_attr_2(attr
)->index
;
264 int nr
= to_sensor_dev_attr_2(attr
)->nr
;
267 return PTR_ERR(data
);
268 return sprintf(buf
, "%d\n", IN_FROM_REG(data
->in
[nr
][index
]));
271 static ssize_t
in_store(struct device
*dev
, struct device_attribute
*attr
,
272 const char *buf
, size_t count
)
274 struct lm80_data
*data
= dev_get_drvdata(dev
);
275 struct i2c_client
*client
= data
->client
;
276 int index
= to_sensor_dev_attr_2(attr
)->index
;
277 int nr
= to_sensor_dev_attr_2(attr
)->nr
;
280 int err
= kstrtol(buf
, 10, &val
);
284 reg
= nr
== i_min
? LM80_REG_IN_MIN(index
) : LM80_REG_IN_MAX(index
);
286 mutex_lock(&data
->update_lock
);
287 data
->in
[nr
][index
] = IN_TO_REG(val
);
288 lm80_write_value(client
, reg
, data
->in
[nr
][index
]);
289 mutex_unlock(&data
->update_lock
);
293 static ssize_t
fan_show(struct device
*dev
, struct device_attribute
*attr
,
296 int index
= to_sensor_dev_attr_2(attr
)->index
;
297 int nr
= to_sensor_dev_attr_2(attr
)->nr
;
298 struct lm80_data
*data
= lm80_update_device(dev
);
300 return PTR_ERR(data
);
301 return sprintf(buf
, "%d\n", FAN_FROM_REG(data
->fan
[nr
][index
],
302 DIV_FROM_REG(data
->fan_div
[index
])));
305 static ssize_t
fan_div_show(struct device
*dev
, struct device_attribute
*attr
,
308 int nr
= to_sensor_dev_attr(attr
)->index
;
309 struct lm80_data
*data
= lm80_update_device(dev
);
311 return PTR_ERR(data
);
312 return sprintf(buf
, "%d\n", DIV_FROM_REG(data
->fan_div
[nr
]));
315 static ssize_t
fan_store(struct device
*dev
, struct device_attribute
*attr
,
316 const char *buf
, size_t count
)
318 int index
= to_sensor_dev_attr_2(attr
)->index
;
319 int nr
= to_sensor_dev_attr_2(attr
)->nr
;
320 struct lm80_data
*data
= dev_get_drvdata(dev
);
321 struct i2c_client
*client
= data
->client
;
323 int err
= kstrtoul(buf
, 10, &val
);
327 mutex_lock(&data
->update_lock
);
328 data
->fan
[nr
][index
] = FAN_TO_REG(val
,
329 DIV_FROM_REG(data
->fan_div
[index
]));
330 lm80_write_value(client
, LM80_REG_FAN_MIN(index
+ 1),
331 data
->fan
[nr
][index
]);
332 mutex_unlock(&data
->update_lock
);
337 * Note: we save and restore the fan minimum here, because its value is
338 * determined in part by the fan divisor. This follows the principle of
339 * least surprise; the user doesn't expect the fan minimum to change just
340 * because the divisor changed.
342 static ssize_t
fan_div_store(struct device
*dev
,
343 struct device_attribute
*attr
, const char *buf
,
346 int nr
= to_sensor_dev_attr(attr
)->index
;
347 struct lm80_data
*data
= dev_get_drvdata(dev
);
348 struct i2c_client
*client
= data
->client
;
349 unsigned long min
, val
;
353 rv
= kstrtoul(buf
, 10, &val
);
358 mutex_lock(&data
->update_lock
);
359 min
= FAN_FROM_REG(data
->fan
[f_min
][nr
],
360 DIV_FROM_REG(data
->fan_div
[nr
]));
364 data
->fan_div
[nr
] = 0;
367 data
->fan_div
[nr
] = 1;
370 data
->fan_div
[nr
] = 2;
373 data
->fan_div
[nr
] = 3;
377 "fan_div value %ld not supported. Choose one of 1, 2, 4 or 8!\n",
379 mutex_unlock(&data
->update_lock
);
383 rv
= lm80_read_value(client
, LM80_REG_FANDIV
);
385 mutex_unlock(&data
->update_lock
);
388 reg
= (rv
& ~(3 << (2 * (nr
+ 1))))
389 | (data
->fan_div
[nr
] << (2 * (nr
+ 1)));
390 lm80_write_value(client
, LM80_REG_FANDIV
, reg
);
392 /* Restore fan_min */
393 data
->fan
[f_min
][nr
] = FAN_TO_REG(min
, DIV_FROM_REG(data
->fan_div
[nr
]));
394 lm80_write_value(client
, LM80_REG_FAN_MIN(nr
+ 1),
395 data
->fan
[f_min
][nr
]);
396 mutex_unlock(&data
->update_lock
);
401 static ssize_t
temp_show(struct device
*dev
, struct device_attribute
*devattr
,
404 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
405 struct lm80_data
*data
= lm80_update_device(dev
);
407 return PTR_ERR(data
);
408 return sprintf(buf
, "%d\n", TEMP_FROM_REG(data
->temp
[attr
->index
]));
411 static ssize_t
temp_store(struct device
*dev
,
412 struct device_attribute
*devattr
, const char *buf
,
415 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
416 struct lm80_data
*data
= dev_get_drvdata(dev
);
417 struct i2c_client
*client
= data
->client
;
418 int nr
= attr
->index
;
420 int err
= kstrtol(buf
, 10, &val
);
424 mutex_lock(&data
->update_lock
);
425 data
->temp
[nr
] = TEMP_TO_REG(val
);
426 lm80_write_value(client
, temp_regs
[nr
], data
->temp
[nr
] >> 8);
427 mutex_unlock(&data
->update_lock
);
431 static ssize_t
alarms_show(struct device
*dev
, struct device_attribute
*attr
,
434 struct lm80_data
*data
= lm80_update_device(dev
);
436 return PTR_ERR(data
);
437 return sprintf(buf
, "%u\n", data
->alarms
);
440 static ssize_t
alarm_show(struct device
*dev
, struct device_attribute
*attr
,
443 int bitnr
= to_sensor_dev_attr(attr
)->index
;
444 struct lm80_data
*data
= lm80_update_device(dev
);
446 return PTR_ERR(data
);
447 return sprintf(buf
, "%u\n", (data
->alarms
>> bitnr
) & 1);
450 static SENSOR_DEVICE_ATTR_2_RW(in0_min
, in
, i_min
, 0);
451 static SENSOR_DEVICE_ATTR_2_RW(in1_min
, in
, i_min
, 1);
452 static SENSOR_DEVICE_ATTR_2_RW(in2_min
, in
, i_min
, 2);
453 static SENSOR_DEVICE_ATTR_2_RW(in3_min
, in
, i_min
, 3);
454 static SENSOR_DEVICE_ATTR_2_RW(in4_min
, in
, i_min
, 4);
455 static SENSOR_DEVICE_ATTR_2_RW(in5_min
, in
, i_min
, 5);
456 static SENSOR_DEVICE_ATTR_2_RW(in6_min
, in
, i_min
, 6);
457 static SENSOR_DEVICE_ATTR_2_RW(in0_max
, in
, i_max
, 0);
458 static SENSOR_DEVICE_ATTR_2_RW(in1_max
, in
, i_max
, 1);
459 static SENSOR_DEVICE_ATTR_2_RW(in2_max
, in
, i_max
, 2);
460 static SENSOR_DEVICE_ATTR_2_RW(in3_max
, in
, i_max
, 3);
461 static SENSOR_DEVICE_ATTR_2_RW(in4_max
, in
, i_max
, 4);
462 static SENSOR_DEVICE_ATTR_2_RW(in5_max
, in
, i_max
, 5);
463 static SENSOR_DEVICE_ATTR_2_RW(in6_max
, in
, i_max
, 6);
464 static SENSOR_DEVICE_ATTR_2_RO(in0_input
, in
, i_input
, 0);
465 static SENSOR_DEVICE_ATTR_2_RO(in1_input
, in
, i_input
, 1);
466 static SENSOR_DEVICE_ATTR_2_RO(in2_input
, in
, i_input
, 2);
467 static SENSOR_DEVICE_ATTR_2_RO(in3_input
, in
, i_input
, 3);
468 static SENSOR_DEVICE_ATTR_2_RO(in4_input
, in
, i_input
, 4);
469 static SENSOR_DEVICE_ATTR_2_RO(in5_input
, in
, i_input
, 5);
470 static SENSOR_DEVICE_ATTR_2_RO(in6_input
, in
, i_input
, 6);
471 static SENSOR_DEVICE_ATTR_2_RW(fan1_min
, fan
, f_min
, 0);
472 static SENSOR_DEVICE_ATTR_2_RW(fan2_min
, fan
, f_min
, 1);
473 static SENSOR_DEVICE_ATTR_2_RO(fan1_input
, fan
, f_input
, 0);
474 static SENSOR_DEVICE_ATTR_2_RO(fan2_input
, fan
, f_input
, 1);
475 static SENSOR_DEVICE_ATTR_RW(fan1_div
, fan_div
, 0);
476 static SENSOR_DEVICE_ATTR_RW(fan2_div
, fan_div
, 1);
477 static SENSOR_DEVICE_ATTR_RO(temp1_input
, temp
, t_input
);
478 static SENSOR_DEVICE_ATTR_RW(temp1_max
, temp
, t_hot_max
);
479 static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst
, temp
, t_hot_hyst
);
480 static SENSOR_DEVICE_ATTR_RW(temp1_crit
, temp
, t_os_max
);
481 static SENSOR_DEVICE_ATTR_RW(temp1_crit_hyst
, temp
, t_os_hyst
);
482 static DEVICE_ATTR_RO(alarms
);
483 static SENSOR_DEVICE_ATTR_RO(in0_alarm
, alarm
, 0);
484 static SENSOR_DEVICE_ATTR_RO(in1_alarm
, alarm
, 1);
485 static SENSOR_DEVICE_ATTR_RO(in2_alarm
, alarm
, 2);
486 static SENSOR_DEVICE_ATTR_RO(in3_alarm
, alarm
, 3);
487 static SENSOR_DEVICE_ATTR_RO(in4_alarm
, alarm
, 4);
488 static SENSOR_DEVICE_ATTR_RO(in5_alarm
, alarm
, 5);
489 static SENSOR_DEVICE_ATTR_RO(in6_alarm
, alarm
, 6);
490 static SENSOR_DEVICE_ATTR_RO(fan1_alarm
, alarm
, 10);
491 static SENSOR_DEVICE_ATTR_RO(fan2_alarm
, alarm
, 11);
492 static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm
, alarm
, 8);
493 static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm
, alarm
, 13);
499 static struct attribute
*lm80_attrs
[] = {
500 &sensor_dev_attr_in0_min
.dev_attr
.attr
,
501 &sensor_dev_attr_in1_min
.dev_attr
.attr
,
502 &sensor_dev_attr_in2_min
.dev_attr
.attr
,
503 &sensor_dev_attr_in3_min
.dev_attr
.attr
,
504 &sensor_dev_attr_in4_min
.dev_attr
.attr
,
505 &sensor_dev_attr_in5_min
.dev_attr
.attr
,
506 &sensor_dev_attr_in6_min
.dev_attr
.attr
,
507 &sensor_dev_attr_in0_max
.dev_attr
.attr
,
508 &sensor_dev_attr_in1_max
.dev_attr
.attr
,
509 &sensor_dev_attr_in2_max
.dev_attr
.attr
,
510 &sensor_dev_attr_in3_max
.dev_attr
.attr
,
511 &sensor_dev_attr_in4_max
.dev_attr
.attr
,
512 &sensor_dev_attr_in5_max
.dev_attr
.attr
,
513 &sensor_dev_attr_in6_max
.dev_attr
.attr
,
514 &sensor_dev_attr_in0_input
.dev_attr
.attr
,
515 &sensor_dev_attr_in1_input
.dev_attr
.attr
,
516 &sensor_dev_attr_in2_input
.dev_attr
.attr
,
517 &sensor_dev_attr_in3_input
.dev_attr
.attr
,
518 &sensor_dev_attr_in4_input
.dev_attr
.attr
,
519 &sensor_dev_attr_in5_input
.dev_attr
.attr
,
520 &sensor_dev_attr_in6_input
.dev_attr
.attr
,
521 &sensor_dev_attr_fan1_min
.dev_attr
.attr
,
522 &sensor_dev_attr_fan2_min
.dev_attr
.attr
,
523 &sensor_dev_attr_fan1_input
.dev_attr
.attr
,
524 &sensor_dev_attr_fan2_input
.dev_attr
.attr
,
525 &sensor_dev_attr_fan1_div
.dev_attr
.attr
,
526 &sensor_dev_attr_fan2_div
.dev_attr
.attr
,
527 &sensor_dev_attr_temp1_input
.dev_attr
.attr
,
528 &sensor_dev_attr_temp1_max
.dev_attr
.attr
,
529 &sensor_dev_attr_temp1_max_hyst
.dev_attr
.attr
,
530 &sensor_dev_attr_temp1_crit
.dev_attr
.attr
,
531 &sensor_dev_attr_temp1_crit_hyst
.dev_attr
.attr
,
532 &dev_attr_alarms
.attr
,
533 &sensor_dev_attr_in0_alarm
.dev_attr
.attr
,
534 &sensor_dev_attr_in1_alarm
.dev_attr
.attr
,
535 &sensor_dev_attr_in2_alarm
.dev_attr
.attr
,
536 &sensor_dev_attr_in3_alarm
.dev_attr
.attr
,
537 &sensor_dev_attr_in4_alarm
.dev_attr
.attr
,
538 &sensor_dev_attr_in5_alarm
.dev_attr
.attr
,
539 &sensor_dev_attr_in6_alarm
.dev_attr
.attr
,
540 &sensor_dev_attr_fan1_alarm
.dev_attr
.attr
,
541 &sensor_dev_attr_fan2_alarm
.dev_attr
.attr
,
542 &sensor_dev_attr_temp1_max_alarm
.dev_attr
.attr
,
543 &sensor_dev_attr_temp1_crit_alarm
.dev_attr
.attr
,
546 ATTRIBUTE_GROUPS(lm80
);
548 /* Return 0 if detection is successful, -ENODEV otherwise */
549 static int lm80_detect(struct i2c_client
*client
, struct i2c_board_info
*info
)
551 struct i2c_adapter
*adapter
= client
->adapter
;
552 int i
, cur
, man_id
, dev_id
;
553 const char *name
= NULL
;
555 if (!i2c_check_functionality(adapter
, I2C_FUNC_SMBUS_BYTE_DATA
))
558 /* First check for unused bits, common to both chip types */
559 if ((lm80_read_value(client
, LM80_REG_ALARM2
) & 0xc0)
560 || (lm80_read_value(client
, LM80_REG_CONFIG
) & 0x80))
564 * The LM96080 has manufacturer and stepping/die rev registers so we
565 * can just check that. The LM80 does not have such registers so we
566 * have to use a more expensive trick.
568 man_id
= lm80_read_value(client
, LM96080_REG_MAN_ID
);
569 dev_id
= lm80_read_value(client
, LM96080_REG_DEV_ID
);
570 if (man_id
== 0x01 && dev_id
== 0x08) {
571 /* Check more unused bits for confirmation */
572 if (lm80_read_value(client
, LM96080_REG_CONV_RATE
) & 0xfe)
577 /* Check 6-bit addressing */
578 for (i
= 0x2a; i
<= 0x3d; i
++) {
579 cur
= i2c_smbus_read_byte_data(client
, i
);
580 if ((i2c_smbus_read_byte_data(client
, i
+ 0x40) != cur
)
581 || (i2c_smbus_read_byte_data(client
, i
+ 0x80) != cur
)
582 || (i2c_smbus_read_byte_data(client
, i
+ 0xc0) != cur
))
589 strlcpy(info
->type
, name
, I2C_NAME_SIZE
);
594 static int lm80_probe(struct i2c_client
*client
)
596 struct device
*dev
= &client
->dev
;
597 struct device
*hwmon_dev
;
598 struct lm80_data
*data
;
601 data
= devm_kzalloc(dev
, sizeof(struct lm80_data
), GFP_KERNEL
);
605 data
->client
= client
;
606 mutex_init(&data
->update_lock
);
608 /* Initialize the LM80 chip */
609 lm80_init_client(client
);
611 /* A few vars need to be filled upon startup */
612 rv
= lm80_read_value(client
, LM80_REG_FAN_MIN(1));
615 data
->fan
[f_min
][0] = rv
;
616 rv
= lm80_read_value(client
, LM80_REG_FAN_MIN(2));
619 data
->fan
[f_min
][1] = rv
;
621 hwmon_dev
= devm_hwmon_device_register_with_groups(dev
, client
->name
,
624 return PTR_ERR_OR_ZERO(hwmon_dev
);
628 * Driver data (common to all clients)
631 static const struct i2c_device_id lm80_id
[] = {
636 MODULE_DEVICE_TABLE(i2c
, lm80_id
);
638 static struct i2c_driver lm80_driver
= {
639 .class = I2C_CLASS_HWMON
,
643 .probe_new
= lm80_probe
,
645 .detect
= lm80_detect
,
646 .address_list
= normal_i2c
,
649 module_i2c_driver(lm80_driver
);
651 MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and "
652 "Philip Edelbrock <phil@netroedge.com>");
653 MODULE_DESCRIPTION("LM80 driver");
654 MODULE_LICENSE("GPL");