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

i2c: stm32f7: report dma error during probe

Distinguish between the case where dma information is not provided
within the DT and the case of an error during the dma init.
Exit the probe with error in case of an error during dma init.

Fixes: bb8822cbbc53 ("i2c: i2c-stm32: Add generic DMA API")
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
d77eceb2 7bdf7c84

+17 -8
+8 -8
drivers/i2c/busses/i2c-stm32.c
··· 20 20 21 21 dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL); 22 22 if (!dma) 23 - return NULL; 23 + return ERR_PTR(-ENOMEM); 24 24 25 25 /* Request and configure I2C TX dma channel */ 26 - dma->chan_tx = dma_request_slave_channel(dev, "tx"); 27 - if (!dma->chan_tx) { 26 + dma->chan_tx = dma_request_chan(dev, "tx"); 27 + if (IS_ERR(dma->chan_tx)) { 28 28 dev_dbg(dev, "can't request DMA tx channel\n"); 29 - ret = -EINVAL; 29 + ret = PTR_ERR(dma->chan_tx); 30 30 goto fail_al; 31 31 } 32 32 ··· 42 42 } 43 43 44 44 /* Request and configure I2C RX dma channel */ 45 - dma->chan_rx = dma_request_slave_channel(dev, "rx"); 46 - if (!dma->chan_rx) { 45 + dma->chan_rx = dma_request_chan(dev, "rx"); 46 + if (IS_ERR(dma->chan_rx)) { 47 47 dev_err(dev, "can't request DMA rx channel\n"); 48 - ret = -EINVAL; 48 + ret = PTR_ERR(dma->chan_rx); 49 49 goto fail_tx; 50 50 } 51 51 ··· 75 75 devm_kfree(dev, dma); 76 76 dev_info(dev, "can't use DMA\n"); 77 77 78 - return NULL; 78 + return ERR_PTR(ret); 79 79 } 80 80 81 81 void stm32_i2c_dma_free(struct stm32_i2c_dma *dma)
+9
drivers/i2c/busses/i2c-stm32f7.c
··· 1950 1950 i2c_dev->dma = stm32_i2c_dma_request(i2c_dev->dev, phy_addr, 1951 1951 STM32F7_I2C_TXDR, 1952 1952 STM32F7_I2C_RXDR); 1953 + if (PTR_ERR(i2c_dev->dma) == -ENODEV) 1954 + i2c_dev->dma = NULL; 1955 + else if (IS_ERR(i2c_dev->dma)) { 1956 + ret = PTR_ERR(i2c_dev->dma); 1957 + if (ret != -EPROBE_DEFER) 1958 + dev_err(&pdev->dev, 1959 + "Failed to request dma error %i\n", ret); 1960 + goto clk_free; 1961 + } 1953 1962 1954 1963 platform_set_drvdata(pdev, i2c_dev); 1955 1964