* [PATCH V2] input: keyboard: snvs: initialize necessary driver data before enabling IRQ
@ 2019-03-27 6:07 Anson Huang
2019-04-03 22:15 ` dmitry.torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Anson Huang @ 2019-03-27 6:07 UTC (permalink / raw)
To: dmitry.torokhov@gmail.com, Fabio Estevam,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: dl-linux-imx
SNVS IRQ is requested before necessary driver data initialized,
if there is a pending IRQ during driver probe phase, kernel
NULL pointer panic will occur in IRQ handler. To avoid such
scenario, just initialize necessary driver data before enabling
IRQ. This patch is inspired by NXP's internal kernel tree.
Fixes: d3dc6e232215 ("input: keyboard: imx: add snvs power key driver")
Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
Changes since V1:
- move the platform data initialization to before IRQ enable instead of moving the IRQ enable
to the end of probe function.
---
drivers/input/keyboard/snvs_pwrkey.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c
index effb632..4c67cf3 100644
--- a/drivers/input/keyboard/snvs_pwrkey.c
+++ b/drivers/input/keyboard/snvs_pwrkey.c
@@ -148,6 +148,9 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
return error;
}
+ pdata->input = input;
+ platform_set_drvdata(pdev, pdata);
+
error = devm_request_irq(&pdev->dev, pdata->irq,
imx_snvs_pwrkey_interrupt,
0, pdev->name, pdev);
@@ -163,9 +166,6 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
return error;
}
- pdata->input = input;
- platform_set_drvdata(pdev, pdata);
-
device_init_wakeup(&pdev->dev, pdata->wakeup);
return 0;
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH V2] input: keyboard: snvs: initialize necessary driver data before enabling IRQ
2019-03-27 6:07 [PATCH V2] input: keyboard: snvs: initialize necessary driver data before enabling IRQ Anson Huang
@ 2019-04-03 22:15 ` dmitry.torokhov
0 siblings, 0 replies; 2+ messages in thread
From: dmitry.torokhov @ 2019-04-03 22:15 UTC (permalink / raw)
To: Anson Huang
Cc: Fabio Estevam, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org, dl-linux-imx
On Wed, Mar 27, 2019 at 06:07:06AM +0000, Anson Huang wrote:
> SNVS IRQ is requested before necessary driver data initialized,
> if there is a pending IRQ during driver probe phase, kernel
> NULL pointer panic will occur in IRQ handler. To avoid such
> scenario, just initialize necessary driver data before enabling
> IRQ. This patch is inspired by NXP's internal kernel tree.
>
> Fixes: d3dc6e232215 ("input: keyboard: imx: add snvs power key driver")
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Applied, thank you.
> ---
> Changes since V1:
> - move the platform data initialization to before IRQ enable instead of moving the IRQ enable
> to the end of probe function.
> ---
> drivers/input/keyboard/snvs_pwrkey.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c
> index effb632..4c67cf3 100644
> --- a/drivers/input/keyboard/snvs_pwrkey.c
> +++ b/drivers/input/keyboard/snvs_pwrkey.c
> @@ -148,6 +148,9 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
> return error;
> }
>
> + pdata->input = input;
> + platform_set_drvdata(pdev, pdata);
> +
> error = devm_request_irq(&pdev->dev, pdata->irq,
> imx_snvs_pwrkey_interrupt,
> 0, pdev->name, pdev);
> @@ -163,9 +166,6 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
> return error;
> }
>
> - pdata->input = input;
> - platform_set_drvdata(pdev, pdata);
> -
> device_init_wakeup(&pdev->dev, pdata->wakeup);
>
> return 0;
> --
> 2.7.4
>
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-03 22:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-27 6:07 [PATCH V2] input: keyboard: snvs: initialize necessary driver data before enabling IRQ Anson Huang
2019-04-03 22:15 ` 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).