* [PATCH] Input: lpc32xx_ts - check for clk_prepare_enable() error
@ 2017-04-12 11:29 Fabio Estevam
2017-04-12 15:44 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Fabio Estevam @ 2017-04-12 11:29 UTC (permalink / raw)
To: dmitry.torokhov; +Cc: vz, linux-input, Fabio Estevam
From: Fabio Estevam <fabio.estevam@nxp.com>
clk_prepare_enable() may fail, so we better check its return value and
propagate it in the case of error.
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
drivers/input/touchscreen/lpc32xx_ts.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/input/touchscreen/lpc32xx_ts.c b/drivers/input/touchscreen/lpc32xx_ts.c
index e0baa7d..4eb31ec 100644
--- a/drivers/input/touchscreen/lpc32xx_ts.c
+++ b/drivers/input/touchscreen/lpc32xx_ts.c
@@ -142,11 +142,14 @@ static void lpc32xx_stop_tsc(struct lpc32xx_tsc *tsc)
clk_disable_unprepare(tsc->clk);
}
-static void lpc32xx_setup_tsc(struct lpc32xx_tsc *tsc)
+static int lpc32xx_setup_tsc(struct lpc32xx_tsc *tsc)
{
u32 tmp;
+ int err;
- clk_prepare_enable(tsc->clk);
+ err = clk_prepare_enable(tsc->clk);
+ if (err)
+ return err;
tmp = tsc_readl(tsc, LPC32XX_TSC_CON) & ~LPC32XX_TSC_ADCCON_POWER_UP;
@@ -184,15 +187,15 @@ static void lpc32xx_setup_tsc(struct lpc32xx_tsc *tsc)
/* Enable automatic ts event capture */
tsc_writel(tsc, LPC32XX_TSC_CON, tmp | LPC32XX_TSC_ADCCON_AUTO_EN);
+
+ return 0;
}
static int lpc32xx_ts_open(struct input_dev *dev)
{
struct lpc32xx_tsc *tsc = input_get_drvdata(dev);
- lpc32xx_setup_tsc(tsc);
-
- return 0;
+ return lpc32xx_setup_tsc(tsc);
}
static void lpc32xx_ts_close(struct input_dev *dev)
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input: lpc32xx_ts - check for clk_prepare_enable() error
2017-04-12 11:29 [PATCH] Input: lpc32xx_ts - check for clk_prepare_enable() error Fabio Estevam
@ 2017-04-12 15:44 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2017-04-12 15:44 UTC (permalink / raw)
To: Fabio Estevam; +Cc: vz, linux-input, Fabio Estevam
On Wed, Apr 12, 2017 at 08:29:23AM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@nxp.com>
>
> clk_prepare_enable() may fail, so we better check its return value and
> propagate it in the case of error.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Applied, thank you.
> ---
> drivers/input/touchscreen/lpc32xx_ts.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/input/touchscreen/lpc32xx_ts.c b/drivers/input/touchscreen/lpc32xx_ts.c
> index e0baa7d..4eb31ec 100644
> --- a/drivers/input/touchscreen/lpc32xx_ts.c
> +++ b/drivers/input/touchscreen/lpc32xx_ts.c
> @@ -142,11 +142,14 @@ static void lpc32xx_stop_tsc(struct lpc32xx_tsc *tsc)
> clk_disable_unprepare(tsc->clk);
> }
>
> -static void lpc32xx_setup_tsc(struct lpc32xx_tsc *tsc)
> +static int lpc32xx_setup_tsc(struct lpc32xx_tsc *tsc)
> {
> u32 tmp;
> + int err;
>
> - clk_prepare_enable(tsc->clk);
> + err = clk_prepare_enable(tsc->clk);
> + if (err)
> + return err;
>
> tmp = tsc_readl(tsc, LPC32XX_TSC_CON) & ~LPC32XX_TSC_ADCCON_POWER_UP;
>
> @@ -184,15 +187,15 @@ static void lpc32xx_setup_tsc(struct lpc32xx_tsc *tsc)
>
> /* Enable automatic ts event capture */
> tsc_writel(tsc, LPC32XX_TSC_CON, tmp | LPC32XX_TSC_ADCCON_AUTO_EN);
> +
> + return 0;
> }
>
> static int lpc32xx_ts_open(struct input_dev *dev)
> {
> struct lpc32xx_tsc *tsc = input_get_drvdata(dev);
>
> - lpc32xx_setup_tsc(tsc);
> -
> - return 0;
> + return lpc32xx_setup_tsc(tsc);
> }
>
> static void lpc32xx_ts_close(struct input_dev *dev)
> --
> 2.7.4
>
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-04-12 15:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-12 11:29 [PATCH] Input: lpc32xx_ts - check for clk_prepare_enable() error Fabio Estevam
2017-04-12 15:44 ` 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).