Re: [PATCH 02/12] dmaengine: dw-edma: Add channel lookup helper

From: Frank Li

Date: Thu May 21 2026 - 13:16:48 EST


On Thu, May 21, 2026 at 03:31:05PM +0900, Koichiro Den wrote:
> Add a helper that maps a DesignWare eDMA write/read hardware channel

Nit: Add a helper dw_edma_find_channel() ...

> number to its DMAengine channel.
>
> PCI endpoint resource enumeration uses the pointer only for later
> ownership reservation.
>
> Signed-off-by: Koichiro Den <den@xxxxxxxxxxxxx>
> ---

Reviewed-by: Frank Li <Frank.Li@xxxxxxx>

> drivers/dma/dw-edma/dw-edma-core.c | 32 ++++++++++++++++++++++++++++++
> include/linux/dma/edma.h | 8 ++++++++
> 2 files changed, 40 insertions(+)
>
> diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c
> index c2feb3adc79f..6660380a1bbc 100644
> --- a/drivers/dma/dw-edma/dw-edma-core.c
> +++ b/drivers/dma/dw-edma/dw-edma-core.c
> @@ -1189,6 +1189,38 @@ int dw_edma_remove(struct dw_edma_chip *chip)
> }
> EXPORT_SYMBOL_GPL(dw_edma_remove);
>
> +struct dma_chan *dw_edma_find_channel(struct dw_edma_chip *chip, bool write,
> + u16 id)
> +{
> + struct dw_edma_chan *chan;
> + struct dw_edma *dw;
> +
> + if (!chip)
> + return NULL;
> +
> + dw = chip->dw;
> +
> + if (!dw)
> + return NULL;
> +
> + if (write) {
> + if (id >= dw->wr_ch_cnt)
> + return NULL;
> + chan = &dw->chan[id];
> + if (chan->dir != EDMA_DIR_WRITE)
> + return NULL;
> + } else {
> + if (id >= dw->rd_ch_cnt)
> + return NULL;
> + chan = &dw->chan[dw->wr_ch_cnt + id];
> + if (chan->dir != EDMA_DIR_READ)
> + return NULL;
> + }
> +
> + return &chan->vc.chan;
> +}
> +EXPORT_SYMBOL_GPL(dw_edma_find_channel);
> +
> MODULE_LICENSE("GPL v2");
> MODULE_DESCRIPTION("Synopsys DesignWare eDMA controller core driver");
> MODULE_AUTHOR("Gustavo Pimentel <gustavo.pimentel@xxxxxxxxxxxx>");
> diff --git a/include/linux/dma/edma.h b/include/linux/dma/edma.h
> index 1fafd5b0e315..b4b42b2278f3 100644
> --- a/include/linux/dma/edma.h
> +++ b/include/linux/dma/edma.h
> @@ -110,6 +110,8 @@ struct dw_edma_chip {
> #if IS_REACHABLE(CONFIG_DW_EDMA)
> int dw_edma_probe(struct dw_edma_chip *chip);
> int dw_edma_remove(struct dw_edma_chip *chip);
> +struct dma_chan *dw_edma_find_channel(struct dw_edma_chip *chip, bool write,
> + u16 id);
> #else
> static inline int dw_edma_probe(struct dw_edma_chip *chip)
> {
> @@ -120,6 +122,12 @@ static inline int dw_edma_remove(struct dw_edma_chip *chip)
> {
> return 0;
> }
> +
> +static inline struct dma_chan *dw_edma_find_channel(struct dw_edma_chip *chip,
> + bool write, u16 id)
> +{
> + return NULL;
> +}
> #endif /* CONFIG_DW_EDMA */
>
> #endif /* _DW_EDMA_H */
> --
> 2.51.0
>