Merge pull request #91 from desowin/pwm-readback-fan2go-workaround

[RFC] Update cached pwm values on pwm store
This commit is contained in:
Frederic BOLTZ 2024-02-23 09:55:00 +01:00 committed by GitHub
commit 0ee35ed954
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;
@ -809,8 +811,17 @@ 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);
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);
return count;