diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2016-01-11 11:29:15 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2016-01-11 15:58:01 -0800 |
commit | d258432fb2fbf1a5a4910dbc31aba99d04801268 (patch) | |
tree | 90dfb1eab214ba465913004e7630916331f68422 /drivers/staging/greybus/arche-apb-ctrl.c | |
parent | a7a794ec540c442999598cf16605ba7962aa3861 (diff) | |
download | op-kernel-dev-d258432fb2fbf1a5a4910dbc31aba99d04801268.zip op-kernel-dev-d258432fb2fbf1a5a4910dbc31aba99d04801268.tar.gz |
greybus: arche-apb: Do cleanup within apb_ctrl_init_seq() for error cases
Relying on apb_ctrl_cleanup() to do the cleanup for errors that occurred
within apb_ctrl_init_seq() isn't a very clean idea. Handle that
separately within apb_ctrl_init_seq().
This will clean apb_ctrl_cleanup() in later patches.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/arche-apb-ctrl.c')
-rw-r--r-- | drivers/staging/greybus/arche-apb-ctrl.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/staging/greybus/arche-apb-ctrl.c b/drivers/staging/greybus/arche-apb-ctrl.c index f83230d..859d22e 100644 --- a/drivers/staging/greybus/arche-apb-ctrl.c +++ b/drivers/staging/greybus/arche-apb-ctrl.c @@ -184,7 +184,7 @@ static int apb_ctrl_init_seq(struct platform_device *pdev, ret = regulator_enable(apb->vio); if (ret) { dev_err(dev, "failed to enable IO regulator\n"); - return ret; + goto out_vcore_disable; } } @@ -193,16 +193,27 @@ static int apb_ctrl_init_seq(struct platform_device *pdev, if (ret) { dev_err(dev, "Failed requesting bootret gpio %d\n", apb->boot_ret_gpio); - return ret; + goto out_vio_disable; } gpio_set_value(apb->boot_ret_gpio, 0); udelay(50); ret = devm_gpio_request_one(dev, apb->wake_detect_gpio, GPIOF_INIT_LOW, "wake detect"); - if (ret) + if (ret) { dev_err(dev, "Failed requesting wake_detect gpio %d\n", apb->wake_detect_gpio); + goto out_vio_disable; + } + + return 0; + +out_vio_disable: + if (!IS_ERR(apb->vio)) + regulator_disable(apb->vio); +out_vcore_disable: + if (!IS_ERR(apb->vcore)) + regulator_disable(apb->vcore); return ret; } @@ -311,7 +322,7 @@ int arche_apb_ctrl_probe(struct platform_device *pdev) if (ret) { dev_err(dev, "failed to set init state of control signal %d\n", ret); - goto exit; + return ret; } spin_lock_init(&apb->lock); @@ -332,7 +343,8 @@ int arche_apb_ctrl_probe(struct platform_device *pdev) "wake detect", apb); if (ret) { dev_err(dev, "failed to request wake detect IRQ\n"); - goto exit; + apb_ctrl_cleanup(apb); + return ret; } platform_set_drvdata(pdev, apb); @@ -341,10 +353,6 @@ int arche_apb_ctrl_probe(struct platform_device *pdev) dev_info(&pdev->dev, "Device registered successfully\n"); return 0; - -exit: - apb_ctrl_cleanup(apb); - return ret; } int arche_apb_ctrl_remove(struct platform_device *pdev) |