diff options
Diffstat (limited to 'drivers/hwmon/adm1031.c')
-rw-r--r-- | drivers/hwmon/adm1031.c | 73 |
1 files changed, 34 insertions, 39 deletions
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 97e2cfb0bc93..ff37363ea5bc 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
@@ -1,25 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | adm1031.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | * adm1031.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | monitoring | 3 | * monitoring |
4 | Based on lm75.c and lm85.c | 4 | * Based on lm75.c and lm85.c |
5 | Supports adm1030 / adm1031 | 5 | * Supports adm1030 / adm1031 |
6 | Copyright (C) 2004 Alexandre d'Alton <alex@alexdalton.org> | 6 | * Copyright (C) 2004 Alexandre d'Alton <alex@alexdalton.org> |
7 | Reworked by Jean Delvare <khali@linux-fr.org> | 7 | * Reworked by Jean Delvare <khali@linux-fr.org> |
8 | 8 | * | |
9 | This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
10 | it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
11 | the Free Software Foundation; either version 2 of the License, or | 11 | * the Free Software Foundation; either version 2 of the License, or |
12 | (at your option) any later version. | 12 | * (at your option) any later version. |
13 | 13 | * | |
14 | This program is distributed in the hope that it will be useful, | 14 | * This program is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | GNU General Public License for more details. | 17 | * GNU General Public License for more details. |
18 | 18 | * | |
19 | You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License |
20 | along with this program; if not, write to the Free Software | 20 | * along with this program; if not, write to the Free Software |
21 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
@@ -80,7 +80,8 @@ struct adm1031_data { | |||
80 | char valid; /* !=0 if following fields are valid */ | 80 | char valid; /* !=0 if following fields are valid */ |
81 | unsigned long last_updated; /* In jiffies */ | 81 | unsigned long last_updated; /* In jiffies */ |
82 | unsigned int update_interval; /* In milliseconds */ | 82 | unsigned int update_interval; /* In milliseconds */ |
83 | /* The chan_select_table contains the possible configurations for | 83 | /* |
84 | * The chan_select_table contains the possible configurations for | ||
84 | * auto fan control. | 85 | * auto fan control. |
85 | */ | 86 | */ |
86 | const auto_chan_table_t *chan_select_table; | 87 | const auto_chan_table_t *chan_select_table; |
@@ -205,7 +206,8 @@ static int AUTO_TEMP_MAX_TO_REG(int val, int reg, int pwm) | |||
205 | #define GET_FAN_AUTO_BITFIELD(data, idx) \ | 206 | #define GET_FAN_AUTO_BITFIELD(data, idx) \ |
206 | (*(data)->chan_select_table)[FAN_CHAN_FROM_REG((data)->conf1)][idx % 2] | 207 | (*(data)->chan_select_table)[FAN_CHAN_FROM_REG((data)->conf1)][idx % 2] |
207 | 208 | ||
208 | /* The tables below contains the possible values for the auto fan | 209 | /* |
210 | * The tables below contains the possible values for the auto fan | ||
209 | * control bitfields. the index in the table is the register value. | 211 | * control bitfields. the index in the table is the register value. |
210 | * MSb is the auto fan control enable bit, so the four first entries | 212 | * MSb is the auto fan control enable bit, so the four first entries |
211 | * in the table disables auto fan control when both bitfields are zero. | 213 | * in the table disables auto fan control when both bitfields are zero. |
@@ -226,7 +228,8 @@ static const auto_chan_table_t auto_channel_select_table_adm1030 = { | |||
226 | { 3 /* 0b11 */ , 0 }, | 228 | { 3 /* 0b11 */ , 0 }, |
227 | }; | 229 | }; |
228 | 230 | ||
229 | /* That function checks if a bitfield is valid and returns the other bitfield | 231 | /* |
232 | * That function checks if a bitfield is valid and returns the other bitfield | ||
230 | * nearest match if no exact match where found. | 233 | * nearest match if no exact match where found. |
231 | */ | 234 | */ |
232 | static int | 235 | static int |
@@ -252,7 +255,8 @@ get_fan_auto_nearest(struct adm1031_data *data, | |||
252 | break; | 255 | break; |
253 | } else if (val == (*data->chan_select_table)[i][chan] && | 256 | } else if (val == (*data->chan_select_table)[i][chan] && |
254 | first_match == -1) { | 257 | first_match == -1) { |
255 | /* Save the first match in case of an exact match has | 258 | /* |
259 | * Save the first match in case of an exact match has | ||
256 | * not been found | 260 | * not been found |
257 | */ | 261 | */ |
258 | first_match = i; | 262 | first_match = i; |
@@ -306,9 +310,11 @@ set_fan_auto_channel(struct device *dev, struct device_attribute *attr, | |||
306 | if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) ^ | 310 | if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) ^ |
307 | (old_fan_mode & ADM1031_CONF1_AUTO_MODE)) { | 311 | (old_fan_mode & ADM1031_CONF1_AUTO_MODE)) { |
308 | if (data->conf1 & ADM1031_CONF1_AUTO_MODE) { | 312 | if (data->conf1 & ADM1031_CONF1_AUTO_MODE) { |
309 | /* Switch to Auto Fan Mode | 313 | /* |
314 | * Switch to Auto Fan Mode | ||
310 | * Save PWM registers | 315 | * Save PWM registers |
311 | * Set PWM registers to 33% Both */ | 316 | * Set PWM registers to 33% Both |
317 | */ | ||
312 | data->old_pwm[0] = data->pwm[0]; | 318 | data->old_pwm[0] = data->pwm[0]; |
313 | data->old_pwm[1] = data->pwm[1]; | 319 | data->old_pwm[1] = data->pwm[1]; |
314 | adm1031_write_value(client, ADM1031_REG_PWM, 0x55); | 320 | adm1031_write_value(client, ADM1031_REG_PWM, 0x55); |
@@ -1131,19 +1137,8 @@ static struct adm1031_data *adm1031_update_device(struct device *dev) | |||
1131 | return data; | 1137 | return data; |
1132 | } | 1138 | } |
1133 | 1139 | ||
1134 | static int __init sensors_adm1031_init(void) | 1140 | module_i2c_driver(adm1031_driver); |
1135 | { | ||
1136 | return i2c_add_driver(&adm1031_driver); | ||
1137 | } | ||
1138 | |||
1139 | static void __exit sensors_adm1031_exit(void) | ||
1140 | { | ||
1141 | i2c_del_driver(&adm1031_driver); | ||
1142 | } | ||
1143 | 1141 | ||
1144 | MODULE_AUTHOR("Alexandre d'Alton <alex@alexdalton.org>"); | 1142 | MODULE_AUTHOR("Alexandre d'Alton <alex@alexdalton.org>"); |
1145 | MODULE_DESCRIPTION("ADM1031/ADM1030 driver"); | 1143 | MODULE_DESCRIPTION("ADM1031/ADM1030 driver"); |
1146 | MODULE_LICENSE("GPL"); | 1144 | MODULE_LICENSE("GPL"); |
1147 | |||
1148 | module_init(sensors_adm1031_init); | ||
1149 | module_exit(sensors_adm1031_exit); | ||