linux-phy.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] phy: phy-rockchip-inno-usb2: Handle failed extcon allocation better
@ 2024-08-13 18:38 Dragan Simic
  2024-08-15 16:12 ` Heiko Stübner
  0 siblings, 1 reply; 3+ messages in thread
From: Dragan Simic @ 2024-08-13 18:38 UTC (permalink / raw)
  To: linux-rockchip, linux-phy
  Cc: vkoul, kishon, heiko, linux-arm-kernel, linux-kernel

Return the actual error code upon failure to allocate extcon device, instead
of hardcoding -ENOMEM.  While there, produce an appropriate error message.

Signed-off-by: Dragan Simic <dsimic@manjaro.org>
---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index 4f71373ae6e1..d33418a1e7a8 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -434,8 +434,10 @@ static int rockchip_usb2phy_extcon_register(struct rockchip_usb2phy *rphy)
 		edev = devm_extcon_dev_allocate(rphy->dev,
 						rockchip_usb2phy_extcon_cable);
 
-		if (IS_ERR(edev))
-			return -ENOMEM;
+		if (IS_ERR(edev)) {
+			dev_err(rphy->dev, "failed to allocate extcon device\n");
+			return PTR_ERR(edev);
+		}
 
 		ret = devm_extcon_dev_register(rphy->dev, edev);
 		if (ret) {

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

* Re: [PATCH] phy: phy-rockchip-inno-usb2: Handle failed extcon allocation better
  2024-08-13 18:38 [PATCH] phy: phy-rockchip-inno-usb2: Handle failed extcon allocation better Dragan Simic
@ 2024-08-15 16:12 ` Heiko Stübner
  2024-08-17  6:52   ` Dragan Simic
  0 siblings, 1 reply; 3+ messages in thread
From: Heiko Stübner @ 2024-08-15 16:12 UTC (permalink / raw)
  To: linux-rockchip, linux-phy, Dragan Simic
  Cc: vkoul, kishon, linux-arm-kernel, linux-kernel

Am Dienstag, 13. August 2024, 20:38:17 CEST schrieb Dragan Simic:
> Return the actual error code upon failure to allocate extcon device, instead
> of hardcoding -ENOMEM.  While there, produce an appropriate error message.
> 
> Signed-off-by: Dragan Simic <dsimic@manjaro.org>
> ---
>  drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> index 4f71373ae6e1..d33418a1e7a8 100644
> --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> @@ -434,8 +434,10 @@ static int rockchip_usb2phy_extcon_register(struct rockchip_usb2phy *rphy)
>  		edev = devm_extcon_dev_allocate(rphy->dev,
>  						rockchip_usb2phy_extcon_cable);
>  
> -		if (IS_ERR(edev))
> -			return -ENOMEM;
> +		if (IS_ERR(edev)) {
> +			dev_err(rphy->dev, "failed to allocate extcon device\n");
> +			return PTR_ERR(edev);
> +		}

maybe even use dev_err_probe?

rockchip_usb2phy_extcon_register() gets called from the probe function,
so even using it is also sematically correct ;-) .


Heiko

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





-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

* Re: [PATCH] phy: phy-rockchip-inno-usb2: Handle failed extcon allocation better
  2024-08-15 16:12 ` Heiko Stübner
@ 2024-08-17  6:52   ` Dragan Simic
  0 siblings, 0 replies; 3+ messages in thread
From: Dragan Simic @ 2024-08-17  6:52 UTC (permalink / raw)
  To: Heiko Stübner
  Cc: linux-rockchip, linux-phy, vkoul, kishon, linux-arm-kernel,
	linux-kernel

Hello Heiko,

On 2024-08-15 18:12, Heiko Stübner wrote:
> Am Dienstag, 13. August 2024, 20:38:17 CEST schrieb Dragan Simic:
>> Return the actual error code upon failure to allocate extcon device, 
>> instead
>> of hardcoding -ENOMEM.  While there, produce an appropriate error 
>> message.
>> 
>> Signed-off-by: Dragan Simic <dsimic@manjaro.org>
>> ---
>>  drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c 
>> b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
>> index 4f71373ae6e1..d33418a1e7a8 100644
>> --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
>> +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
>> @@ -434,8 +434,10 @@ static int 
>> rockchip_usb2phy_extcon_register(struct rockchip_usb2phy *rphy)
>>  		edev = devm_extcon_dev_allocate(rphy->dev,
>>  						rockchip_usb2phy_extcon_cable);
>> 
>> -		if (IS_ERR(edev))
>> -			return -ENOMEM;
>> +		if (IS_ERR(edev)) {
>> +			dev_err(rphy->dev, "failed to allocate extcon device\n");
>> +			return PTR_ERR(edev);
>> +		}
> 
> maybe even use dev_err_probe?
> 
> rockchip_usb2phy_extcon_register() gets called from the probe function,
> so even using it is also sematically correct ;-) .

Good suggestion, thanks!  I'll use dev_err_probe() in the v2, albeit it
also calls for turning this into a small patch series that additionally
replaces dev_err() with dev_err_probe() in the rockchip_usb2phy_probe()
function, for consistency. :)

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

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

end of thread, other threads:[~2024-08-17  6:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-13 18:38 [PATCH] phy: phy-rockchip-inno-usb2: Handle failed extcon allocation better Dragan Simic
2024-08-15 16:12 ` Heiko Stübner
2024-08-17  6:52   ` Dragan Simic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).