mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-28 15:41:40 +00:00
power:pmic: prevent data abort for pmic bat command
This patch prevents data abort when pmic bat command is called on non-batery pmic device. Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> CC: Lukasz Majewski <l.majewski@samsung.com> CC: Minkyu Kang <mk7.kang@samsung.com>
This commit is contained in:
parent
f835c77fb7
commit
a6abaadcfa
1 changed files with 11 additions and 8 deletions
|
@ -184,18 +184,21 @@ int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||
if (argc < 4)
|
||||
return CMD_RET_USAGE;
|
||||
|
||||
if (!p->pbat) {
|
||||
printf("%s is not a battery\n", p->name);
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
if (strcmp(argv[3], "state") == 0)
|
||||
p->fg->fg_battery_check(p->pbat->fg, p);
|
||||
|
||||
if (strcmp(argv[3], "charge") == 0) {
|
||||
if (p->pbat) {
|
||||
printf("BAT: %s charging (ctrl+c to break)\n",
|
||||
p->name);
|
||||
if (p->low_power_mode)
|
||||
p->low_power_mode();
|
||||
if (p->pbat->battery_charge)
|
||||
p->pbat->battery_charge(p);
|
||||
}
|
||||
printf("BAT: %s charging (ctrl+c to break)\n",
|
||||
p->name);
|
||||
if (p->low_power_mode)
|
||||
p->low_power_mode();
|
||||
if (p->pbat->battery_charge)
|
||||
p->pbat->battery_charge(p);
|
||||
}
|
||||
|
||||
return CMD_RET_SUCCESS;
|
||||
|
|
Loading…
Reference in a new issue