drivers: dma: Apply DMA callback change to relevant drivers

Now the dma device instance is passed as parameter to the callback.

Fixes #26923

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2020-07-08 21:19:29 +02:00 committed by Carles Cufí
parent 020dab824c
commit 6acee3dcba
19 changed files with 81 additions and 58 deletions

View file

@ -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;

View file

@ -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);
}
}
}

View file

@ -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

View file

@ -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);

View file

@ -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,

View file

@ -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);
}

View file

@ -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 */

View file

@ -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);
}
}

View file

@ -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);
}
}
}

View file

@ -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)

View file

@ -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 */
}
}

View file

@ -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 {

View file

@ -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();

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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;