mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Dragan Simic <dsimic@manjaro.org>,
	linux-rockchip@lists.infradead.org,
	linux-phy@lists.infradead.org
Cc: vkoul@kernel.org, kishon@kernel.org, heiko@sntech.de,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] phy: phy-rockchip-inno-usb2: Handle failed extcon allocation better
Date: Wed, 21 Aug 2024 13:17:23 +0200	[thread overview]
Message-ID: <816aa82c-1f50-4dfe-a41f-e396e0bdf219@wanadoo.fr> (raw)
In-Reply-To: <96200baf794a0c451f3bbc3f5530b8cf0e359dfc.1724225528.git.dsimic@manjaro.org>

Le 21/08/2024 à 09:37, Dragan Simic a écrit :
> Return the actual error code upon failure to allocate extcon device, instead
> of hardcoding -ENOMEM.  Use dev_err_probe() to also log appropriate messages,
> which is fine because the containing function is used in the probe path.
> 
> Helped-by: Heiko Stubner <heiko@sntech.de>
> Signed-off-by: Dragan Simic <dsimic@manjaro.org>
> ---
>   drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> index 113bfc717ff0..05af46dda11d 100644
> --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> @@ -435,7 +435,8 @@ static int rockchip_usb2phy_extcon_register(struct rockchip_usb2phy *rphy)
>   						rockchip_usb2phy_extcon_cable);
>   
>   		if (IS_ERR(edev))
> -			return -ENOMEM;
> +			return dev_err_probe(rphy->dev, PTR_ERR(edev),
> +					     "failed to allocate extcon device\n");

Returning PTR_ERR(edev) may make sense, but I don't think that adding a 
dev_err_probe() really helps.

devm_extcon_dev_allocate() can only return -EINVAL if it 2nd argument is 
NULL. It is trivial to see that it can't happen here, 
rockchip_usb2phy_extcon_cable is a global variable.

in all other cases, it returns -ENOMEM because of a failed memory 
allocation. In this case, usually it is not needed to log anything 
because it is already loud enough.

Just my 2c.

CJ


>   
>   		ret = devm_extcon_dev_register(rphy->dev, edev);
>   		if (ret) {
> 
> 


  parent reply	other threads:[~2024-08-21 11:18 UTC|newest]

Thread overview: 14+ 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 ` [PATCH v2 1/3] phy: phy-rockchip-inno-usb2: Perform trivial code cleanups Dragan Simic
2024-08-21  8:39   ` Heiko Stübner
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  8:41   ` Heiko Stübner
2024-08-21  8:55     ` Dragan Simic
2024-08-21 11:17   ` Christophe JAILLET [this message]
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  8:44   ` Heiko Stübner
2024-08-21  9:09     ` Dragan Simic
2024-08-21  9:17       ` Heiko Stübner
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=816aa82c-1f50-4dfe-a41f-e396e0bdf219@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=dsimic@manjaro.org \
    --cc=heiko@sntech.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®