Skip to content

Commit 90d21f6

Browse files
1991Joyzouvinodkoul
authored andcommitted
dmaengine: fsl-edma: change to guard(mutex) within fsl_edma3_xlate()
Introduce a scope guard to automatically unlock the mutex within fsl_edma3_xlate() to simplify the code. Prepare to add source ID checks in the future. Signed-off-by: Joy Zou <joy.zou@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://lore.kernel.org/r/20240701070232.2519179-2-joy.zou@nxp.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent ae04342 commit 90d21f6

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

drivers/dma/fsl-edma-main.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static struct dma_chan *fsl_edma3_xlate(struct of_phandle_args *dma_spec,
153153

154154
b_chmux = !!(fsl_edma->drvdata->flags & FSL_EDMA_DRV_HAS_CHMUX);
155155

156-
mutex_lock(&fsl_edma->fsl_edma_mutex);
156+
guard(mutex)(&fsl_edma->fsl_edma_mutex);
157157
list_for_each_entry_safe(chan, _chan, &fsl_edma->dma_dev.channels,
158158
device_node) {
159159

@@ -177,18 +177,15 @@ static struct dma_chan *fsl_edma3_xlate(struct of_phandle_args *dma_spec,
177177
if (!b_chmux && i == dma_spec->args[0]) {
178178
chan = dma_get_slave_channel(chan);
179179
chan->device->privatecnt++;
180-
mutex_unlock(&fsl_edma->fsl_edma_mutex);
181180
return chan;
182181
} else if (b_chmux && !fsl_chan->srcid) {
183182
/* if controller support channel mux, choose a free channel */
184183
chan = dma_get_slave_channel(chan);
185184
chan->device->privatecnt++;
186185
fsl_chan->srcid = dma_spec->args[0];
187-
mutex_unlock(&fsl_edma->fsl_edma_mutex);
188186
return chan;
189187
}
190188
}
191-
mutex_unlock(&fsl_edma->fsl_edma_mutex);
192189
return NULL;
193190
}
194191

0 commit comments

Comments
 (0)