diff options
author | Jean Delvare <khali@linux-fr.org> | 2005-11-29 16:27:14 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-11-30 00:39:22 -0500 |
commit | 9632051963cb6e6f7412990f8b962209b9334e13 (patch) | |
tree | 1f1fe030107d06e4b43dbee90e95b374ccec7fc2 /drivers/hwmon/w83792d.c | |
parent | d2ef5ebb4c4fe141a82252d4db8d8521e6765c5a (diff) |
[PATCH] hwmon: w83792d fix unused fan pins
1. This patch add check for fan4,5,6,7 and do not create device file
if their pins are not configured as fan.
2. Fix the issue that can not set fan divisor to 128.
3. Fix the index out of bounds bug in w83792d_detect function.
Signed-off-by: Yuan Mu <ymu@winbond.com.tw>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hwmon/w83792d.c')
-rw-r--r-- | drivers/hwmon/w83792d.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 4be59dbb78c4..1ba072630361 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -193,6 +193,7 @@ static const u8 W83792D_REG_LEVELS[3][4] = { | |||
193 | 0xE2 } /* (bit3-0) SmartFanII: Fan3 Level 3 */ | 193 | 0xE2 } /* (bit3-0) SmartFanII: Fan3 Level 3 */ |
194 | }; | 194 | }; |
195 | 195 | ||
196 | #define W83792D_REG_GPIO_EN 0x1A | ||
196 | #define W83792D_REG_CONFIG 0x40 | 197 | #define W83792D_REG_CONFIG 0x40 |
197 | #define W83792D_REG_VID_FANDIV 0x47 | 198 | #define W83792D_REG_VID_FANDIV 0x47 |
198 | #define W83792D_REG_CHIPID 0x49 | 199 | #define W83792D_REG_CHIPID 0x49 |
@@ -257,7 +258,7 @@ DIV_TO_REG(long val) | |||
257 | { | 258 | { |
258 | int i; | 259 | int i; |
259 | val = SENSORS_LIMIT(val, 1, 128) >> 1; | 260 | val = SENSORS_LIMIT(val, 1, 128) >> 1; |
260 | for (i = 0; i < 6; i++) { | 261 | for (i = 0; i < 7; i++) { |
261 | if (val == 0) | 262 | if (val == 0) |
262 | break; | 263 | break; |
263 | val >>= 1; | 264 | val >>= 1; |
@@ -1282,8 +1283,8 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1282 | w83792d_init_client(new_client); | 1283 | w83792d_init_client(new_client); |
1283 | 1284 | ||
1284 | /* A few vars need to be filled upon startup */ | 1285 | /* A few vars need to be filled upon startup */ |
1285 | for (i = 1; i <= 7; i++) { | 1286 | for (i = 0; i < 7; i++) { |
1286 | data->fan_min[i - 1] = w83792d_read_value(new_client, | 1287 | data->fan_min[i] = w83792d_read_value(new_client, |
1287 | W83792D_REG_FAN_MIN[i]); | 1288 | W83792D_REG_FAN_MIN[i]); |
1288 | } | 1289 | } |
1289 | 1290 | ||
@@ -1306,10 +1307,20 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1306 | device_create_file_fan(new_client, 1); | 1307 | device_create_file_fan(new_client, 1); |
1307 | device_create_file_fan(new_client, 2); | 1308 | device_create_file_fan(new_client, 2); |
1308 | device_create_file_fan(new_client, 3); | 1309 | device_create_file_fan(new_client, 3); |
1309 | device_create_file_fan(new_client, 4); | 1310 | |
1310 | device_create_file_fan(new_client, 5); | 1311 | /* Read GPIO enable register to check if pins for fan 4,5 are used as |
1311 | device_create_file_fan(new_client, 6); | 1312 | GPIO */ |
1312 | device_create_file_fan(new_client, 7); | 1313 | val1 = w83792d_read_value(new_client, W83792D_REG_GPIO_EN); |
1314 | if (!(val1 & 0x40)) | ||
1315 | device_create_file_fan(new_client, 4); | ||
1316 | if (!(val1 & 0x20)) | ||
1317 | device_create_file_fan(new_client, 5); | ||
1318 | |||
1319 | val1 = w83792d_read_value(new_client, W83792D_REG_PIN); | ||
1320 | if (val1 & 0x40) | ||
1321 | device_create_file_fan(new_client, 6); | ||
1322 | if (val1 & 0x04) | ||
1323 | device_create_file_fan(new_client, 7); | ||
1313 | 1324 | ||
1314 | device_create_file_temp1(new_client); /* Temp1 */ | 1325 | device_create_file_temp1(new_client); /* Temp1 */ |
1315 | device_create_file_temp_add(new_client, 2); /* Temp2 */ | 1326 | device_create_file_temp_add(new_client, 2); /* Temp2 */ |