[PATCH 4/5] power: supply: bd71828: Do not hide errors

Matti Vaittinen <[email protected]>
Newsgroups org.kernel.vger.linux-pm,org.kernel.vger.linux-kernel
Message-ID <22db56cf35252d2d8f67828a0554e8daac7ae251.1786356145.git.mazziesaccount@gmail.com>
From: Matti Vaittinen <[email protected]>

The bd71828 reports success / continues operation even when some regmap
operations fail. This can lead incorrect data to be reported.

Return appropriate errors when operations fail.

Signed-off-by: Matti Vaittinen <[email protected]>
Fixes: 5bff79dad20a ("power: supply: Add bd718(15/28/78) charger driver")
---
 drivers/power/supply/bd71828-power.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/power/supply/bd71828-power.c b/drivers/power/supply/bd71828-power.c
index a564ad7210be..589e12225cb2 100644
--- a/drivers/power/supply/bd71828-power.c
+++ b/drivers/power/supply/bd71828-power.c
@@ -456,8 +456,10 @@ static int bd71828_charger_get_property(struct power_supply *psy,
 	switch (psp) {
 	case POWER_SUPPLY_PROP_ONLINE:
 		ret = get_chg_online(pwr, &online);
-		if (!ret)
-			val->intval = online;
+		if (ret)
+			return ret;
+
+		val->intval = online;
 		break;
 	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
 		ret = bd7182x_read16_himask(pwr, pwr->regs->vdcin,
@@ -1218,7 +1220,9 @@ static int bd71828_power_probe(struct platform_device *pdev)
 		return dev_err_probe(&pdev->dev, ret, "sense resistor missing\n");
 
 	dev_set_drvdata(&pdev->dev, pwr);
-	bd71828_init_hardware(pwr);
+	ret = bd71828_init_hardware(pwr);
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "hardware init failed\n");
 
 	bat_cfg.drv_data	= pwr;
 	bat_cfg.fwnode		= dev_fwnode(&pdev->dev);
-- 
2.55.0
signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmp5o2kACgkQeFA3/03a
ocWkegf/YusS2b56gPOHzH39KEPYRN7NDbriYotkZPFsK7i0B2/rnIjRVuCk+vbN
MinJaMD103QjsKeqf8K4U77m/cD1L58DBRLc/12A0Qi29/zEUe6OSuSIdlADRi+g
jFvzMhoSGn8kNKcszF43iPO56N7/9VBq8pNyMyxSehSRK0x0ID0JmO3KCEnnqiBE
zOfDJCWq6Abh8LFFg9hKCUHSvrqyY3HHY9L7qHkHwks8BRqT1n5rGU/hr82MeYEG
Wd/3taohyZHT/s+Z8Ew7jjDkJOgFq0Xv05RHZgdrXjZHKj7ep9Ndso8tHxuGsaPK
q7PYyEmqsiiIYCbg2fqwDVe99yx+ag==
=a2Co
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.