Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Andy Shevchenko and committed by
Vinod Koul
f709b38e b49c7027

+6 -4
+6 -4
drivers/dma/dmaengine.c
··· 943 943 944 944 struct dma_chan *devm_dma_request_chan(struct device *dev, const char *name) 945 945 { 946 - struct dma_chan *chan = dma_request_chan(dev, name); 947 - int ret = 0; 946 + struct dma_chan *chan; 947 + int ret; 948 948 949 - if (!IS_ERR(chan)) 950 - ret = devm_add_action_or_reset(dev, dmaenginem_release_channel, chan); 949 + chan = dma_request_chan(dev, name); 950 + if (IS_ERR(chan)) 951 + return chan; 951 952 953 + ret = devm_add_action_or_reset(dev, dmaenginem_release_channel, chan); 952 954 if (ret) 953 955 return ERR_PTR(ret); 954 956