From a7a794ec540c442999598cf16605ba7962aa3861 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Mon, 11 Jan 2016 11:29:14 +0530 Subject: [PATCH] greybus: arche-apb: Don't use gpio after failing to request it If devm_gpio_request() returns an error, we shouldn't try to set the direction of the same gpio. Signed-off-by: Viresh Kumar Reviewed-by: Vaibhav Hiremath Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/arche-apb-ctrl.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/staging/greybus/arche-apb-ctrl.c b/drivers/staging/greybus/arche-apb-ctrl.c index 8582a4849221..f83230deb4b4 100644 --- a/drivers/staging/greybus/arche-apb-ctrl.c +++ b/drivers/staging/greybus/arche-apb-ctrl.c @@ -137,12 +137,15 @@ static int apb_ctrl_init_seq(struct platform_device *pdev, /* On DB3 clock was not mandatory */ if (gpio_is_valid(apb->clk_en_gpio)) { ret = devm_gpio_request(dev, apb->clk_en_gpio, "apb_clk_en"); - if (ret) + if (ret) { dev_warn(dev, "Failed requesting APB clock en gpio %d\n", - apb->clk_en_gpio); - ret = gpio_direction_output(apb->clk_en_gpio, 1); - if (ret) - dev_warn(dev, "failed to set APB clock en gpio dir:%d\n", ret); + apb->clk_en_gpio); + } else { + ret = gpio_direction_output(apb->clk_en_gpio, 1); + if (ret) + dev_warn(dev, "failed to set APB clock en gpio dir:%d\n", + ret); + } } /* Hold APB in reset state */ ret = devm_gpio_request(dev, apb->resetn_gpio, "apb-reset"); -- 2.20.1