public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] phy: can-transceiver: Drop unnecessary "mux-states" property presence check
@ 2024-12-31 16:32 Rob Herring (Arm)
  2025-01-10 10:13 ` Marc Kleine-Budde
  0 siblings, 1 reply; 5+ messages in thread
From: Rob Herring (Arm) @ 2024-12-31 16:32 UTC (permalink / raw)
  To: Marc Kleine-Budde, Vincent Mailhol, Vinod Koul,
	Kishon Vijay Abraham I
  Cc: linux-can, linux-phy, linux-kernel

It doesn't matter whether "mux-states" is not present or there is some
other issue parsing it causing an error. Drop the presence check and
rework the error handling to ignore anything other than deferred probe.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
 drivers/phy/phy-can-transceiver.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c
index ee4ce4249698..ed8ba30eb038 100644
--- a/drivers/phy/phy-can-transceiver.c
+++ b/drivers/phy/phy-can-transceiver.c
@@ -103,6 +103,7 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
 	struct phy *phy;
 	struct gpio_desc *standby_gpio;
 	struct gpio_desc *enable_gpio;
+	struct mux_state *mux_state;
 	u32 max_bitrate = 0;
 	int err;
 
@@ -113,15 +114,12 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
 	match = of_match_node(can_transceiver_phy_ids, pdev->dev.of_node);
 	drvdata = match->data;
 
-	if (of_property_read_bool(dev->of_node, "mux-states")) {
-		struct mux_state *mux_state;
-
-		mux_state = devm_mux_state_get(dev, NULL);
-		if (IS_ERR(mux_state))
-			return dev_err_probe(&pdev->dev, PTR_ERR(mux_state),
-					     "failed to get mux\n");
+	mux_state = devm_mux_state_get(dev, NULL);
+	if (IS_ERR(mux_state)) {
+		if (PTR_ERR(mux_state) == -EPROBE_DEFER)
+			return PTR_ERR(mux_state);
+	} else
 		can_transceiver_phy->mux_state = mux_state;
-	}
 
 	phy = devm_phy_create(dev, dev->of_node,
 			      &can_transceiver_phy_ops);
-- 
2.45.2


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

* Re: [PATCH] phy: can-transceiver: Drop unnecessary "mux-states" property presence check
  2024-12-31 16:32 [PATCH] phy: can-transceiver: Drop unnecessary "mux-states" property presence check Rob Herring (Arm)
@ 2025-01-10 10:13 ` Marc Kleine-Budde
  0 siblings, 0 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2025-01-10 10:13 UTC (permalink / raw)
  To: Rob Herring (Arm)
  Cc: Vincent Mailhol, Vinod Koul, Kishon Vijay Abraham I, linux-can,
	linux-phy, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2153 bytes --]

On 31.12.2024 10:32:51, Rob Herring (Arm) wrote:
> It doesn't matter whether "mux-states" is not present or there is some
> other issue parsing it causing an error. Drop the presence check and
> rework the error handling to ignore anything other than deferred probe.
> 
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
>  drivers/phy/phy-can-transceiver.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c
> index ee4ce4249698..ed8ba30eb038 100644
> --- a/drivers/phy/phy-can-transceiver.c
> +++ b/drivers/phy/phy-can-transceiver.c
> @@ -103,6 +103,7 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
>  	struct phy *phy;
>  	struct gpio_desc *standby_gpio;
>  	struct gpio_desc *enable_gpio;
> +	struct mux_state *mux_state;
>  	u32 max_bitrate = 0;
>  	int err;
>  
> @@ -113,15 +114,12 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
>  	match = of_match_node(can_transceiver_phy_ids, pdev->dev.of_node);
>  	drvdata = match->data;
>  
> -	if (of_property_read_bool(dev->of_node, "mux-states")) {
> -		struct mux_state *mux_state;
> -
> -		mux_state = devm_mux_state_get(dev, NULL);
> -		if (IS_ERR(mux_state))
> -			return dev_err_probe(&pdev->dev, PTR_ERR(mux_state),
> -					     "failed to get mux\n");
> +	mux_state = devm_mux_state_get(dev, NULL);
> +	if (IS_ERR(mux_state)) {
> +		if (PTR_ERR(mux_state) == -EPROBE_DEFER)
> +			return PTR_ERR(mux_state);
> +	} else
>  		can_transceiver_phy->mux_state = mux_state;
> -	}

Nitpick:
I think we want { } on both sides of the if/else.

After fixing this:
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>

>  
>  	phy = devm_phy_create(dev, dev->of_node,
>  			      &can_transceiver_phy_ops);
> -- 

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* [PATCH] phy: can-transceiver: Drop unnecessary "mux-states" property presence check
@ 2025-02-03 18:54 Rob Herring (Arm)
  2025-02-10 17:21 ` Vinod Koul
  2025-02-19 16:34 ` Geert Uytterhoeven
  0 siblings, 2 replies; 5+ messages in thread
From: Rob Herring (Arm) @ 2025-02-03 18:54 UTC (permalink / raw)
  To: Marc Kleine-Budde, Vincent Mailhol, Vinod Koul,
	Kishon Vijay Abraham I
  Cc: linux-can, linux-phy, linux-kernel

It doesn't matter whether "mux-states" is not present or there is some
other issue parsing it causing an error. Drop the presence check and
rework the error handling to ignore anything other than deferred probe.

Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
Now a warning in v6.14-rc1, so please apply for 6.14.

v2:
 - Use brackets on else clause
---
 drivers/phy/phy-can-transceiver.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c
index ee4ce4249698..2bec70615449 100644
--- a/drivers/phy/phy-can-transceiver.c
+++ b/drivers/phy/phy-can-transceiver.c
@@ -103,6 +103,7 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
 	struct phy *phy;
 	struct gpio_desc *standby_gpio;
 	struct gpio_desc *enable_gpio;
+	struct mux_state *mux_state;
 	u32 max_bitrate = 0;
 	int err;
 
@@ -113,13 +114,11 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
 	match = of_match_node(can_transceiver_phy_ids, pdev->dev.of_node);
 	drvdata = match->data;
 
-	if (of_property_read_bool(dev->of_node, "mux-states")) {
-		struct mux_state *mux_state;
-
-		mux_state = devm_mux_state_get(dev, NULL);
-		if (IS_ERR(mux_state))
-			return dev_err_probe(&pdev->dev, PTR_ERR(mux_state),
-					     "failed to get mux\n");
+	mux_state = devm_mux_state_get(dev, NULL);
+	if (IS_ERR(mux_state)) {
+		if (PTR_ERR(mux_state) == -EPROBE_DEFER)
+			return PTR_ERR(mux_state);
+	} else {
 		can_transceiver_phy->mux_state = mux_state;
 	}
 
-- 
2.47.2


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

* Re: [PATCH] phy: can-transceiver: Drop unnecessary "mux-states" property presence check
  2025-02-03 18:54 Rob Herring (Arm)
@ 2025-02-10 17:21 ` Vinod Koul
  2025-02-19 16:34 ` Geert Uytterhoeven
  1 sibling, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2025-02-10 17:21 UTC (permalink / raw)
  To: Marc Kleine-Budde, Vincent Mailhol, Kishon Vijay Abraham I,
	Rob Herring (Arm)
  Cc: linux-can, linux-phy, linux-kernel


On Mon, 03 Feb 2025 12:54:21 -0600, Rob Herring (Arm) wrote:
> It doesn't matter whether "mux-states" is not present or there is some
> other issue parsing it causing an error. Drop the presence check and
> rework the error handling to ignore anything other than deferred probe.
> 
> 

Applied, thanks!

[1/1] phy: can-transceiver: Drop unnecessary "mux-states" property presence check
      commit: d02dfd4ceb2e9f34caaaaf87105267e2f722f443

Best regards,
-- 
~Vinod



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

* Re: [PATCH] phy: can-transceiver: Drop unnecessary "mux-states" property presence check
  2025-02-03 18:54 Rob Herring (Arm)
  2025-02-10 17:21 ` Vinod Koul
@ 2025-02-19 16:34 ` Geert Uytterhoeven
  1 sibling, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2025-02-19 16:34 UTC (permalink / raw)
  To: Rob Herring (Arm)
  Cc: Marc Kleine-Budde, Vincent Mailhol, Vinod Koul,
	Kishon Vijay Abraham I, linux-can, linux-phy, linux-kernel,
	Linux-Renesas

Hi Rob,

On Mon, 3 Feb 2025 at 19:55, Rob Herring (Arm) <robh@kernel.org> wrote:
> It doesn't matter whether "mux-states" is not present or there is some
> other issue parsing it causing an error. Drop the presence check and
> rework the error handling to ignore anything other than deferred probe.
>
> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
> Now a warning in v6.14-rc1, so please apply for 6.14.
>
> v2:
>  - Use brackets on else clause

Thanks for your patch, which is now commit d02dfd4ceb2e9f34 ("phy:
can-transceiver: Drop unnecessary "mux-states" property presence check")
in phy/next (next-20250212 and later).

I have bisected the following error during boot on the Gray Hawk Single
and White Hawk development boards:

    can-transceiver-phy can-phy0: /can-phy0: failed to get mux-state (0)

> --- a/drivers/phy/phy-can-transceiver.c
> +++ b/drivers/phy/phy-can-transceiver.c
> @@ -113,13 +114,11 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
>         match = of_match_node(can_transceiver_phy_ids, pdev->dev.of_node);
>         drvdata = match->data;
>
> -       if (of_property_read_bool(dev->of_node, "mux-states")) {
> -               struct mux_state *mux_state;
> -
> -               mux_state = devm_mux_state_get(dev, NULL);
> -               if (IS_ERR(mux_state))
> -                       return dev_err_probe(&pdev->dev, PTR_ERR(mux_state),
> -                                            "failed to get mux\n");
> +       mux_state = devm_mux_state_get(dev, NULL);

If the (optional) "mux-states" property is not present, mux_get()
prints an error message, and returns -ENOENT....

> +       if (IS_ERR(mux_state)) {
> +               if (PTR_ERR(mux_state) == -EPROBE_DEFER)
> +                       return PTR_ERR(mux_state);

... which is ignored here, so in the end all is good.
Still, it is confusing to erroneously print an error message.

> +       } else {
>                 can_transceiver_phy->mux_state = mux_state;
>         }

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

end of thread, other threads:[~2025-02-19 16:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-31 16:32 [PATCH] phy: can-transceiver: Drop unnecessary "mux-states" property presence check Rob Herring (Arm)
2025-01-10 10:13 ` Marc Kleine-Budde
  -- strict thread matches above, loose matches on Subject: below --
2025-02-03 18:54 Rob Herring (Arm)
2025-02-10 17:21 ` Vinod Koul
2025-02-19 16:34 ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox