sw5100_bms: Return error if GBMS sets float voltage below minimum

This case may happen if a device is connected to the charger with its
input path suspended, since GBMS will send -1 as the float voltage
value to sw5100_bms. sw5100_bms will set the value to the minimum
supported value, which is 3.6V. If VBAT is significantly higher, the
3.6V setting may cause electrical backfeed.

Thus, instead:
- Leave float voltage value as-is.
- Log an error.
- Return -EINVAL to the caller (GBMS).

Bug: 328534364
Signed-off-by: Andrei Ciubotariu <[email protected]>
(cherry picked from https://partner-android-review.googlesource.com/q/commit:bb363c10da46f6c4e54c2fb20089804fda4aeea7)
Merged-In: Icc082ee2ad2bccca9db7a3c0d4007b43c65ef161
Change-Id: Icc082ee2ad2bccca9db7a3c0d4007b43c65ef161
diff --git a/sw5100_bms.c b/sw5100_bms.c
index f6d6783..5740cbf 100644
--- a/sw5100_bms.c
+++ b/sw5100_bms.c
@@ -1215,8 +1215,12 @@
 		 * Float voltage setting = 3.6V + (DATA x 10mV)
 		 */
 		ivalue = pval->intval;
-		if (ivalue < CHGR_FLOAT_VOLTAGE_BASE)
-			val = 0;
+		if (ivalue < CHGR_FLOAT_VOLTAGE_BASE) {
+			pr_err("CONSTANT_CHARGE_VOLTAGE_MAX : %d (ivalue) < %d (base). Ignoring\n",
+				ivalue, CHGR_FLOAT_VOLTAGE_BASE);
+			rc = -EINVAL;
+			break;
+		}
 		else
 			val = (ivalue - CHGR_FLOAT_VOLTAGE_BASE) / 10000;