Skip to contentSkip to conversation

usb: typec: qcom-pmic-typec: Switch to use dev_err_probe() helper

PATCH In review Yang Yingliang 2 participants 2 messages Sep 22, 2022

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

PATCH 1/1 usb: typec: qcom-pmic-typec: Switch to use dev_err_probe() helper

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. It's more simple in error path.

---
 drivers/usb/typec/qcom-pmic-typec.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/usb/typec/qcom-pmic-typec.c +2 -3
index a0454a80c4a2..432ea62f1bab 100644
@@ -195,9 +195,8 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev)
 
 	qcom_usb->role_sw = fwnode_usb_role_switch_get(dev_fwnode(qcom_usb->dev));
 	if (IS_ERR(qcom_usb->role_sw)) {
-		if (PTR_ERR(qcom_usb->role_sw) != -EPROBE_DEFER)
-			dev_err(dev, "failed to get role switch\n");
-		ret = PTR_ERR(qcom_usb->role_sw);
+		ret = dev_err_probe(dev, PTR_ERR(qcom_usb->role_sw),
+				    "failed to get role switch\n");
 		goto err_typec_port;
 	}
 
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Yang Yingliang

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. It's more simple in error path.

Quoted 22 lines
---
 drivers/usb/typec/qcom-pmic-typec.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/usb/typec/qcom-pmic-typec.c +2 -3
index a0454a80c4a2..432ea62f1bab 100644
@@ -195,9 +195,8 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev)
 
 	qcom_usb->role_sw = fwnode_usb_role_switch_get(dev_fwnode(qcom_usb->dev));
 	if (IS_ERR(qcom_usb->role_sw)) {
-		if (PTR_ERR(qcom_usb->role_sw) != -EPROBE_DEFER)
-			dev_err(dev, "failed to get role switch\n");
-		ret = PTR_ERR(qcom_usb->role_sw);
+		ret = dev_err_probe(dev, PTR_ERR(qcom_usb->role_sw),
+				    "failed to get role switch\n");
 		goto err_typec_port;
 	}
 
Signature · 1 line
2.25.1
Signature · 1 line
heikki