Skip to content

Commit

Permalink
Merge pull request #91 from desowin/pwm-readback-fan2go-workaround
Browse files Browse the repository at this point in the history
[RFC] Update cached pwm values on pwm store
  • Loading branch information
Fred78290 authored Feb 23, 2024
2 parents ba813f1 + 3e7e79c commit 0ee35ed
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion nct6687.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,8 @@ static ssize_t store_pwm(struct device *dev, struct device_attribute *attr, cons
struct nct6687_data *data = dev_get_drvdata(dev);
int index = sattr->index;
unsigned long val;
int retry;
u16 readback;
u16 mode;
u8 bitMask;

Expand All @@ -809,7 +811,16 @@ static ssize_t store_pwm(struct device *dev, struct device_attribute *attr, cons
msleep(50);
nct6687_write(data, NCT6687_REG_PWM_WRITE(index), val);
nct6687_write(data, NCT6687_REG_FAN_PWM_COMMAND(index), NCT6687_FAN_CFG_DONE);
msleep(50);

for (retry = 0; retry < 20; retry++) {
msleep(50);

readback = nct6687_read(data, NCT6687_REG_PWM(index));
if (readback == val)
break;
}
data->pwm[index] = readback;
data->pwm_enable[index] = nct6687_get_pwm_enable(data, index);

mutex_unlock(&data->update_lock);

Expand Down

0 comments on commit 0ee35ed

Please sign in to comment.