summaryrefslogtreecommitdiff
path: root/rust/helpers/helpers.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2025-08-30 17:38:51 -0700
committerGuenter Roeck <linux@roeck-us.net>2025-09-07 16:34:18 -0700
commit40a5da1ec101476dd6abb9cfa181f1b50dc24ad0 (patch)
treea1815c59d87404cb5a43eed9a44e21c082fd8fb5 /rust/helpers/helpers.c
parent8640f9ab1015741e22dff2dd1d6665ad024d5534 (diff)
hwmon: (ina238) Rework and simplify temperature calculations
The temperature register is 16 bit wide for all chips. The decimal point is at the same location (bit 7 = 1 degree C). That means we can use the resolution to calculate temperatures. Do that to simplify the code. There is only a single writeable temperature attribute, and it is very unlikely that the chips supported by this driver will ever require another one. That means checking for that attribute in the write function is unnecessary. Drop the check. Rename the write function from ina238_write_temp() to ina238_write_temp_max() to reflect that a single attribute is written. Also extend the accepted temperature value range to the range supported by the chip registers. Limiting the accepted value range to the temperature range supported by the chip would make it impossible to read an out-of-range limit from the chip and to write the same value back into it. This is undesirable, especially since the maximum temperature register does contain the maximum register value after a chip reset, not the temperature limit supported by the chip. Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # INA780 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'rust/helpers/helpers.c')
0 files changed, 0 insertions, 0 deletions