Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754469AbbGEJsj (ORCPT ); Sun, 5 Jul 2015 05:48:39 -0400 Received: from gproxy7-pub.mail.unifiedlayer.com ([70.40.196.235]:46868 "HELO gproxy7-pub.mail.unifiedlayer.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751593AbbGEJsc (ORCPT ); Sun, 5 Jul 2015 05:48:32 -0400 X-Authority-Analysis: v=2.1 cv=ALgDonD0 c=1 sm=1 tr=0 a=J7Q474dc+DFtUK1fo70nSg==:117 a=J7Q474dc+DFtUK1fo70nSg==:17 a=cNaOj0WVAAAA:8 a=f5113yIGAAAA:8 a=dSbym95GAAAA:8 a=ZhRHZX3j7ZUA:10 a=tvnXkgGHczcA:10 a=zOBTXjUuO1YA:10 a=sl0HyEQVHg6VpehBPigA:9 From: Constantine Shulyupin To: Jean Delvare , Guenter Roeck , lm-sensors@lm-sensors.org (open list:HARDWARE MONITORING), linux-kernel@vger.kernel.org (open list) Cc: Constantine Shulyupin Subject: [PATCH v2] hwmon: (nct7802) Add pwm mode Date: Sun, 5 Jul 2015 01:41:31 +0300 Message-Id: <1436049691-20312-1-git-send-email-const@MakeLinux.com> X-Mailer: git-send-email 1.9.1 X-Identified-User: {1470:box668.bluehost.com:makelinu:makelinux.net} {sentby:smtp auth 84.228.198.137 authed with poster@makelinux.net} Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2438 Lines: 73 Introduced: show_pwm_mode, pwm1_mode, pwm2_mode, pwm2_mode --- Changelog: Fixed in v2: - used SENSOR_DEVICE_ATTR instead of SENSOR_DEVICE_ATTR_2 for pwmX_mode Signed-off-by: Constantine Shulyupin --- drivers/hwmon/nct7802.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/hwmon/nct7802.c b/drivers/hwmon/nct7802.c index 56b6f7b..a0d9010 100644 --- a/drivers/hwmon/nct7802.c +++ b/drivers/hwmon/nct7802.c @@ -102,6 +102,24 @@ static ssize_t store_temp_type(struct device *dev, return err ? : count; } +static ssize_t show_pwm_mode(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); + struct nct7802_data *data = dev_get_drvdata(dev); + unsigned int regval; + int ret; + + if (sattr->index > 1) + return sprintf(buf, "1\n"); + + ret = regmap_read(data->regmap, 0x5E, ®val); + if (ret < 0) + return ret; + + return sprintf(buf, "%u\n", !(regval & (1 << sattr->index))); +} + static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) { @@ -765,6 +783,11 @@ static SENSOR_DEVICE_ATTR_2(fan3_alarm, S_IRUGO, show_alarm, NULL, 0x1a, 2); static SENSOR_DEVICE_ATTR_2(fan3_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, 0x5b, 2); +/* 7.2.89 Fan Control Output Type */ +static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0); +static SENSOR_DEVICE_ATTR(pwm2_mode, S_IRUGO, show_pwm_mode, NULL, 1); +static SENSOR_DEVICE_ATTR(pwm3_mode, S_IRUGO, show_pwm_mode, NULL, 2); + /* 7.2.91... Fan Control Output Value */ static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, store_pwm, 0x60); static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm, store_pwm, 0x61); @@ -809,8 +832,11 @@ static struct attribute_group nct7802_fan_group = { }; static struct attribute *nct7802_pwm_attrs[] = { + &sensor_dev_attr_pwm1_mode.dev_attr.attr, &sensor_dev_attr_pwm1.dev_attr.attr, + &sensor_dev_attr_pwm2_mode.dev_attr.attr, &sensor_dev_attr_pwm2.dev_attr.attr, + &sensor_dev_attr_pwm3_mode.dev_attr.attr, &sensor_dev_attr_pwm3.dev_attr.attr, NULL }; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/