Skip to contentSkip to conversation

staging: mt7621-pci: PTR_ERR_OR_ZERO can be used

PATCH In review Bhanusree Pola 2 participants 2 messages Oct 22, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: mt7621-pci: PTR_ERR_OR_ZERO can be used

Replace multiple return statements with single return Used the following script by coccinelle
scripts/coccinelle/api/ptr_ret.cocci

---
 drivers/staging/mt7621-pci/pci-mt7621.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/mt7621-pci/pci-mt7621.c +1 -4
index a49e279..bb08fd2 100644
@@ -403,10 +403,7 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie)
 	}
 
 	pcie->base = devm_ioremap_resource(dev, &regs);
-	if (IS_ERR(pcie->base))
-		return PTR_ERR(pcie->base);
-
-	return 0;
+	return PTR_ERR_OR_ZERO(pcie->base);
 }
 
 static int mt7621_pcie_request_resources(struct mt7621_pcie *pcie,
Signature · 1 line
2.7.4
#1 lore raw
Quoted 14 lines · Bhanusree Pola

Replace multiple return statements with single return Used the following script by coccinelle
scripts/coccinelle/api/ptr_ret.cocci

---
 drivers/staging/mt7621-pci/pci-mt7621.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/mt7621-pci/pci-mt7621.c +0 -0
index a49e279..bb08fd2 100644

drivers/staging/mt7621-pci/pci-mt7621.c static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie) · line 406

Quoted 8 lines
drivers/staging/mt7621-pci/pci-mt7621.c +1 -4
@@ -403,10 +403,7 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie)
 	}
 
 	pcie->base = devm_ioremap_resource(dev, &regs);
-	if (IS_ERR(pcie->base))
-		return PTR_ERR(pcie->base);
-
-	return 0;
+	return PTR_ERR_OR_ZERO(pcie->base);

It might be considered to be unfavorable to make the change in this case, because there is a previous if ... return, so using PTR_ERR_OR_ZERO breaks the style.

julia

Quoted 13 lines
drivers/staging/mt7621-pci/pci-mt7621.c +0 -1
 }
 
 static int mt7621_pcie_request_resources(struct mt7621_pcie *pcie,
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20181022070014.GA7822%40aakashd-VirtualBox.
For more options, visit https://groups.google.com/d/optout.