Commit 2377e52f authored by Marcus Danielsson's avatar Marcus Danielsson Committed by Lee Jones

mfd: ab8500-sysctrl: Error check clean up

Add error checks to see if sysctrl was probed as it should.
If the sysctrl_dev is not set the return value is -EINVAL.
Signed-off-by: default avatarMarcus Danielsson <marcus.danielsson@stericsson.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Reviewed-by: default avatarMattias WALLIN <mattias.wallin@stericsson.com>
Tested-by: default avatarPer FORLIN <per.forlin@stericsson.com>
Acked-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 2cf64e26
...@@ -28,6 +28,11 @@ void ab8500_power_off(void) ...@@ -28,6 +28,11 @@ void ab8500_power_off(void)
struct power_supply *psy; struct power_supply *psy;
int ret; int ret;
if (sysctrl_dev == NULL) {
pr_err("%s: sysctrl not initialized\n", __func__);
return;
}
/* /*
* If we have a charger connected and we're powering off, * If we have a charger connected and we're powering off,
* reboot into charge-only mode. * reboot into charge-only mode.
...@@ -85,7 +90,7 @@ int ab8500_sysctrl_read(u16 reg, u8 *value) ...@@ -85,7 +90,7 @@ int ab8500_sysctrl_read(u16 reg, u8 *value)
u8 bank; u8 bank;
if (sysctrl_dev == NULL) if (sysctrl_dev == NULL)
return -EAGAIN; return -EINVAL;
bank = (reg >> 8); bank = (reg >> 8);
if (!valid_bank(bank)) if (!valid_bank(bank))
...@@ -101,7 +106,7 @@ int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value) ...@@ -101,7 +106,7 @@ int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value)
u8 bank; u8 bank;
if (sysctrl_dev == NULL) if (sysctrl_dev == NULL)
return -EAGAIN; return -EINVAL;
bank = (reg >> 8); bank = (reg >> 8);
if (!valid_bank(bank)) if (!valid_bank(bank))
...@@ -116,16 +121,18 @@ static int ab8500_sysctrl_probe(struct platform_device *pdev) ...@@ -116,16 +121,18 @@ static int ab8500_sysctrl_probe(struct platform_device *pdev)
{ {
struct ab8500_platform_data *plat; struct ab8500_platform_data *plat;
struct ab8500_sysctrl_platform_data *pdata; struct ab8500_sysctrl_platform_data *pdata;
int ret, i, j;
sysctrl_dev = &pdev->dev;
plat = dev_get_platdata(pdev->dev.parent); plat = dev_get_platdata(pdev->dev.parent);
if (!(plat && plat->sysctrl))
return -EINVAL;
if (plat->pm_power_off) if (plat->pm_power_off)
pm_power_off = ab8500_power_off; pm_power_off = ab8500_power_off;
pdata = plat->sysctrl; pdata = plat->sysctrl;
if (pdata) {
int ret, i, j;
for (i = AB8500_SYSCLKREQ1RFCLKBUF; for (i = AB8500_SYSCLKREQ1RFCLKBUF;
i <= AB8500_SYSCLKREQ8RFCLKBUF; i++) { i <= AB8500_SYSCLKREQ8RFCLKBUF; i++) {
...@@ -142,7 +149,6 @@ static int ab8500_sysctrl_probe(struct platform_device *pdev) ...@@ -142,7 +149,6 @@ static int ab8500_sysctrl_probe(struct platform_device *pdev)
"%d\n", j + 1, ret); "%d\n", j + 1, ret);
} }
} }
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment