linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Input: tegra-kbc: Handle return value of clk_prepare_enable.
@ 2017-08-01 10:02 Arvind Yadav
  2017-08-01 10:04 ` [PATCH 2/2] Input: pxa27x_keypad: " Arvind Yadav
       [not found] ` <e18b64df1c144ac6ac05bd16e0d5d0cd59a20d13.1501581502.git.arvind.yadav.cs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Arvind Yadav @ 2017-08-01 10:02 UTC (permalink / raw)
  To: riyer, ldewangan, dmitry.torokhov, thierry.reding, jonathanh
  Cc: linux-input, linux-tegra, linux-kernel

clk_prepare_enable() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/input/keyboard/tegra-kbc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
index 0c07e10..edc1385 100644
--- a/drivers/input/keyboard/tegra-kbc.c
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -370,8 +370,11 @@ static int tegra_kbc_start(struct tegra_kbc *kbc)
 {
 	unsigned int debounce_cnt;
 	u32 val = 0;
+	int ret;
 
-	clk_prepare_enable(kbc->clk);
+	ret = clk_prepare_enable(kbc->clk);
+	if (ret)
+		return ret;
 
 	/* Reset the KBC controller to clear all previous status.*/
 	reset_control_assert(kbc->rst);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] Input: pxa27x_keypad: Handle return value of clk_prepare_enable.
  2017-08-01 10:02 [PATCH 1/2] Input: tegra-kbc: Handle return value of clk_prepare_enable Arvind Yadav
@ 2017-08-01 10:04 ` Arvind Yadav
  2017-08-31 18:50   ` Dmitry Torokhov
       [not found] ` <e18b64df1c144ac6ac05bd16e0d5d0cd59a20d13.1501581502.git.arvind.yadav.cs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  1 sibling, 1 reply; 4+ messages in thread
From: Arvind Yadav @ 2017-08-01 10:04 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, linux-kernel

clk_prepare_enable() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/input/keyboard/pxa27x_keypad.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index 3841fa3..a3396a7 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -644,9 +644,12 @@ static void pxa27x_keypad_config(struct pxa27x_keypad *keypad)
 static int pxa27x_keypad_open(struct input_dev *dev)
 {
 	struct pxa27x_keypad *keypad = input_get_drvdata(dev);
-
+	int ret;
 	/* Enable unit clock */
-	clk_prepare_enable(keypad->clk);
+	ret = clk_prepare_enable(keypad->clk);
+	if (ret)
+		return ret;
+
 	pxa27x_keypad_config(keypad);
 
 	return 0;
@@ -683,6 +686,7 @@ static int pxa27x_keypad_resume(struct device *dev)
 	struct platform_device *pdev = to_platform_device(dev);
 	struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
 	struct input_dev *input_dev = keypad->input_dev;
+	int ret;
 
 	/*
 	 * If the keypad is used as wake up source, the clock is not turned
@@ -695,7 +699,11 @@ static int pxa27x_keypad_resume(struct device *dev)
 
 		if (input_dev->users) {
 			/* Enable unit clock */
-			clk_prepare_enable(keypad->clk);
+			ret = clk_prepare_enable(keypad->clk);
+			if (ret) {
+				mutex_unlock(&input_dev->mutex);
+				return ret;
+			}
 			pxa27x_keypad_config(keypad);
 		}
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] Input: pxa27x_keypad: Handle return value of clk_prepare_enable.
  2017-08-01 10:04 ` [PATCH 2/2] Input: pxa27x_keypad: " Arvind Yadav
@ 2017-08-31 18:50   ` Dmitry Torokhov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2017-08-31 18:50 UTC (permalink / raw)
  To: Arvind Yadav; +Cc: linux-input, linux-kernel

On Tue, Aug 01, 2017 at 03:34:10PM +0530, Arvind Yadav wrote:
> clk_prepare_enable() can fail here and we must check its return value.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
>  drivers/input/keyboard/pxa27x_keypad.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
> index 3841fa3..a3396a7 100644
> --- a/drivers/input/keyboard/pxa27x_keypad.c
> +++ b/drivers/input/keyboard/pxa27x_keypad.c
> @@ -644,9 +644,12 @@ static void pxa27x_keypad_config(struct pxa27x_keypad *keypad)
>  static int pxa27x_keypad_open(struct input_dev *dev)
>  {
>  	struct pxa27x_keypad *keypad = input_get_drvdata(dev);
> -
> +	int ret;
>  	/* Enable unit clock */
> -	clk_prepare_enable(keypad->clk);
> +	ret = clk_prepare_enable(keypad->clk);
> +	if (ret)
> +		return ret;
> +
>  	pxa27x_keypad_config(keypad);
>  
>  	return 0;
> @@ -683,6 +686,7 @@ static int pxa27x_keypad_resume(struct device *dev)
>  	struct platform_device *pdev = to_platform_device(dev);
>  	struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
>  	struct input_dev *input_dev = keypad->input_dev;
> +	int ret;
>  
>  	/*
>  	 * If the keypad is used as wake up source, the clock is not turned
> @@ -695,7 +699,11 @@ static int pxa27x_keypad_resume(struct device *dev)
>  
>  		if (input_dev->users) {
>  			/* Enable unit clock */
> -			clk_prepare_enable(keypad->clk);
> +			ret = clk_prepare_enable(keypad->clk);
> +			if (ret) {
> +				mutex_unlock(&input_dev->mutex);
> +				return ret;
> +			}
>  			pxa27x_keypad_config(keypad);
>  		}

Rewrote as

	int ret = 0;

	...

		mutex_lock(&input_dev->mutex);

		if (input_dev->users) {
			/* Enable unit clock */
			ret = clk_prepare_enable(keypad->clk);
			if (!ret)
				pxa27x_keypad_config(keypad);
		}

		mutex_unlock(&input_dev->mutex);

	...
	return ret;

to avoid unlocking mutex in 2 places and applied, thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] Input: tegra-kbc: Handle return value of clk_prepare_enable.
       [not found] ` <e18b64df1c144ac6ac05bd16e0d5d0cd59a20d13.1501581502.git.arvind.yadav.cs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-08-31 18:51   ` Dmitry Torokhov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2017-08-31 18:51 UTC (permalink / raw)
  To: Arvind Yadav
  Cc: riyer-DDmLM1+adcrQT0dZR+AlfA, ldewangan-DDmLM1+adcrQT0dZR+AlfA,
	thierry.reding-Re5JQEeQqe8AvxtiuMwx3w,
	jonathanh-DDmLM1+adcrQT0dZR+AlfA,
	linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Tue, Aug 01, 2017 at 03:32:26PM +0530, Arvind Yadav wrote:
> clk_prepare_enable() can fail here and we must check its return value.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Applied, thank you.

> ---
>  drivers/input/keyboard/tegra-kbc.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
> index 0c07e10..edc1385 100644
> --- a/drivers/input/keyboard/tegra-kbc.c
> +++ b/drivers/input/keyboard/tegra-kbc.c
> @@ -370,8 +370,11 @@ static int tegra_kbc_start(struct tegra_kbc *kbc)
>  {
>  	unsigned int debounce_cnt;
>  	u32 val = 0;
> +	int ret;
>  
> -	clk_prepare_enable(kbc->clk);
> +	ret = clk_prepare_enable(kbc->clk);
> +	if (ret)
> +		return ret;
>  
>  	/* Reset the KBC controller to clear all previous status.*/
>  	reset_control_assert(kbc->rst);
> -- 
> 1.9.1
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-31 18:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-01 10:02 [PATCH 1/2] Input: tegra-kbc: Handle return value of clk_prepare_enable Arvind Yadav
2017-08-01 10:04 ` [PATCH 2/2] Input: pxa27x_keypad: " Arvind Yadav
2017-08-31 18:50   ` Dmitry Torokhov
     [not found] ` <e18b64df1c144ac6ac05bd16e0d5d0cd59a20d13.1501581502.git.arvind.yadav.cs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-08-31 18:51   ` [PATCH 1/2] Input: tegra-kbc: " Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).