[PATCH v1] pmdomain: bcm: Simplify with dev_err_probe()

Shen Lichuan shenlichuan at vivo.com
Fri Aug 30 04:04:21 PDT 2024


Use dev_err_probe() to simplify the error path and unify a message
template.

Using this helper is totally fine even if err is known to never
be -EPROBE_DEFER.

The benefit compared to a normal dev_err() is the standardized format
of the error code, it being emitted symbolically and the fact that
the error code is returned which allows more compact error paths.

Signed-off-by: Shen Lichuan <shenlichuan at vivo.com>
---
 drivers/pmdomain/bcm/bcm2835-power.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/pmdomain/bcm/bcm2835-power.c b/drivers/pmdomain/bcm/bcm2835-power.c
index d2f0233cb620..be07ab8a663c 100644
--- a/drivers/pmdomain/bcm/bcm2835-power.c
+++ b/drivers/pmdomain/bcm/bcm2835-power.c
@@ -643,18 +643,16 @@ static int bcm2835_power_probe(struct platform_device *pdev)
 	power->rpivid_asb = pm->rpivid_asb;
 
 	id = readl(power->asb + ASB_AXI_BRDG_ID);
-	if (id != BCM2835_BRDG_ID /* "BRDG" */) {
-		dev_err(dev, "ASB register ID returned 0x%08x\n", id);
-		return -ENODEV;
-	}
+	if (id != BCM2835_BRDG_ID /* "BRDG" */)
+		return dev_err_probe(dev, -ENODEV,
+				     "ASB register ID returned 0x%08x\n", id);
 
 	if (power->rpivid_asb) {
 		id = readl(power->rpivid_asb + ASB_AXI_BRDG_ID);
-		if (id != BCM2835_BRDG_ID /* "BRDG" */) {
-			dev_err(dev, "RPiVid ASB register ID returned 0x%08x\n",
-				     id);
-			return -ENODEV;
-		}
+		if (id != BCM2835_BRDG_ID /* "BRDG" */)
+			return dev_err_probe(dev, -ENODEV,
+					     "RPiVid ASB register ID returned 0x%08x\n",
+					     id);
 	}
 
 	power->pd_xlate.domains = devm_kcalloc(dev,
-- 
2.17.1




More information about the linux-arm-kernel mailing list