Skip to content

Commit 7d76dc5

Browse files
abonislawskicarlescufi
authored andcommitted
drivers: dma: return einval if specified channel not found
chan_filter is used when a specified channel is required so a specified channel needs to be returned, otherwise it should return einval instead of the last channel tried Signed-off-by: Adrian Bonislawski <[email protected]>
1 parent e4340c1 commit 7d76dc5

File tree

1 file changed

+3
-3
lines changed
  • include/zephyr/drivers

1 file changed

+3
-3
lines changed

include/zephyr/drivers/dma.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,12 +487,12 @@ static inline int z_impl_dma_request_channel(const struct device *dev,
487487

488488
for (i = 0; i < dma_ctx->dma_channels; i++) {
489489
if (!atomic_test_and_set_bit(dma_ctx->atomic, i)) {
490-
channel = i;
491490
if (api->chan_filter &&
492-
!api->chan_filter(dev, channel, filter_param)) {
493-
atomic_clear_bit(dma_ctx->atomic, channel);
491+
!api->chan_filter(dev, i, filter_param)) {
492+
atomic_clear_bit(dma_ctx->atomic, i);
494493
continue;
495494
}
495+
channel = i;
496496
break;
497497
}
498498
}

0 commit comments

Comments
 (0)