mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-18 12:22:27 -04:00
dmaengine: Refactor devm_dma_request_chan() for readability
Yes, while it's a bit longer in terms of LoCs, it's more readable when we use the usual patter to check for errors, and not for a success). This eliminates unneeded assignment and moves the needed one closer to its user which is better programming pattern because it allows avoiding potential errors in case the variable is getting reused. Also note that the same pattern have been used already in dmaenginem_async_device_register(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20260109173718.3605829-2-andriy.shevchenko@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
committed by
Vinod Koul
parent
b49c702738
commit
f709b38e5b
@@ -943,12 +943,14 @@ static void dmaenginem_release_channel(void *chan)
|
||||
|
||||
struct dma_chan *devm_dma_request_chan(struct device *dev, const char *name)
|
||||
{
|
||||
struct dma_chan *chan = dma_request_chan(dev, name);
|
||||
int ret = 0;
|
||||
struct dma_chan *chan;
|
||||
int ret;
|
||||
|
||||
if (!IS_ERR(chan))
|
||||
ret = devm_add_action_or_reset(dev, dmaenginem_release_channel, chan);
|
||||
chan = dma_request_chan(dev, name);
|
||||
if (IS_ERR(chan))
|
||||
return chan;
|
||||
|
||||
ret = devm_add_action_or_reset(dev, dmaenginem_release_channel, chan);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user