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
343 343
344config SENSORS_ASPEED344config SENSORS_ASPEED
345 tristate "ASPEED AST2400/AST2500 PWM and Fan tach driver"345 tristate "ASPEED AST2400/AST2500 PWM and Fan tach driver"
346 select REGMAP
346 help347 help
347 This driver provides support for ASPEED AST2400/AST2500 PWM348 This driver provides support for ASPEED AST2400/AST2500 PWM
348 and Fan Tacho controllers.349 and Fan Tacho controllers.
drivers/hwmon/aspeed-pwm-tacho.c+35−30
@@ -7,6 +7,7 @@ · 6 unmodified lines
7 */7 */
8 8
9#include <linux/clk.h>9#include <linux/clk.h>
10#include <linux/errno.h>
10#include <linux/gpio/consumer.h>11#include <linux/gpio/consumer.h>
11#include <linux/delay.h>12#include <linux/delay.h>
12#include <linux/hwmon.h>13#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
494 return clk / (clk_unit * div_h * div_l * tacho_div * tacho_unit);495 return clk / (clk_unit * div_h * div_l * tacho_div * tacho_unit);
495}496}
496 497
497static u32 aspeed_get_fan_tach_ch_rpm(struct aspeed_pwm_tacho_data *priv,498static int aspeed_get_fan_tach_ch_rpm(struct aspeed_pwm_tacho_data *priv,
498 u8 fan_tach_ch)499 u8 fan_tach_ch)
499{500{
500 u32 raw_data, tach_div, clk_source, sec, val;501 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
510 msleep(sec);511 msleep(sec);
511 512
512 regmap_read(priv->regmap, ASPEED_PTCR_RESULT, &val);513 regmap_read(priv->regmap, ASPEED_PTCR_RESULT, &val);
514 if (!(val & RESULT_STATUS_MASK))
515 return -ETIMEDOUT;
516
513 raw_data = val & RESULT_VALUE_MASK;517 raw_data = val & RESULT_VALUE_MASK;
514 tach_div = priv->type_fan_tach_clock_division[type];518 tach_div = priv->type_fan_tach_clock_division[type];
515 tach_div = 0x4 << (tach_div * 2);519 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
561{565{
562 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);566 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
563 int index = sensor_attr->index;567 int index = sensor_attr->index;
564 u32 rpm;568 int rpm;
565 struct aspeed_pwm_tacho_data *priv = dev_get_drvdata(dev);569 struct aspeed_pwm_tacho_data *priv = dev_get_drvdata(dev);
566 570
567 rpm = aspeed_get_fan_tach_ch_rpm(priv, index);571 rpm = aspeed_get_fan_tach_ch_rpm(priv, index);
572 if (rpm < 0)
573 return rpm;
568 574
569 return sprintf(buf, "%u\n", rpm);575 return sprintf(buf, "%d\n", rpm);
570}576}
571 577
572static umode_t pwm_is_visible(struct kobject *kobj,578static 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
591 return a->mode;597 return a->mode;
592}598}
593 599
594static SENSOR_DEVICE_ATTR(pwm0, 0644,
595 show_pwm, set_pwm, 0);
596static SENSOR_DEVICE_ATTR(pwm1, 0644,600static SENSOR_DEVICE_ATTR(pwm1, 0644,
597 show_pwm, set_pwm, 1);601 show_pwm, set_pwm, 0);
598static SENSOR_DEVICE_ATTR(pwm2, 0644,602static SENSOR_DEVICE_ATTR(pwm2, 0644,
599 show_pwm, set_pwm, 2);603 show_pwm, set_pwm, 1);
600static SENSOR_DEVICE_ATTR(pwm3, 0644,604static SENSOR_DEVICE_ATTR(pwm3, 0644,
601 show_pwm, set_pwm, 3);605 show_pwm, set_pwm, 2);
602static SENSOR_DEVICE_ATTR(pwm4, 0644,606static SENSOR_DEVICE_ATTR(pwm4, 0644,
603 show_pwm, set_pwm, 4);607 show_pwm, set_pwm, 3);
604static SENSOR_DEVICE_ATTR(pwm5, 0644,608static SENSOR_DEVICE_ATTR(pwm5, 0644,
605 show_pwm, set_pwm, 5);609 show_pwm, set_pwm, 4);
606static SENSOR_DEVICE_ATTR(pwm6, 0644,610static SENSOR_DEVICE_ATTR(pwm6, 0644,
607 show_pwm, set_pwm, 6);611 show_pwm, set_pwm, 5);
608static SENSOR_DEVICE_ATTR(pwm7, 0644,612static SENSOR_DEVICE_ATTR(pwm7, 0644,
613 show_pwm, set_pwm, 6);
614static SENSOR_DEVICE_ATTR(pwm8, 0644,
609 show_pwm, set_pwm, 7);615 show_pwm, set_pwm, 7);
610static struct attribute *pwm_dev_attrs[] = {616static struct attribute *pwm_dev_attrs[] = {
611 &sensor_dev_attr_pwm0.dev_attr.attr,
612 &sensor_dev_attr_pwm1.dev_attr.attr,617 &sensor_dev_attr_pwm1.dev_attr.attr,
613 &sensor_dev_attr_pwm2.dev_attr.attr,618 &sensor_dev_attr_pwm2.dev_attr.attr,
614 &sensor_dev_attr_pwm3.dev_attr.attr,619 &sensor_dev_attr_pwm3.dev_attr.attr,
@@ -616,6 +621,7 @@ static struct attribute *pwm_dev_attrs[] = { · 1 unmodified line
616 &sensor_dev_attr_pwm5.dev_attr.attr,621 &sensor_dev_attr_pwm5.dev_attr.attr,
617 &sensor_dev_attr_pwm6.dev_attr.attr,622 &sensor_dev_attr_pwm6.dev_attr.attr,
618 &sensor_dev_attr_pwm7.dev_attr.attr,623 &sensor_dev_attr_pwm7.dev_attr.attr,
624 &sensor_dev_attr_pwm8.dev_attr.attr,
619 NULL,625 NULL,
620};626};
621 627
@@ -624,40 +630,39 @@ static const struct attribute_group pwm_dev_group = { · 2 unmodified lines
624 .is_visible = pwm_is_visible,630 .is_visible = pwm_is_visible,
625};631};
626 632
627static SENSOR_DEVICE_ATTR(fan0_input, 0444,
628 show_rpm, NULL, 0);
629static SENSOR_DEVICE_ATTR(fan1_input, 0444,633static SENSOR_DEVICE_ATTR(fan1_input, 0444,
630 show_rpm, NULL, 1);634 show_rpm, NULL, 0);
631static SENSOR_DEVICE_ATTR(fan2_input, 0444,635static SENSOR_DEVICE_ATTR(fan2_input, 0444,
632 show_rpm, NULL, 2);636 show_rpm, NULL, 1);
633static SENSOR_DEVICE_ATTR(fan3_input, 0444,637static SENSOR_DEVICE_ATTR(fan3_input, 0444,
634 show_rpm, NULL, 3);638 show_rpm, NULL, 2);
635static SENSOR_DEVICE_ATTR(fan4_input, 0444,639static SENSOR_DEVICE_ATTR(fan4_input, 0444,
636 show_rpm, NULL, 4);640 show_rpm, NULL, 3);
637static SENSOR_DEVICE_ATTR(fan5_input, 0444,641static SENSOR_DEVICE_ATTR(fan5_input, 0444,
638 show_rpm, NULL, 5);642 show_rpm, NULL, 4);
639static SENSOR_DEVICE_ATTR(fan6_input, 0444,643static SENSOR_DEVICE_ATTR(fan6_input, 0444,
640 show_rpm, NULL, 6);644 show_rpm, NULL, 5);
641static SENSOR_DEVICE_ATTR(fan7_input, 0444,645static SENSOR_DEVICE_ATTR(fan7_input, 0444,
642 show_rpm, NULL, 7);646 show_rpm, NULL, 6);
643static SENSOR_DEVICE_ATTR(fan8_input, 0444,647static SENSOR_DEVICE_ATTR(fan8_input, 0444,
644 show_rpm, NULL, 8);648 show_rpm, NULL, 7);
645static SENSOR_DEVICE_ATTR(fan9_input, 0444,649static SENSOR_DEVICE_ATTR(fan9_input, 0444,
646 show_rpm, NULL, 9);650 show_rpm, NULL, 8);
647static SENSOR_DEVICE_ATTR(fan10_input, 0444,651static SENSOR_DEVICE_ATTR(fan10_input, 0444,
648 show_rpm, NULL, 10);652 show_rpm, NULL, 9);
649static SENSOR_DEVICE_ATTR(fan11_input, 0444,653static SENSOR_DEVICE_ATTR(fan11_input, 0444,
650 show_rpm, NULL, 11);654 show_rpm, NULL, 10);
651static SENSOR_DEVICE_ATTR(fan12_input, 0444,655static SENSOR_DEVICE_ATTR(fan12_input, 0444,
652 show_rpm, NULL, 12);656 show_rpm, NULL, 11);
653static SENSOR_DEVICE_ATTR(fan13_input, 0444,657static SENSOR_DEVICE_ATTR(fan13_input, 0444,
654 show_rpm, NULL, 13);658 show_rpm, NULL, 12);
655static SENSOR_DEVICE_ATTR(fan14_input, 0444,659static SENSOR_DEVICE_ATTR(fan14_input, 0444,
656 show_rpm, NULL, 14);660 show_rpm, NULL, 13);
657static SENSOR_DEVICE_ATTR(fan15_input, 0444,661static SENSOR_DEVICE_ATTR(fan15_input, 0444,
662 show_rpm, NULL, 14);
663static SENSOR_DEVICE_ATTR(fan16_input, 0444,
658 show_rpm, NULL, 15);664 show_rpm, NULL, 15);
659static struct attribute *fan_dev_attrs[] = {665static struct attribute *fan_dev_attrs[] = {
660 &sensor_dev_attr_fan0_input.dev_attr.attr,
661 &sensor_dev_attr_fan1_input.dev_attr.attr,666 &sensor_dev_attr_fan1_input.dev_attr.attr,
662 &sensor_dev_attr_fan2_input.dev_attr.attr,667 &sensor_dev_attr_fan2_input.dev_attr.attr,
663 &sensor_dev_attr_fan3_input.dev_attr.attr,668 &sensor_dev_attr_fan3_input.dev_attr.attr,
@@ -673,6 +678,7 @@ static struct attribute *fan_dev_attrs[] = { · 9 unmodified lines
673 &sensor_dev_attr_fan13_input.dev_attr.attr,678 &sensor_dev_attr_fan13_input.dev_attr.attr,
674 &sensor_dev_attr_fan14_input.dev_attr.attr,679 &sensor_dev_attr_fan14_input.dev_attr.attr,
675 &sensor_dev_attr_fan15_input.dev_attr.attr,680 &sensor_dev_attr_fan15_input.dev_attr.attr,
681 &sensor_dev_attr_fan16_input.dev_attr.attr,
676 NULL682 NULL
677};683};
678 684
@@ -802,7 +808,6 @@ static int aspeed_pwm_tacho_probe(struct platform_device *pdev) · 123 unmodified lines
802 if (ret)808 if (ret)
803 return ret;809 return ret;
804 }810 }
805 of_node_put(np);
806 811
807 priv->groups[0] = &pwm_dev_group;812 priv->groups[0] = &pwm_dev_group;
808 priv->groups[1] = &fan_dev_group;813 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