power_supply: smbcharger: use psy pointers to check init
The current driver uses a boolean flag psy_registered to track whether the power supplies are initialized. Instead check if the psy pointers are non null to ensure they are initialized. Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
This commit is contained in:
parent
638f324728
commit
e95affa994
1 changed files with 20 additions and 19 deletions
|
@ -245,7 +245,6 @@ struct smbchg_chip {
|
|||
int dc_psy_type;
|
||||
const char *bms_psy_name;
|
||||
const char *battery_psy_name;
|
||||
bool psy_registered;
|
||||
|
||||
struct smbchg_regulator otg_vreg;
|
||||
struct smbchg_regulator ext_otg_vreg;
|
||||
|
@ -2347,7 +2346,7 @@ static int dc_suspend_vote_cb(struct device *dev, int suspend,
|
|||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
if (chip->dc_psy_type != -EINVAL && chip->psy_registered)
|
||||
if (chip->dc_psy_type != -EINVAL && chip->dc_psy)
|
||||
power_supply_changed(chip->dc_psy);
|
||||
|
||||
return rc;
|
||||
|
@ -3597,7 +3596,8 @@ static void smbchg_external_power_changed(struct power_supply *psy)
|
|||
skip_current_for_non_sdp:
|
||||
smbchg_vfloat_adjust_check(chip);
|
||||
|
||||
power_supply_changed(chip->batt_psy);
|
||||
if (chip->batt_psy)
|
||||
power_supply_changed(chip->batt_psy);
|
||||
}
|
||||
|
||||
static int smbchg_otg_regulator_enable(struct regulator_dev *rdev)
|
||||
|
@ -4398,7 +4398,7 @@ static void smbchg_hvdcp_det_work(struct work_struct *work)
|
|||
}
|
||||
smbchg_change_usb_supply_type(chip,
|
||||
POWER_SUPPLY_TYPE_USB_HVDCP);
|
||||
if (chip->psy_registered)
|
||||
if (chip->batt_psy)
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_aicl_deglitch_wa_check(chip);
|
||||
}
|
||||
|
@ -5611,7 +5611,8 @@ static int smbchg_battery_set_property(struct power_supply *psy,
|
|||
break;
|
||||
case POWER_SUPPLY_PROP_CAPACITY:
|
||||
chip->fake_battery_soc = val->intval;
|
||||
power_supply_changed(chip->batt_psy);
|
||||
if (chip->batt_psy)
|
||||
power_supply_changed(chip->batt_psy);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL:
|
||||
smbchg_system_temp_level_set(chip, val->intval);
|
||||
|
@ -5885,7 +5886,7 @@ static irqreturn_t batt_hot_handler(int irq, void *_chip)
|
|||
chip->batt_hot = !!(reg & HOT_BAT_HARD_BIT);
|
||||
pr_smb(PR_INTERRUPT, "triggered: 0x%02x\n", reg);
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
if (chip->batt_psy)
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
smbchg_wipower_check(chip);
|
||||
|
@ -5903,7 +5904,7 @@ static irqreturn_t batt_cold_handler(int irq, void *_chip)
|
|||
chip->batt_cold = !!(reg & COLD_BAT_HARD_BIT);
|
||||
pr_smb(PR_INTERRUPT, "triggered: 0x%02x\n", reg);
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
if (chip->batt_psy)
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
smbchg_wipower_check(chip);
|
||||
|
@ -5921,7 +5922,7 @@ static irqreturn_t batt_warm_handler(int irq, void *_chip)
|
|||
chip->batt_warm = !!(reg & HOT_BAT_SOFT_BIT);
|
||||
pr_smb(PR_INTERRUPT, "triggered: 0x%02x\n", reg);
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
if (chip->batt_psy)
|
||||
power_supply_changed(chip->batt_psy);
|
||||
set_property_on_fg(chip, POWER_SUPPLY_PROP_HEALTH,
|
||||
get_prop_batt_health(chip));
|
||||
|
@ -5937,7 +5938,7 @@ static irqreturn_t batt_cool_handler(int irq, void *_chip)
|
|||
chip->batt_cool = !!(reg & COLD_BAT_SOFT_BIT);
|
||||
pr_smb(PR_INTERRUPT, "triggered: 0x%02x\n", reg);
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
if (chip->batt_psy)
|
||||
power_supply_changed(chip->batt_psy);
|
||||
set_property_on_fg(chip, POWER_SUPPLY_PROP_HEALTH,
|
||||
get_prop_batt_health(chip));
|
||||
|
@ -5952,7 +5953,7 @@ static irqreturn_t batt_pres_handler(int irq, void *_chip)
|
|||
smbchg_read(chip, ®, chip->bat_if_base + RT_STS, 1);
|
||||
chip->batt_present = !(reg & BAT_MISSING_BIT);
|
||||
pr_smb(PR_INTERRUPT, "triggered: 0x%02x\n", reg);
|
||||
if (chip->psy_registered)
|
||||
if (chip->batt_psy)
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
set_property_on_fg(chip, POWER_SUPPLY_PROP_HEALTH,
|
||||
|
@ -5987,7 +5988,7 @@ static irqreturn_t chg_error_handler(int irq, void *_chip)
|
|||
}
|
||||
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
if (chip->batt_psy)
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
smbchg_wipower_check(chip);
|
||||
|
@ -6000,7 +6001,7 @@ static irqreturn_t fastchg_handler(int irq, void *_chip)
|
|||
|
||||
pr_smb(PR_INTERRUPT, "p2f triggered\n");
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
if (chip->batt_psy)
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
smbchg_wipower_check(chip);
|
||||
|
@ -6029,7 +6030,7 @@ static irqreturn_t chg_term_handler(int irq, void *_chip)
|
|||
set_property_on_fg(chip, POWER_SUPPLY_PROP_CHARGE_DONE, 1);
|
||||
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
if (chip->batt_psy)
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
|
||||
|
@ -6045,7 +6046,7 @@ static irqreturn_t taper_handler(int irq, void *_chip)
|
|||
smbchg_read(chip, ®, chip->chgr_base + RT_STS, 1);
|
||||
pr_smb(PR_INTERRUPT, "triggered: 0x%02x\n", reg);
|
||||
smbchg_parallel_usb_taper(chip);
|
||||
if (chip->psy_registered)
|
||||
if (chip->batt_psy)
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
smbchg_wipower_check(chip);
|
||||
|
@ -6060,7 +6061,7 @@ static irqreturn_t recharge_handler(int irq, void *_chip)
|
|||
smbchg_read(chip, ®, chip->chgr_base + RT_STS, 1);
|
||||
pr_smb(PR_INTERRUPT, "triggered: 0x%02x\n", reg);
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
if (chip->batt_psy)
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
return IRQ_HANDLED;
|
||||
|
@ -6073,7 +6074,7 @@ static irqreturn_t wdog_timeout_handler(int irq, void *_chip)
|
|||
|
||||
smbchg_read(chip, ®, chip->misc_base + RT_STS, 1);
|
||||
pr_warn_ratelimited("wdog timeout rt_stat = 0x%02x\n", reg);
|
||||
if (chip->psy_registered)
|
||||
if (chip->batt_psy)
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
return IRQ_HANDLED;
|
||||
|
@ -6111,7 +6112,7 @@ static irqreturn_t dcin_uv_handler(int irq, void *_chip)
|
|||
if (chip->dc_present != dc_present) {
|
||||
/* dc changed */
|
||||
chip->dc_present = dc_present;
|
||||
if (chip->dc_psy_type != -EINVAL && chip->psy_registered)
|
||||
if (chip->dc_psy_type != -EINVAL && chip->batt_psy)
|
||||
power_supply_changed(chip->dc_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
smbchg_aicl_deglitch_wa_check(chip);
|
||||
|
@ -6388,7 +6389,7 @@ static irqreturn_t aicl_done_handler(int irq, void *_chip)
|
|||
if (usb_present)
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
|
||||
if (chip->aicl_complete)
|
||||
if (chip->aicl_complete && chip->batt_psy)
|
||||
power_supply_changed(chip->batt_psy);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
|
@ -8049,6 +8050,7 @@ static int smbchg_probe(struct platform_device *pdev)
|
|||
PTR_ERR(chip->batt_psy));
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (chip->dc_psy_type != -EINVAL) {
|
||||
chip->dc_psy_d.name = "dc";
|
||||
chip->dc_psy_d.type = chip->dc_psy_type;
|
||||
|
@ -8074,7 +8076,6 @@ static int smbchg_probe(struct platform_device *pdev)
|
|||
goto out;
|
||||
}
|
||||
}
|
||||
chip->psy_registered = true;
|
||||
|
||||
if (chip->cfg_chg_led_support &&
|
||||
chip->schg_version == QPNP_SCHG_LITE) {
|
||||
|
|
Loading…
Add table
Reference in a new issue