From: Guenter Roeck <linux@roeck-us.net>
To: Patrick Venture <venture@google.com>
Cc: joel@jms.id.au, jdelvare@suse.com, linux-hwmon@vger.kernel.org
Subject: Re: [v3] hwmon: (aspeed-pwm-tacho) On read failure return -ETIMEDOUT
Date: Tue, 30 May 2017 15:14:10 -0700 [thread overview]
Message-ID: <20170530221410.GA9755@roeck-us.net> (raw)
In-Reply-To: <20170530194201.4540-1-venture@google.com>
On Tue, May 30, 2017 at 12:42:01PM -0700, Patrick Venture wrote:
> 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 <venture@google.com>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/aspeed-pwm-tacho.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c
> index 48403a2115be..12b716b70ead 100644
> --- a/drivers/hwmon/aspeed-pwm-tacho.c
> +++ b/drivers/hwmon/aspeed-pwm-tacho.c
> @@ -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_data
> return 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,
prev parent reply other threads:[~2017-05-30 22:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-30 19:42 [PATCH v3] hwmon: (aspeed-pwm-tacho) On read failure return -ETIMEDOUT Patrick Venture
2017-05-30 22:14 ` Guenter Roeck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170530221410.GA9755@roeck-us.net \
--to=linux@roeck-us.net \
--cc=jdelvare@suse.com \
--cc=joel@jms.id.au \
--cc=linux-hwmon@vger.kernel.org \
--cc=venture@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox