Commit ad77c3e1 authored by Guenter Roeck's avatar Guenter Roeck Committed by Guenter Roeck

hwmon: (w83627ehf) Disable setting DC mode for pwm2, pwm3 on NCT6776F

NCT6776F only supports pwm mode for pwm2 and pwm3. Return error if an attempt
is made to set those pwm channels to DC mode.
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Acked-by: default avatarJean Delvare <khali@linux-fr.org>
Cc: stable@vger.kernel.org # 3.0+
Signed-off-by: default avatarGuenter Roeck <guenter.roeck@ericsson.com>
parent 6edf3c30
...@@ -1319,6 +1319,7 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr, ...@@ -1319,6 +1319,7 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr,
{ {
struct w83627ehf_data *data = dev_get_drvdata(dev); struct w83627ehf_data *data = dev_get_drvdata(dev);
struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
struct w83627ehf_sio_data *sio_data = dev->platform_data;
int nr = sensor_attr->index; int nr = sensor_attr->index;
unsigned long val; unsigned long val;
int err; int err;
...@@ -1330,6 +1331,11 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr, ...@@ -1330,6 +1331,11 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr,
if (val > 1) if (val > 1)
return -EINVAL; return -EINVAL;
/* On NCT67766F, DC mode is only supported for pwm1 */
if (sio_data->kind == nct6776 && nr && val != 1)
return -EINVAL;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
reg = w83627ehf_read_value(data, W83627EHF_REG_PWM_ENABLE[nr]); reg = w83627ehf_read_value(data, W83627EHF_REG_PWM_ENABLE[nr]);
data->pwm_mode[nr] = val; data->pwm_mode[nr] = val;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment