Message ID | 20240830110421.62980-1-shenlichuan@vivo.com (mailing list archive) |
---|---|
State | Handled Elsewhere, archived |
Headers | show |
Series | [v1] pmdomain: bcm: Simplify with dev_err_probe() | expand |
On Fri, 30 Aug 2024 at 13:04, Shen Lichuan <shenlichuan@vivo.com> wrote: > > Use dev_err_probe() to simplify the error path and unify a message > template. In this case the simplification is questionable, I think. > > 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. Right, which I guess boils down to what people preferes. That said, my take on this is that we should move from dev_err() to dev_err_probe(), at least there needs to be some simplification involved too. Kind regards Uffe > > Signed-off-by: Shen Lichuan <shenlichuan@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 >
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,
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@vivo.com> --- drivers/pmdomain/bcm/bcm2835-power.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)