Skip to contentSkip to conversation

sc27xx-fuel-gauge: fix battery detect

PATCH Applied Stanislav Jakubek 4 participants 9 messages Nov 4, 2024 – Nov 11, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover sc27xx-fuel-gauge: fix battery detect

Marked this as V2, since the DTS (last) patch is a continuation of the 2nd patch from [1].

[1] https://lore.kernel.org/lkml/[email protected]/

Stanislav Jakubek (3):
dt-bindings: power: supply: sc27xx-fg: document deprecated
bat-detect-gpio
power: supply: sc27xx: Fix battery detect GPIO probe
arm64: dts: sprd: Fix battery-detect-gpios property

 .../devicetree/bindings/power/supply/sc27xx-fg.yaml    |  5 +++++
 arch/arm64/boot/dts/sprd/sc2731.dtsi                   |  2 +-
 drivers/power/supply/sc27xx_fuel_gauge.c               | 10 +++++++---
 3 files changed, 13 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/3 dt-bindings: power: supply: sc27xx-fg: document deprecated bat-detect-gpio

While the bindings have always used the correct 'battery-detect-gpios' property, the DTS and the Linux driver have been using the incorrect 'bat-detect-gpio' property. Document this property and mark it as deprecated.

---
Changes in V2:
- new patch

 .../devicetree/bindings/power/supply/sc27xx-fg.yaml          | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/power/supply/sc27xx-fg.yaml +5 -0
index 9108a2841caf..b10f155afe68 100644
@@ -27,6 +27,11 @@ properties:
   battery-detect-gpios:
     maxItems: 1
 
+  bat-detect-gpio:
+    maxItems: 1
+    deprecated: true
+    description: use battery-detect-gpios instead
+
   interrupts:
     maxItems: 1
 
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH v2 1/3] dt-bindings: power: supply: sc27xx-fg: document deprecated bat-detect-gpio

Quoted 4 lines · Stanislav Jakubek

While the bindings have always used the correct 'battery-detect-gpios' property, the DTS and the Linux driver have been using the incorrect 'bat-detect-gpio' property. Document this property and mark it as deprecated.

Well, I would just correct bindings instead - much less changes needed. Document 'bat-detect-gpios' (note the 's') and drop 'battery-detect-gpios'.

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH v2 1/3] dt-bindings: power: supply: sc27xx-fg: document deprecated bat-detect-gpio

Quoted 9 lines · Krzysztof Kozlowski
Quoted 4 lines · Stanislav Jakubek

While the bindings have always used the correct 'battery-detect-gpios' property, the DTS and the Linux driver have been using the incorrect 'bat-detect-gpio' property. Document this property and mark it as deprecated.

Well, I would just correct bindings instead - much less changes needed. Document 'bat-detect-gpios' (note the 's') and drop 'battery-detect-gpios'.

Hi Krzysztof,

this approach was preferred by one of the Spreadtrum maintainers [1], so I did it this way.

[1] https://lore.kernel.org/lkml/CAAfSe-uC+G8iEk_37vBr3+dQsv4a4tTTsz11hUguVRnU=r+4qQ@mail.gmail.com/

Regards,
Stanislav

Quoted 4 lines

Best regards,
Krzysztof

#4 lore raw

Re: [PATCH v2 1/3] dt-bindings: power: supply: sc27xx-fg: document deprecated bat-detect-gpio

Quoted 11 lines · Stanislav Jakubek
Quoted 9 lines · Krzysztof Kozlowski
Quoted 4 lines · Stanislav Jakubek

While the bindings have always used the correct 'battery-detect-gpios' property, the DTS and the Linux driver have been using the incorrect 'bat-detect-gpio' property. Document this property and mark it as deprecated.

Well, I would just correct bindings instead - much less changes needed. Document 'bat-detect-gpios' (note the 's') and drop 'battery-detect-gpios'.

Quoted 6 lines

Hi Krzysztof,

this approach was preferred by one of the Spreadtrum maintainers [1], so I did it this way.

[1] https://lore.kernel.org/lkml/CAAfSe-uC+G8iEk_37vBr3+dQsv4a4tTTsz11hUguVRnU=r+4qQ@mail.gmail.com/

Wow, really? But that advice affects users of DTS... OK, I don't want to stop your fix for that, so let's get this done:

(But I am not happy so I don;t want above ack to be used against me in the future :) )

Best regards,
Krzysztof

reviewer Reviewed-by on v2 1/3
#5 lore raw

Re: [PATCH v2 1/3] dt-bindings: power: supply: sc27xx-fg: document deprecated bat-detect-gpio

In reply to Stanislav Jakubek
Quoted 7 lines · Stanislav Jakubek

