linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: (gsc-hwmon) fix fan pwm temperature scaling
@ 2023-06-06 15:30 Tim Harvey
  2023-06-08 13:36 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Tim Harvey @ 2023-06-06 15:30 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: Guenter Roeck, Jean Delvare, Tim Harvey

The GSC fan pwm temperature register is in centidegrees celcius but the
Linux hwmon convention is to use milidegrees celcius. Fix the scaling.

Fixes: 3bce5377ef66 ("hwmon: Add Gateworks System Controller support")
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
 drivers/hwmon/gsc-hwmon.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/gsc-hwmon.c b/drivers/hwmon/gsc-hwmon.c
index 73e5d92b200b..1501ceb551e7 100644
--- a/drivers/hwmon/gsc-hwmon.c
+++ b/drivers/hwmon/gsc-hwmon.c
@@ -82,8 +82,8 @@ static ssize_t pwm_auto_point_temp_store(struct device *dev,
 	if (kstrtol(buf, 10, &temp))
 		return -EINVAL;
 
-	temp = clamp_val(temp, 0, 10000);
-	temp = DIV_ROUND_CLOSEST(temp, 10);
+	temp = clamp_val(temp, 0, 100000);
+	temp = DIV_ROUND_CLOSEST(temp, 100);
 
 	regs[0] = temp & 0xff;
 	regs[1] = (temp >> 8) & 0xff;
@@ -100,7 +100,7 @@ static ssize_t pwm_auto_point_pwm_show(struct device *dev,
 {
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
 
-	return sprintf(buf, "%d\n", 255 * (50 + (attr->index * 10)) / 100);
+	return sprintf(buf, "%d\n", 255 * (50 + (attr->index * 10)));
 }
 
 static SENSOR_DEVICE_ATTR_RO(pwm1_auto_point1_pwm, pwm_auto_point_pwm, 0);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hwmon: (gsc-hwmon) fix fan pwm temperature scaling
  2023-06-06 15:30 [PATCH] hwmon: (gsc-hwmon) fix fan pwm temperature scaling Tim Harvey
@ 2023-06-08 13:36 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2023-06-08 13:36 UTC (permalink / raw)
  To: Tim Harvey; +Cc: linux-kernel, linux-hwmon, Jean Delvare

On Tue, Jun 06, 2023 at 08:30:04AM -0700, Tim Harvey wrote:
> The GSC fan pwm temperature register is in centidegrees celcius but the
> Linux hwmon convention is to use milidegrees celcius. Fix the scaling.
> 
> Fixes: 3bce5377ef66 ("hwmon: Add Gateworks System Controller support")
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/gsc-hwmon.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwmon/gsc-hwmon.c b/drivers/hwmon/gsc-hwmon.c
> index 73e5d92b200b..1501ceb551e7 100644
> --- a/drivers/hwmon/gsc-hwmon.c
> +++ b/drivers/hwmon/gsc-hwmon.c
> @@ -82,8 +82,8 @@ static ssize_t pwm_auto_point_temp_store(struct device *dev,
>  	if (kstrtol(buf, 10, &temp))
>  		return -EINVAL;
>  
> -	temp = clamp_val(temp, 0, 10000);
> -	temp = DIV_ROUND_CLOSEST(temp, 10);
> +	temp = clamp_val(temp, 0, 100000);
> +	temp = DIV_ROUND_CLOSEST(temp, 100);
>  
>  	regs[0] = temp & 0xff;
>  	regs[1] = (temp >> 8) & 0xff;
> @@ -100,7 +100,7 @@ static ssize_t pwm_auto_point_pwm_show(struct device *dev,
>  {
>  	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
>  
> -	return sprintf(buf, "%d\n", 255 * (50 + (attr->index * 10)) / 100);
> +	return sprintf(buf, "%d\n", 255 * (50 + (attr->index * 10)));
>  }
>  
>  static SENSOR_DEVICE_ATTR_RO(pwm1_auto_point1_pwm, pwm_auto_point_pwm, 0);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-08 13:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-06 15:30 [PATCH] hwmon: (gsc-hwmon) fix fan pwm temperature scaling Tim Harvey
2023-06-08 13:36 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).