lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241109-b4-max17042-v1-3-9e2b07e54e76@gmail.com>
Date: Sat, 09 Nov 2024 15:44:35 +0300
From: Dzmitry Sankouski <dsankouski@...il.com>
To: Hans de Goede <hdegoede@...hat.com>, 
 Krzysztof Kozlowski <krzk@...nel.org>, 
 Marek Szyprowski <m.szyprowski@...sung.com>, 
 Sebastian Krzyszkowiak <sebastian.krzyszkowiak@...i.sm>, 
 Purism Kernel Team <kernel@...i.sm>, Sebastian Reichel <sre@...nel.org>, 
 Rob Herring <robh@...nel.org>, Conor Dooley <conor+dt@...nel.org>, 
 Alim Akhtar <alim.akhtar@...sung.com>, Shawn Guo <shawnguo@...nel.org>, 
 Sascha Hauer <s.hauer@...gutronix.de>, 
 Pengutronix Kernel Team <kernel@...gutronix.de>, 
 Fabio Estevam <festevam@...il.com>, Bjorn Andersson <andersson@...nel.org>, 
 Konrad Dybcio <konradybcio@...nel.org>
Cc: linux-pm@...r.kernel.org, devicetree@...r.kernel.org, 
 linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org, 
 linux-samsung-soc@...r.kernel.org, imx@...ts.linux.dev, 
 linux-arm-msm@...r.kernel.org, Dzmitry Sankouski <dsankouski@...il.com>
Subject: [PATCH 3/4] power: supply: max17042: use microvolts for voltage
 comparison

Do not convert VCELL register value from uV to mV to compare
with vmin/vmax. Rather use uV for vim/vmax, since that's a
standard measure unit in power supply drivers.

Convert "maxim,dead-volt" and "maxim,over-volt" to uV.

Signed-off-by: Dzmitry Sankouski <dsankouski@...il.com>
---
 Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml | 2 +-
 arch/arm/boot/dts/samsung/exynos4210-i9100.dts                     | 2 +-
 arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi                     | 2 +-
 arch/arm/boot/dts/samsung/exynos4412-midas.dtsi                    | 2 +-
 arch/arm/boot/dts/samsung/exynos4412-p4note.dtsi                   | 2 +-
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi                  | 2 +-
 arch/arm64/boot/dts/qcom/msm8916-motorola-harpia.dts               | 4 ++--
 arch/arm64/boot/dts/qcom/msm8916-motorola-osprey.dts               | 4 ++--
 arch/arm64/boot/dts/qcom/msm8916-motorola-surnia.dts               | 4 ++--
 arch/arm64/boot/dts/qcom/msm8916-samsung-gt5-common.dtsi           | 2 +-
 drivers/power/supply/max17042_battery.c                            | 4 ----
 11 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
index e98ffdad1ec3..d1ad597e0837 100644
--- a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
+++ b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
@@ -83,7 +83,7 @@ examples:
         reg = <0x36>;
         maxim,rsns-microohm = <10000>;
         maxim,over-heat-temp = <600>;
-        maxim,over-volt = <4300>;
+        maxim,over-volt = <4300000>;
         shared-irq;
       };
     };
diff --git a/arch/arm/boot/dts/samsung/exynos4210-i9100.dts b/arch/arm/boot/dts/samsung/exynos4210-i9100.dts
index 0d8495792a70..0ca755160bef 100644
--- a/arch/arm/boot/dts/samsung/exynos4210-i9100.dts
+++ b/arch/arm/boot/dts/samsung/exynos4210-i9100.dts
@@ -150,7 +150,7 @@ battery@36 {
 
 			reg = <0x36>;
 			maxim,over-heat-temp = <700>;
-			maxim,over-volt = <4500>;
+			maxim,over-volt = <4500000>;
 		};
 	};
 
diff --git a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi
index 9bc05961577d..758bfc10826f 100644
--- a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi
+++ b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi
@@ -186,7 +186,7 @@ fuel-gauge@36 {
 			pinctrl-0 = <&max77693_fuel_irq>;
 
 			maxim,over-heat-temp = <500>;
-			maxim,over-volt = <4500>;
+			maxim,over-volt = <450000>;
 		};
 	};
 
diff --git a/arch/arm/boot/dts/samsung/exynos4412-midas.dtsi b/arch/arm/boot/dts/samsung/exynos4412-midas.dtsi
index 3d5aace668dc..c744907b7c42 100644
--- a/arch/arm/boot/dts/samsung/exynos4412-midas.dtsi
+++ b/arch/arm/boot/dts/samsung/exynos4412-midas.dtsi
@@ -263,7 +263,7 @@ fuel-gauge@36 {
 			reg = <0x36>;
 
 			maxim,over-heat-temp = <700>;
-			maxim,over-volt = <4500>;
+			maxim,over-volt = <4500000>;
 		};
 	};
 
