diff options
author | Nikolaus Schulz <mail@microschulz.de> | 2012-02-28 16:15:51 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-02-28 17:39:47 -0500 |
commit | 331255d35d6f517020485aee38dbb8b8dfaa1642 (patch) | |
tree | a36b477d0aeae0d8ebc74439ffa113df35340c3a /drivers/hwmon/f75375s.c | |
parent | 6b21d18ed50c7d145220b0724ea7f2613abf0f95 (diff) |
hwmon: (f75375s) Fix writes to the pwm* attribute for the F75387
For the F75387, the register holding the current PWM duty cycle value is
r/o; changing it requires writing to the fan expect register instead.
Signed-off-by: Nikolaus Schulz <mail@microschulz.de>
[guenter.roeck@ericsson.com: Simplified function parameters]
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to 'drivers/hwmon/f75375s.c')
-rw-r--r-- | drivers/hwmon/f75375s.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c index 6bab2001ef3b..61cc9c396a98 100644 --- a/drivers/hwmon/f75375s.c +++ b/drivers/hwmon/f75375s.c | |||
@@ -178,6 +178,16 @@ static inline void f75375_write16(struct i2c_client *client, u8 reg, | |||
178 | i2c_smbus_write_byte_data(client, reg + 1, (value & 0xFF)); | 178 | i2c_smbus_write_byte_data(client, reg + 1, (value & 0xFF)); |
179 | } | 179 | } |
180 | 180 | ||
181 | static void f75375_write_pwm(struct i2c_client *client, int nr) | ||
182 | { | ||
183 | struct f75375_data *data = i2c_get_clientdata(client); | ||
184 | if (data->kind == f75387) | ||
185 | f75375_write16(client, F75375_REG_FAN_EXP(nr), data->pwm[nr]); | ||
186 | else | ||
187 | f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr), | ||
188 | data->pwm[nr]); | ||
189 | } | ||
190 | |||
181 | static struct f75375_data *f75375_update_device(struct device *dev) | 191 | static struct f75375_data *f75375_update_device(struct device *dev) |
182 | { | 192 | { |
183 | struct i2c_client *client = to_i2c_client(dev); | 193 | struct i2c_client *client = to_i2c_client(dev); |
@@ -309,7 +319,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, | |||
309 | 319 | ||
310 | mutex_lock(&data->update_lock); | 320 | mutex_lock(&data->update_lock); |
311 | data->pwm[nr] = SENSORS_LIMIT(val, 0, 255); | 321 | data->pwm[nr] = SENSORS_LIMIT(val, 0, 255); |
312 | f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr), data->pwm[nr]); | 322 | f75375_write_pwm(client, nr); |
313 | mutex_unlock(&data->update_lock); | 323 | mutex_unlock(&data->update_lock); |
314 | return count; | 324 | return count; |
315 | } | 325 | } |
@@ -374,8 +384,7 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val) | |||
374 | f75375_write8(client, F75375_REG_FAN_TIMER, fanmode); | 384 | f75375_write8(client, F75375_REG_FAN_TIMER, fanmode); |
375 | data->pwm_enable[nr] = val; | 385 | data->pwm_enable[nr] = val; |
376 | if (val == 0) | 386 | if (val == 0) |
377 | f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr), | 387 | f75375_write_pwm(client, nr); |
378 | data->pwm[nr]); | ||
379 | return 0; | 388 | return 0; |
380 | } | 389 | } |
381 | 390 | ||
@@ -759,8 +768,7 @@ static void f75375_init(struct i2c_client *client, struct f75375_data *data, | |||
759 | set_pwm_enable_direct(client, 1, f75375s_pdata->pwm_enable[1]); | 768 | set_pwm_enable_direct(client, 1, f75375s_pdata->pwm_enable[1]); |
760 | for (nr = 0; nr < 2; nr++) { | 769 | for (nr = 0; nr < 2; nr++) { |
761 | data->pwm[nr] = SENSORS_LIMIT(f75375s_pdata->pwm[nr], 0, 255); | 770 | data->pwm[nr] = SENSORS_LIMIT(f75375s_pdata->pwm[nr], 0, 255); |
762 | f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr), | 771 | f75375_write_pwm(client, nr); |
763 | data->pwm[nr]); | ||
764 | } | 772 | } |
765 | 773 | ||
766 | } | 774 | } |