From: "Heiko Stübner" <heiko@sntech.de>
To: Dragan Simic <dsimic@manjaro.org>
Cc: linux-rockchip@lists.infradead.org,
linux-phy@lists.infradead.org, vkoul@kernel.org,
kishon@kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] phy: phy-rockchip-inno-usb2: Improve error handling while probing
Date: Wed, 21 Aug 2024 11:17:06 +0200 [thread overview]
Message-ID: <6073817.31tnzDBltd@diego> (raw)
In-Reply-To: <486bddb6aad14d05a3fb2d876d0d9d0d@manjaro.org>
Am Mittwoch, 21. August 2024, 11:09:03 CEST schrieb Dragan Simic:
> On 2024-08-21 10:44, Heiko Stübner wrote:
> > Am Mittwoch, 21. August 2024, 09:37:55 CEST schrieb Dragan Simic:
> >> Improve error handling in the probe path by using function
> >> dev_err_probe()
> >> where appropriate, and by no longer using it rather pointlessly in one
> >> place
> >> that actually produces a single, hardcoded error code.
> >>
> >> Signed-off-by: Dragan Simic <dsimic@manjaro.org>
> >
> >> @@ -1375,8 +1372,10 @@ static int rockchip_usb2phy_probe(struct
> >> platform_device *pdev)
> >> rphy->irq = platform_get_irq_optional(pdev, 0);
> >> platform_set_drvdata(pdev, rphy);
> >>
> >> - if (!phy_cfgs)
> >> - return dev_err_probe(dev, -EINVAL, "phy configs are not
> >> assigned!\n");
> >> + if (!phy_cfgs) {
> >> + dev_err(dev, "phy configs are not assigned\n");
> >> + return -EINVAL;
> >> + }
> >>
> >> ret = rockchip_usb2phy_extcon_register(rphy);
> >> if (ret)
> >
> > I really don't understand the rationale here. Using dev_err_probe here
> > is just fine and with that change you just introduce more lines of code
> > for exactly the same functionality?
>
> As we know, dev_err_probe() decides how to log the received error
> message
> based on the error code it receives, but in this case the error code is
> hardcoded as -EINVAL. Thus, in this case it isn't about keeping the LoC
> count a bit lower, but about using dev_err() where the resulting outcome
> of error logging is aleady known, and where logging the error code
> actually
> isn't helpful, because it's hardcoded and the logged error message
> already
> tells everything about the error condition.
>
> In other words, it's about being as precise as possible when deciding
> between
> dev_err() and dev_err_probe(), in both directions. I hope it makes
> sense.
I'd disagree a bit, using one format only creates a way nicer pattern in the
driver, by not mixing different styles.
dev_err_probe documentation seems to agree [0], by stating:
"Using this helper in your probe function 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 (i.e. you get "EAGAIN"
instead of "-35") and the fact that the error code is returned which allows
more compact error paths."
[0] https://elixir.bootlin.com/linux/v6.10.6/source/drivers/base/core.c#L5009
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
WARNING: multiple messages have this Message-ID (diff)
From: "Heiko Stübner" <heiko@sntech.de>
To: Dragan Simic <dsimic@manjaro.org>
Cc: linux-rockchip@lists.infradead.org,
linux-phy@lists.infradead.org, vkoul@kernel.org,
kishon@kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] phy: phy-rockchip-inno-usb2: Improve error handling while probing
Date: Wed, 21 Aug 2024 11:17:06 +0200 [thread overview]
Message-ID: <6073817.31tnzDBltd@diego> (raw)
In-Reply-To: <486bddb6aad14d05a3fb2d876d0d9d0d@manjaro.org>
Am Mittwoch, 21. August 2024, 11:09:03 CEST schrieb Dragan Simic:
> On 2024-08-21 10:44, Heiko Stübner wrote:
> > Am Mittwoch, 21. August 2024, 09:37:55 CEST schrieb Dragan Simic:
> >> Improve error handling in the probe path by using function
> >> dev_err_probe()
> >> where appropriate, and by no longer using it rather pointlessly in one
> >> place
> >> that actually produces a single, hardcoded error code.
> >>
> >> Signed-off-by: Dragan Simic <dsimic@manjaro.org>
> >
> >> @@ -1375,8 +1372,10 @@ static int rockchip_usb2phy_probe(struct
> >> platform_device *pdev)
> >> rphy->irq = platform_get_irq_optional(pdev, 0);
> >> platform_set_drvdata(pdev, rphy);
> >>
> >> - if (!phy_cfgs)
> >> - return dev_err_probe(dev, -EINVAL, "phy configs are not
> >> assigned!\n");
> >> + if (!phy_cfgs) {
> >> + dev_err(dev, "phy configs are not assigned\n");
> >> + return -EINVAL;
> >> + }
> >>
> >> ret = rockchip_usb2phy_extcon_register(rphy);
> >> if (ret)
> >
> > I really don't understand the rationale here. Using dev_err_probe here
> > is just fine and with that change you just introduce more lines of code
> > for exactly the same functionality?
>
> As we know, dev_err_probe() decides how to log the received error
> message
> based on the error code it receives, but in this case the error code is
> hardcoded as -EINVAL. Thus, in this case it isn't about keeping the LoC
> count a bit lower, but about using dev_err() where the resulting outcome
> of error logging is aleady known, and where logging the error code
> actually
> isn't helpful, because it's hardcoded and the logged error message
> already
> tells everything about the error condition.
>
> In other words, it's about being as precise as possible when deciding
> between
> dev_err() and dev_err_probe(), in both directions. I hope it makes
> sense.
I'd disagree a bit, using one format only creates a way nicer pattern in the
driver, by not mixing different styles.
dev_err_probe documentation seems to agree [0], by stating:
"Using this helper in your probe function 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 (i.e. you get "EAGAIN"
instead of "-35") and the fact that the error code is returned which allows
more compact error paths."
[0] https://elixir.bootlin.com/linux/v6.10.6/source/drivers/base/core.c#L5009
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
WARNING: multiple messages have this Message-ID (diff)
From: "Heiko Stübner" <heiko@sntech.de>
To: Dragan Simic <dsimic@manjaro.org>
Cc: linux-rockchip@lists.infradead.org,
linux-phy@lists.infradead.org, vkoul@kernel.org,
kishon@kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] phy: phy-rockchip-inno-usb2: Improve error handling while probing
Date: Wed, 21 Aug 2024 11:17:06 +0200 [thread overview]
Message-ID: <6073817.31tnzDBltd@diego> (raw)
In-Reply-To: <486bddb6aad14d05a3fb2d876d0d9d0d@manjaro.org>
Am Mittwoch, 21. August 2024, 11:09:03 CEST schrieb Dragan Simic:
> On 2024-08-21 10:44, Heiko Stübner wrote:
> > Am Mittwoch, 21. August 2024, 09:37:55 CEST schrieb Dragan Simic:
> >> Improve error handling in the probe path by using function
> >> dev_err_probe()
> >> where appropriate, and by no longer using it rather pointlessly in one
> >> place
> >> that actually produces a single, hardcoded error code.
> >>
> >> Signed-off-by: Dragan Simic <dsimic@manjaro.org>
> >
> >> @@ -1375,8 +1372,10 @@ static int rockchip_usb2phy_probe(struct
> >> platform_device *pdev)
> >> rphy->irq = platform_get_irq_optional(pdev, 0);
> >> platform_set_drvdata(pdev, rphy);
> >>
> >> - if (!phy_cfgs)
> >> - return dev_err_probe(dev, -EINVAL, "phy configs are not
> >> assigned!\n");
> >> + if (!phy_cfgs) {
> >> + dev_err(dev, "phy configs are not assigned\n");
> >> + return -EINVAL;
> >> + }
> >>
> >> ret = rockchip_usb2phy_extcon_register(rphy);
> >> if (ret)
> >
> > I really don't understand the rationale here. Using dev_err_probe here
> > is just fine and with that change you just introduce more lines of code
> > for exactly the same functionality?
>
> As we know, dev_err_probe() decides how to log the received error
> message
> based on the error code it receives, but in this case the error code is
> hardcoded as -EINVAL. Thus, in this case it isn't about keeping the LoC
> count a bit lower, but about using dev_err() where the resulting outcome
> of error logging is aleady known, and where logging the error code
> actually
> isn't helpful, because it's hardcoded and the logged error message
> already
> tells everything about the error condition.
>
> In other words, it's about being as precise as possible when deciding
> between
> dev_err() and dev_err_probe(), in both directions. I hope it makes
> sense.
I'd disagree a bit, using one format only creates a way nicer pattern in the
driver, by not mixing different styles.
dev_err_probe documentation seems to agree [0], by stating:
"Using this helper in your probe function 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 (i.e. you get "EAGAIN"
instead of "-35") and the fact that the error code is returned which allows
more compact error paths."
[0] https://elixir.bootlin.com/linux/v6.10.6/source/drivers/base/core.c#L5009
next prev parent reply other threads:[~2024-08-21 9:16 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-21 7:37 [PATCH v2 0/3] Improve error handling in Rockchip Inno USB 2.0 PHY driver Dragan Simic
2024-08-21 7:37 ` Dragan Simic
2024-08-21 7:37 ` Dragan Simic
2024-08-21 7:37 ` [PATCH v2 1/3] phy: phy-rockchip-inno-usb2: Perform trivial code cleanups Dragan Simic
2024-08-21 7:37 ` Dragan Simic
2024-08-21 7:37 ` Dragan Simic
2024-08-21 8:39 ` Heiko Stübner
2024-08-21 8:39 ` Heiko Stübner
2024-08-21 8:39 ` Heiko Stübner
2024-08-21 8:53 ` Dragan Simic
2024-08-21 8:53 ` Dragan Simic
2024-08-21 8:53 ` Dragan Simic
2024-08-21 7:37 ` [PATCH v2 2/3] phy: phy-rockchip-inno-usb2: Handle failed extcon allocation better Dragan Simic
2024-08-21 7:37 ` Dragan Simic
2024-08-21 7:37 ` Dragan Simic
2024-08-21 8:41 ` Heiko Stübner
2024-08-21 8:41 ` Heiko Stübner
2024-08-21 8:41 ` Heiko Stübner
2024-08-21 8:55 ` Dragan Simic
2024-08-21 8:55 ` Dragan Simic
2024-08-21 8:55 ` Dragan Simic
2024-08-21 11:17 ` Christophe JAILLET
2024-08-21 11:17 ` Christophe JAILLET
2024-08-21 11:17 ` Christophe JAILLET
2024-08-21 19:05 ` Dragan Simic
2024-08-21 19:05 ` Dragan Simic
2024-08-21 19:05 ` Dragan Simic
2024-08-21 7:37 ` [PATCH v2 3/3] phy: phy-rockchip-inno-usb2: Improve error handling while probing Dragan Simic
2024-08-21 7:37 ` Dragan Simic
2024-08-21 7:37 ` Dragan Simic
2024-08-21 8:44 ` Heiko Stübner
2024-08-21 8:44 ` Heiko Stübner
2024-08-21 8:44 ` Heiko Stübner
2024-08-21 9:09 ` Dragan Simic
2024-08-21 9:09 ` Dragan Simic
2024-08-21 9:09 ` Dragan Simic
2024-08-21 9:17 ` Heiko Stübner [this message]
2024-08-21 9:17 ` Heiko Stübner
2024-08-21 9:17 ` Heiko Stübner
2024-08-21 9:34 ` Dragan Simic
2024-08-21 9:34 ` Dragan Simic
2024-08-21 9:34 ` Dragan Simic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6073817.31tnzDBltd@diego \
--to=heiko@sntech.de \
--cc=dsimic@manjaro.org \
--cc=kishon@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.