power: supply: qti_battery_charger: change battery power supply registration

Userspace health HAL implementation waits for capacity property from
the battery power supply to be available before starting health HAL
service. This is needed to ensure the battery power supply device
is found by health HAL consistently. However, if the registration
of other power supply devices like USB and Wireless takes time and
health HAL initializes before that, Android battery monitor would
not be reading any properties from these power supply devices.

Fix this by registering the battery power supply after registering
USB and Wireless power supply. This would ensure that by the time
health HAL initializes, USB and Wireless power supply devices can
be available.

CRs-Fixed: 2998433
Change-Id: I3b71c86eaa774bdfcef3686109d7a25ac52be16c
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
This commit is contained in:
Subbaraman Narayanamurthy 2021-09-30 10:36:31 -07:00 committed by Anjelique Melendez
parent 721490d386
commit 0381948dcc

View File

@ -1192,15 +1192,6 @@ static int battery_chg_init_psy(struct battery_chg_dev *bcdev)
psy_cfg.drv_data = bcdev;
psy_cfg.of_node = bcdev->dev->of_node;
bcdev->psy_list[PSY_TYPE_BATTERY].psy =
devm_power_supply_register(bcdev->dev, &batt_psy_desc,
&psy_cfg);
if (IS_ERR(bcdev->psy_list[PSY_TYPE_BATTERY].psy)) {
rc = PTR_ERR(bcdev->psy_list[PSY_TYPE_BATTERY].psy);
pr_err("Failed to register battery power supply, rc=%d\n", rc);
return rc;
}
bcdev->psy_list[PSY_TYPE_USB].psy =
devm_power_supply_register(bcdev->dev, &usb_psy_desc, &psy_cfg);
if (IS_ERR(bcdev->psy_list[PSY_TYPE_USB].psy)) {
@ -1217,6 +1208,15 @@ static int battery_chg_init_psy(struct battery_chg_dev *bcdev)
return rc;
}
bcdev->psy_list[PSY_TYPE_BATTERY].psy =
devm_power_supply_register(bcdev->dev, &batt_psy_desc,
&psy_cfg);
if (IS_ERR(bcdev->psy_list[PSY_TYPE_BATTERY].psy)) {
rc = PTR_ERR(bcdev->psy_list[PSY_TYPE_BATTERY].psy);
pr_err("Failed to register battery power supply, rc=%d\n", rc);
return rc;
}
return 0;
}