diff --git a/drivers/audio/intel_dmic.c b/drivers/audio/intel_dmic.c index 0670d140e03..23185be9647 100644 --- a/drivers/audio/intel_dmic.c +++ b/drivers/audio/intel_dmic.c @@ -949,7 +949,8 @@ static int configure_registers(struct device *dev, return 0; } -static void dmic_dma_callback(void *arg, uint32_t chan, int err_code) +static void dmic_dma_callback(struct device *dev, void *arg, + uint32_t chan, int err_code) { void *buffer; size_t size; diff --git a/drivers/dma/dma_dw.c b/drivers/dma/dma_dw.c index f5cecb8c0eb..8c6cf7b568a 100644 --- a/drivers/dma/dma_dw.c +++ b/drivers/dma/dma_dw.c @@ -98,8 +98,9 @@ static void dw_dma_isr(void *arg) * freed in the user callback function once * all the blocks are transferred. */ - chan_data->dma_blkcallback(chan_data->blkcallback_arg, - channel, 0); + chan_data->dma_blkcallback(dev, + chan_data->blkcallback_arg, + channel, 0); } } @@ -108,8 +109,9 @@ static void dw_dma_isr(void *arg) status_tfr &= ~(1 << channel); chan_data = &dev_data->chan[channel]; if (chan_data->dma_tfrcallback) { - chan_data->dma_tfrcallback(chan_data->tfrcallback_arg, - channel, 0); + chan_data->dma_tfrcallback(dev, + chan_data->tfrcallback_arg, + channel, 0); } } } diff --git a/drivers/dma/dma_dw.h b/drivers/dma/dma_dw.h index 00b06c16549..13a778062d1 100644 --- a/drivers/dma/dma_dw.h +++ b/drivers/dma/dma_dw.h @@ -32,11 +32,11 @@ extern "C" { struct dma_chan_data { uint32_t direction; void *blkcallback_arg; - void (*dma_blkcallback)(void *arg, uint32_t channel, - int error_code); + void (*dma_blkcallback)(struct device *dev, void *arg, + uint32_t channel, int error_code); void *tfrcallback_arg; - void (*dma_tfrcallback)(void *arg, uint32_t channel, - int error_code); + void (*dma_tfrcallback)(struct device *dev, void *arg, + uint32_t channel, int error_code); }; #define DW_MAX_CHAN 8 diff --git a/drivers/dma/dma_mcux_edma.c b/drivers/dma/dma_mcux_edma.c index c16ae54ccdc..1544c5ee1a5 100644 --- a/drivers/dma/dma_mcux_edma.c +++ b/drivers/dma/dma_mcux_edma.c @@ -37,9 +37,10 @@ static __aligned(32) edma_tcd_t struct call_back { edma_transfer_config_t transferConfig; edma_handle_t edma_handle; + struct device *dev; void *callback_arg; - void (*dma_callback)(void *callback_arg, uint32_t channel, - int error_code); + void (*dma_callback)(struct device *dev, void *callback_arg, + uint32_t channel, int error_code); enum dma_channel_direction dir; bool busy; }; @@ -73,7 +74,7 @@ static void nxp_edma_callback(edma_handle_t *handle, void *param, ret = 0; } LOG_DBG("transfer %d", tcds); - data->dma_callback(data->callback_arg, channel, ret); + data->dma_callback(data->dev, data->callback_arg, channel, ret); } static void channel_irq(edma_handle_t *handle) @@ -330,6 +331,7 @@ static int dma_mcux_edma_configure(struct device *dev, uint32_t channel, LOG_DBG("INSTALL call back on channel %d", channel); data->callback_arg = config->callback_arg; data->dma_callback = config->dma_callback; + data->dev = dev; } irq_unlock(key); diff --git a/drivers/dma/dma_nios2_msgdma.c b/drivers/dma/dma_nios2_msgdma.c index 6979b5ea477..af3effbbeb6 100644 --- a/drivers/dma/dma_nios2_msgdma.c +++ b/drivers/dma/dma_nios2_msgdma.c @@ -26,8 +26,8 @@ struct nios2_msgdma_dev_cfg { uint32_t direction; struct k_sem sem_lock; void *callback_arg; - void (*dma_callback)(void *arg, uint32_t id, - int error_code); + void (*dma_callback)(struct device *dev, void *arg, + uint32_t id, int error_code); }; #define DEV_NAME(dev) ((dev)->name) @@ -45,8 +45,8 @@ static void nios2_msgdma_isr(void *arg) static void nios2_msgdma_callback(void *context) { - struct nios2_msgdma_dev_cfg *dev_cfg = - DEV_CFG((struct device *)context); + struct device *dev = (struct device *)context; + struct nios2_msgdma_dev_cfg *dev_cfg = DEV_CFG(dev); int err_code; uint32_t status; @@ -62,7 +62,7 @@ static void nios2_msgdma_callback(void *context) LOG_DBG("msgdma csr status Reg: 0x%x", status); - dev_cfg->dma_callback(dev_cfg->callback_arg, 0, err_code); + dev_cfg->dma_callback(dev, dev_cfg->callback_arg, 0, err_code); } static int nios2_msgdma_config(struct device *dev, uint32_t channel, diff --git a/drivers/dma/dma_pl330.c b/drivers/dma/dma_pl330.c index 1b9af79a3b7..e569c20e013 100644 --- a/drivers/dma/dma_pl330.c +++ b/drivers/dma/dma_pl330.c @@ -536,7 +536,7 @@ static int dma_pl330_transfer_start(struct device *dev, uint32_t channel) /* Execute callback */ if (channel_cfg->dma_callback) { - channel_cfg->dma_callback(channel_cfg->callback_arg, + channel_cfg->dma_callback(dev, channel_cfg->callback_arg, channel, ret); } diff --git a/drivers/dma/dma_pl330.h b/drivers/dma/dma_pl330.h index 32ba3fa86ab..8b7cbb44487 100644 --- a/drivers/dma/dma_pl330.h +++ b/drivers/dma/dma_pl330.h @@ -133,8 +133,8 @@ struct dma_pl330_ch_internal { int nonsec_mode; }; -typedef void (*dma_xfer_callback)(void *callback_arg, uint32_t channel, - int error_code); +typedef void (*dma_xfer_callback)(struct device *dev, void *callback_arg, + uint32_t channel, int error_code); struct dma_pl330_ch_config { /* Channel configuration details */ diff --git a/drivers/dma/dma_sam0.c b/drivers/dma/dma_sam0.c index 9eac3a0c09c..4d65f3bcf08 100644 --- a/drivers/dma/dma_sam0.c +++ b/drivers/dma/dma_sam0.c @@ -15,8 +15,8 @@ LOG_MODULE_REGISTER(dma_sam0, CONFIG_DMA_LOG_LEVEL); #define DMA_REGS ((Dmac *)DT_INST_REG_ADDR(0)) -typedef void (*dma_callback)(void *callback_arg, uint32_t channel, - int error_code); +typedef void (*dma_callback)(struct device *dev, void *callback_arg, + uint32_t channel, int error_code); struct dma_sam0_channel { dma_callback cb; @@ -50,11 +50,12 @@ static void dma_sam0_isr(void *arg) if (pend & DMAC_INTPEND_TERR) { if (chdata->cb) { - chdata->cb(chdata->cb_arg, channel, -DMAC_INTPEND_TERR); + chdata->cb(dev, chdata->cb_arg, + channel, -DMAC_INTPEND_TERR); } } else if (pend & DMAC_INTPEND_TCMPL) { if (chdata->cb) { - chdata->cb(chdata->cb_arg, channel, 0); + chdata->cb(dev, chdata->cb_arg, channel, 0); } } diff --git a/drivers/dma/dma_sam_xdmac.c b/drivers/dma/dma_sam_xdmac.c index f5f60a1fdd7..0f76904920e 100644 --- a/drivers/dma/dma_sam_xdmac.c +++ b/drivers/dma/dma_sam_xdmac.c @@ -76,8 +76,8 @@ static void sam_xdmac_isr(void *arg) /* Execute callback */ if (channel_cfg->callback) { - channel_cfg->callback(channel_cfg->callback_arg, - channel, err); + channel_cfg->callback(dev, channel_cfg->callback_arg, + channel, err); } } } diff --git a/drivers/dma/dma_sam_xdmac.h b/drivers/dma/dma_sam_xdmac.h index 505560958d4..aeeef23b080 100644 --- a/drivers/dma/dma_sam_xdmac.h +++ b/drivers/dma/dma_sam_xdmac.h @@ -18,7 +18,8 @@ extern "C" { #endif /** DMA transfer callback */ -typedef void (*dma_callback)(void *arg, uint32_t channel, int error_code); +typedef void (*dma_callback)(struct device *dev, void *arg, + uint32_t channel, int error_code); /* XDMA_MBR_UBC */ #define XDMA_UBC_NDE (0x1u << 24) diff --git a/drivers/dma/dma_stm32.c b/drivers/dma/dma_stm32.c index cb801f58341..0bdca74af45 100644 --- a/drivers/dma/dma_stm32.c +++ b/drivers/dma/dma_stm32.c @@ -90,21 +90,21 @@ static void dma_stm32_irq_handler(void *arg) #ifdef CONFIG_DMAMUX_STM32 stream->busy = false; /* the callback function expects the dmamux channel nb */ - stream->dma_callback(stream->callback_arg, - stream->mux_channel, 0); + stream->dma_callback(dev, stream->callback_arg, + stream->mux_channel, 0); #else - stream->dma_callback(stream->callback_arg, id + STREAM_OFFSET, - 0); + stream->dma_callback(dev, stream->callback_arg, + id + STREAM_OFFSET, 0); #endif /* CONFIG_DMAMUX_STM32 */ } else if (stm32_dma_is_unexpected_irq_happened(dma, id)) { LOG_ERR("Unexpected irq happened."); #ifdef CONFIG_DMAMUX_STM32 - stream->dma_callback(stream->callback_arg, - stream->mux_channel, -EIO); + stream->dma_callback(dev, stream->callback_arg, + stream->mux_channel, -EIO); #else - stream->dma_callback(stream->callback_arg, id + STREAM_OFFSET, - -EIO); + stream->dma_callback(dev, stream->callback_arg, + id + STREAM_OFFSET, -EIO); #endif /* CONFIG_DMAMUX_STM32 */ } else { LOG_ERR("Transfer Error."); @@ -112,11 +112,11 @@ static void dma_stm32_irq_handler(void *arg) dma_stm32_clear_stream_irq(dev, id); #ifdef CONFIG_DMAMUX_STM32 - stream->dma_callback(stream->callback_arg, - stream->mux_channel, -EIO); + stream->dma_callback(dev, stream->callback_arg, + stream->mux_channel, -EIO); #else - stream->dma_callback(stream->callback_arg, id + STREAM_OFFSET, - -EIO); + stream->dma_callback(dev, stream->callback_arg, + id + STREAM_OFFSET, -EIO); #endif /* CONFIG_DMAMUX_STM32 */ } } diff --git a/drivers/dma/dma_stm32.h b/drivers/dma/dma_stm32.h index 4547721cbed..a5567203854 100644 --- a/drivers/dma/dma_stm32.h +++ b/drivers/dma/dma_stm32.h @@ -20,8 +20,8 @@ struct dma_stm32_stream { uint32_t src_size; uint32_t dst_size; void *callback_arg; /* holds the client data */ - void (*dma_callback)(void *arg, uint32_t id, - int error_code); + void (*dma_callback)(struct device *dev, void *arg, + uint32_t id, int error_code); }; struct dma_stm32_data { diff --git a/drivers/i2c/i2c_sam0.c b/drivers/i2c/i2c_sam0.c index f52c7810460..f17f3d7cb33 100644 --- a/drivers/i2c/i2c_sam0.c +++ b/drivers/i2c/i2c_sam0.c @@ -181,13 +181,15 @@ static void i2c_sam0_isr(void *arg) #ifdef CONFIG_I2C_SAM0_DMA_DRIVEN -static void i2c_sam0_dma_write_done(void *arg, uint32_t id, int error_code) +static void i2c_sam0_dma_write_done(struct device *dma_dev, void *arg, + uint32_t id, int error_code) { struct device *dev = arg; struct i2c_sam0_dev_data *data = DEV_DATA(dev); const struct i2c_sam0_dev_config *const cfg = DEV_CFG(dev); SercomI2cm *i2c = cfg->regs; + ARG_UNUSED(dma_dev); ARG_UNUSED(id); int key = irq_lock(); @@ -274,13 +276,15 @@ static bool i2c_sam0_dma_write_start(struct device *dev) return true; } -static void i2c_sam0_dma_read_done(void *arg, uint32_t id, int error_code) +static void i2c_sam0_dma_read_done(struct device *dma_dev, void *arg, + uint32_t id, int error_code) { struct device *dev = arg; struct i2c_sam0_dev_data *data = DEV_DATA(dev); const struct i2c_sam0_dev_config *const cfg = DEV_CFG(dev); SercomI2cm *i2c = cfg->regs; + ARG_UNUSED(dma_dev); ARG_UNUSED(id); int key = irq_lock(); diff --git a/drivers/i2s/i2s_cavs.c b/drivers/i2s/i2s_cavs.c index 46af6fa9d10..7738e294c5f 100644 --- a/drivers/i2s/i2s_cavs.c +++ b/drivers/i2s/i2s_cavs.c @@ -166,7 +166,7 @@ I2S_DEVICE_OBJECT_DECLARE(1); I2S_DEVICE_OBJECT_DECLARE(2); I2S_DEVICE_OBJECT_DECLARE(3); -static void i2s_dma_tx_callback(void *, uint32_t, int); +static void i2s_dma_tx_callback(struct device *, void *, uint32_t, int); static void i2s_tx_stream_disable(struct i2s_cavs_dev_data *, volatile struct i2s_cavs_ssp *const, struct device *); static void i2s_rx_stream_disable(struct i2s_cavs_dev_data *, @@ -186,8 +186,8 @@ static inline void i2s_purge_stream_buffers(struct stream *strm, } /* This function is executed in the interrupt context */ -static void i2s_dma_tx_callback(void *arg, uint32_t channel, - int status) +static void i2s_dma_tx_callback(struct device *dma_dev, void *arg, + uint32_t channel, int status) { struct device *dev = (struct device *)arg; const struct i2s_cavs_config *const dev_cfg = DEV_CFG(dev); @@ -242,7 +242,8 @@ static void i2s_dma_tx_callback(void *arg, uint32_t channel, } } -static void i2s_dma_rx_callback(void *arg, uint32_t channel, int status) +static void i2s_dma_rx_callback(struct device *dma_dev, void *arg, + uint32_t channel, int status) { struct device *dev = (struct device *)arg; const struct i2s_cavs_config *const dev_cfg = DEV_CFG(dev); diff --git a/drivers/i2s/i2s_ll_stm32.c b/drivers/i2s/i2s_ll_stm32.c index 572f05d9662..d30903aaefd 100644 --- a/drivers/i2s/i2s_ll_stm32.c +++ b/drivers/i2s/i2s_ll_stm32.c @@ -492,7 +492,8 @@ static void rx_stream_disable(struct stream *stream, struct device *dev); static void tx_stream_disable(struct stream *stream, struct device *dev); /* This function is executed in the interrupt context */ -static void dma_rx_callback(void *arg, uint32_t channel, int status) +static void dma_rx_callback(struct device *dma_dev, void *arg, + uint32_t channel, int status) { struct device *dev = get_dev_from_rx_dma_channel(channel); const struct i2s_stm32_cfg *cfg = DEV_CFG(dev); @@ -558,7 +559,8 @@ rx_disable: rx_stream_disable(stream, dev); } -static void dma_tx_callback(void *arg, uint32_t channel, int status) +static void dma_tx_callback(struct device *dma_dev, void *arg, + uint32_t channel, int status) { struct device *dev = get_dev_from_tx_dma_channel(channel); const struct i2s_stm32_cfg *cfg = DEV_CFG(dev); diff --git a/drivers/i2s/i2s_sam_ssc.c b/drivers/i2s/i2s_sam_ssc.c index 11c9de82d01..100861b79fb 100644 --- a/drivers/i2s/i2s_sam_ssc.c +++ b/drivers/i2s/i2s_sam_ssc.c @@ -104,8 +104,8 @@ struct i2s_sam_dev_data { #define MODULO_INC(val, max) { val = (++val < max) ? val : 0; } static struct device *get_dev_from_dma_channel(uint32_t dma_channel); -static void dma_rx_callback(void *, uint32_t, int); -static void dma_tx_callback(void *, uint32_t, int); +static void dma_rx_callback(struct device *, void *, uint32_t, int); +static void dma_tx_callback(struct device *, void *, uint32_t, int); static void rx_stream_disable(struct stream *, Ssc *const, struct device *); static void tx_stream_disable(struct stream *, Ssc *const, struct device *); @@ -186,7 +186,8 @@ static int start_dma(struct device *dev_dma, uint32_t channel, } /* This function is executed in the interrupt context */ -static void dma_rx_callback(void *callback_arg, uint32_t channel, int status) +static void dma_rx_callback(struct device *dma_dev, void *callback_arg, + uint32_t channel, int status) { struct device *dev = get_dev_from_dma_channel(channel); const struct i2s_sam_dev_cfg *const dev_cfg = DEV_CFG(dev); @@ -245,7 +246,8 @@ rx_disable: } /* This function is executed in the interrupt context */ -static void dma_tx_callback(void *callback_arg, uint32_t channel, int status) +static void dma_tx_callback(struct device *dma_dev, void *callback_arg, + uint32_t channel, int status) { struct device *dev = get_dev_from_dma_channel(channel); const struct i2s_sam_dev_cfg *const dev_cfg = DEV_CFG(dev); diff --git a/drivers/serial/uart_sam0.c b/drivers/serial/uart_sam0.c index 028a52f3aaf..2a4caf4306b 100644 --- a/drivers/serial/uart_sam0.c +++ b/drivers/serial/uart_sam0.c @@ -120,8 +120,10 @@ static int uart_sam0_set_baudrate(SercomUsart *const usart, uint32_t baudrate, #if CONFIG_UART_ASYNC_API -static void uart_sam0_dma_tx_done(void *arg, uint32_t id, int error_code) +static void uart_sam0_dma_tx_done(struct device *dma_dev, void *arg, + uint32_t id, int error_code) { + ARG_UNUSED(dma_dev); ARG_UNUSED(id); ARG_UNUSED(error_code); @@ -222,8 +224,10 @@ static void uart_sam0_notify_rx_processed(struct uart_sam0_dev_data *dev_data, &evt, dev_data->async_cb_data); } -static void uart_sam0_dma_rx_done(void *arg, uint32_t id, int error_code) +static void uart_sam0_dma_rx_done(struct device *dma_dev, void *arg, + uint32_t id, int error_code) { + ARG_UNUSED(dma_dev); ARG_UNUSED(id); ARG_UNUSED(error_code); diff --git a/drivers/spi/spi_ll_stm32.c b/drivers/spi/spi_ll_stm32.c index 58ff8a56262..4747435ed62 100644 --- a/drivers/spi/spi_ll_stm32.c +++ b/drivers/spi/spi_ll_stm32.c @@ -57,7 +57,8 @@ LOG_MODULE_REGISTER(spi_ll_stm32); uint32_t nop_tx; /* This function is executed in the interrupt context */ -static void dma_callback(void *arg, uint32_t channel, int status) +static void dma_callback(struct device *dev, void *arg, + uint32_t channel, int status) { /* callback_arg directly holds the client data */ struct spi_stm32_data *data = arg; diff --git a/drivers/spi/spi_sam0.c b/drivers/spi/spi_sam0.c index 536ba75caeb..0b7f4108152 100644 --- a/drivers/spi/spi_sam0.c +++ b/drivers/spi/spi_sam0.c @@ -436,7 +436,8 @@ static int spi_sam0_transceive_sync(struct device *dev, #ifdef CONFIG_SPI_ASYNC -static void spi_sam0_dma_rx_done(void *arg, uint32_t id, int error_code); +static void spi_sam0_dma_rx_done(struct device *dma_dev, void *arg, + uint32_t id, int error_code); static int spi_sam0_dma_rx_load(struct device *dev, uint8_t *buf, size_t len) @@ -582,7 +583,8 @@ static int spi_sam0_dma_advance_buffers(struct device *dev) return 0; } -static void spi_sam0_dma_rx_done(void *arg, uint32_t id, int error_code) +static void spi_sam0_dma_rx_done(struct device *dma_dev, void *arg, + uint32_t id, int error_code) { struct device *dev = arg; const struct spi_sam0_config *cfg = dev->config_info;