Skip to content

Commit

Permalink
Merge pull request #88 from SergeyMy/patch-5
Browse files Browse the repository at this point in the history
fixed "mode" to "enable"
  • Loading branch information
Fred78290 authored Feb 4, 2024
2 parents 5295dfa + 1c0b17a commit ba813f1
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions nct6687.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ enum kinds
nct6687
};

enum pwm_mode
enum pwm_enable
{
manual_mode = 1,
// There are multiple automatic modes, none of which is configurable by this module yet.
Expand Down Expand Up @@ -344,7 +344,7 @@ struct nct6687_data
bool _restoreDefaultFanControlRequired[NCT6687_NUM_REG_FAN];

u8 pwm[NCT6687_NUM_REG_PWM];
enum pwm_mode pwm_mode[NCT6687_NUM_REG_PWM];
enum pwm_enable pwm_enable[NCT6687_NUM_REG_PWM];

/* Remember extra register values over suspend/resume */
u8 hwm_cfg;
Expand Down Expand Up @@ -581,7 +581,7 @@ static void nct6687_update_voltage(struct nct6687_data *data)
pr_debug("nct6687_update_voltage\n");
}

static enum pwm_mode nct6687_get_pwm_mode(struct nct6687_data *data, int index)
static enum pwm_enable nct6687_get_pwm_enable(struct nct6687_data *data, int index)
{
u16 bitMask = 0x01 << index;
if (nct6687_read(data, NCT6687_REG_FAN_CTRL_MODE(index)) & bitMask)
Expand Down Expand Up @@ -609,7 +609,7 @@ static void nct6687_update_fans(struct nct6687_data *data)
for (i = 0; i < NCT6687_NUM_REG_PWM; i++)
{
data->pwm[i] = nct6687_read(data, NCT6687_REG_PWM(i));
data->pwm_mode[i] = nct6687_get_pwm_mode(data, i);
data->pwm_enable[i] = nct6687_get_pwm_enable(data, i);

pr_debug("nct6687_update_fans[%d], pwm=%d", i, data->pwm[i]);
}
Expand Down Expand Up @@ -816,15 +816,15 @@ static ssize_t store_pwm(struct device *dev, struct device_attribute *attr, cons
return count;
}

static ssize_t show_pwm_mode(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t show_pwm_enable(struct device *dev, struct device_attribute *attr, char *buf)
{
struct nct6687_data *data = nct6687_update_device(dev);
struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);

return sprintf(buf, "%d\n", data->pwm_mode[sattr->nr]);
return sprintf(buf, "%d\n", data->pwm_enable[sattr->nr]);
}

static ssize_t store_pwm_mode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
static ssize_t store_pwm_enable(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
struct nct6687_data *data = dev_get_drvdata(dev);
Expand Down Expand Up @@ -862,7 +862,7 @@ static ssize_t store_pwm_mode(struct device *dev, struct device_attribute *attr,
}

SENSOR_TEMPLATE(pwm, "pwm%d", S_IRUGO, show_pwm, store_pwm, 0);
SENSOR_TEMPLATE_2(pwm_mode, "pwm%d_enable", S_IRUGO, show_pwm_mode, store_pwm_mode, 0, 0);
SENSOR_TEMPLATE_2(pwm_enable, "pwm%d_enable", S_IRUGO, show_pwm_enable, store_pwm_enable, 0, 0);

static void nct6687_save_fan_control(struct nct6687_data *data, int index)
{
Expand Down Expand Up @@ -908,7 +908,7 @@ static umode_t nct6687_pwm_is_visible(struct kobject *kobj, struct attribute *at

static struct sensor_device_template *nct6687_attributes_pwm_template[] = {
&sensor_dev_template_pwm,
&sensor_dev_template_pwm_mode,
&sensor_dev_template_pwm_enable,
NULL,
};

Expand Down Expand Up @@ -1012,13 +1012,13 @@ static void nct6687_setup_pwm(struct nct6687_data *data)
{
data->_initialFanPwmCommand[i] = nct6687_read(data, NCT6687_REG_FAN_PWM_COMMAND(i));
data->pwm[i] = nct6687_read(data, NCT6687_REG_PWM(i));
data->pwm_mode[i] = nct6687_get_pwm_mode(data, i);
data->pwm_enable[i] = nct6687_get_pwm_enable(data, i);

pr_debug("nct6687_setup_pwm[%d], addr=%04X, pwm=%d, pwm_mode=%d, _initialFanPwmCommand=%d\n",
pr_debug("nct6687_setup_pwm[%d], addr=%04X, pwm=%d, pwm_enable=%d, _initialFanPwmCommand=%d\n",
i,
NCT6687_REG_FAN_PWM_COMMAND(i),
data->pwm[i],
data->pwm_mode[i],
data->pwm_enable[i],
data->_initialFanPwmCommand[i]);
}
}
Expand Down

0 comments on commit ba813f1

Please sign in to comment.