root/lm-sensors/trunk/kernel/chips/lm80.c @ 2781

Revision 2781, 18.3 KB (checked in by khali, 8 years ago)

Discard owner field from i2c_driver structure. I do not restore
inc_use/dec_use because they are not actually used anywhere.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2    lm80.c - Part of lm_sensors, Linux kernel modules for hardware
3             monitoring
4    Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl>
5    and Philip Edelbrock <phil@netroedge.com>
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#include <linux/module.h>
23#include <linux/slab.h>
24#include <linux/i2c.h>
25#include <linux/i2c-proc.h>
26#include <linux/init.h>
27#include "version.h"
28
29MODULE_LICENSE("GPL");
30
31/* Addresses to scan */
32static unsigned short normal_i2c[] = { SENSORS_I2C_END };
33static unsigned short normal_i2c_range[] = { 0x20, 0x2f, SENSORS_I2C_END };
34static unsigned int normal_isa[] = { SENSORS_ISA_END };
35static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
36
37/* Insmod parameters */
38SENSORS_INSMOD_1(lm80);
39
40/* Many LM80 constants specified below */
41
42/* The LM80 registers */
43#define LM80_REG_IN_MAX(nr) (0x2a + (nr) * 2)
44#define LM80_REG_IN_MIN(nr) (0x2b + (nr) * 2)
45#define LM80_REG_IN(nr) (0x20 + (nr))
46
47#define LM80_REG_FAN1_MIN 0x3c
48#define LM80_REG_FAN2_MIN 0x3d
49#define LM80_REG_FAN1 0x28
50#define LM80_REG_FAN2 0x29
51
52#define LM80_REG_TEMP 0x27
53#define LM80_REG_TEMP_HOT_MAX 0x38
54#define LM80_REG_TEMP_HOT_HYST 0x39
55#define LM80_REG_TEMP_OS_MAX 0x3a
56#define LM80_REG_TEMP_OS_HYST 0x3b
57
58#define LM80_REG_CONFIG 0x00
59#define LM80_REG_ALARM1 0x01
60#define LM80_REG_ALARM2 0x02
61#define LM80_REG_MASK1 0x03
62#define LM80_REG_MASK2 0x04
63#define LM80_REG_FANDIV 0x05
64#define LM80_REG_RES 0x06
65
66
67/* Conversions. Rounding and limit checking is only done on the TO_REG
68   variants. Note that you should be a bit careful with which arguments
69   these macros are called: arguments may be evaluated more than once.
70   Fixing this is just not worth it. */
71
72#define IN_TO_REG(val) (SENSORS_LIMIT((val),0,255))
73#define IN_FROM_REG(val) (val)
74
75static inline unsigned char FAN_TO_REG(unsigned rpm, unsigned div)
76{
77        if (rpm == 0)
78                return 255;
79        rpm = SENSORS_LIMIT(rpm, 1, 1000000);
80        return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1,
81                             254);
82}
83
84#define FAN_FROM_REG(val,div) ((val)==0?-1:\
85                               (val)==255?0:1350000/((div)*(val)))
86
87static inline long TEMP_FROM_REG(u16 temp)
88{
89        long res;
90
91        temp >>= 4;
92        if (temp < 0x0800)
93                res = 625 * (long) temp;
94        else
95                res = ((long) temp - 0x01000) * 625;
96
97        return res / 100;
98}
99
100#define TEMP_LIMIT_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*100)
101
102#define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT(((val)<0?(((val)-50)/100):\
103                                                      ((val)+50)/100), \
104                                             0,255)
105
106#define ALARMS_FROM_REG(val) (val)
107
108#define DIV_FROM_REG(val) (1 << (val))
109#define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1)
110
111struct lm80_data {
112        struct i2c_client client;
113        int sysctl_id;
114
115        struct semaphore update_lock;
116        char valid;             /* !=0 if following fields are valid */
117        unsigned long last_updated;     /* In jiffies */
118
119        u8 in[7];               /* Register value */
120        u8 in_max[7];           /* Register value */
121        u8 in_min[7];           /* Register value */
122        u8 fan[2];              /* Register value */
123        u8 fan_min[2];          /* Register value */
124        u8 fan_div[2];          /* Register encoding, shifted right */
125        u16 temp;               /* Register values, shifted right */
126        u8 temp_hot_max;        /* Register value */
127        u8 temp_hot_hyst;       /* Register value */
128        u8 temp_os_max;         /* Register value */
129        u8 temp_os_hyst;        /* Register value */
130        u16 alarms;             /* Register encoding, combined */
131};
132
133
134
135static int lm80_attach_adapter(struct i2c_adapter *adapter);
136static int lm80_detect(struct i2c_adapter *adapter, int address,
137                       unsigned short flags, int kind);
138static int lm80_detach_client(struct i2c_client *client);
139
140static int lm80_read_value(struct i2c_client *client, u8 reg);
141static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value);
142static void lm80_update_client(struct i2c_client *client);
143static void lm80_init_client(struct i2c_client *client);
144
145
146static void lm80_in(struct i2c_client *client, int operation, int ctl_name,
147                    int *nrels_mag, long *results);
148static void lm80_fan(struct i2c_client *client, int operation,
149                     int ctl_name, int *nrels_mag, long *results);
150static void lm80_temp(struct i2c_client *client, int operation,
151                      int ctl_name, int *nrels_mag, long *results);
152static void lm80_alarms(struct i2c_client *client, int operation,
153                        int ctl_name, int *nrels_mag, long *results);
154static void lm80_fan_div(struct i2c_client *client, int operation,
155                         int ctl_name, int *nrels_mag, long *results);
156
157static int lm80_id = 0;
158
159static struct i2c_driver lm80_driver = {
160        .name           = "LM80 sensor driver",
161        .id             = I2C_DRIVERID_LM80,
162        .flags          = I2C_DF_NOTIFY,
163        .attach_adapter = lm80_attach_adapter,
164        .detach_client  = lm80_detach_client,
165};
166
167/* The /proc/sys entries */
168
169/* -- SENSORS SYSCTL START -- */
170
171#define LM80_SYSCTL_IN0 1000    /* Volts * 100 */
172#define LM80_SYSCTL_IN1 1001
173#define LM80_SYSCTL_IN2 1002
174#define LM80_SYSCTL_IN3 1003
175#define LM80_SYSCTL_IN4 1004
176#define LM80_SYSCTL_IN5 1005
177#define LM80_SYSCTL_IN6 1006
178#define LM80_SYSCTL_FAN1 1101   /* Rotations/min */
179#define LM80_SYSCTL_FAN2 1102
180#define LM80_SYSCTL_TEMP 1250   /* Degrees Celcius * 100 */
181#define LM80_SYSCTL_FAN_DIV 2000        /* 1, 2, 4 or 8 */
182#define LM80_SYSCTL_ALARMS 2001 /* bitvector */
183
184#define LM80_ALARM_IN0 0x0001
185#define LM80_ALARM_IN1 0x0002
186#define LM80_ALARM_IN2 0x0004
187#define LM80_ALARM_IN3 0x0008
188#define LM80_ALARM_IN4 0x0010
189#define LM80_ALARM_IN5 0x0020
190#define LM80_ALARM_IN6 0x0040
191#define LM80_ALARM_FAN1 0x0400
192#define LM80_ALARM_FAN2 0x0800
193#define LM80_ALARM_TEMP_HOT 0x0100
194#define LM80_ALARM_TEMP_OS 0x2000
195#define LM80_ALARM_CHAS 0x1000
196#define LM80_ALARM_BTI 0x0200
197#define LM80_ALARM_INT_IN 0x0080
198
199/* -- SENSORS SYSCTL END -- */
200
201/* These files are created for each detected LM80. This is just a template;
202   though at first sight, you might think we could use a statically
203   allocated list, we need some way to get back to the parent - which
204   is done through one of the 'extra' fields which are initialized
205   when a new copy is allocated. */
206static ctl_table lm80_dir_table_template[] = {
207        {LM80_SYSCTL_IN0, "in0", NULL, 0, 0644, NULL, &i2c_proc_real,
208         &i2c_sysctl_real, NULL, &lm80_in},
209        {LM80_SYSCTL_IN1, "in1", NULL, 0, 0644, NULL, &i2c_proc_real,
210         &i2c_sysctl_real, NULL, &lm80_in},
211        {LM80_SYSCTL_IN2, "in2", NULL, 0, 0644, NULL, &i2c_proc_real,
212         &i2c_sysctl_real, NULL, &lm80_in},
213        {LM80_SYSCTL_IN3, "in3", NULL, 0, 0644, NULL, &i2c_proc_real,
214         &i2c_sysctl_real, NULL, &lm80_in},
215        {LM80_SYSCTL_IN4, "in4", NULL, 0, 0644, NULL, &i2c_proc_real,
216         &i2c_sysctl_real, NULL, &lm80_in},
217        {LM80_SYSCTL_IN5, "in5", NULL, 0, 0644, NULL, &i2c_proc_real,
218         &i2c_sysctl_real, NULL, &lm80_in},
219        {LM80_SYSCTL_IN6, "in6", NULL, 0, 0644, NULL, &i2c_proc_real,
220         &i2c_sysctl_real, NULL, &lm80_in},
221        {LM80_SYSCTL_FAN1, "fan1", NULL, 0, 0644, NULL, &i2c_proc_real,
222         &i2c_sysctl_real, NULL, &lm80_fan},
223        {LM80_SYSCTL_FAN2, "fan2", NULL, 0, 0644, NULL, &i2c_proc_real,
224         &i2c_sysctl_real, NULL, &lm80_fan},
225        {LM80_SYSCTL_TEMP, "temp", NULL, 0, 0644, NULL, &i2c_proc_real,
226         &i2c_sysctl_real, NULL, &lm80_temp},
227        {LM80_SYSCTL_FAN_DIV, "fan_div", NULL, 0, 0644, NULL, &i2c_proc_real,
228         &i2c_sysctl_real, NULL, &lm80_fan_div},
229        {LM80_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &i2c_proc_real,
230         &i2c_sysctl_real, NULL, &lm80_alarms},
231        {0}
232};
233
234static int lm80_attach_adapter(struct i2c_adapter *adapter)
235{
236        return i2c_detect(adapter, &addr_data, lm80_detect);
237}
238
239int lm80_detect(struct i2c_adapter *adapter, int address,
240                unsigned short flags, int kind)
241{
242        int i, cur;
243        struct i2c_client *new_client;
244        struct lm80_data *data;
245        int err = 0;
246        const char *type_name, *client_name;
247
248        /* Make sure we aren't probing the ISA bus!! This is just a safety check
249           at this moment; i2c_detect really won't call us. */
250#ifdef DEBUG
251        if (i2c_is_isa_adapter(adapter)) {
252                printk
253                    ("lm80.o: lm80_detect called for an ISA bus adapter?!?\n");
254                return 0;
255        }
256#endif
257
258        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
259                goto ERROR0;
260
261        /* OK. For now, we presume we have a valid client. We now create the
262           client structure, even though we cannot fill it completely yet.
263           But it allows us to access lm80_{read,write}_value. */
264        if (!(data = kmalloc(sizeof(struct lm80_data), GFP_KERNEL))) {
265                err = -ENOMEM;
266                goto ERROR0;
267        }
268
269        new_client = &data->client;
270        new_client->addr = address;
271        new_client->data = data;
272        new_client->adapter = adapter;
273        new_client->driver = &lm80_driver;
274        new_client->flags = 0;
275
276        /* Now, we do the remaining detection. It is lousy. */
277        if (lm80_read_value(new_client, LM80_REG_ALARM2) & 0xc0)
278                goto ERROR1;
279        for (i = 0x2a; i <= 0x3d; i++) {
280                cur = i2c_smbus_read_byte_data(new_client, i);
281                if ((i2c_smbus_read_byte_data(new_client, i + 0x40) != cur)
282                    || (i2c_smbus_read_byte_data(new_client, i + 0x80) !=
283                        cur)
284                    || (i2c_smbus_read_byte_data(new_client, i + 0xc0) !=
285                        cur)) goto ERROR1;
286        }
287
288        /* Determine the chip type - only one kind supported! */
289        if (kind <= 0)
290                kind = lm80;
291
292        if (kind == lm80) {
293                type_name = "lm80";
294                client_name = "LM80 chip";
295        } else {
296#ifdef DEBUG
297                printk("lm80.o: Internal error: unknown kind (%d)?!?",
298                       kind);
299#endif
300                goto ERROR1;
301        }
302
303        /* Fill in the remaining client fields and put it into the global list */
304        strcpy(new_client->name, client_name);
305
306        new_client->id = lm80_id++;
307        data->valid = 0;
308        init_MUTEX(&data->update_lock);
309
310        /* Tell the I2C layer a new client has arrived */
311        if ((err = i2c_attach_client(new_client)))
312                goto ERROR3;
313
314        /* Register a new directory entry with module sensors */
315        if ((i = i2c_register_entry(new_client, type_name,
316                                        lm80_dir_table_template)) < 0) {
317                err = i;
318                goto ERROR4;
319        }
320        data->sysctl_id = i;
321
322        lm80_init_client(new_client);
323        return 0;
324
325/* OK, this is not exactly good programming practice, usually. But it is
326   very code-efficient in this case. */
327      ERROR4:
328        i2c_detach_client(new_client);
329      ERROR3:
330      ERROR1:
331        kfree(data);
332      ERROR0:
333        return err;
334}
335
336static int lm80_detach_client(struct i2c_client *client)
337{
338        int err;
339
340        i2c_deregister_entry(((struct lm80_data *) (client->data))->
341                                 sysctl_id);
342
343        if ((err = i2c_detach_client(client))) {
344                printk
345                    ("lm80.o: Client deregistration failed, client not detached.\n");
346                return err;
347        }
348
349        kfree(client->data);
350
351        return 0;
352}
353
354static int lm80_read_value(struct i2c_client *client, u8 reg)
355{
356        return i2c_smbus_read_byte_data(client, reg);
357}
358
359static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value)
360{
361        return i2c_smbus_write_byte_data(client, reg, value);
362}
363
364/* Called when we have found a new LM80. */
365static void lm80_init_client(struct i2c_client *client)
366{
367        /* Reset all except Watchdog values and last conversion values
368           This sets fan-divs to 2, among others. This makes most other
369           initializations unnecessary */
370        lm80_write_value(client, LM80_REG_CONFIG, 0x80);
371        /* Set 11-bit temperature resolution */
372        lm80_write_value(client, LM80_REG_RES, 0x08);
373
374        /* Start monitoring */
375        lm80_write_value(client, LM80_REG_CONFIG, 0x01);
376}
377
378static void lm80_update_client(struct i2c_client *client)
379{
380        struct lm80_data *data = client->data;
381        int i;
382
383        down(&data->update_lock);
384
385        if ((jiffies - data->last_updated > 2 * HZ) ||
386            (jiffies < data->last_updated) || !data->valid) {
387
388#ifdef DEBUG
389                printk("Starting lm80 update\n");
390#endif
391                for (i = 0; i <= 6; i++) {
392                        data->in[i] =
393                            lm80_read_value(client, LM80_REG_IN(i));
394                        data->in_min[i] =
395                            lm80_read_value(client, LM80_REG_IN_MIN(i));
396                        data->in_max[i] =
397                            lm80_read_value(client, LM80_REG_IN_MAX(i));
398                }
399                data->fan[0] = lm80_read_value(client, LM80_REG_FAN1);
400                data->fan_min[0] =
401                    lm80_read_value(client, LM80_REG_FAN1_MIN);
402                data->fan[1] = lm80_read_value(client, LM80_REG_FAN2);
403                data->fan_min[1] =
404                    lm80_read_value(client, LM80_REG_FAN2_MIN);
405
406                data->temp =
407                    (lm80_read_value(client, LM80_REG_TEMP) << 8) |
408                    (lm80_read_value(client, LM80_REG_RES) & 0xf0);
409                data->temp_os_max =
410                    lm80_read_value(client, LM80_REG_TEMP_OS_MAX);
411                data->temp_os_hyst =
412                    lm80_read_value(client, LM80_REG_TEMP_OS_HYST);
413                data->temp_hot_max =
414                    lm80_read_value(client, LM80_REG_TEMP_HOT_MAX);
415                data->temp_hot_hyst =
416                    lm80_read_value(client, LM80_REG_TEMP_HOT_HYST);
417
418                i = lm80_read_value(client, LM80_REG_FANDIV);
419                data->fan_div[0] = (i >> 2) & 0x03;
420                data->fan_div[1] = (i >> 4) & 0x03;
421                data->alarms = lm80_read_value(client, LM80_REG_ALARM1) +
422                    (lm80_read_value(client, LM80_REG_ALARM2) << 8);
423                data->last_updated = jiffies;
424                data->valid = 1;
425        }
426
427        up(&data->update_lock);
428}
429
430
431/* The next few functions are the call-back functions of the /proc/sys and
432   sysctl files. Which function is used is defined in the ctl_table in
433   the extra1 field.
434   Each function must return the magnitude (power of 10 to divide the date
435   with) if it is called with operation==SENSORS_PROC_REAL_INFO. It must
436   put a maximum of *nrels elements in results reflecting the data of this
437   file, and set *nrels to the number it actually put in it, if operation==
438   SENSORS_PROC_REAL_READ. Finally, it must get upto *nrels elements from
439   results and write them to the chip, if operations==SENSORS_PROC_REAL_WRITE.
440   Note that on SENSORS_PROC_REAL_READ, I do not check whether results is
441   large enough (by checking the incoming value of *nrels). This is not very
442   good practice, but as long as you put less than about 5 values in results,
443   you can assume it is large enough. */
444void lm80_in(struct i2c_client *client, int operation, int ctl_name,
445             int *nrels_mag, long *results)
446{
447        struct lm80_data *data = client->data;
448        int nr = ctl_name - LM80_SYSCTL_IN0;
449
450        if (operation == SENSORS_PROC_REAL_INFO)
451                *nrels_mag = 2;
452        else if (operation == SENSORS_PROC_REAL_READ) {
453                lm80_update_client(client);
454                results[0] = IN_FROM_REG(data->in_min[nr]);
455                results[1] = IN_FROM_REG(data->in_max[nr]);
456                results[2] = IN_FROM_REG(data->in[nr]);
457                *nrels_mag = 3;
458        } else if (operation == SENSORS_PROC_REAL_WRITE) {
459                if (*nrels_mag >= 1) {
460                        data->in_min[nr] = IN_TO_REG(results[0]);
461                        lm80_write_value(client, LM80_REG_IN_MIN(nr),
462                                         data->in_min[nr]);
463                }
464                if (*nrels_mag >= 2) {
465                        data->in_max[nr] = IN_TO_REG(results[1]);
466                        lm80_write_value(client, LM80_REG_IN_MAX(nr),
467                                         data->in_max[nr]);
468                }
469        }
470}
471
472void lm80_fan(struct i2c_client *client, int operation, int ctl_name,
473              int *nrels_mag, long *results)
474{
475        struct lm80_data *data = client->data;
476        int nr = ctl_name - LM80_SYSCTL_FAN1 + 1;
477
478        if (operation == SENSORS_PROC_REAL_INFO)
479                *nrels_mag = 0;
480        else if (operation == SENSORS_PROC_REAL_READ) {
481                lm80_update_client(client);
482                results[0] = FAN_FROM_REG(data->fan_min[nr - 1],
483                                          DIV_FROM_REG(data->
484                                                       fan_div[nr - 1]));
485                results[1] =
486                    FAN_FROM_REG(data->fan[nr - 1],
487                                 DIV_FROM_REG(data->fan_div[nr - 1]));
488                *nrels_mag = 2;
489        } else if (operation == SENSORS_PROC_REAL_WRITE) {
490                if (*nrels_mag >= 1) {
491                        data->fan_min[nr - 1] = FAN_TO_REG(results[0],
492                                                           DIV_FROM_REG
493                                                           (data->
494                                                            fan_div[nr -
495                                                                    1]));
496                        lm80_write_value(client,
497                                         nr ==
498                                         1 ? LM80_REG_FAN1_MIN :
499                                         LM80_REG_FAN2_MIN,
500                                         data->fan_min[nr - 1]);
501                }
502        }
503}
504
505
506void lm80_temp(struct i2c_client *client, int operation, int ctl_name,
507               int *nrels_mag, long *results)
508{
509        struct lm80_data *data = client->data;
510        if (operation == SENSORS_PROC_REAL_INFO)
511                *nrels_mag = 2;
512        else if (operation == SENSORS_PROC_REAL_READ) {
513                lm80_update_client(client);
514                results[0] = TEMP_LIMIT_FROM_REG(data->temp_hot_max);
515                results[1] = TEMP_LIMIT_FROM_REG(data->temp_hot_hyst);
516                results[2] = TEMP_LIMIT_FROM_REG(data->temp_os_max);
517                results[3] = TEMP_LIMIT_FROM_REG(data->temp_os_hyst);
518                results[4] = TEMP_FROM_REG(data->temp);
519                *nrels_mag = 5;
520        } else if (operation == SENSORS_PROC_REAL_WRITE) {
521                if (*nrels_mag >= 1) {
522                        data->temp_hot_max = TEMP_LIMIT_TO_REG(results[0]);
523                        lm80_write_value(client, LM80_REG_TEMP_HOT_MAX,
524                                         data->temp_hot_max);
525                }
526                if (*nrels_mag >= 2) {
527                        data->temp_hot_hyst =
528                            TEMP_LIMIT_TO_REG(results[1]);
529                        lm80_write_value(client, LM80_REG_TEMP_HOT_HYST,
530                                         data->temp_hot_hyst);
531                }
532                if (*nrels_mag >= 3) {
533                        data->temp_os_max = TEMP_LIMIT_TO_REG(results[2]);
534                        lm80_write_value(client, LM80_REG_TEMP_OS_MAX,
535                                         data->temp_os_max);
536                }
537                if (*nrels_mag >= 4) {
538                        data->temp_os_hyst = TEMP_LIMIT_TO_REG(results[3]);
539                        lm80_write_value(client, LM80_REG_TEMP_OS_HYST,
540                                         data->temp_os_hyst);
541                }
542        }
543}
544
545void lm80_alarms(struct i2c_client *client, int operation, int ctl_name,
546                 int *nrels_mag, long *results)
547{
548        struct lm80_data *data = client->data;
549        if (operation == SENSORS_PROC_REAL_INFO)
550                *nrels_mag = 0;
551        else if (operation == SENSORS_PROC_REAL_READ) {
552                lm80_update_client(client);
553                results[0] = ALARMS_FROM_REG(data->alarms);
554                *nrels_mag = 1;
555        }
556}
557
558void lm80_fan_div(struct i2c_client *client, int operation, int ctl_name,
559                  int *nrels_mag, long *results)
560{
561        struct lm80_data *data = client->data;
562        int old;
563
564        if (operation == SENSORS_PROC_REAL_INFO)
565                *nrels_mag = 0;
566        else if (operation == SENSORS_PROC_REAL_READ) {
567                lm80_update_client(client);
568                results[0] = DIV_FROM_REG(data->fan_div[0]);
569                results[1] = DIV_FROM_REG(data->fan_div[1]);
570                results[2] = 2;
571                *nrels_mag = 3;
572        } else if (operation == SENSORS_PROC_REAL_WRITE) {
573                old = lm80_read_value(client, LM80_REG_FANDIV);
574                if (*nrels_mag >= 2) {
575                        data->fan_div[1] = DIV_TO_REG(results[1]);
576                        old = (old & 0xcf) | (data->fan_div[1] << 4);
577                }
578                if (*nrels_mag >= 1) {
579                        data->fan_div[0] = DIV_TO_REG(results[0]);
580                        old = (old & 0xf3) | (data->fan_div[0] << 2);
581                        lm80_write_value(client, LM80_REG_FANDIV, old);
582                }
583        }
584}
585
586static int __init sm_lm80_init(void)
587{
588        printk("lm80.o version %s (%s)\n", LM_VERSION, LM_DATE);
589        return i2c_add_driver(&lm80_driver);
590}
591
592static void __exit sm_lm80_exit(void)
593{
594        i2c_del_driver(&lm80_driver);
595}
596
597
598
599MODULE_AUTHOR
600    ("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
601MODULE_DESCRIPTION("LM80 driver");
602
603module_init(sm_lm80_init);
604module_exit(sm_lm80_exit);
Note: See TracBrowser for help on using the browser.