Commit d77eceb2 authored by Alain Volmat's avatar Alain Volmat Committed by Wolfram Sang
Browse files

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: bb8822cb ("i2c: i2c-stm32: Add generic DMA API")
Signed-off-by: default avatarAlain Volmat <alain.volmat@st.com>
Reviewed-by: default avatarPierre-Yves MORDRET <pierre-yves.mordret@st.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 7bdf7c84
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -20,13 +20,13 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,

	dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);
	if (!dma)
		return NULL;
		return ERR_PTR(-ENOMEM);

	/* Request and configure I2C TX dma channel */
	dma->chan_tx = dma_request_slave_channel(dev, "tx");
	if (!dma->chan_tx) {
	dma->chan_tx = dma_request_chan(dev, "tx");
	if (IS_ERR(dma->chan_tx)) {
		dev_dbg(dev, "can't request DMA tx channel\n");
		ret = -EINVAL;
		ret = PTR_ERR(dma->chan_tx);
		goto fail_al;
	}

@@ -42,10 +42,10 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,
	}

	/* Request and configure I2C RX dma channel */
	dma->chan_rx = dma_request_slave_channel(dev, "rx");
	if (!dma->chan_rx) {
	dma->chan_rx = dma_request_chan(dev, "rx");
	if (IS_ERR(dma->chan_rx)) {
		dev_err(dev, "can't request DMA rx channel\n");
		ret = -EINVAL;
		ret = PTR_ERR(dma->chan_rx);
		goto fail_tx;
	}

@@ -75,7 +75,7 @@ fail_al:
	devm_kfree(dev, dma);
	dev_info(dev, "can't use DMA\n");

	return NULL;
	return ERR_PTR(ret);
}

void stm32_i2c_dma_free(struct stm32_i2c_dma *dma)
+9 −0
Original line number Diff line number Diff line
@@ -1950,6 +1950,15 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
	i2c_dev->dma = stm32_i2c_dma_request(i2c_dev->dev, phy_addr,
					     STM32F7_I2C_TXDR,
					     STM32F7_I2C_RXDR);
	if (PTR_ERR(i2c_dev->dma) == -ENODEV)
		i2c_dev->dma = NULL;
	else if (IS_ERR(i2c_dev->dma)) {
		ret = PTR_ERR(i2c_dev->dma);
		if (ret != -EPROBE_DEFER)
			dev_err(&pdev->dev,
				"Failed to request dma error %i\n", ret);
		goto clk_free;
	}

	platform_set_drvdata(pdev, i2c_dev);