Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: stm32f7: fix & reorder remove & probe error handling

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>
Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

authored by

Alain Volmat and committed by
Wolfram Sang
53aaaa5d 7375e079

+12 -7
+12 -7
drivers/i2c/busses/i2c-stm32f7.c
··· 1980 1980 pm_runtime_set_suspended(i2c_dev->dev); 1981 1981 pm_runtime_dont_use_autosuspend(i2c_dev->dev); 1982 1982 1983 + if (i2c_dev->dma) { 1984 + stm32_i2c_dma_free(i2c_dev->dma); 1985 + i2c_dev->dma = NULL; 1986 + } 1987 + 1983 1988 clk_free: 1984 1989 clk_disable_unprepare(i2c_dev->clk); 1985 1990 ··· 1995 1990 { 1996 1991 struct stm32f7_i2c_dev *i2c_dev = platform_get_drvdata(pdev); 1997 1992 1998 - if (i2c_dev->dma) { 1999 - stm32_i2c_dma_free(i2c_dev->dma); 2000 - i2c_dev->dma = NULL; 2001 - } 2002 - 2003 1993 i2c_del_adapter(&i2c_dev->adap); 2004 1994 pm_runtime_get_sync(i2c_dev->dev); 2005 - 2006 - clk_disable_unprepare(i2c_dev->clk); 2007 1995 2008 1996 pm_runtime_put_noidle(i2c_dev->dev); 2009 1997 pm_runtime_disable(i2c_dev->dev); 2010 1998 pm_runtime_set_suspended(i2c_dev->dev); 2011 1999 pm_runtime_dont_use_autosuspend(i2c_dev->dev); 2000 + 2001 + if (i2c_dev->dma) { 2002 + stm32_i2c_dma_free(i2c_dev->dma); 2003 + i2c_dev->dma = NULL; 2004 + } 2005 + 2006 + clk_disable_unprepare(i2c_dev->clk); 2012 2007 2013 2008 return 0; 2014 2009 }