All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] extcon: palmas: Simplify with dev_err_probe()
@ 2020-08-28 15:13 Krzysztof Kozlowski
  2020-08-29 13:09 ` Chanwoo Choi
  0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-28 15:13 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi, linux-kernel; +Cc: Krzysztof Kozlowski

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

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/extcon/extcon-palmas.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index e8e9eebe6b1d..a2852bcc5f0d 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -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;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] extcon: palmas: Simplify with dev_err_probe()
  2020-08-28 15:13 [PATCH] extcon: palmas: Simplify with dev_err_probe() Krzysztof Kozlowski
@ 2020-08-29 13:09 ` Chanwoo Choi
  0 siblings, 0 replies; 2+ messages in thread
From: Chanwoo Choi @ 2020-08-29 13:09 UTC (permalink / raw)
  To: Krzysztof Kozlowski; +Cc: MyungJoo Ham, Chanwoo Choi, linux-kernel

On Sat, Aug 29, 2020 at 12:15 AM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe().  Less code and the error value gets printed.
>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> ---
>  drivers/extcon/extcon-palmas.c | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
> index e8e9eebe6b1d..a2852bcc5f0d 100644
> --- a/drivers/extcon/extcon-palmas.c
> +++ b/drivers/extcon/extcon-palmas.c
> @@ -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;
> --
> 2.17.1
>

Applied it. Thanks.

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-29 13:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28 15:13 [PATCH] extcon: palmas: Simplify with dev_err_probe() Krzysztof Kozlowski
2020-08-29 13:09 ` Chanwoo Choi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.