Skip to contentSkip to conversation

extcon: palmas: Simplify with dev_err_probe()

PATCH Applied Krzysztof Kozlowski 2 participants 2 messages Aug 28, 2020 – Aug 29, 2020 External connector subsystem (extcon)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 extcon: palmas: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed.

---
 drivers/extcon/extcon-palmas.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/extcon/extcon-palmas.c +6 -12
index e8e9eebe6b1d..a2852bcc5f0d 100644
@@ -205,21 +205,15 @@ static int palmas_usb_probe(struct platform_device *pdev)
 
 	palmas_usb->id_gpiod = devm_gpiod_get_optional(&pdev->dev, "id",
 							GPIOD_IN);
-	if (PTR_ERR(palmas_usb->id_gpiod) == -EPROBE_DEFER) {
-		return -EPROBE_DEFER;
-	} else if (IS_ERR(palmas_usb->id_gpiod)) {
-		dev_err(&pdev->dev, "failed to get id gpio\n");
-		return PTR_ERR(palmas_usb->id_gpiod);
-	}
+	if (IS_ERR(palmas_usb->id_gpiod))
+		return dev_err_probe(&pdev->dev, PTR_ERR(palmas_usb->id_gpiod),
+				     "failed to get id gpio\n");
 
 	palmas_usb->vbus_gpiod = devm_gpiod_get_optional(&pdev->dev, "vbus",
 							GPIOD_IN);
-	if (PTR_ERR(palmas_usb->vbus_gpiod) == -EPROBE_DEFER) {
-		return -EPROBE_DEFER;
-	} else if (IS_ERR(palmas_usb->vbus_gpiod)) {
-		dev_err(&pdev->dev, "failed to get vbus gpio\n");
-		return PTR_ERR(palmas_usb->vbus_gpiod);
-	}
+	if (IS_ERR(palmas_usb->vbus_gpiod))
+		return dev_err_probe(&pdev->dev, PTR_ERR(palmas_usb->vbus_gpiod),
+				     "failed to get id gpio\n");
 
 	if (palmas_usb->enable_id_detection && palmas_usb->id_gpiod) {
 		palmas_usb->enable_id_detection = false;
Signature · 1 line
2.17.1
Applied
#1 lore raw
Quoted 42 lines · Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed.

---
 drivers/extcon/extcon-palmas.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/extcon/extcon-palmas.c +6 -13
index e8e9eebe6b1d..a2852bcc5f0d 100644
@@ -205,21 +205,15 @@ static int palmas_usb_probe(struct platform_device *pdev)
 
        palmas_usb->id_gpiod = devm_gpiod_get_optional(&pdev->dev, "id",
                                                        GPIOD_IN);
-       if (PTR_ERR(palmas_usb->id_gpiod) == -EPROBE_DEFER) {
-               return -EPROBE_DEFER;
-       } else if (IS_ERR(palmas_usb->id_gpiod)) {
-               dev_err(&pdev->dev, "failed to get id gpio\n");
-               return PTR_ERR(palmas_usb->id_gpiod);
-       }
+       if (IS_ERR(palmas_usb->id_gpiod))
+               return dev_err_probe(&pdev->dev, PTR_ERR(palmas_usb->id_gpiod),
+                                    "failed to get id gpio\n");
 
        palmas_usb->vbus_gpiod = devm_gpiod_get_optional(&pdev->dev, "vbus",
                                                        GPIOD_IN);
-       if (PTR_ERR(palmas_usb->vbus_gpiod) == -EPROBE_DEFER) {
-               return -EPROBE_DEFER;
-       } else if (IS_ERR(palmas_usb->vbus_gpiod)) {
-               dev_err(&pdev->dev, "failed to get vbus gpio\n");
-               return PTR_ERR(palmas_usb->vbus_gpiod);
-       }
+       if (IS_ERR(palmas_usb->vbus_gpiod))
+               return dev_err_probe(&pdev->dev, PTR_ERR(palmas_usb->vbus_gpiod),
+                                    "failed to get id gpio\n");
 
        if (palmas_usb->enable_id_detection && palmas_usb->id_gpiod) {
                palmas_usb->enable_id_detection = false;
--
Quoted 2 lines

2.17.1

Applied it. Thanks.

Signature · 3 lines
Best Regards,
Chanwoo Choi
Samsung Electronics