i2c: use dmaengine_desc_set_callback()
Subsystems (14)
PATCH 1/1 i2c: use dmaengine_desc_set_callback()
From: Frank Li <[email protected]>
Replace open-coded assignments to callback and callback_param fields of struct dma_async_tx_descriptor with calls to the dmaengine_desc_set_callback() helper across various I2C bus drivers.
No functional change intended. Prepare make to struct dma_async_tx_descriptor private to the DMA engine.
--- drivers/i2c/busses/i2c-at91-master.c | 6 ++---- drivers/i2c/busses/i2c-imx-lpi2c.c | 3 +-- drivers/i2c/busses/i2c-imx.c | 3 +-- drivers/i2c/busses/i2c-mxs.c | 3 +-- drivers/i2c/busses/i2c-qcom-geni.c | 3 +-- drivers/i2c/busses/i2c-qup.c | 6 ++---- drivers/i2c/busses/i2c-rcar.c | 3 +-- drivers/i2c/busses/i2c-sh_mobile.c | 3 +-- drivers/i2c/busses/i2c-stm32.c | 3 +-- drivers/i2c/busses/i2c-tegra.c | 3 +-- 10 files changed, 12 insertions(+), 24 deletions(-)
drivers/i2c/busses/i2c-at91-master.c +2 -4
@@ -256,8 +256,7 @@ static void at91_twi_write_data_dma(struct at91_twi_dev *dev) goto error; } - txdesc->callback = at91_twi_write_data_dma_callback; - txdesc->callback_param = dev; +dmaengine_desc_set_callback (txdesc, at91_twi_write_data_dma_callback,NULL , dev); dma->xfer_in_progress = true;dmaengine_submit (txdesc);
@@ -374,8 +373,7 @@ static void at91_twi_read_data_dma(struct at91_twi_dev *dev) goto error; } - rxdesc->callback = at91_twi_read_data_dma_callback; - rxdesc->callback_param = dev; +dmaengine_desc_set_callback (rxdesc, at91_twi_read_data_dma_callback,NULL , dev); dma->xfer_in_progress = true;dmaengine_submit (rxdesc);
drivers/i2c/busses/i2c-imx-lpi2c.c +1 -2
@@ -887,8 +887,7 @@ static int lpi2c_dma_submit(struct lpi2c_imx_struct *lpi2c_imx) }reinit_completion (&lpi2c_imx->complete); - desc->callback = lpi2c_dma_callback; - desc->callback_param = lpi2c_imx; +dmaengine_desc_set_callback (desc, lpi2c_dma_callback,NULL , lpi2c_imx); cookie =dmaengine_submit (desc);if (dma_submit_error (cookie)) {
drivers/i2c/busses/i2c-imx.c +1 -2
@@ -498,8 +498,7 @@ static int i2c_imx_dma_xfer(struct imx_i2c_struct *i2c_imx, }reinit_completion (&dma->cmd_complete); - txdesc->callback = i2c_imx_dma_callback; - txdesc->callback_param = i2c_imx; +dmaengine_desc_set_callback (txdesc, i2c_imx_dma_callback,NULL , i2c_imx);if (dma_submit_error (dmaengine_submit (txdesc))) {dev_err (dev,"DMA submit failed\n" ); goto err_submit;
drivers/i2c/busses/i2c-mxs.c +1 -2
@@ -283,8 +283,7 @@ static int mxs_i2c_dma_setup_xfer(struct i2c_adapter *adap,* The last descriptor must have this callback, * to finish the DMA transaction. */ - desc->callback = mxs_i2c_dma_irq_callback; - desc->callback_param = i2c; +dmaengine_desc_set_callback (desc, mxs_i2c_dma_irq_callback,NULL , i2c);/* Start the transfer. */ dmaengine_submit (desc);
drivers/i2c/busses/i2c-qcom-geni.c +1 -2
@@ -800,8 +800,7 @@ static int geni_i2c_gpi(struct geni_i2c_dev *gi2c, struct i2c_msg msgs[], goto err_config; } - desc->callback_result = i2c_gpi_cb_result; - desc->callback_param = gi2c; +dmaengine_desc_set_callback (desc,NULL , i2c_gpi_cb_result, gi2c);if (!((msgs[msg_idx].flags &I2C_M_RD ) && op ==I2C_WRITE )) gi2c_gpi_xfer->msg_idx_cnt++;
drivers/i2c/busses/i2c-qup.c +2 -4
@@ -784,8 +784,7 @@ static int qup_i2c_bam_schedule_desc(struct qup_i2c_dev *qup) }if (!rx_cnt) { - txd->callback = qup_i2c_bam_cb; - txd->callback_param = qup; +dmaengine_desc_set_callback (txd, qup_i2c_bam_cb,NULL , qup); } cookie_tx =dmaengine_submit (txd);
@@ -809,8 +808,7 @@ static int qup_i2c_bam_schedule_desc(struct qup_i2c_dev *qup) goto desc_err; } - rxd->callback = qup_i2c_bam_cb; - rxd->callback_param = qup; +dmaengine_desc_set_callback (rxd, qup_i2c_bam_cb,NULL , qup); cookie_rx =dmaengine_submit (rxd);if (dma_submit_error (cookie_rx)) { ret = -EINVAL ;
drivers/i2c/busses/i2c-rcar.c +1 -2
@@ -531,8 +531,7 @@ static bool rcar_i2c_dma(struct rcar_i2c_priv *priv)return false; } - txdesc->callback = rcar_i2c_dma_callback; - txdesc->callback_param = priv; +dmaengine_desc_set_callback (txdesc, rcar_i2c_dma_callback,NULL , priv); cookie =dmaengine_submit (txdesc);if (dma_submit_error (cookie)) {
drivers/i2c/busses/i2c-sh_mobile.c +1 -2
@@ -546,8 +546,7 @@ static void sh_mobile_i2c_xfer_dma(struct sh_mobile_i2c_data *pd)return ; } - txdesc->callback = sh_mobile_i2c_dma_callback; - txdesc->callback_param = pd; +dmaengine_desc_set_callback (txdesc, sh_mobile_i2c_dma_callback,NULL , pd); cookie =dmaengine_submit (txdesc);if (dma_submit_error (cookie)) {
drivers/i2c/busses/i2c-stm32.c +1 -2
@@ -134,8 +134,7 @@ int stm32_i2c_prep_dma_xfer(struct device *dev, struct stm32_i2c_dma *dma,reinit_completion (&dma->dma_complete); - txdesc->callback = callback; - txdesc->callback_param = dma_async_param; +dmaengine_desc_set_callback (txdesc, callback,NULL , dma_async_param); ret =dma_submit_error (dmaengine_submit (txdesc));if (ret <0 ) {dev_err (dev,"DMA submit failed\n" );
drivers/i2c/busses/i2c-tegra.c +1 -2
@@ -657,8 +657,7 @@ static int tegra_i2c_dma_submit(struct tegra_i2c_dev *i2c_dev, size_t len)return -EINVAL ; } - dma_desc->callback = tegra_i2c_dma_complete; - dma_desc->callback_param = i2c_dev; +dmaengine_desc_set_callback (dma_desc, tegra_i2c_dma_complete,NULL , i2c_dev);dmaengine_submit (dma_desc);dma_async_issue_pending (i2c_dev->dma_chan);
Signature · 1 line
2.43.0
Quoted 11 lines · On 11/2/2026 10:30 PM, [email protected] wrote:
From: Frank Li <[email protected]>
Replace open-coded assignments to callback and
callback_paramfields of structdma_async_tx_descriptorwith calls to thedmaengine_desc_set_callback()helper across various I2C bus drivers.No functional change intended. Prepare make to struct
dma_async_tx_descriptorprivate to the DMA engine.Signed-off-by Frank Li <[email protected]>---
Quoted 10 lines · On Mon, Nov 02, 2026 at 12:00:02PM -0500, [email protected] wrote:
From: Frank Li <[email protected]>
Replace open-coded assignments to callback and
callback_paramfields of structdma_async_tx_descriptorwith calls to thedmaengine_desc_set_callback()helper across various I2C bus drivers.No functional change intended. Prepare make to struct
dma_async_tx_descriptorprivate to the DMA engine.Signed-off-by Frank Li <[email protected]>
Quoted 10 lines
--- drivers/i2c/busses/i2c-at91-master.c | 6 ++---- drivers/i2c/busses/i2c-imx-lpi2c.c | 3 +-- drivers/i2c/busses/i2c-imx.c | 3 +-- drivers/i2c/busses/i2c-mxs.c | 3 +-- drivers/i2c/busses/i2c-qcom-geni.c | 3 +-- drivers/i2c/busses/i2c-qup.c | 6 ++---- drivers/i2c/busses/i2c-rcar.c | 3 +-- drivers/i2c/busses/i2c-sh_mobile.c | 3 +-- drivers/i2c/busses/i2c-stm32.c | 3 +--
For the STM32 I2C driver:
Regards,
Alain
Quoted 10 lines · On Mon, Nov 02, 2026 at 12:00:02PM -0500, [email protected] wrote:
From: Frank Li <[email protected]>
Replace open-coded assignments to callback and
callback_paramfields of structdma_async_tx_descriptorwith calls to thedmaengine_desc_set_callback()helper across various I2C bus drivers.No functional change intended. Prepare make to struct
dma_async_tx_descriptorprivate to the DMA engine.Signed-off-by Frank Li <[email protected]>
Looks actually less readable to me, but I won't bike-shed. Code changes look okay.
Quoted 7 lines · On Mon, Nov 02, 2026 at 12:00:02PM -0500, [email protected] wrote:
From: Frank Li <[email protected]>
Replace open-coded assignments to callback and
callback_paramfields of structdma_async_tx_descriptorwith calls to thedmaengine_desc_set_callback()helper across various I2C bus drivers.No functional change intended. Prepare make to struct
"Prepare to make struct ..." perhaps? Also, I think it'd be good to reference the commit that added the new dmaengine_desc_set_callback() so people have more context for why you're changing this. It's not immediately clear why this is helpful: "more readable" is very subjective and the fact that you're not hiding the structure definition somewhat weakens the argument of consistency because people can still manually set the fields after this patch. Maybe the plan is to eventually hide the structure altogether...
Still, seems like a worthwhile change to me and the patch looks correct, so: