summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Wilczek <p.wilczek@samsung.com>2013-09-26 14:43:35 +0200
committerTom Rini <trini@ti.com>2013-10-07 08:21:13 -0400
commita6abaadcfa69d02aafc51b22a39b8dbde1a7a76c (patch)
treefbb6c0217e746ba828231c90552db4b621f8adc7
parentf835c77fb7e57508ffe8d8ca3a092ee28add77b2 (diff)
downloadu-boot-imx-a6abaadcfa69d02aafc51b22a39b8dbde1a7a76c.zip
u-boot-imx-a6abaadcfa69d02aafc51b22a39b8dbde1a7a76c.tar.gz
u-boot-imx-a6abaadcfa69d02aafc51b22a39b8dbde1a7a76c.tar.bz2
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>
-rw-r--r--drivers/power/power_core.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/power/power_core.c b/drivers/power/power_core.c
index d79971b..29ccc83 100644
--- a/drivers/power/power_core.c
+++ b/drivers/power/power_core.c
@@ -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;