Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 294828
b: refs/heads/master
c: 72fea69
h: refs/heads/master
v: v3
  • Loading branch information
Jean Delvare authored and Jean Delvare committed Mar 23, 2012
1 parent 7c02e2e commit d9a6c45
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 941a956b0e387b21f385f486c34ef67576775cfc
refs/heads/master: 72fea694c4208d7ee1704a7dbccddd54af352cde
9 changes: 5 additions & 4 deletions trunk/drivers/hwmon/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1229,18 +1229,19 @@ config SENSORS_W83795
depends on I2C && EXPERIMENTAL
help
If you say yes here you get support for the Winbond W83795G and
W83795ADG hardware monitoring chip.
W83795ADG hardware monitoring chip, including manual fan speed
control.

This driver can also be built as a module. If so, the module
will be called w83795.

config SENSORS_W83795_FANCTRL
boolean "Include fan control support (DANGEROUS)"
boolean "Include automatic fan control support (DANGEROUS)"
depends on SENSORS_W83795 && EXPERIMENTAL
default n
help
If you say yes here, support for the both manual and automatic
fan control features will be included in the driver.
If you say yes here, support for automatic fan speed control
will be included in the driver.

This part of the code wasn't carefully reviewed and tested yet,
so enabling this option is strongly discouraged on production
Expand Down
38 changes: 24 additions & 14 deletions trunk/drivers/hwmon/w83795.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,14 @@ store_pwm_enable(struct device *dev, struct device_attribute *attr,
if (val < 1 || val > 2)
return -EINVAL;

#ifndef CONFIG_SENSORS_W83795_FANCTRL
if (val > 1) {
dev_warn(dev, "Automatic fan speed control support disabled\n");
dev_warn(dev, "Build with CONFIG_SENSORS_W83795_FANCTRL=y if you want it\n");
return -EOPNOTSUPP;
}
#endif

mutex_lock(&data->update_lock);
switch (val) {
case 1:
Expand Down Expand Up @@ -1625,18 +1633,18 @@ store_sf_setup(struct device *dev, struct device_attribute *attr,
#define SENSOR_ATTR_PWM(index) { \
SENSOR_ATTR_2(pwm##index, S_IWUSR | S_IRUGO, show_pwm, \
store_pwm, PWM_OUTPUT, index - 1), \
SENSOR_ATTR_2(pwm##index##_enable, S_IWUSR | S_IRUGO, \
show_pwm_enable, store_pwm_enable, NOT_USED, index - 1), \
SENSOR_ATTR_2(pwm##index##_mode, S_IRUGO, \
show_pwm_mode, NULL, NOT_USED, index - 1), \
SENSOR_ATTR_2(pwm##index##_freq, S_IWUSR | S_IRUGO, \
show_pwm, store_pwm, PWM_FREQ, index - 1), \
SENSOR_ATTR_2(pwm##index##_nonstop, S_IWUSR | S_IRUGO, \
show_pwm, store_pwm, PWM_NONSTOP, index - 1), \
SENSOR_ATTR_2(pwm##index##_start, S_IWUSR | S_IRUGO, \
show_pwm, store_pwm, PWM_START, index - 1), \
SENSOR_ATTR_2(pwm##index##_stop_time, S_IWUSR | S_IRUGO, \
show_pwm, store_pwm, PWM_STOP_TIME, index - 1), \
SENSOR_ATTR_2(pwm##index##_freq, S_IWUSR | S_IRUGO, \
show_pwm, store_pwm, PWM_FREQ, index - 1), \
SENSOR_ATTR_2(pwm##index##_enable, S_IWUSR | S_IRUGO, \
show_pwm_enable, store_pwm_enable, NOT_USED, index - 1), \
SENSOR_ATTR_2(pwm##index##_mode, S_IRUGO, \
show_pwm_mode, NULL, NOT_USED, index - 1), \
SENSOR_ATTR_2(fan##index##_target, S_IWUSR | S_IRUGO, \
show_fanin, store_fanin, FANIN_TARGET, index - 1) }

Expand Down Expand Up @@ -1953,6 +1961,14 @@ static int w83795_detect(struct i2c_client *client,
return 0;
}

#ifdef CONFIG_SENSORS_W83795_FANCTRL
#define NUM_PWM_ATTRIBUTES ARRAY_SIZE(w83795_pwm[0])
#define NUM_TEMP_ATTRIBUTES ARRAY_SIZE(w83795_temp[0])
#else
#define NUM_PWM_ATTRIBUTES 4
#define NUM_TEMP_ATTRIBUTES 8
#endif

static int w83795_handle_files(struct device *dev, int (*fn)(struct device *,
const struct device_attribute *))
{
Expand Down Expand Up @@ -2006,24 +2022,18 @@ static int w83795_handle_files(struct device *dev, int (*fn)(struct device *,
}
}

#ifdef CONFIG_SENSORS_W83795_FANCTRL
for (i = 0; i < data->has_pwm; i++) {
for (j = 0; j < ARRAY_SIZE(w83795_pwm[0]); j++) {
for (j = 0; j < NUM_PWM_ATTRIBUTES; j++) {
err = fn(dev, &w83795_pwm[i][j].dev_attr);
if (err)
return err;
}
}
#endif

for (i = 0; i < ARRAY_SIZE(w83795_temp); i++) {
if (!(data->has_temp & (1 << i)))
continue;
#ifdef CONFIG_SENSORS_W83795_FANCTRL
for (j = 0; j < ARRAY_SIZE(w83795_temp[0]); j++) {
#else
for (j = 0; j < 8; j++) {
#endif
for (j = 0; j < NUM_TEMP_ATTRIBUTES; j++) {
if (j == 7 && !data->enable_beep)
continue;
err = fn(dev, &w83795_temp[i][j].dev_attr);
Expand Down

0 comments on commit d9a6c45

Please sign in to comment.