From b2b1b9730df34d25d1488006bd9d4ba85ef0f807beedd317c9b922b4678f6477 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 7 Jan 2026 18:35:07 +0100 Subject: [PATCH] Fix PWM values scaling This closes boo#1255928. --- ...d-scaling-due-to-use-of-integer-type.patch | 28 +++++++++++++++++++ sensors.changes | 7 +++++ sensors.spec | 1 + 3 files changed, 36 insertions(+) create mode 100644 pwm-fix-bad-scaling-due-to-use-of-integer-type.patch diff --git a/pwm-fix-bad-scaling-due-to-use-of-integer-type.patch b/pwm-fix-bad-scaling-due-to-use-of-integer-type.patch new file mode 100644 index 0000000..bd9be64 --- /dev/null +++ b/pwm-fix-bad-scaling-due-to-use-of-integer-type.patch @@ -0,0 +1,28 @@ +From: xaizek +Date: Sat, 7 Jun 2025 13:33:11 +0300 +Subject: pwm: fix bad scaling due to use of integer type +References: boo#1255928 +Patch-mainline: No, pending PR https://github.com/hramrach/lm-sensors/pull/12 + +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. +--- + lib/sysfs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/sysfs.c b/lib/sysfs.c +index 39644f114..6e93b95cc 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/sensors.changes b/sensors.changes index 469ffcd..ae13e4d 100644 --- a/sensors.changes +++ b/sensors.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Jan 7 17:33:42 UTC 2026 - Jean Delvare + +- Add pwm-fix-bad-scaling-due-to-use-of-integer-type.patch which + fixes PWM values being scaled to 0-128% instead of 0-100% + (boo#1255928). + ------------------------------------------------------------------- Thu Oct 2 12:52:41 UTC 2025 - Andreas Schwab diff --git a/sensors.spec b/sensors.spec index 1c38913..734920a 100644 --- a/sensors.spec +++ b/sensors.spec @@ -38,6 +38,7 @@ Patch1: lm_sensors-3.1.1-build.patch Patch2: lm_sensors-3.0.0-sensord-separate.patch Patch3: lm_sensors-3.0.0-sysconfig_metadata.patch Patch4: lm_sensors-3.0.3-hint-at-kernel-extra-package.patch +Patch5: pwm-fix-bad-scaling-due-to-use-of-integer-type.patch Patch8: lm_sensors-3.5.0-libsensors-fix-soname.patch BuildRequires: bison BuildRequires: flex -- 2.51.1