diff options
author | Viresh Kumar | 2016-01-11 06:59:12 +0100 |
---|---|---|
committer | Greg Kroah-Hartman | 2016-01-12 00:58:01 +0100 |
commit | dcf77c397918178af09b72f63145eed3fde788ba (patch) | |
tree | c5292e6249a5a6dbc88f478c39debac299a9dd8d /drivers/staging/greybus/arche-apb-ctrl.c | |
parent | greybus: arche-apb: devm_regulator_get() doesn't return NULL (diff) | |
download | kernel-qcow2-linux-dcf77c397918178af09b72f63145eed3fde788ba.tar.gz kernel-qcow2-linux-dcf77c397918178af09b72f63145eed3fde788ba.tar.xz kernel-qcow2-linux-dcf77c397918178af09b72f63145eed3fde788ba.zip |
greybus: arche-apb: NULL is a valid regulator
Since NULL could in theory be a valid regulator we ought to check for
IS_ERR() rather than for NULL. In practice this is unlikely to be an
issue but it's better for neatness.
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 | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/staging/greybus/arche-apb-ctrl.c b/drivers/staging/greybus/arche-apb-ctrl.c index 1ae2c06c8e33..acdeb71dde7b 100644 --- a/drivers/staging/greybus/arche-apb-ctrl.c +++ b/drivers/staging/greybus/arche-apb-ctrl.c @@ -170,14 +170,14 @@ static int apb_ctrl_init_seq(struct platform_device *pdev, } /* Enable power to APB */ - if (apb->vcore) { + if (!IS_ERR(apb->vcore)) { ret = regulator_enable(apb->vcore); if (ret) { dev_err(dev, "failed to enable core regulator\n"); return ret; } } - if (apb->vio) { + if (!IS_ERR(apb->vio)) { ret = regulator_enable(apb->vio); if (ret) { dev_err(dev, "failed to enable IO regulator\n"); @@ -246,16 +246,12 @@ static int apb_ctrl_get_devtree_data(struct platform_device *pdev, /* Regulators are optional, as we may have fixed supply coming in */ apb->vcore = devm_regulator_get(dev, "vcore"); - if (IS_ERR(apb->vcore)) { + if (IS_ERR(apb->vcore)) dev_info(dev, "no core regulator found\n"); - apb->vcore = NULL; - } apb->vio = devm_regulator_get(dev, "vio"); - if (IS_ERR(apb->vio)) { + if (IS_ERR(apb->vio)) dev_info(dev, "no IO regulator found\n"); - apb->vio = NULL; - } apb->pinctrl = devm_pinctrl_get(&pdev->dev); if (IS_ERR(apb->pinctrl)) { @@ -275,10 +271,10 @@ static void apb_ctrl_cleanup(struct arche_apb_ctrl_drvdata *apb) { unsigned long flags; - if (apb->vcore && regulator_is_enabled(apb->vcore) > 0) + if (!IS_ERR(apb->vcore) && regulator_is_enabled(apb->vcore) > 0) regulator_disable(apb->vcore); - if (apb->vio && regulator_is_enabled(apb->vio) > 0) + if (!IS_ERR(apb->vio) && regulator_is_enabled(apb->vio) > 0) regulator_disable(apb->vio); spin_lock_irqsave(&apb->lock, flags); |