From 62a955319152ce0595932789d10e955304213beb Mon Sep 17 00:00:00 2001 From: xaizek Date: Sat, 7 Jun 2025 13:33:11 +0300 Subject: [PATCH] pwm: fix bad scaling due to use of integer type This fixes commit c1a1f4ff206c0e6959c3e4d6b19ba27963076d5e ("pwm: Move scaling factor from sensors prog to library") which didn't account for return type of `get_type_scaling()` being `int` rather than `double` or `float`, so the scaling was done by a factor of 2 instead of 2.55, thus making the result off by quite a lot. ms: adjust test --- lib/sysfs.c | 2 +- prog/sensors/test/data/laptop.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sysfs.c b/lib/sysfs.c index 39644f11..6e93b95c 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -139,7 +139,7 @@ static int sysfs_foreach_busdev(const char *bus_type, const char *sensors_sysfs_mount = "/sys"; static -int get_type_scaling(sensors_subfeature_type type) +double get_type_scaling(sensors_subfeature_type type) { /* Multipliers for second class subfeatures that need their own multiplier */ diff --git a/prog/sensors/test/data/laptop.json b/prog/sensors/test/data/laptop.json index 7ed072e2..81a3839b 100644 --- a/prog/sensors/test/data/laptop.json +++ b/prog/sensors/test/data/laptop.json @@ -388,7 +388,7 @@ "crit": { "quantity": "temperature", "unit": "°C", - "value": 93.85 + "value": 93.84999999999999 }, "input": { "quantity": "temperature", @@ -399,7 +399,7 @@ "max": { "quantity": "temperature", "unit": "°C", - "value": 89.85 + "value": 89.84999999999999 }, "min": { "quantity": "temperature",