Skip to contentSkip to conversation

phy: can-transceiver: Drop unnecessary "mux-states" property presence check

PATCH In review Rob Herring (Arm) 2 participants 2 messages Dec 31, 2024 – Jan 10, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 phy: can-transceiver: Drop unnecessary "mux-states" property presence check

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.

---
 drivers/phy/phy-can-transceiver.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/phy/phy-can-transceiver.c +6 -8
index ee4ce4249698..ed8ba30eb038 100644
@@ -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);
Signature · 1 line
2.45.2
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 29 lines · Rob Herring (Arm)

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.

---
 drivers/phy/phy-can-transceiver.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/phy/phy-can-transceiver.c +1 -4
index ee4ce4249698..ed8ba30eb038 100644
@@ -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);

drivers/phy/phy-can-transceiver.c static int can_transceiver_phy_probe(struct platform_device *pdev) · line 124

Quoted 10 lines
drivers/phy/phy-can-transceiver.c +5 -4
-		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:

drivers/phy/phy-can-transceiver.c static int can_transceiver_phy_probe(struct platform_device *pdev) · line 125

Quoted 4 lines
drivers/phy/phy-can-transceiver.c +0 -0
 	phy = devm_phy_create(dev, dev->of_node,
 			      &can_transceiver_phy_ops);

regards,
Marc

Signature · 4 lines
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   |