[PATCH] power: supply: sbs-battery: return -EPROBE_DEFER when battery err

tongjian posted 1 patch 2 years, 7 months ago
drivers/power/supply/sbs-battery.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[PATCH] power: supply: sbs-battery: return -EPROBE_DEFER when battery err
Posted by tongjian 2 years, 7 months ago
Some batteries are not init complete when the first poweron, this cause
the devm_power_supply cannt be registered. we will return -EPROBE_DEFER
for probe retry.

Signed-off-by: tongjian <tongjian@huaqin.corp-partner.google.com>
---
 drivers/power/supply/sbs-battery.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index f84dbaab283a..0669c1bc1e4f 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -1187,7 +1187,8 @@ static int sbs_probe(struct i2c_client *client)
 skip_gpio:
 	/*
 	 * Before we register, we might need to make sure we can actually talk
-	 * to the battery.
+	 * to the battery. If a failure occurs when talking to the battery, we
+	 * will return -EPROBE_DEFER for probe retry.
 	 */
 	if (!(force_load || chip->gpio_detect)) {
 		union power_supply_propval val;
@@ -1195,7 +1196,7 @@ static int sbs_probe(struct i2c_client *client)
 		rc = sbs_get_battery_presence_and_health(
 				client, POWER_SUPPLY_PROP_PRESENT, &val);
 		if (rc < 0 || !val.intval)
-			return dev_err_probe(&client->dev, -ENODEV,
+			return dev_err_probe(&client->dev, -EPROBE_DEFER,
 					     "Failed to get present status\n");
 	}
 
-- 
2.34.1