diff mbox

Input: imx6ul_tsc - fix error handling

Message ID 1491996010-19947-1-git-send-email-festevam@gmail.com (mailing list archive)
State Accepted
Headers show

Commit Message

Fabio Estevam April 12, 2017, 11:20 a.m. UTC
From: Fabio Estevam <fabio.estevam@nxp.com>

If imx6ul_tsc_init() fails we should not return directly.

We should disable the previously acquired clocks in this case.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
 drivers/input/touchscreen/imx6ul_tsc.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Dmitry Torokhov April 12, 2017, 3:43 p.m. UTC | #1
On Wed, Apr 12, 2017 at 08:20:10AM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@nxp.com>
> 
> If imx6ul_tsc_init() fails we should not return directly.
> 
> We should disable the previously acquired clocks in this case.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>

Applied, thank you.

> ---
>  drivers/input/touchscreen/imx6ul_tsc.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c
> index 7098e0a..ee82a97 100644
> --- a/drivers/input/touchscreen/imx6ul_tsc.c
> +++ b/drivers/input/touchscreen/imx6ul_tsc.c
> @@ -337,11 +337,20 @@ static int imx6ul_tsc_open(struct input_dev *input_dev)
>  		dev_err(tsc->dev,
>  			"Could not prepare or enable the tsc clock: %d\n",
>  			err);
> -		clk_disable_unprepare(tsc->adc_clk);
> -		return err;
> +		goto disable_adc_clk;
>  	}
>  
> -	return imx6ul_tsc_init(tsc);
> +	err = imx6ul_tsc_init(tsc);
> +	if (err)
> +		goto disable_tsc_clk;
> +
> +	return 0;
> +
> +disable_tsc_clk:
> +	clk_disable_unprepare(tsc->tsc_clk);
> +disable_adc_clk:
> +	clk_disable_unprepare(tsc->adc_clk);
> +	return err;
>  }
>  
>  static void imx6ul_tsc_close(struct input_dev *input_dev)
> -- 
> 2.7.4
>
diff mbox

Patch

diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c
index 7098e0a..ee82a97 100644
--- a/drivers/input/touchscreen/imx6ul_tsc.c
+++ b/drivers/input/touchscreen/imx6ul_tsc.c
@@ -337,11 +337,20 @@  static int imx6ul_tsc_open(struct input_dev *input_dev)
 		dev_err(tsc->dev,
 			"Could not prepare or enable the tsc clock: %d\n",
 			err);
-		clk_disable_unprepare(tsc->adc_clk);
-		return err;
+		goto disable_adc_clk;
 	}
 
-	return imx6ul_tsc_init(tsc);
+	err = imx6ul_tsc_init(tsc);
+	if (err)
+		goto disable_tsc_clk;
+
+	return 0;
+
+disable_tsc_clk:
+	clk_disable_unprepare(tsc->tsc_clk);
+disable_adc_clk:
+	clk_disable_unprepare(tsc->adc_clk);
+	return err;
 }
 
 static void imx6ul_tsc_close(struct input_dev *input_dev)