hwmon: (aspeed-pwm-tacho) On read failure return -ETIMEDOUT
Subsystems (2)
PATCH v3 1/1 hwmon: (aspeed-pwm-tacho) On read failure return -ETIMEDOUT
When the controller fails to provide an RPM reading within the alloted time; the driver returns -ETIMEDOUT and no file contents.
Signed-off-by Patrick Venture <[email protected]>
--- drivers/hwmon/aspeed-pwm-tacho.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/hwmon/aspeed-pwm-tacho.c +9 -3
@@ -7,6 +7,7 @@*/ #include <linux/clk.h> +#include <linux/errno.h> #include <linux/gpio/consumer.h> #include <linux/delay.h> #include <linux/hwmon.h>
@@ -494,7 +495,7 @@ static u32 aspeed_get_fan_tach_ch_measure_period(struct aspeed_pwm_tacho_datareturn clk / (clk_unit * div_h * div_l * tacho_div * tacho_unit); } -static u32 aspeed_get_fan_tach_ch_rpm (struct aspeed_pwm_tacho_data *priv, +static int aspeed_get_fan_tach_ch_rpm (struct aspeed_pwm_tacho_data *priv,u8 fan_tach_ch) {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,msleep (sec);regmap_read (priv->regmap,ASPEED_PTCR_RESULT , &val); +if (!(val &RESULT_STATUS_MASK )) +return -ETIMEDOUT ; + raw_data = val &RESULT_VALUE_MASK ; tach_div = priv->type_fan_tach_clock_division[type]; tach_div =0x4 << (tach_div *2 );
@@ -561,12 +565,14 @@ static ssize_t show_rpm(struct device *dev, struct device_attribute *attr, {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int index = sensor_attr->index; -u32 rpm; +int rpm;struct aspeed_pwm_tacho_data *priv =dev_get_drvdata (dev); rpm =aspeed_get_fan_tach_ch_rpm (priv, index); +if (rpm <0 ) +return rpm; -return sprintf (buf,"%u\n" , rpm); +return sprintf (buf,"%d\n" , rpm); } static umode_t pwm_is_visible(struct kobject *kobj,
Signature · 1 line
2.13.0.219.gdb65acc882-goog
Quoted 4 lines · Patrick Venture
When the controller fails to provide an RPM reading within the alloted time; the driver returns
-ETIMEDOUTand no file contents.Signed-off-by Patrick Venture <[email protected]>
Applied.
Thanks,
Guenter
Quoted 52 lines
--- drivers/hwmon/aspeed-pwm-tacho.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/hwmon/aspeed-pwm-tacho.c +9
-3@@ -7,6 +7,7 @@*/ #include <linux/clk.h> +#include <linux/errno.h> #include <linux/gpio/consumer.h> #include <linux/delay.h> #include <linux/hwmon.h> @@ -494,7 +495,7 @@ static u32 aspeed_get_fan_tach_ch_measure_period(struct aspeed_pwm_tacho_datareturn clk / (clk_unit * div_h * div_l * tacho_div * tacho_unit); } -static u32 aspeed_get_fan_tach_ch_rpm (struct aspeed_pwm_tacho_data *priv, +static int aspeed_get_fan_tach_ch_rpm (struct aspeed_pwm_tacho_data *priv,u8 fan_tach_ch) {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,msleep (sec);regmap_read (priv->regmap,ASPEED_PTCR_RESULT , &val); +if (!(val &RESULT_STATUS_MASK )) +return -ETIMEDOUT ; + raw_data = val &RESULT_VALUE_MASK ; tach_div = priv->type_fan_tach_clock_division[type]; tach_div =0x4 << (tach_div *2 );@@ -561,12 +565,14 @@ static ssize_t show_rpm(struct device *dev, struct device_attribute *attr, {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int index = sensor_attr->index; -u32 rpm; +int rpm;struct aspeed_pwm_tacho_data *priv =dev_get_drvdata (dev); rpm =aspeed_get_fan_tach_ch_rpm (priv, index); +if (rpm <0 ) +return rpm; -return sprintf (buf,"%u\n" , rpm); +return sprintf (buf,"%d\n" , rpm); } static umode_t pwm_is_visible(struct kobject *kobj,