* [PATCH] i2c: i2c-stm32f7: fix & reorder remove & probe error handling
@ 2019-10-25 14:04 Alain Volmat
2019-10-25 14:11 ` Pierre Yves MORDRET
2019-11-11 19:42 ` Wolfram Sang
0 siblings, 2 replies; 3+ messages in thread
From: Alain Volmat @ 2019-10-25 14:04 UTC (permalink / raw)
To: wsa, pierre-yves.mordret
Cc: alain.volmat, alexandre.torgue, linux-i2c, linux-stm32,
linux-arm-kernel, linux-kernel, fabrice.gasnier
Add missing dma channels free calls in case of error during probe
and reorder the remove function so that dma channels are freed after
the i2c adapter is deleted.
Overall, reorder the remove function so that probe error handling order
and remove function order are same.
Fixes: 7ecc8cfde553 ("i2c: i2c-stm32f7: Add DMA support")
Signed-off-by: Alain Volmat <alain.volmat@st.com>
---
drivers/i2c/busses/i2c-stm32f7.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index d36cf08461f7..f8ef203dabfc 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -1980,6 +1980,11 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
pm_runtime_set_suspended(i2c_dev->dev);
pm_runtime_dont_use_autosuspend(i2c_dev->dev);
+ if (i2c_dev->dma) {
+ stm32_i2c_dma_free(i2c_dev->dma);
+ i2c_dev->dma = NULL;
+ }
+
clk_free:
clk_disable_unprepare(i2c_dev->clk);
@@ -1990,21 +1995,21 @@ static int stm32f7_i2c_remove(struct platform_device *pdev)
{
struct stm32f7_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
- if (i2c_dev->dma) {
- stm32_i2c_dma_free(i2c_dev->dma);
- i2c_dev->dma = NULL;
- }
-
i2c_del_adapter(&i2c_dev->adap);
pm_runtime_get_sync(i2c_dev->dev);
- clk_disable_unprepare(i2c_dev->clk);
-
pm_runtime_put_noidle(i2c_dev->dev);
pm_runtime_disable(i2c_dev->dev);
pm_runtime_set_suspended(i2c_dev->dev);
pm_runtime_dont_use_autosuspend(i2c_dev->dev);
+ if (i2c_dev->dma) {
+ stm32_i2c_dma_free(i2c_dev->dma);
+ i2c_dev->dma = NULL;
+ }
+
+ clk_disable_unprepare(i2c_dev->clk);
+
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] i2c: i2c-stm32f7: fix & reorder remove & probe error handling
2019-10-25 14:04 [PATCH] i2c: i2c-stm32f7: fix & reorder remove & probe error handling Alain Volmat
@ 2019-10-25 14:11 ` Pierre Yves MORDRET
2019-11-11 19:42 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Pierre Yves MORDRET @ 2019-10-25 14:11 UTC (permalink / raw)
To: Alain Volmat, wsa
Cc: alexandre.torgue, linux-i2c, linux-stm32, linux-arm-kernel,
linux-kernel, fabrice.gasnier
Hi
Look good for me
Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com>
Thanks
On 10/25/19 4:04 PM, Alain Volmat wrote:
> Add missing dma channels free calls in case of error during probe
> and reorder the remove function so that dma channels are freed after
> the i2c adapter is deleted.
> Overall, reorder the remove function so that probe error handling order
> and remove function order are same.
>
> Fixes: 7ecc8cfde553 ("i2c: i2c-stm32f7: Add DMA support")
>
> Signed-off-by: Alain Volmat <alain.volmat@st.com>
> ---
> drivers/i2c/busses/i2c-stm32f7.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> index d36cf08461f7..f8ef203dabfc 100644
> --- a/drivers/i2c/busses/i2c-stm32f7.c
> +++ b/drivers/i2c/busses/i2c-stm32f7.c
> @@ -1980,6 +1980,11 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
> pm_runtime_set_suspended(i2c_dev->dev);
> pm_runtime_dont_use_autosuspend(i2c_dev->dev);
>
> + if (i2c_dev->dma) {
> + stm32_i2c_dma_free(i2c_dev->dma);
> + i2c_dev->dma = NULL;
> + }
> +
> clk_free:
> clk_disable_unprepare(i2c_dev->clk);
>
> @@ -1990,21 +1995,21 @@ static int stm32f7_i2c_remove(struct platform_device *pdev)
> {
> struct stm32f7_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
>
> - if (i2c_dev->dma) {
> - stm32_i2c_dma_free(i2c_dev->dma);
> - i2c_dev->dma = NULL;
> - }
> -
> i2c_del_adapter(&i2c_dev->adap);
> pm_runtime_get_sync(i2c_dev->dev);
>
> - clk_disable_unprepare(i2c_dev->clk);
> -
> pm_runtime_put_noidle(i2c_dev->dev);
> pm_runtime_disable(i2c_dev->dev);
> pm_runtime_set_suspended(i2c_dev->dev);
> pm_runtime_dont_use_autosuspend(i2c_dev->dev);
>
> + if (i2c_dev->dma) {
> + stm32_i2c_dma_free(i2c_dev->dma);
> + i2c_dev->dma = NULL;
> + }
> +
> + clk_disable_unprepare(i2c_dev->clk);
> +
> return 0;
> }
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i2c: i2c-stm32f7: fix & reorder remove & probe error handling
2019-10-25 14:04 [PATCH] i2c: i2c-stm32f7: fix & reorder remove & probe error handling Alain Volmat
2019-10-25 14:11 ` Pierre Yves MORDRET
@ 2019-11-11 19:42 ` Wolfram Sang
1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2019-11-11 19:42 UTC (permalink / raw)
To: Alain Volmat
Cc: pierre-yves.mordret, alexandre.torgue, linux-i2c, linux-stm32,
linux-arm-kernel, linux-kernel, fabrice.gasnier
[-- Attachment #1: Type: text/plain, Size: 505 bytes --]
On Fri, Oct 25, 2019 at 04:04:24PM +0200, Alain Volmat wrote:
> Add missing dma channels free calls in case of error during probe
> and reorder the remove function so that dma channels are freed after
> the i2c adapter is deleted.
> Overall, reorder the remove function so that probe error handling order
> and remove function order are same.
>
> Fixes: 7ecc8cfde553 ("i2c: i2c-stm32f7: Add DMA support")
>
> Signed-off-by: Alain Volmat <alain.volmat@st.com>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-11-11 19:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25 14:04 [PATCH] i2c: i2c-stm32f7: fix & reorder remove & probe error handling Alain Volmat
2019-10-25 14:11 ` Pierre Yves MORDRET
2019-11-11 19:42 ` Wolfram Sang
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).