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

Revision 2784, 18.3 KB (checked in by khali, 9 years ago)

Restore controlling_mod argument to i2c_register_entry(). This
is needed to properly lock chip drivers in memory while anyone uses their
/proc entries. This also brings back compatibility with the 2.4 Linux
kernel.

  • 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,
317                                        THIS_MODULE)) < 0) {
318                err = i;
319                goto ERROR4;
320        }
321        data->sysctl_id = i;
322
323        lm80_init_client(new_client);
324        return 0;
325
326/* OK, this is not exactly good programming practice, usually. But it is
327   very code-efficient in this case. */
328      ERROR4:
329        i2c_detach_client(new_client);
330      ERROR3:
331      ERROR1:
332        kfree(data);
333      ERROR0:
334        return err;
335}
336
337static int lm80_detach_client(struct i2c_client *client)
338{
339        int err;
340
341        i2c_deregister_entry(((struct lm80_data *) (client->data))->
342                                 sysctl_id);
343
344        if ((err = i2c_detach_client(client))) {
345                printk
346                    ("lm80.o: Client deregistration failed, client not detached.\n");
347                return err;
348        }
349
350        kfree(client->data);
351
352        return 0;
353}
354
355static int lm80_read_value(struct i2c_client *client, u8 reg)
356{
357        return i2c_smbus_read_byte_data(client, reg);
358}
359
360static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value)
361{
362        return i2c_smbus_write_byte_data(client, reg, value);
363}
364
365/* Called when we have found a new LM80. */
366static void lm80_init_client(struct i2c_client *client)
367{
368        /* Reset all except Watchdog values and last conversion values
369           This sets fan-divs to 2, among others. This makes most other
370           initializations unnecessary */
371        lm80_write_value(client, LM80_REG_CONFIG, 0x80);
372        /* Set 11-bit temperature resolution */
373        lm80_write_value(client, LM80_REG_RES, 0x08);
374
375        /* Start monitoring */
376        lm80_write_value(client, LM80_REG_CONFIG, 0x01);
377}
378
379static void lm80_update_client(struct i2c_client *client)
380{
381        struct lm80_data *data = client->data;
382        int i;
383
384        down(&data->update_lock);
385
386        if ((jiffies - data->last_updated > 2 * HZ) ||
387            (jiffies < data->last_updated) || !data->valid) {
388
389#ifdef DEBUG
390                printk("Starting lm80 update\n");
391#endif
392                for (i = 0; i <= 6; i++) {
393                        data->in[i] =
394                            lm80_read_value(client, LM80_REG_IN(i));
395                        data->in_min[i] =
396                            lm80_read_value(client, LM80_REG_IN_MIN(i));
397                        data->in_max[i] =
398                            lm80_read_value(client, LM80_REG_IN_MAX(i));
399                }
400                data->fan[0] = lm80_read_value(client, LM80_REG_FAN1);
401                data->fan_min[0] =
402                    lm80_read_value(client, LM80_REG_FAN1_MIN);
403                data->fan[1] = lm80_read_value(client, LM80_REG_FAN2);
404                data->fan_min[1] =
405                    lm80_read_value(client, LM80_REG_FAN2_MIN);
406
407                data->temp =
408                    (lm80_read_value(client, LM80_REG_TEMP) << 8) |
409                    (lm80_read_value(client, LM80_REG_RES) & 0xf0);
410                data->temp_os_max =
411                    lm80_read_value(client, LM80_REG_TEMP_OS_MAX);
412                data->temp_os_hyst =
413                    lm80_read_value(client, LM80_REG_TEMP_OS_HYST);
414                data->temp_hot_max =
415                    lm80_read_value(client, LM80_REG_TEMP_HOT_MAX);
416                data->temp_hot_hyst =
417                    lm80_read_value(client, LM80_REG_TEMP_HOT_HYST);
418
419                i = lm80_read_value(client, LM80_REG_FANDIV);
420                data->fan_div[0] = (i >> 2) & 0x03;
421                data->fan_div[1] = (i >> 4) & 0x03;
422                data->alarms = lm80_read_value(client, LM80_REG_ALARM1) +
423                    (lm80_read_value(client, LM80_REG_ALARM2) << 8);
424                data->last_updated = jiffies;
425                data->valid = 1;
426        }
427
428        up(&data->update_lock);
429}
430
431
432/* The next few functions are the call-back functions of the /proc/sys and
433   sysctl files. Which function is used is defined in the ctl_table in
434   the extra1 field.
435   Each function must return the magnitude (power of 10 to divide the date
436   with) if it is called with operation==SENSORS_PROC_REAL_INFO. It must
437   put a maximum of *nrels elements in results reflecting the data of this
438   file, and set *nrels to the number it actually put in it, if operation==
439   SENSORS_PROC_REAL_READ. Finally, it must get upto *nrels elements from
440   results and write them to the chip, if operations==SENSORS_PROC_REAL_WRITE.
441   Note that on SENSORS_PROC_REAL_READ, I do not check whether results is
442   large enough (by checking the incoming value of *nrels). This is not very
443   good practice, but as long as you put less than about 5 values in results,
444   you can assume it is large enough. */
445void lm80_in(struct i2c_client *client, int operation, int ctl_name,
446             int *nrels_mag, long *results)
447{
448        struct lm80_data *data = client->data;
449        int nr = ctl_name - LM80_SYSCTL_IN0;
450
451        if (operation == SENSORS_PROC_REAL_INFO)
452                *nrels_mag = 2;
453        else if (operation == SENSORS_PROC_REAL_READ) {
454                lm80_update_client(client);
455                results[0] = IN_FROM_REG(data->in_min[nr]);
456                results[1] = IN_FROM_REG(data->in_max[nr]);
457                results[2] = IN_FROM_REG(data->in[nr]);
458                *nrels_mag = 3;
459        } else if (operation == SENSORS_PROC_REAL_WRITE) {
460                if (*nrels_mag >= 1) {
461                        data->in_min[nr] = IN_TO_REG(results[0]);
462                        lm80_write_value(client, LM80_REG_IN_MIN(nr),
463                                         data->in_min[nr]);
464                }
465                if (*nrels_mag >= 2) {
466                        data->in_max[nr] = IN_TO_REG(results[1]);
467                        lm80_write_value(client, LM80_REG_IN_MAX(nr),
468                                         data->in_max[nr]);
469                }
470        }
471}
472
473void lm80_fan(struct i2c_client *client, int operation, int ctl_name,
474              int *nrels_mag, long *results)
475{
476        struct lm80_data *data = client->data;
477        int nr = ctl_name - LM80_SYSCTL_FAN1 + 1;
478
479        if (operation == SENSORS_PROC_REAL_INFO)
480                *nrels_mag = 0;
481        else if (operation == SENSORS_PROC_REAL_READ) {
482                lm80_update_client(client);
483                results[0] = FAN_FROM_REG(data->fan_min[nr - 1],
484                                          DIV_FROM_REG(data->
485                                                       fan_div[nr - 1]));
486                results[1] =
487                    FAN_FROM_REG(data->fan[nr - 1],
488                                 DIV_FROM_REG(data->fan_div[nr - 1]));
489                *nrels_mag = 2;
490        } else if (operation == SENSORS_PROC_REAL_WRITE) {
491                if (*nrels_mag >= 1) {
492                        data->fan_min[nr - 1] = FAN_TO_REG(results[0],
493                                                           DIV_FROM_REG
494                                                           (data->
495                                                            fan_div[nr -
496                                                                    1]));
497                        lm80_write_value(client,
498                                         nr ==
499                                         1 ? LM80_REG_FAN1_MIN :
500                                         LM80_REG_FAN2_MIN,
501                                         data->fan_min[nr - 1]);
502                }
503        }
504}
505
506
507void lm80_temp(struct i2c_client *client, int operation, int ctl_name,
508               int *nrels_mag, long *results)
509{
510        struct lm80_data *data = client->data;
511        if (operation == SENSORS_PROC_REAL_INFO)
512                *nrels_mag = 2;
513        else if (operation == SENSORS_PROC_REAL_READ) {
514                lm80_update_client(client);
515                results[0] = TEMP_LIMIT_FROM_REG(data->temp_hot_max);
516                results[1] = TEMP_LIMIT_FROM_REG(data->temp_hot_hyst);
517                results[2] = TEMP_LIMIT_FROM_REG(data->temp_os_max);
518                results[3] = TEMP_LIMIT_FROM_REG(data->temp_os_hyst);
519                results[4] = TEMP_FROM_REG(data->temp);
520                *nrels_mag = 5;
521        } else if (operation == SENSORS_PROC_REAL_WRITE) {
522                if (*nrels_mag >= 1) {
523                        data->temp_hot_max = TEMP_LIMIT_TO_REG(results[0]);
524                        lm80_write_value(client, LM80_REG_TEMP_HOT_MAX,
525                                         data->temp_hot_max);
526                }
527                if (*nrels_mag >= 2) {
528                        data->temp_hot_hyst =
529                            TEMP_LIMIT_TO_REG(results[1]);
530                        lm80_write_value(client, LM80_REG_TEMP_HOT_HYST,
531                                         data->temp_hot_hyst);
532                }
533                if (*nrels_mag >= 3) {
534                        data->temp_os_max = TEMP_LIMIT_TO_REG(results[2]);
535                        lm80_write_value(client, LM80_REG_TEMP_OS_MAX,
536                                         data->temp_os_max);
537                }
538                if (*nrels_mag >= 4) {
539                        data->temp_os_hyst = TEMP_LIMIT_TO_REG(results[3]);
540                        lm80_write_value(client, LM80_REG_TEMP_OS_HYST,
541                                         data->temp_os_hyst);
542                }
543        }
544}
545
546void lm80_alarms(struct i2c_client *client, int operation, int ctl_name,
547                 int *nrels_mag, long *results)
548{
549        struct lm80_data *data = client->data;
550        if (operation == SENSORS_PROC_REAL_INFO)
551                *nrels_mag = 0;
552        else if (operation == SENSORS_PROC_REAL_READ) {
553                lm80_update_client(client);
554                results[0] = ALARMS_FROM_REG(data->alarms);
555                *nrels_mag = 1;
556        }
557}
558
559void lm80_fan_div(struct i2c_client *client, int operation, int ctl_name,
560                  int *nrels_mag, long *results)
561{
562        struct lm80_data *data = client->data;
563        int old;
564
565        if (operation == SENSORS_PROC_REAL_INFO)
566                *nrels_mag = 0;
567        else if (operation == SENSORS_PROC_REAL_READ) {
568                lm80_update_client(client);
569                results[0] = DIV_FROM_REG(data->fan_div[0]);
570                results[1] = DIV_FROM_REG(data->fan_div[1]);
571                results[2] = 2;
572                *nrels_mag = 3;
573        } else if (operation == SENSORS_PROC_REAL_WRITE) {
574                old = lm80_read_value(client, LM80_REG_FANDIV);
575                if (*nrels_mag >= 2) {
576                        data->fan_div[1] = DIV_TO_REG(results[1]);
577                        old = (old & 0xcf) | (data->fan_div[1] << 4);
578                }
579                if (*nrels_mag >= 1) {
580                        data->fan_div[0] = DIV_TO_REG(results[0]);
581                        old = (old & 0xf3) | (data->fan_div[0] << 2);
582                        lm80_write_value(client, LM80_REG_FANDIV, old);
583                }
584        }
585}
586
587static int __init sm_lm80_init(void)
588{
589        printk("lm80.o version %s (%s)\n", LM_VERSION, LM_DATE);
590        return i2c_add_driver(&lm80_driver);
591}
592
593static void __exit sm_lm80_exit(void)
594{
595        i2c_del_driver(&lm80_driver);
596}
597
598
599
600MODULE_AUTHOR
601    ("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>");
602MODULE_DESCRIPTION("LM80 driver");
603
604module_init(sm_lm80_init);
605module_exit(sm_lm80_exit);
Note: See TracBrowser for help on using the browser.