diff options
Diffstat (limited to 'drivers/hwmon/max6639.c')
-rw-r--r-- | drivers/hwmon/max6639.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/hwmon/max6639.c b/drivers/hwmon/max6639.c index e10a092c603c..a6760bacd915 100644 --- a/drivers/hwmon/max6639.c +++ b/drivers/hwmon/max6639.c | |||
@@ -72,8 +72,8 @@ static unsigned short normal_i2c[] = { 0x2c, 0x2e, 0x2f, I2C_CLIENT_END }; | |||
72 | 72 | ||
73 | static const int rpm_ranges[] = { 2000, 4000, 8000, 16000 }; | 73 | static const int rpm_ranges[] = { 2000, 4000, 8000, 16000 }; |
74 | 74 | ||
75 | #define FAN_FROM_REG(val, div, rpm_range) ((val) == 0 ? -1 : \ | 75 | #define FAN_FROM_REG(val, rpm_range) ((val) == 0 || (val) == 255 ? \ |
76 | (val) == 255 ? 0 : (rpm_ranges[rpm_range] * 30) / ((div + 1) * (val))) | 76 | 0 : (rpm_ranges[rpm_range] * 30) / (val)) |
77 | #define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT((val) / 1000, 0, 255) | 77 | #define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT((val) / 1000, 0, 255) |
78 | 78 | ||
79 | /* | 79 | /* |
@@ -333,7 +333,7 @@ static ssize_t show_fan_input(struct device *dev, | |||
333 | return PTR_ERR(data); | 333 | return PTR_ERR(data); |
334 | 334 | ||
335 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index], | 335 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index], |
336 | data->ppr, data->rpm_range)); | 336 | data->rpm_range)); |
337 | } | 337 | } |
338 | 338 | ||
339 | static ssize_t show_alarm(struct device *dev, | 339 | static ssize_t show_alarm(struct device *dev, |
@@ -429,9 +429,9 @@ static int max6639_init_client(struct i2c_client *client) | |||
429 | struct max6639_data *data = i2c_get_clientdata(client); | 429 | struct max6639_data *data = i2c_get_clientdata(client); |
430 | struct max6639_platform_data *max6639_info = | 430 | struct max6639_platform_data *max6639_info = |
431 | client->dev.platform_data; | 431 | client->dev.platform_data; |
432 | int i = 0; | 432 | int i; |
433 | int rpm_range = 1; /* default: 4000 RPM */ | 433 | int rpm_range = 1; /* default: 4000 RPM */ |
434 | int err = 0; | 434 | int err; |
435 | 435 | ||
436 | /* Reset chip to default values, see below for GCONFIG setup */ | 436 | /* Reset chip to default values, see below for GCONFIG setup */ |
437 | err = i2c_smbus_write_byte_data(client, MAX6639_REG_GCONFIG, | 437 | err = i2c_smbus_write_byte_data(client, MAX6639_REG_GCONFIG, |
@@ -446,11 +446,6 @@ static int max6639_init_client(struct i2c_client *client) | |||
446 | else | 446 | else |
447 | data->ppr = 2; | 447 | data->ppr = 2; |
448 | data->ppr -= 1; | 448 | data->ppr -= 1; |
449 | err = i2c_smbus_write_byte_data(client, | ||
450 | MAX6639_REG_FAN_PPR(i), | ||
451 | data->ppr << 5); | ||
452 | if (err) | ||
453 | goto exit; | ||
454 | 449 | ||
455 | if (max6639_info) | 450 | if (max6639_info) |
456 | rpm_range = rpm_range_to_reg(max6639_info->rpm_range); | 451 | rpm_range = rpm_range_to_reg(max6639_info->rpm_range); |
@@ -458,6 +453,13 @@ static int max6639_init_client(struct i2c_client *client) | |||
458 | 453 | ||
459 | for (i = 0; i < 2; i++) { | 454 | for (i = 0; i < 2; i++) { |
460 | 455 | ||
456 | /* Set Fan pulse per revolution */ | ||
457 | err = i2c_smbus_write_byte_data(client, | ||
458 | MAX6639_REG_FAN_PPR(i), | ||
459 | data->ppr << 6); | ||
460 | if (err) | ||
461 | goto exit; | ||
462 | |||
461 | /* Fans config PWM, RPM */ | 463 | /* Fans config PWM, RPM */ |
462 | err = i2c_smbus_write_byte_data(client, | 464 | err = i2c_smbus_write_byte_data(client, |
463 | MAX6639_REG_FAN_CONFIG1(i), | 465 | MAX6639_REG_FAN_CONFIG1(i), |