diff --git a/arch/arm/boot/dts/samsung/exynos4412-p4note.dtsi b/arch/arm/boot/dts/samsung/exynos4412-p4note.dtsi
index 28a605802733..3d52aa25c83c 100644
--- a/arch/arm/boot/dts/samsung/exynos4412-p4note.dtsi
+++ b/arch/arm/boot/dts/samsung/exynos4412-p4note.dtsi
@@ -175,7 +175,7 @@ fuel-gauge@36 {
 			interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
 			maxim,rsns-microohm = <10000>;
 			maxim,over-heat-temp = <600>;
-			maxim,over-volt = <4300>;
+			maxim,over-volt = <4300000>;
 		};
 	};
 
diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index 1b39514d5c12..90beefaa644f 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -1141,7 +1141,7 @@ bat: fuel-gauge@36 {
 		pinctrl-0 = <&pinctrl_gauge>;
 		power-supplies = <&bq25895>;
 		maxim,over-heat-temp = <700>;
-		maxim,over-volt = <4500>;
+		maxim,over-volt = <4500000>;
 		maxim,rsns-microohm = <5000>;
 	};
 
diff --git a/arch/arm64/boot/dts/qcom/msm8916-motorola-harpia.dts b/arch/arm64/boot/dts/qcom/msm8916-motorola-harpia.dts
index 8380451ebbf6..a02ece82ff5b 100644
--- a/arch/arm64/boot/dts/qcom/msm8916-motorola-harpia.dts
+++ b/arch/arm64/boot/dts/qcom/msm8916-motorola-harpia.dts
@@ -25,8 +25,8 @@ battery@36 {
 		maxim,rsns-microohm = <10000>;
 		maxim,over-heat-temp = <600>;
 		maxim,cold-temp = <(-200)>;
-		maxim,dead-volt = <3200>;
-		maxim,over-volt = <4500>;
+		maxim,dead-volt = <3200000>;
+		maxim,over-volt = <4500000>;
 	};
 
 	/* charger@6b */
diff --git a/arch/arm64/boot/dts/qcom/msm8916-motorola-osprey.dts b/arch/arm64/boot/dts/qcom/msm8916-motorola-osprey.dts
index ec5589fc69bd..f567b7ffb613 100644
--- a/arch/arm64/boot/dts/qcom/msm8916-motorola-osprey.dts
+++ b/arch/arm64/boot/dts/qcom/msm8916-motorola-osprey.dts
@@ -36,8 +36,8 @@ battery@36 {
 		maxim,rsns-microohm = <10000>;
 		maxim,over-heat-temp = <600>;
 		maxim,cold-temp = <(-200)>;
-		maxim,dead-volt = <3200>;
-		maxim,over-volt = <4500>;
+		maxim,dead-volt = <3200000>;
+		maxim,over-volt = <4500000>;
 
 	};
 };
diff --git a/arch/arm64/boot/dts/qcom/msm8916-motorola-surnia.dts b/arch/arm64/boot/dts/qcom/msm8916-motorola-surnia.dts
index eecf78ba45bb..45ddd17243e7 100644
--- a/arch/arm64/boot/dts/qcom/msm8916-motorola-surnia.dts
+++ b/arch/arm64/boot/dts/qcom/msm8916-motorola-surnia.dts
@@ -25,8 +25,8 @@ battery@36 {
 		maxim,rsns-microohm = <10000>;
 		maxim,over-heat-temp = <600>;
 		maxim,cold-temp = <(-200)>;
-		maxim,dead-volt = <3200>;
-		maxim,over-volt = <4500>;
+		maxim,dead-volt = <3200000>;
+		maxim,over-volt = <4500000>;
 
 	};
 };
diff --git a/arch/arm64/boot/dts/qcom/msm8916-samsung-gt5-common.dtsi b/arch/arm64/boot/dts/qcom/msm8916-samsung-gt5-common.dtsi
index fbd2caf405d5..2c387c8b6344 100644
--- a/arch/arm64/boot/dts/qcom/msm8916-samsung-gt5-common.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8916-samsung-gt5-common.dtsi
@@ -105,7 +105,7 @@ fuelgauge@36 {
 
 		maxim,rsns-microohm = <10000>;
 		maxim,over-heat-temp = <600>;
-		maxim,over-volt = <4400>;
+		maxim,over-volt = <4400000>;
 
 		interrupt-parent = <&tlmm>;
 		interrupts = <121 IRQ_TYPE_EDGE_FALLING>;
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index f3d89d4d5c42..ea212cb10360 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -182,8 +182,6 @@ static int max17042_get_battery_health(struct max17042_chip *chip, int *health)
 
 	/* bits [0-3] unused */
 	vavg = val * 625 / 8;
-	/* Convert to millivolts */
-	vavg /= 1000;
 
 	ret = regmap_read(chip->regmap, MAX17042_VCELL, &val);
 	if (ret < 0)
@@ -191,8 +189,6 @@ static int max17042_get_battery_health(struct max17042_chip *chip, int *health)
 
 	/* bits [0-3] unused */
 	vbatt = val * 625 / 8;
-	/* Convert to millivolts */
-	vbatt /= 1000;
 
 	if (vavg < chip->pdata->vmin) {
 		*health = POWER_SUPPLY_HEALTH_DEAD;

-- 
2.39.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