While the bindings have always used the correct 'battery-detect-gpios' property, the DTS and the Linux driver have been using the incorrect 'bat-detect-gpio' property. Document this property and mark it as deprecated.

Thanks,
Chunyan

Quoted 26 lines

---
Changes in V2:
- new patch

 .../devicetree/bindings/power/supply/sc27xx-fg.yaml          | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/power/supply/sc27xx-fg.yaml +5 -1
index 9108a2841caf..b10f155afe68 100644
@@ -27,6 +27,11 @@ properties:
   battery-detect-gpios:
     maxItems: 1
 
+  bat-detect-gpio:
+    maxItems: 1
+    deprecated: true
+    description: use battery-detect-gpios instead
+
   interrupts:
     maxItems: 1
 
--

2.43.0

#6 lore raw

PATCH v2 2/3 power: supply: sc27xx: Fix battery detect GPIO probe

In reply to Stanislav Jakubek

The DT bindings specify the property as 'battery-detect-gpios', add handling for it. Keep fallback to the deprecated 'bat-detect-gpio' property to keep compatibility with older DTS.

---
Changes in V2:
- new patch

 drivers/power/supply/sc27xx_fuel_gauge.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/power/supply/sc27xx_fuel_gauge.c +7 -3
index 426d423b935b..f36edc2ba708 100644
@@ -1183,10 +1183,14 @@ static int sc27xx_fgu_probe(struct platform_device *pdev)
 		return PTR_ERR(data->charge_chan);
 	}
 
-	data->gpiod = devm_gpiod_get(dev, "bat-detect", GPIOD_IN);
+	data->gpiod = devm_gpiod_get(dev, "battery-detect", GPIOD_IN);
 	if (IS_ERR(data->gpiod)) {
-		dev_err(dev, "failed to get battery detection GPIO\n");
-		return PTR_ERR(data->gpiod);
+		data->gpiod = devm_gpiod_get(dev, "bat-detect", GPIOD_IN);
+		if (IS_ERR(data->gpiod)) {
+			dev_err(dev, "failed to get battery detection GPIO\n");
+			return PTR_ERR(data->gpiod);
+		}
+		dev_warn(dev, "bat-detect is deprecated, please use battery-detect\n");
 	}
 
 	ret = gpiod_get_value_cansleep(data->gpiod);
Signature · 1 line
2.43.0
#7 lore raw

PATCH v2 3/3 arm64: dts: sprd: Fix battery-detect-gpios property

In reply to Stanislav Jakubek

According to DT bindings, the property is called 'battery-detect-gpios', not 'bat-detect-gpio'. Update the property as such.

---
Changes in V2:
- actually fix the property, as per bindings
- drop Baolin's R-b as the original patch was incorrect

 arch/arm64/boot/dts/sprd/sc2731.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/sprd/sc2731.dtsi +1 -1
index 12136e68dada..b8e70c337d40 100644
@@ -97,7 +97,7 @@ pmic_adc: adc@480 {
 		fuel-gauge@a00 {
 			compatible = "sprd,sc2731-fgu";
 			reg = <0xa00>;
-			bat-detect-gpio = <&pmic_eic 9 GPIO_ACTIVE_HIGH>;
+			battery-detect-gpios = <&pmic_eic 9 GPIO_ACTIVE_HIGH>;
 			io-channels = <&pmic_adc 3>, <&pmic_adc 6>;
 			io-channel-names = "bat-temp", "charge-vol";
 			monitored-battery = <&bat>;
Signature · 1 line
2.43.0
#8 lore raw

Re: (subset) [PATCH v2 0/3] sc27xx-fuel-gauge: fix battery detect

In reply to Stanislav Jakubek
Quoted 5 lines · Stanislav Jakubek

Marked this as V2, since the DTS (last) patch is a continuation of the 2nd patch from [1].

[1] https://lore.kernel.org/lkml/[email protected]/

Quoted 7 lines

Stanislav Jakubek (3):
dt-bindings: power: supply: sc27xx-fg: document deprecated
bat-detect-gpio
power: supply: sc27xx: Fix battery detect GPIO probe
arm64: dts: sprd: Fix battery-detect-gpios property

[...]

Applied, thanks!

[1/3] dt-bindings: power: supply: sc27xx-fg: document deprecated bat-detect-gpio

      commit: 2da0cb9f03bd9b726fa1b4accb210ef2ab439925
[2/3] power: supply: sc27xx: Fix battery detect GPIO probe
      commit: f29cc6d9a3917f98f1fb109f0c8841dd095f3fb0

Best regards,

Signature · 1 line
Sebastian Reichel <[email protected]>