Skip to contentSkip to conversation

dmaengine: Save few bytes and increase readability of dma_request_chan()

PATCH Applied Andy Shevchenko 2 participants 2 messages Aug 28, 2020 – Sep 3, 2020 dmaengine

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: Save few bytes and increase readability of dma_request_chan()

Split IS_ERR_OR_NULL() check followed by additional conditional to two simple conditionals. This increases readability and saves memory:

Function                                     old     new   delta
dma_request_chan                             700     697      -3

Total: Before=10224, After=10221, chg -0.03%

---
 drivers/dma/dmaengine.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/dma/dmaengine.c +4 -2
index a53e71d2bbd4..adf804aa50a5 100644
@@ -847,8 +847,10 @@ struct dma_chan *dma_request_chan(struct device *dev, const char *name)
 	}
 	mutex_unlock(&dma_list_mutex);
 
-	if (IS_ERR_OR_NULL(chan))
-		return chan ? chan : ERR_PTR(-EPROBE_DEFER);
+	if (IS_ERR(chan))
+		return chan;
+	if (!chan)
+		return ERR_PTR(-EPROBE_DEFER);
 
 found:
 #ifdef CONFIG_DEBUG_FS
Signature · 1 line
2.28.0
maintainer Applied
#1 lore raw
Quoted 6 lines · Andy Shevchenko

Split IS_ERR_OR_NULL() check followed by additional conditional to two simple conditionals. This increases readability and saves memory:

Function                                     old     new   delta
dma_request_chan                             700     697      -3

Total: Before=10224, After=10221, chg -0.03%

Applied, thanks

Signature · 1 line
~Vinod