Skip to content

Commit e1ab9a4

Browse files
oleremWolfram Sang
authored and
Wolfram Sang
committed
i2c: imx: improve the error handling in i2c_imx_dma_request()
Improve the error handling in i2c_imx_dma_request() and let it return an error indication that the caller then can handle accordingly. Signed-off-by: Oleksij Rempel <[email protected]> Acked-by: Uwe Kleine-König <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 5b3a23a commit e1ab9a4

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

drivers/i2c/busses/i2c-imx.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ static inline unsigned char imx_i2c_read_reg(struct imx_i2c_struct *i2c_imx,
273273
}
274274

275275
/* Functions for DMA support */
276-
static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
277-
dma_addr_t phy_addr)
276+
static int i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
277+
dma_addr_t phy_addr)
278278
{
279279
struct imx_i2c_dma *dma;
280280
struct dma_slave_config dma_sconfig;
@@ -283,7 +283,7 @@ static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
283283

284284
dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);
285285
if (!dma)
286-
return;
286+
return -ENOMEM;
287287

288288
dma->chan_tx = dma_request_chan(dev, "tx");
289289
if (IS_ERR(dma->chan_tx)) {
@@ -328,14 +328,16 @@ static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
328328
dev_info(dev, "using %s (tx) and %s (rx) for DMA transfers\n",
329329
dma_chan_name(dma->chan_tx), dma_chan_name(dma->chan_rx));
330330

331-
return;
331+
return 0;
332332

333333
fail_rx:
334334
dma_release_channel(dma->chan_rx);
335335
fail_tx:
336336
dma_release_channel(dma->chan_tx);
337337
fail_al:
338338
devm_kfree(dev, dma);
339+
/* return successfully if there is no dma support */
340+
return ret == -ENODEV ? 0 : ret;
339341
}
340342

341343
static void i2c_imx_dma_callback(void *arg)
@@ -1163,11 +1165,13 @@ static int i2c_imx_probe(struct platform_device *pdev)
11631165
dev_dbg(&i2c_imx->adapter.dev, "device resources: %pR\n", res);
11641166
dev_dbg(&i2c_imx->adapter.dev, "adapter name: \"%s\"\n",
11651167
i2c_imx->adapter.name);
1166-
dev_info(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n");
11671168

11681169
/* Init DMA config if supported */
1169-
i2c_imx_dma_request(i2c_imx, phy_addr);
1170+
ret = i2c_imx_dma_request(i2c_imx, phy_addr);
1171+
if (ret < 0)
1172+
goto clk_notifier_unregister;
11701173

1174+
dev_info(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n");
11711175
return 0; /* Return OK */
11721176

11731177
clk_notifier_unregister:

0 commit comments

Comments
 (0)