mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] phy: renesas: rcar-gen2: Return -EINVAL for out-of-range channel reg
@ 2026-08-03 13:07 Felix Gu
  2026-08-03 13:26 ` Biju Das
  0 siblings, 1 reply; 3+ messages in thread
From: Felix Gu @ 2026-08-03 13:07 UTC (permalink / raw)
  To: Vinod Koul, Neil Armstrong, Geert Uytterhoeven, Magnus Damm,
	Ulrich Hecht, Wolfram Sang, Biju Das, Yoshihiro Shimoda,
	Sergei Shtylyov
  Cc: Kishon Vijay Abraham I, linux-phy, linux-renesas-soc,
	linux-kernel, Felix Gu

When of_property_read_u32() succeeds but channel_num exceeds
data->num_channels, rcar_gen2_phy_probe() returns error which is 0,
so probe reports success even though no PHY provider is registered.

Return -EINVAL in that case.

Fixes: 1233f59f745b ("phy: Renesas R-Car Gen2 PHY driver")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
 drivers/phy/renesas/phy-rcar-gen2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c
index 6c671254c625..f0858d8cc705 100644
--- a/drivers/phy/renesas/phy-rcar-gen2.c
+++ b/drivers/phy/renesas/phy-rcar-gen2.c
@@ -390,7 +390,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
 		error = of_property_read_u32(np, "reg", &channel_num);
 		if (error || channel_num >= data->num_channels) {
 			dev_err(dev, "Invalid \"reg\" property\n");
-			return error;
+			return error ?: -EINVAL;
 		}
 		channel->select_mask = select_mask[channel_num];
 

---
base-commit: 415606a7be939835db9b0d6b711887586646346d
change-id: 20260803-rcar-gen2-1-98f440b28b35

Best regards,
--  
Felix Gu <ustc.gu@gmail.com>


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

* RE: [PATCH] phy: renesas: rcar-gen2: Return -EINVAL for out-of-range channel reg
  2026-08-03 13:07 [PATCH] phy: renesas: rcar-gen2: Return -EINVAL for out-of-range channel reg Felix Gu
@ 2026-08-03 13:26 ` Biju Das
  2026-08-04 14:39   ` Felix Gu
  0 siblings, 1 reply; 3+ messages in thread
From: Biju Das @ 2026-08-03 13:26 UTC (permalink / raw)
  To: Felix Gu, Vinod Koul, Neil Armstrong, Geert Uytterhoeven,
	magnus.damm, Ulrich Hecht, wsa+renesas, Yoshihiro Shimoda,
	Sergei Shtylyov
  Cc: Kishon Vijay Abraham I, linux-phy, linux-renesas-soc, linux-kernel

Hi Felix Gu,

Thanks for the patch.

> -----Original Message-----
> From: Felix Gu <ustc.gu@gmail.com>
> Sent: 03 August 2026 14:07
> Subject: [PATCH] phy: renesas: rcar-gen2: Return -EINVAL for out-of-range channel reg
> 
> When of_property_read_u32() succeeds but channel_num exceeds
> data->num_channels, rcar_gen2_phy_probe() returns error which is 0,
> so probe reports success even though no PHY provider is registered.
> 
> Return -EINVAL in that case.
> 
> Fixes: 1233f59f745b ("phy: Renesas R-Car Gen2 PHY driver")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
>  drivers/phy/renesas/phy-rcar-gen2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c
> index 6c671254c625..f0858d8cc705 100644
> --- a/drivers/phy/renesas/phy-rcar-gen2.c
> +++ b/drivers/phy/renesas/phy-rcar-gen2.c
> @@ -390,7 +390,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
>  		error = of_property_read_u32(np, "reg", &channel_num);
>  		if (error || channel_num >= data->num_channels) {
>  			dev_err(dev, "Invalid \"reg\" property\n");
> -			return error;
> +			return error ?: -EINVAL;

Can we use dev_error_probe() here as well??

Cheers,
Biju

>  		}
>  		channel->select_mask = select_mask[channel_num];
> 
> 
> ---
> base-commit: 415606a7be939835db9b0d6b711887586646346d
> change-id: 20260803-rcar-gen2-1-98f440b28b35
> 
> Best regards,
> --
> Felix Gu <ustc.gu@gmail.com>


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

* Re: [PATCH] phy: renesas: rcar-gen2: Return -EINVAL for out-of-range channel reg
  2026-08-03 13:26 ` Biju Das
@ 2026-08-04 14:39   ` Felix Gu
  0 siblings, 0 replies; 3+ messages in thread
From: Felix Gu @ 2026-08-04 14:39 UTC (permalink / raw)
  To: Biju Das
  Cc: Vinod Koul, Neil Armstrong, Geert Uytterhoeven, magnus.damm,
	Ulrich Hecht, wsa+renesas, Yoshihiro Shimoda, Sergei Shtylyov,
	Kishon Vijay Abraham I, linux-phy, linux-renesas-soc,
	linux-kernel

On Mon, Aug 3, 2026 at 9:26 PM Biju Das <biju.das.jz@bp.renesas.com> wrote:
>
> Hi Felix Gu,
>
> Can we use dev_error_probe() here as well??
>
> Cheers,
> Biju
>
Hi Biju,
It may be better to convert to use dev_err_probe in the probe function
with a new patch.
I will send out one later.

Best regards,
Felix

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

end of thread, other threads:[~2026-08-04 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-03 13:07 [PATCH] phy: renesas: rcar-gen2: Return -EINVAL for out-of-range channel reg Felix Gu
2026-08-03 13:26 ` Biju Das
2026-08-04 14:39   ` Felix Gu

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®