drivers: dma: Align all drivers using user_data for callback

s/callback_arg/user_data

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2020-07-29 09:02:03 +02:00 committed by Carles Cufí
commit 1580768fd3
16 changed files with 44 additions and 44 deletions

View file

@ -99,7 +99,7 @@ static void dw_dma_isr(void *arg)
* all the blocks are transferred. * all the blocks are transferred.
*/ */
chan_data->dma_blkcallback(dev, chan_data->dma_blkcallback(dev,
chan_data->blkcallback_arg, chan_data->blkuser_data,
channel, 0); channel, 0);
} }
} }
@ -110,7 +110,7 @@ static void dw_dma_isr(void *arg)
chan_data = &dev_data->chan[channel]; chan_data = &dev_data->chan[channel];
if (chan_data->dma_tfrcallback) { if (chan_data->dma_tfrcallback) {
chan_data->dma_tfrcallback(dev, chan_data->dma_tfrcallback(dev,
chan_data->tfrcallback_arg, chan_data->tfruser_data,
channel, 0); channel, 0);
} }
} }
@ -216,11 +216,11 @@ static int dw_dma_config(struct device *dev, uint32_t channel,
*/ */
if (cfg->complete_callback_en) { if (cfg->complete_callback_en) {
chan_data->dma_blkcallback = cfg->dma_callback; chan_data->dma_blkcallback = cfg->dma_callback;
chan_data->blkcallback_arg = cfg->callback_arg; chan_data->blkuser_data = cfg->user_data;
dw_write(dev_cfg->base, DW_MASK_BLOCK, INT_UNMASK(channel)); dw_write(dev_cfg->base, DW_MASK_BLOCK, INT_UNMASK(channel));
} else { } else {
chan_data->dma_tfrcallback = cfg->dma_callback; chan_data->dma_tfrcallback = cfg->dma_callback;
chan_data->tfrcallback_arg = cfg->callback_arg; chan_data->tfruser_data = cfg->user_data;
dw_write(dev_cfg->base, DW_MASK_TFR, INT_UNMASK(channel)); dw_write(dev_cfg->base, DW_MASK_TFR, INT_UNMASK(channel));
} }

View file

@ -31,9 +31,9 @@ extern "C" {
/* data for each DMA channel */ /* data for each DMA channel */
struct dma_chan_data { struct dma_chan_data {
uint32_t direction; uint32_t direction;
void *blkcallback_arg; void *blkuser_data;
dma_callback_t dma_blkcallback; dma_callback_t dma_blkcallback;
void *tfrcallback_arg; void *tfruser_data;
dma_callback_t dma_tfrcallback; dma_callback_t dma_tfrcallback;
}; };

View file

@ -38,7 +38,7 @@ struct call_back {
edma_transfer_config_t transferConfig; edma_transfer_config_t transferConfig;
edma_handle_t edma_handle; edma_handle_t edma_handle;
struct device *dev; struct device *dev;
void *callback_arg; void *user_data;
dma_callback_t dma_callback; dma_callback_t dma_callback;
enum dma_channel_direction dir; enum dma_channel_direction dir;
bool busy; bool busy;
@ -73,7 +73,7 @@ static void nxp_edma_callback(edma_handle_t *handle, void *param,
ret = 0; ret = 0;
} }
LOG_DBG("transfer %d", tcds); LOG_DBG("transfer %d", tcds);
data->dma_callback(data->dev, data->callback_arg, channel, ret); data->dma_callback(data->dev, data->user_data, channel, ret);
} }
static void channel_irq(edma_handle_t *handle) static void channel_irq(edma_handle_t *handle)
@ -328,7 +328,7 @@ static int dma_mcux_edma_configure(struct device *dev, uint32_t channel,
data->busy = false; data->busy = false;
if (config->dma_callback) { if (config->dma_callback) {
LOG_DBG("INSTALL call back on channel %d", channel); LOG_DBG("INSTALL call back on channel %d", channel);
data->callback_arg = config->callback_arg; data->user_data = config->user_data;
data->dma_callback = config->dma_callback; data->dma_callback = config->dma_callback;
data->dev = dev; data->dev = dev;
} }

View file

@ -25,7 +25,7 @@ struct nios2_msgdma_dev_cfg {
alt_msgdma_standard_descriptor desc; alt_msgdma_standard_descriptor desc;
uint32_t direction; uint32_t direction;
struct k_sem sem_lock; struct k_sem sem_lock;
void *callback_arg; void *user_data;
dma_callback_t dma_callback; dma_callback_t dma_callback;
}; };
@ -61,7 +61,7 @@ static void nios2_msgdma_callback(void *context)
LOG_DBG("msgdma csr status Reg: 0x%x", status); LOG_DBG("msgdma csr status Reg: 0x%x", status);
dev_cfg->dma_callback(dev, dev_cfg->callback_arg, 0, err_code); dev_cfg->dma_callback(dev, dev_cfg->user_data, 0, err_code);
} }
static int nios2_msgdma_config(struct device *dev, uint32_t channel, static int nios2_msgdma_config(struct device *dev, uint32_t channel,
@ -103,7 +103,7 @@ static int nios2_msgdma_config(struct device *dev, uint32_t channel,
k_sem_take(&dev_cfg->sem_lock, K_FOREVER); k_sem_take(&dev_cfg->sem_lock, K_FOREVER);
dev_cfg->dma_callback = cfg->dma_callback; dev_cfg->dma_callback = cfg->dma_callback;
dev_cfg->callback_arg = cfg->callback_arg; dev_cfg->user_data = cfg->user_data;
dev_cfg->direction = cfg->channel_direction; dev_cfg->direction = cfg->channel_direction;
dma_block = cfg->head_block; dma_block = cfg->head_block;
control = ALTERA_MSGDMA_DESCRIPTOR_CONTROL_TRANSFER_COMPLETE_IRQ_MASK | control = ALTERA_MSGDMA_DESCRIPTOR_CONTROL_TRANSFER_COMPLETE_IRQ_MASK |

View file

@ -500,7 +500,7 @@ static int dma_pl330_configure(struct device *dev, uint32_t channel,
channel_cfg->trans_size = cfg->head_block->block_size; channel_cfg->trans_size = cfg->head_block->block_size;
channel_cfg->dma_callback = cfg->dma_callback; channel_cfg->dma_callback = cfg->dma_callback;
channel_cfg->callback_arg = cfg->callback_arg; channel_cfg->user_data = cfg->user_data;
if (cfg->head_block->source_addr_adj == DMA_ADDR_ADJ_INCREMENT || if (cfg->head_block->source_addr_adj == DMA_ADDR_ADJ_INCREMENT ||
cfg->head_block->source_addr_adj == DMA_ADDR_ADJ_NO_CHANGE) { cfg->head_block->source_addr_adj == DMA_ADDR_ADJ_NO_CHANGE) {
@ -536,7 +536,7 @@ static int dma_pl330_transfer_start(struct device *dev, uint32_t channel)
/* Execute callback */ /* Execute callback */
if (channel_cfg->dma_callback) { if (channel_cfg->dma_callback) {
channel_cfg->dma_callback(dev, channel_cfg->callback_arg, channel_cfg->dma_callback(dev, channel_cfg->user_data,
channel, ret); channel, ret);
} }

View file

@ -141,7 +141,7 @@ struct dma_pl330_ch_config {
enum dma_addr_adj dst_addr_adj; enum dma_addr_adj dst_addr_adj;
enum dma_channel_direction direction; enum dma_channel_direction direction;
uint32_t trans_size; uint32_t trans_size;
void *callback_arg; void *user_data;
dma_callback_t dma_callback; dma_callback_t dma_callback;
uint32_t dma_exe_addr; uint32_t dma_exe_addr;
struct k_mutex ch_mutex; struct k_mutex ch_mutex;

View file

@ -17,7 +17,7 @@ LOG_MODULE_REGISTER(dma_sam0, CONFIG_DMA_LOG_LEVEL);
struct dma_sam0_channel { struct dma_sam0_channel {
dma_callback_t cb; dma_callback_t cb;
void *cb_arg; void *user_data;
}; };
struct dma_sam0_data { struct dma_sam0_data {
@ -47,12 +47,12 @@ static void dma_sam0_isr(void *arg)
if (pend & DMAC_INTPEND_TERR) { if (pend & DMAC_INTPEND_TERR) {
if (chdata->cb) { if (chdata->cb) {
chdata->cb(dev, chdata->cb_arg, chdata->cb(dev, chdata->user_data,
channel, -DMAC_INTPEND_TERR); channel, -DMAC_INTPEND_TERR);
} }
} else if (pend & DMAC_INTPEND_TCMPL) { } else if (pend & DMAC_INTPEND_TCMPL) {
if (chdata->cb) { if (chdata->cb) {
chdata->cb(dev, chdata->cb_arg, channel, 0); chdata->cb(dev, chdata->user_data, channel, 0);
} }
} }
@ -249,7 +249,7 @@ static int dma_sam0_config(struct device *dev, uint32_t channel,
channel_control = &data->channels[channel]; channel_control = &data->channels[channel];
channel_control->cb = config->dma_callback; channel_control->cb = config->dma_callback;
channel_control->cb_arg = config->callback_arg; channel_control->user_data = config->user_data;
LOG_DBG("Configured channel %d for %08X to %08X (%u)", LOG_DBG("Configured channel %d for %08X to %08X (%u)",
channel, channel,

View file

@ -28,7 +28,7 @@ LOG_MODULE_REGISTER(dma_sam_xdmac);
/* DMA channel configuration */ /* DMA channel configuration */
struct sam_xdmac_channel_cfg { struct sam_xdmac_channel_cfg {
void *callback_arg; void *user_data;
dma_callback_t callback; dma_callback_t callback;
}; };
@ -76,7 +76,7 @@ static void sam_xdmac_isr(void *arg)
/* Execute callback */ /* Execute callback */
if (channel_cfg->callback) { if (channel_cfg->callback) {
channel_cfg->callback(dev, channel_cfg->callback_arg, channel_cfg->callback(dev, channel_cfg->user_data,
channel, err); channel, err);
} }
} }
@ -258,7 +258,7 @@ static int sam_xdmac_config(struct device *dev, uint32_t channel,
} }
dev_data->dma_channels[channel].callback = cfg->dma_callback; dev_data->dma_channels[channel].callback = cfg->dma_callback;
dev_data->dma_channels[channel].callback_arg = cfg->callback_arg; dev_data->dma_channels[channel].user_data = cfg->user_data;
(void)memset(&transfer_cfg, 0, sizeof(transfer_cfg)); (void)memset(&transfer_cfg, 0, sizeof(transfer_cfg));
transfer_cfg.sa = cfg->head_block->source_address; transfer_cfg.sa = cfg->head_block->source_address;

View file

@ -90,20 +90,20 @@ static void dma_stm32_irq_handler(void *arg)
#ifdef CONFIG_DMAMUX_STM32 #ifdef CONFIG_DMAMUX_STM32
stream->busy = false; stream->busy = false;
/* the callback function expects the dmamux channel nb */ /* the callback function expects the dmamux channel nb */
stream->dma_callback(dev, stream->callback_arg, stream->dma_callback(dev, stream->user_data,
stream->mux_channel, 0); stream->mux_channel, 0);
#else #else
stream->dma_callback(dev, stream->callback_arg, stream->dma_callback(dev, stream->user_data,
id + STREAM_OFFSET, 0); id + STREAM_OFFSET, 0);
#endif /* CONFIG_DMAMUX_STM32 */ #endif /* CONFIG_DMAMUX_STM32 */
} else if (stm32_dma_is_unexpected_irq_happened(dma, id)) { } else if (stm32_dma_is_unexpected_irq_happened(dma, id)) {
LOG_ERR("Unexpected irq happened."); LOG_ERR("Unexpected irq happened.");
#ifdef CONFIG_DMAMUX_STM32 #ifdef CONFIG_DMAMUX_STM32
stream->dma_callback(dev, stream->callback_arg, stream->dma_callback(dev, stream->user_data,
stream->mux_channel, -EIO); stream->mux_channel, -EIO);
#else #else
stream->dma_callback(dev, stream->callback_arg, stream->dma_callback(dev, stream->user_data,
id + STREAM_OFFSET, -EIO); id + STREAM_OFFSET, -EIO);
#endif /* CONFIG_DMAMUX_STM32 */ #endif /* CONFIG_DMAMUX_STM32 */
} else { } else {
@ -112,10 +112,10 @@ static void dma_stm32_irq_handler(void *arg)
dma_stm32_clear_stream_irq(dev, id); dma_stm32_clear_stream_irq(dev, id);
#ifdef CONFIG_DMAMUX_STM32 #ifdef CONFIG_DMAMUX_STM32
stream->dma_callback(dev, stream->callback_arg, stream->dma_callback(dev, stream->user_data,
stream->mux_channel, -EIO); stream->mux_channel, -EIO);
#else #else
stream->dma_callback(dev, stream->callback_arg, stream->dma_callback(dev, stream->user_data,
id + STREAM_OFFSET, -EIO); id + STREAM_OFFSET, -EIO);
#endif /* CONFIG_DMAMUX_STM32 */ #endif /* CONFIG_DMAMUX_STM32 */
} }
@ -310,7 +310,7 @@ static int dma_stm32_configure(struct device *dev, uint32_t id,
stream->busy = true; stream->busy = true;
stream->dma_callback = config->dma_callback; stream->dma_callback = config->dma_callback;
stream->direction = config->channel_direction; stream->direction = config->channel_direction;
stream->callback_arg = config->callback_arg; stream->user_data = config->user_data;
stream->src_size = config->source_data_size; stream->src_size = config->source_data_size;
stream->dst_size = config->dest_data_size; stream->dst_size = config->dest_data_size;

View file

@ -19,7 +19,7 @@ struct dma_stm32_stream {
bool busy; bool busy;
uint32_t src_size; uint32_t src_size;
uint32_t dst_size; uint32_t dst_size;
void *callback_arg; /* holds the client data */ void *user_data; /* holds the client data */
dma_callback_t dma_callback; dma_callback_t dma_callback;
}; };

View file

@ -248,7 +248,7 @@ static bool i2c_sam0_dma_write_start(struct device *dev)
dma_cfg.channel_direction = MEMORY_TO_PERIPHERAL; dma_cfg.channel_direction = MEMORY_TO_PERIPHERAL;
dma_cfg.source_data_size = 1; dma_cfg.source_data_size = 1;
dma_cfg.dest_data_size = 1; dma_cfg.dest_data_size = 1;
dma_cfg.callback_arg = dev; dma_cfg.user_data = dev;
dma_cfg.dma_callback = i2c_sam0_dma_write_done; dma_cfg.dma_callback = i2c_sam0_dma_write_done;
dma_cfg.block_count = 1; dma_cfg.block_count = 1;
dma_cfg.head_block = &dma_blk; dma_cfg.head_block = &dma_blk;
@ -345,7 +345,7 @@ static bool i2c_sam0_dma_read_start(struct device *dev)
dma_cfg.channel_direction = PERIPHERAL_TO_MEMORY; dma_cfg.channel_direction = PERIPHERAL_TO_MEMORY;
dma_cfg.source_data_size = 1; dma_cfg.source_data_size = 1;
dma_cfg.dest_data_size = 1; dma_cfg.dest_data_size = 1;
dma_cfg.callback_arg = dev; dma_cfg.user_data = dev;
dma_cfg.dma_callback = i2c_sam0_dma_read_done; dma_cfg.dma_callback = i2c_sam0_dma_read_done;
dma_cfg.block_count = 1; dma_cfg.block_count = 1;
dma_cfg.head_block = &dma_blk; dma_cfg.head_block = &dma_blk;

View file

@ -63,7 +63,7 @@ LOG_MODULE_REGISTER(LOG_DOMAIN);
.source_burst_length = CAVS_I2S_DMA_BURST_SIZE,\ .source_burst_length = CAVS_I2S_DMA_BURST_SIZE,\
.dest_burst_length = CAVS_I2S_DMA_BURST_SIZE,\ .dest_burst_length = CAVS_I2S_DMA_BURST_SIZE,\
.dma_callback = i2s_dma_tx_callback, \ .dma_callback = i2s_dma_tx_callback, \
.callback_arg = I2S_DEVICE_OBJECT(i2s_id),\ .user_data = I2S_DEVICE_OBJECT(i2s_id),\
.complete_callback_en = 1, \ .complete_callback_en = 1, \
.error_callback_en = 1, \ .error_callback_en = 1, \
.block_count = 1, \ .block_count = 1, \
@ -79,7 +79,7 @@ LOG_MODULE_REGISTER(LOG_DOMAIN);
.source_burst_length = CAVS_I2S_DMA_BURST_SIZE,\ .source_burst_length = CAVS_I2S_DMA_BURST_SIZE,\
.dest_burst_length = CAVS_I2S_DMA_BURST_SIZE,\ .dest_burst_length = CAVS_I2S_DMA_BURST_SIZE,\
.dma_callback = i2s_dma_rx_callback,\ .dma_callback = i2s_dma_rx_callback,\
.callback_arg = I2S_DEVICE_OBJECT(i2s_id),\ .user_data = I2S_DEVICE_OBJECT(i2s_id),\
.complete_callback_en = 1, \ .complete_callback_en = 1, \
.error_callback_en = 1, \ .error_callback_en = 1, \
.block_count = 1, \ .block_count = 1, \

View file

@ -186,7 +186,7 @@ static int start_dma(struct device *dev_dma, uint32_t channel,
} }
/* This function is executed in the interrupt context */ /* This function is executed in the interrupt context */
static void dma_rx_callback(struct device *dma_dev, void *callback_arg, static void dma_rx_callback(struct device *dma_dev, void *user_data,
uint32_t channel, int status) uint32_t channel, int status)
{ {
struct device *dev = get_dev_from_dma_channel(channel); struct device *dev = get_dev_from_dma_channel(channel);
@ -196,7 +196,7 @@ static void dma_rx_callback(struct device *dma_dev, void *callback_arg,
struct stream *stream = &dev_data->rx; struct stream *stream = &dev_data->rx;
int ret; int ret;
ARG_UNUSED(callback_arg); ARG_UNUSED(user_data);
__ASSERT_NO_MSG(stream->mem_block != NULL); __ASSERT_NO_MSG(stream->mem_block != NULL);
/* Stop reception if there was an error */ /* Stop reception if there was an error */
@ -246,7 +246,7 @@ rx_disable:
} }
/* This function is executed in the interrupt context */ /* This function is executed in the interrupt context */
static void dma_tx_callback(struct device *dma_dev, void *callback_arg, static void dma_tx_callback(struct device *dma_dev, void *user_data,
uint32_t channel, int status) uint32_t channel, int status)
{ {
struct device *dev = get_dev_from_dma_channel(channel); struct device *dev = get_dev_from_dma_channel(channel);
@ -257,7 +257,7 @@ static void dma_tx_callback(struct device *dma_dev, void *callback_arg,
size_t mem_block_size; size_t mem_block_size;
int ret; int ret;
ARG_UNUSED(callback_arg); ARG_UNUSED(user_data);
__ASSERT_NO_MSG(stream->mem_block != NULL); __ASSERT_NO_MSG(stream->mem_block != NULL);
/* All block data sent */ /* All block data sent */

View file

@ -581,7 +581,7 @@ static int uart_sam0_init(struct device *dev)
dma_cfg.channel_direction = MEMORY_TO_PERIPHERAL; dma_cfg.channel_direction = MEMORY_TO_PERIPHERAL;
dma_cfg.source_data_size = 1; dma_cfg.source_data_size = 1;
dma_cfg.dest_data_size = 1; dma_cfg.dest_data_size = 1;
dma_cfg.callback_arg = dev; dma_cfg.user_data = dev;
dma_cfg.dma_callback = uart_sam0_dma_tx_done; dma_cfg.dma_callback = uart_sam0_dma_tx_done;
dma_cfg.block_count = 1; dma_cfg.block_count = 1;
dma_cfg.head_block = &dma_blk; dma_cfg.head_block = &dma_blk;
@ -609,7 +609,7 @@ static int uart_sam0_init(struct device *dev)
dma_cfg.channel_direction = PERIPHERAL_TO_MEMORY; dma_cfg.channel_direction = PERIPHERAL_TO_MEMORY;
dma_cfg.source_data_size = 1; dma_cfg.source_data_size = 1;
dma_cfg.dest_data_size = 1; dma_cfg.dest_data_size = 1;
dma_cfg.callback_arg = dev; dma_cfg.user_data = dev;
dma_cfg.dma_callback = uart_sam0_dma_rx_done; dma_cfg.dma_callback = uart_sam0_dma_rx_done;
dma_cfg.block_count = 1; dma_cfg.block_count = 1;
dma_cfg.head_block = &dma_blk; dma_cfg.head_block = &dma_blk;

View file

@ -60,7 +60,7 @@ uint32_t nop_tx;
static void dma_callback(struct device *dev, void *arg, static void dma_callback(struct device *dev, void *arg,
uint32_t channel, int status) uint32_t channel, int status)
{ {
/* callback_arg directly holds the client data */ /* arg directly holds the client data */
struct spi_stm32_data *data = arg; struct spi_stm32_data *data = arg;
if (status != 0) { if (status != 0) {
@ -129,7 +129,7 @@ static int spi_stm32_dma_tx_load(struct device *dev, const uint8_t *buf,
/* direction is given by the DT */ /* direction is given by the DT */
stream->dma_cfg.head_block = &blk_cfg; stream->dma_cfg.head_block = &blk_cfg;
/* give the client data as arg, as the callback comes from the dma */ /* give the client data as arg, as the callback comes from the dma */
stream->dma_cfg.callback_arg = data; stream->dma_cfg.user_data = data;
/* pass our client origin to the dma: data->dma_tx.dma_channel */ /* pass our client origin to the dma: data->dma_tx.dma_channel */
ret = dma_config(data->dev_dma_tx, data->dma_tx.channel, ret = dma_config(data->dev_dma_tx, data->dma_tx.channel,
&stream->dma_cfg); &stream->dma_cfg);
@ -178,7 +178,7 @@ static int spi_stm32_dma_rx_load(struct device *dev, uint8_t *buf, size_t len)
/* direction is given by the DT */ /* direction is given by the DT */
stream->dma_cfg.head_block = &blk_cfg; stream->dma_cfg.head_block = &blk_cfg;
stream->dma_cfg.callback_arg = data; stream->dma_cfg.user_data = data;
/* pass our client origin to the dma: data->dma_rx.channel */ /* pass our client origin to the dma: data->dma_rx.channel */

View file

@ -452,7 +452,7 @@ static int spi_sam0_dma_rx_load(struct device *dev, uint8_t *buf,
dma_cfg.channel_direction = PERIPHERAL_TO_MEMORY; dma_cfg.channel_direction = PERIPHERAL_TO_MEMORY;
dma_cfg.source_data_size = 1; dma_cfg.source_data_size = 1;
dma_cfg.dest_data_size = 1; dma_cfg.dest_data_size = 1;
dma_cfg.callback_arg = dev; dma_cfg.user_data = dev;
dma_cfg.dma_callback = spi_sam0_dma_rx_done; dma_cfg.dma_callback = spi_sam0_dma_rx_done;
dma_cfg.block_count = 1; dma_cfg.block_count = 1;
dma_cfg.head_block = &dma_blk; dma_cfg.head_block = &dma_blk;