Message ID | 20220922111228.36355-7-yuancan@huawei.com |
---|---|
State | Accepted |
Commit | 72f1f6085a731efb655ba6308e1ac54b787b416f |
Headers | show |
Series | Use dev_err_probe() to simplify code | expand |
On 22/09/2022 13:12, Yuan Can wrote: > In the probe path, dev_err() can be replaced with dev_err_probe() > which will check if error code is -EPROBE_DEFER and prints the > error name. It also sets the defer probe reason which can be > checked later through debugfs. > > Signed-off-by: Yuan Can <yuancan@huawei.com> > --- > drivers/phy/qualcomm/phy-qcom-qusb2.c | 27 +++++++++------------------ > 1 file changed, 9 insertions(+), 18 deletions(-) > > diff --git a/drivers/phy/qualcomm/phy-qcom-qusb2.c b/drivers/phy/qualcomm/phy-qcom-qusb2.c > index 7529a7e6e5df..2ef638b32e8f 100644 > --- a/drivers/phy/qualcomm/phy-qcom-qusb2.c > +++ b/drivers/phy/qualcomm/phy-qcom-qusb2.c > @@ -973,20 +973,14 @@ static int qusb2_phy_probe(struct platform_device *pdev) > return PTR_ERR(qphy->base); > > qphy->cfg_ahb_clk = devm_clk_get(dev, "cfg_ahb"); > - if (IS_ERR(qphy->cfg_ahb_clk)) { > - ret = PTR_ERR(qphy->cfg_ahb_clk); > - if (ret != -EPROBE_DEFER) > - dev_err(dev, "failed to get cfg ahb clk, %d\n", ret); > - return ret; > - } > + if (IS_ERR(qphy->cfg_ahb_clk)) > + return dev_err_probe(dev, PTR_ERR(qphy->cfg_ahb_clk), > + "failed to get cfg ahb clk\n"); > > qphy->ref_clk = devm_clk_get(dev, "ref"); > - if (IS_ERR(qphy->ref_clk)) { > - ret = PTR_ERR(qphy->ref_clk); > - if (ret != -EPROBE_DEFER) > - dev_err(dev, "failed to get ref clk, %d\n", ret); > - return ret; > - } > + if (IS_ERR(qphy->ref_clk)) > + return dev_err_probe(dev, PTR_ERR(qphy->ref_clk), > + "failed to get ref clk\n"); > > qphy->iface_clk = devm_clk_get_optional(dev, "iface"); > if (IS_ERR(qphy->iface_clk)) > @@ -1003,12 +997,9 @@ static int qusb2_phy_probe(struct platform_device *pdev) > qphy->vregs[i].supply = qusb2_phy_vreg_names[i]; > > ret = devm_regulator_bulk_get(dev, num, qphy->vregs); > - if (ret) { > - if (ret != -EPROBE_DEFER) > - dev_err(dev, "failed to get regulator supplies: %d\n", > - ret); > - return ret; > - } > + if (ret) > + return dev_err_probe(dev, ret, > + "failed to get regulator supplies\n"); > > /* Get the specific init parameters of QMP phy */ > qphy->cfg = of_device_get_match_data(dev); The error handling of devm_reset_control_get_by_index() could probably be replaced with dev_err_probe() aswell. Anyway: Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
On 22/09/2022 14:12, Yuan Can wrote: > In the probe path, dev_err() can be replaced with dev_err_probe() > which will check if error code is -EPROBE_DEFER and prints the > error name. It also sets the defer probe reason which can be > checked later through debugfs. > > Signed-off-by: Yuan Can <yuancan@huawei.com> > --- > drivers/phy/qualcomm/phy-qcom-qusb2.c | 27 +++++++++------------------ > 1 file changed, 9 insertions(+), 18 deletions(-) Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
diff --git a/drivers/phy/qualcomm/phy-qcom-qusb2.c b/drivers/phy/qualcomm/phy-qcom-qusb2.c index 7529a7e6e5df..2ef638b32e8f 100644 --- a/drivers/phy/qualcomm/phy-qcom-qusb2.c +++ b/drivers/phy/qualcomm/phy-qcom-qusb2.c @@ -973,20 +973,14 @@ static int qusb2_phy_probe(struct platform_device *pdev) return PTR_ERR(qphy->base); qphy->cfg_ahb_clk = devm_clk_get(dev, "cfg_ahb"); - if (IS_ERR(qphy->cfg_ahb_clk)) { - ret = PTR_ERR(qphy->cfg_ahb_clk); - if (ret != -EPROBE_DEFER) - dev_err(dev, "failed to get cfg ahb clk, %d\n", ret); - return ret; - } + if (IS_ERR(qphy->cfg_ahb_clk)) + return dev_err_probe(dev, PTR_ERR(qphy->cfg_ahb_clk), + "failed to get cfg ahb clk\n"); qphy->ref_clk = devm_clk_get(dev, "ref"); - if (IS_ERR(qphy->ref_clk)) { - ret = PTR_ERR(qphy->ref_clk); - if (ret != -EPROBE_DEFER) - dev_err(dev, "failed to get ref clk, %d\n", ret); - return ret; - } + if (IS_ERR(qphy->ref_clk)) + return dev_err_probe(dev, PTR_ERR(qphy->ref_clk), + "failed to get ref clk\n"); qphy->iface_clk = devm_clk_get_optional(dev, "iface"); if (IS_ERR(qphy->iface_clk)) @@ -1003,12 +997,9 @@ static int qusb2_phy_probe(struct platform_device *pdev) qphy->vregs[i].supply = qusb2_phy_vreg_names[i]; ret = devm_regulator_bulk_get(dev, num, qphy->vregs); - if (ret) { - if (ret != -EPROBE_DEFER) - dev_err(dev, "failed to get regulator supplies: %d\n", - ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, + "failed to get regulator supplies\n"); /* Get the specific init parameters of QMP phy */ qphy->cfg = of_device_get_match_data(dev);
In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs. Signed-off-by: Yuan Can <yuancan@huawei.com> --- drivers/phy/qualcomm/phy-qcom-qusb2.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)