Skip to content

Commit 4180d70

Browse files
teburdnashif
authored andcommitted
dma: Fix error_callback enable/disable confusion
Previously the logic was inverted for error_callback_en where 0 was enablement and 1 was disable. This was likely done so that the default, sensibly so, was to enable the error callback if possible. A variety of in tree users had confused the enable/disable value. Change the name of the flag to error_callback_dis where the default remains 0 (do not disable the callback!) and correct in tree uses of the flag where it seemed incorrect. Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
1 parent 85b3e45 commit 4180d70

File tree

20 files changed

+32
-34
lines changed

20 files changed

+32
-34
lines changed

drivers/dma/dma_andes_atcdmac300.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static int dma_atcdmac300_config(const struct device *dev, uint32_t channel,
273273
ch_ctrl |= DMA_CH_CTRL_INTABT;
274274

275275
/* Disable the error callback */
276-
if (!cfg->error_callback_en) {
276+
if (!cfg->error_callback_dis) {
277277
ch_ctrl |= DMA_CH_CTRL_INTERR;
278278
}
279279

drivers/dma/dma_emul.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static const char *dma_emul_xfer_config_to_string(const struct dma_config *cfg)
129129
"\n\tslot: %u"
130130
"\n\tchannel_direction: %u"
131131
"\n\tcomplete_callback_en: %u"
132-
"\n\terror_callback_en: %u"
132+
"\n\terror_callback_dis: %u"
133133
"\n\tsource_handshake: %u"
134134
"\n\tdest_handshake: %u"
135135
"\n\tchannel_priority: %u"
@@ -148,7 +148,7 @@ static const char *dma_emul_xfer_config_to_string(const struct dma_config *cfg)
148148
"\n\tdma_callback: %p"
149149
"\n}",
150150
cfg->dma_slot, cfg->channel_direction, cfg->complete_callback_en,
151-
cfg->error_callback_en, cfg->source_handshake, cfg->dest_handshake,
151+
cfg->error_callback_dis, cfg->source_handshake, cfg->dest_handshake,
152152
cfg->channel_priority, cfg->source_chaining_en, cfg->dest_chaining_en,
153153
cfg->linked_channel, cfg->cyclic, cfg->_reserved, cfg->source_data_size,
154154
cfg->dest_data_size, cfg->source_burst_length, cfg->dest_burst_length,
@@ -248,11 +248,11 @@ static void dma_emul_work_handler(struct k_work *work)
248248

249249
if (state == DMA_EMUL_CHANNEL_STOPPED) {
250250
LOG_DBG("asynchronously canceled");
251-
if (xfer_config.error_callback_en) {
251+
if (!xfer_config.error_callback_dis) {
252252
xfer_config.dma_callback(dev, xfer_config.user_data,
253253
channel, -ECANCELED);
254254
} else {
255-
LOG_DBG("error_callback_en is not set (async "
255+
LOG_DBG("error_callback_dis is not set (async "
256256
"cancel)");
257257
}
258258
goto out;

drivers/dma/dma_mchp_xec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static int check_blocks(struct dma_xec_channel *chdata, struct dma_block_config
272272
* dma_slot - peripheral source/target ID. Not used for Mem2Mem
273273
* channel_direction - HW supports Mem2Mem, Mem2Periph, and Periph2Mem
274274
* complete_callback_en - if true invoke callback on completion (no error)
275-
* error_callback_en - if true invoke callback on error
275+
* error_callback_dis - if true disable callback on error
276276
* source_handshake - 0=HW, 1=SW
277277
* dest_handshake - 0=HW, 1=SW
278278
* channel_priority - 4-bit field. HW implements round-robin only.
@@ -384,7 +384,7 @@ static int dma_xec_configure(const struct device *dev, uint32_t channel,
384384
if (config->complete_callback_en) {
385385
chdata->flags |= BIT(DMA_XEC_CHAN_FLAGS_CB_EOB_POS);
386386
}
387-
if (config->error_callback_en) { /* disable callback on errors ? */
387+
if (config->error_callback_dis) { /* disable callback on errors ? */
388388
chdata->flags |= BIT(DMA_XEC_CHAN_FLAGS_CB_ERR_DIS_POS);
389389
}
390390

@@ -690,7 +690,7 @@ static int dmac_xec_pm_action(const struct device *dev,
690690
* completion_callback_en
691691
* 0 = invoke at completion of all blocks
692692
* 1 = invoke at completin of each block
693-
* error_callback_en
693+
* error_callback_dis
694694
* 0 = invoke on all errors
695695
* 1 = disabled, do not invoke on errors
696696
*/

drivers/dma/dma_sam0.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static int dma_sam0_config(const struct device *dev, uint32_t channel,
125125

126126
/* Enable the interrupts */
127127
DMA_REGS->CHINTENSET.reg = DMAC_CHINTENSET_TCMPL;
128-
if (!config->error_callback_en) {
128+
if (!config->error_callback_dis) {
129129
DMA_REGS->CHINTENSET.reg = DMAC_CHINTENSET_TERR;
130130
} else {
131131
DMA_REGS->CHINTENCLR.reg = DMAC_CHINTENSET_TERR;
@@ -179,7 +179,7 @@ static int dma_sam0_config(const struct device *dev, uint32_t channel,
179179

180180
/* Enable the interrupts */
181181
chcfg->CHINTENSET.reg = DMAC_CHINTENSET_TCMPL;
182-
if (!config->error_callback_en) {
182+
if (!config->error_callback_dis) {
183183
chcfg->CHINTENSET.reg = DMAC_CHINTENSET_TERR;
184184
} else {
185185
chcfg->CHINTENCLR.reg = DMAC_CHINTENSET_TERR;

drivers/dma/dma_sam_xdmac.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static int sam_xdmac_config(const struct device *dev, uint32_t channel,
264264
channel_cfg.dus = 0U;
265265
channel_cfg.cie =
266266
(cfg->complete_callback_en ? XDMAC_CIE_BIE : XDMAC_CIE_LIE)
267-
| (cfg->error_callback_en ? XDMAC_INT_ERR : 0);
267+
| (cfg->error_callback_dis ? 0 : XDMAC_INT_ERR);
268268

269269
ret = sam_xdmac_channel_configure(dev, channel, &channel_cfg);
270270
if (ret < 0) {

drivers/dma/dma_sedi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static void dma_handler(sedi_dma_t dma_device, int channel, int event_id,
5757
(config->complete_callback_en)) {
5858
config->dma_callback(dev, config->user_data,
5959
channel, 0);
60-
} else if (config->error_callback_en) {
60+
} else if (!config->error_callback_dis) {
6161
config->dma_callback(dev, config->user_data,
6262
channel, event_id);
6363
}

drivers/dma/dma_smartbond.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ static int dma_smartbond_config(const struct device *dev, uint32_t channel, stru
483483
}
484484

485485
/* Error handling is not supported; just warn user. */
486-
if (cfg->error_callback_en) {
486+
if (!cfg->error_callback_dis) {
487487
LOG_WRN("Error handling is not supported");
488488
}
489489

drivers/dma/dma_xmc4xxx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ static int dma_xmc4xxx_config(const struct device *dev, uint32_t channel, struct
294294
XMC_DMA_CH_EnableEvent(dma, channel, XMC_DMA_CH_EVENT_BLOCK_TRANSFER_COMPLETE);
295295
}
296296

297-
if (config->error_callback_en) {
297+
if (!config->error_callback_dis) {
298298
XMC_DMA_CH_EnableEvent(dma, channel, XMC_DMA_CH_EVENT_ERROR);
299299
}
300300

drivers/i2c/i2c_dw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ int32_t i2c_dw_idma_rx_transfer(const struct device *dev)
124124
dma_cfg.dma_callback = cb_i2c_idma_transfer;
125125
dma_cfg.user_data = (void *)dev;
126126
dma_cfg.complete_callback_en = 0U;
127-
dma_cfg.error_callback_en = 1U;
127+
dma_cfg.error_callback_dis = 0U;
128128
dma_cfg.block_count = 1U;
129129
dma_cfg.head_block = &dma_block_cfg;
130130

@@ -172,7 +172,7 @@ int32_t i2c_dw_idma_tx_transfer(const struct device *dev,
172172
dma_cfg.dma_callback = cb_i2c_idma_transfer;
173173
dma_cfg.user_data = (void *)dev;
174174
dma_cfg.complete_callback_en = 0U;
175-
dma_cfg.error_callback_en = 1U;
175+
dma_cfg.error_callback_dis = 0U;
176176
dma_cfg.block_count = 1U;
177177
dma_cfg.head_block = &dma_block_cfg;
178178

drivers/i2s/i2s_mcux_flexcomm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ static void i2s_mcux_config_dma_blocks(const struct device *dev,
449449
LOG_DBG("channel_direction is %d", stream->dma_cfg.channel_direction);
450450
LOG_DBG("complete_callback_en is %d",
451451
stream->dma_cfg.complete_callback_en);
452-
LOG_DBG("error_callback_en is %d", stream->dma_cfg.error_callback_en);
452+
LOG_DBG("error_callback_dis is %d", stream->dma_cfg.error_callback_dis);
453453
LOG_DBG("source_handshake is %d", stream->dma_cfg.source_handshake);
454454
LOG_DBG("dest_handshake is %d", stream->dma_cfg.dest_handshake);
455455
LOG_DBG("channel_priority is %d", stream->dma_cfg.channel_priority);

0 commit comments

Comments
 (0)