hwmon: (nct7802) Add pwm control
PATCH v2 1/1 hwmon: (nct7802) Add pwm control
Notes:
Some lines intentionally more than 80 characters because wrapping this lines decreases readability.
The patch was checked with scripts/checkpatch.pl --max-line-lengthˆ
--- drivers/hwmon/nct7802.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
drivers/hwmon/nct7802.c +47 -0
@@ -102,6 +102,36 @@ static ssize_t store_temp_type(struct device *dev,return err ? : count; } +static ssize_t show_pwm (struct device *dev,struct device_attribute *devattr,char *buf) +{ +int ret =-1 ; +struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr); +struct nct7802_data *data =dev_get_drvdata (dev); +unsigned int val =0 ; + + ret =regmap_read (data->regmap, attr->index, &val); +if (ret <0 ) +return ret; + + ret =sprintf (buf,"%d\n" , val); +return ret; +} + +static ssize_t store_u8 (struct device *dev,struct device_attribute *devattr, +const char *buf,size_t count) +{ +struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr); +struct nct7802_data *data =dev_get_drvdata (dev); +int err; +u8 val; + + err =kstrtou8 (buf,0 , &val); +if (err <0 ) +return err; + + err =regmap_write (data->regmap, attr->index, val); +return err ? : count; +}static int nct7802_read_temp (struct nct7802_data *data,u8 reg_temp,u8 reg_temp_low,int *temp)
@@ -735,6 +765,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.91... Fan Control Output Value */ +static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, store_u8, 0x60); +static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm, store_u8, 0x61); +static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, show_pwm, store_u8, 0x62); +static struct attribute *nct7802_fan_attrs[] = { &sensor_dev_attr_fan1_input.dev_attr.attr, &sensor_dev_attr_fan1_min.dev_attr.attr,
@@ -773,10 +808,22 @@ static struct attribute_group nct7802_fan_group = { .is_visible = nct7802_fan_is_visible, }; +static struct attribute *nct7802_pwm_attrs[] = { + &sensor_dev_attr_pwm1.dev_attr.attr, + &sensor_dev_attr_pwm2.dev_attr.attr, + &sensor_dev_attr_pwm3.dev_attr.attr, +NULL +}; + +static struct attribute_group nct7802_pwm_group = { + .attrs = nct7802_pwm_attrs, +}; +static const struct attribute_group *nct7802_groups[] = { &nct7802_temp_group, &nct7802_in_group, &nct7802_fan_group, + &nct7802_pwm_group,NULL };
Signature · 7 lines
1.9.1 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerHi Constantine,
Quoted 6 lines · Constantine Shulyupin
Notes:
Some lines intentionally more than 80 characters because wrapping this lines decreases readability.
The patch was checked withscripts/checkpatch.pl--max-line-lengthˆ
Please see section 2 of Documentation/SubmittingPatches for how to describe a patch. The above is not a patch description, and provides no value in the change log.
I got three copies of this patch, two of them marked as v2. I have no idea which is the newest one, or what you changed in v2. Above mentioned document also tells you how to describe patch versions.
Quoted 2 lines
Signed-off-by Constantine Shulyupin <[email protected]>---
FWIW, here would be the place to add notes.
drivers/hwmon/nct7802.c static ssize_t store_temp_type(struct device *dev, · line 105
Quoted 12 lines
drivers/hwmon/nct7802.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)drivers/hwmon/nct7802.c +1
-0@@ -102,6 +102,36 @@ static ssize_t store_temp_type(struct device *dev,return err ? : count; } +static ssize_t show_pwm (struct device *dev,struct device_attribute *devattr,char *buf)
Please split this line. It does not hurt readability at all. Besides, the same split is already done for other similar functions.
drivers/hwmon/nct7802.c static ssize_t store_temp_type(struct device *dev, · line 107
Quoted 2 lines
drivers/hwmon/nct7802.c +2
-0+{ +int ret =-1 ;
Unnecessary initialization.
drivers/hwmon/nct7802.c static ssize_t store_temp_type(struct device *dev, · line 110
Quoted 3 lines
drivers/hwmon/nct7802.c +3
-0+struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr); +struct nct7802_data *data =dev_get_drvdata (dev); +unsigned int val =0 ;
Unnecessary initialization.
Please arrange variable declarations length wise where possible.
drivers/hwmon/nct7802.c static ssize_t store_temp_type(struct device *dev, · line 117
Quoted 7 lines
drivers/hwmon/nct7802.c +7
-0+ + ret =regmap_read (data->regmap, attr->index, &val); +if (ret <0 ) +return ret; + + ret =sprintf (buf,"%d\n" , val); +return ret;
I think I already asked for
return sprintf(buf, "%d\n", val);
drivers/hwmon/nct7802.c static ssize_t store_temp_type(struct device *dev, · line 121
Quoted 4 lines
drivers/hwmon/nct7802.c +4
-0+} + +static ssize_t store_u8 (struct device *dev,struct device_attribute *devattr, +const char *buf,size_t count)
store_pwm, please.
Thanks,
Guenter
Quoted 42 lines
drivers/hwmon/nct7802.c +27
-0+{ +struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr); +struct nct7802_data *data =dev_get_drvdata (dev); +int err; +u8 val; + + err =kstrtou8 (buf,0 , &val); +if (err <0 ) +return err; + + err =regmap_write (data->regmap, attr->index, val); +return err ? : count; +}static int nct7802_read_temp (struct nct7802_data *data,u8 reg_temp,u8 reg_temp_low,int *temp)@@ -735,6 +765,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.91... Fan Control Output Value */ +static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, store_u8, 0x60); +static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm, store_u8, 0x61); +static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, show_pwm, store_u8, 0x62); +static struct attribute *nct7802_fan_attrs[] = { &sensor_dev_attr_fan1_input.dev_attr.attr, &sensor_dev_attr_fan1_min.dev_attr.attr,@@ -773,10 +808,22 @@ static struct attribute_group nct7802_fan_group = { .is_visible = nct7802_fan_is_visible, }; +static struct attribute *nct7802_pwm_attrs[] = { + &sensor_dev_attr_pwm1.dev_attr.attr, + &sensor_dev_attr_pwm2.dev_attr.attr, + &sensor_dev_attr_pwm3.dev_attr.attr, +NULL +}; + +static struct attribute_group nct7802_pwm_group = { + .attrs = nct7802_pwm_attrs,
drivers/hwmon/nct7802.c static struct attribute_group nct7802_fan_group = { · line 829
Quoted 10 lines
drivers/hwmon/nct7802.c +3
-0+}; +static const struct attribute_group *nct7802_groups[] = { &nct7802_temp_group, &nct7802_in_group, &nct7802_fan_group, + &nct7802_pwm_group,NULL };
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors