History

Merge tag 'hwmon-for-linus-v4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon fixes from Guenter Roeck: "A couple of patches for the aspeed pwm fan driver" * tag 'hwmon-for-linus-v4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (aspeed-pwm-tacho) make fan/pwm names start with index 1 hwmon: (aspeed-pwm-tacho) Call of_node_put() on a node not claimed hwmon: (aspeed-pwm-tacho) On read failure return -ETIMEDOUT hwmon: (aspeed-pwm-tacho) Select REGMAP

Linus Torvalds committed 9 years ago

Commit ea094f32 parents cc54874 5f348fa2 files · +36 −30Browse files

Unified · Split

2 files
  1. drivers/hwmon/Kconfig +1 −0
  2. drivers/hwmon/aspeed-pwm-tacho.c +35 −30
drivers/hwmon/Kconfig+1−0
@@ -343,6 +343,7 @@ config SENSORS_ASB100 · 342 unmodified lines
343343
344344 config SENSORS_ASPEED
345345 tristate "ASPEED AST2400/AST2500 PWM and Fan tach driver"
346+ select REGMAP
346347 help
347348 This driver provides support for ASPEED AST2400/AST2500 PWM
348349 and Fan Tacho controllers.
drivers/hwmon/aspeed-pwm-tacho.c+35−30
@@ -7,6 +7,7 @@ · 6 unmodified lines
77 */
88
99 #include <linux/clk.h>
10+#include <linux/errno.h>
1011 #include <linux/gpio/consumer.h>
1112 #include <linux/delay.h>
1213 #include <linux/hwmon.h>
@@ -494,7 +495,7 @@ static u32 aspeed_get_fan_tach_ch_measure_period(struct aspeed_pwm_tacho_data · 481 unmodified lines
494495 return clk / (clk_unit * div_h * div_l * tacho_div * tacho_unit);
495496 }
496497
497−static u32 aspeed_get_fan_tach_ch_rpm(struct aspeed_pwm_tacho_data *priv,
498+static int aspeed_get_fan_tach_ch_rpm(struct aspeed_pwm_tacho_data *priv,
498499 u8 fan_tach_ch)
499500 {
500501 u32 raw_data, tach_div, clk_source, sec, val;
@@ -510,6 +511,9 @@ static u32 aspeed_get_fan_tach_ch_rpm(struct aspeed_pwm_tacho_data *priv, · 9 unmodified lines
510511 msleep(sec);
511512
512513 regmap_read(priv->regmap, ASPEED_PTCR_RESULT, &val);
514+ if (!(val & RESULT_STATUS_MASK))
515+ return -ETIMEDOUT;
516+
513517 raw_data = val & RESULT_VALUE_MASK;
514518 tach_div = priv->type_fan_tach_clock_division[type];
515519 tach_div = 0x4 << (tach_div * 2);
@@ -561,12 +565,14 @@ static ssize_t show_rpm(struct device *dev, struct device_attribute *attr, · 45 unmodified lines
561565 {
562566 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
563567 int index = sensor_attr->index;
564− u32 rpm;
568+ int rpm;
565569 struct aspeed_pwm_tacho_data *priv = dev_get_drvdata(dev);
566570
567571 rpm = aspeed_get_fan_tach_ch_rpm(priv, index);
572+ if (rpm < 0)
573+ return rpm;
568574
569− return sprintf(buf, "%u\n", rpm);
575+ return sprintf(buf, "%d\n", rpm);
570576 }
571577
572578 static umode_t pwm_is_visible(struct kobject *kobj,
@@ -591,24 +597,23 @@ static umode_t fan_dev_is_visible(struct kobject *kobj, · 18 unmodified lines
591597 return a->mode;
592598 }
593599
594−static SENSOR_DEVICE_ATTR(pwm0, 0644,
595− show_pwm, set_pwm, 0);
596600 static SENSOR_DEVICE_ATTR(pwm1, 0644,
597− show_pwm, set_pwm, 1);
601+ show_pwm, set_pwm, 0);
598602 static SENSOR_DEVICE_ATTR(pwm2, 0644,
599− show_pwm, set_pwm, 2);
603+ show_pwm, set_pwm, 1);
600604 static SENSOR_DEVICE_ATTR(pwm3, 0644,
601− show_pwm, set_pwm, 3);
605+ show_pwm, set_pwm, 2);
602606 static SENSOR_DEVICE_ATTR(pwm4, 0644,
603− show_pwm, set_pwm, 4);
607+ show_pwm, set_pwm, 3);
604608 static SENSOR_DEVICE_ATTR(pwm5, 0644,
605− show_pwm, set_pwm, 5);
609+ show_pwm, set_pwm, 4);
606610 static SENSOR_DEVICE_ATTR(pwm6, 0644,
607− show_pwm, set_pwm, 6);
611+ show_pwm, set_pwm, 5);
608612 static SENSOR_DEVICE_ATTR(pwm7, 0644,
613+ show_pwm, set_pwm, 6);
614+static SENSOR_DEVICE_ATTR(pwm8, 0644,
609615 show_pwm, set_pwm, 7);
610616 static struct attribute *pwm_dev_attrs[] = {
611− &sensor_dev_attr_pwm0.dev_attr.attr,
612617 &sensor_dev_attr_pwm1.dev_attr.attr,
613618 &sensor_dev_attr_pwm2.dev_attr.attr,
614619 &sensor_dev_attr_pwm3.dev_attr.attr,
@@ -616,6 +621,7 @@ static struct attribute *pwm_dev_attrs[] = { · 1 unmodified line
616621 &sensor_dev_attr_pwm5.dev_attr.attr,
617622 &sensor_dev_attr_pwm6.dev_attr.attr,
618623 &sensor_dev_attr_pwm7.dev_attr.attr,
624+ &sensor_dev_attr_pwm8.dev_attr.attr,
619625 NULL,
620626 };
621627
@@ -624,40 +630,39 @@ static const struct attribute_group pwm_dev_group = { · 2 unmodified lines
624630 .is_visible = pwm_is_visible,
625631 };
626632
627−static SENSOR_DEVICE_ATTR(fan0_input, 0444,
628− show_rpm, NULL, 0);
629633 static SENSOR_DEVICE_ATTR(fan1_input, 0444,
630− show_rpm, NULL, 1);
634+ show_rpm, NULL, 0);
631635 static SENSOR_DEVICE_ATTR(fan2_input, 0444,
632− show_rpm, NULL, 2);
636+ show_rpm, NULL, 1);
633637 static SENSOR_DEVICE_ATTR(fan3_input, 0444,
634− show_rpm, NULL, 3);
638+ show_rpm, NULL, 2);
635639 static SENSOR_DEVICE_ATTR(fan4_input, 0444,
636− show_rpm, NULL, 4);
640+ show_rpm, NULL, 3);
637641 static SENSOR_DEVICE_ATTR(fan5_input, 0444,
638− show_rpm, NULL, 5);
642+ show_rpm, NULL, 4);
639643 static SENSOR_DEVICE_ATTR(fan6_input, 0444,
640− show_rpm, NULL, 6);
644+ show_rpm, NULL, 5);
641645 static SENSOR_DEVICE_ATTR(fan7_input, 0444,
642− show_rpm, NULL, 7);
646+ show_rpm, NULL, 6);
643647 static SENSOR_DEVICE_ATTR(fan8_input, 0444,
644− show_rpm, NULL, 8);
648+ show_rpm, NULL, 7);
645649 static SENSOR_DEVICE_ATTR(fan9_input, 0444,
646− show_rpm, NULL, 9);
650+ show_rpm, NULL, 8);
647651 static SENSOR_DEVICE_ATTR(fan10_input, 0444,
648− show_rpm, NULL, 10);
652+ show_rpm, NULL, 9);
649653 static SENSOR_DEVICE_ATTR(fan11_input, 0444,
650− show_rpm, NULL, 11);
654+ show_rpm, NULL, 10);
651655 static SENSOR_DEVICE_ATTR(fan12_input, 0444,
652− show_rpm, NULL, 12);
656+ show_rpm, NULL, 11);
653657 static SENSOR_DEVICE_ATTR(fan13_input, 0444,
654− show_rpm, NULL, 13);
658+ show_rpm, NULL, 12);
655659 static SENSOR_DEVICE_ATTR(fan14_input, 0444,
656− show_rpm, NULL, 14);
660+ show_rpm, NULL, 13);
657661 static SENSOR_DEVICE_ATTR(fan15_input, 0444,
662+ show_rpm, NULL, 14);
663+static SENSOR_DEVICE_ATTR(fan16_input, 0444,
658664 show_rpm, NULL, 15);
659665 static struct attribute *fan_dev_attrs[] = {
660− &sensor_dev_attr_fan0_input.dev_attr.attr,
661666 &sensor_dev_attr_fan1_input.dev_attr.attr,
662667 &sensor_dev_attr_fan2_input.dev_attr.attr,
663668 &sensor_dev_attr_fan3_input.dev_attr.attr,
@@ -673,6 +678,7 @@ static struct attribute *fan_dev_attrs[] = { · 9 unmodified lines
673678 &sensor_dev_attr_fan13_input.dev_attr.attr,
674679 &sensor_dev_attr_fan14_input.dev_attr.attr,
675680 &sensor_dev_attr_fan15_input.dev_attr.attr,
681+ &sensor_dev_attr_fan16_input.dev_attr.attr,
676682 NULL
677683 };
678684
@@ -802,7 +808,6 @@ static int aspeed_pwm_tacho_probe(struct platform_device *pdev) · 123 unmodified lines
802808 if (ret)
803809 return ret;
804810 }
805− of_node_put(np);
806811
807812 priv->groups[0] = &pwm_dev_group;
808813 priv->groups[1] = &fan_dev_group;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t