Skip to contentSkip to conversation

net: phy: ti: Fix clock output DT property

PATCH In review Trent Piepho 4 participants 4 messages May 10, 2019 – Jul 15, 2019

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

PATCH 1/1 net: phy: ti: Fix clock output DT property

The code block reading the DT property for the clock output control was before the phy's DT node pointer was set, so it could never work. Move it after the node pointer is set.

Also store the unsigned 32-bit property into an unsigned value, not a signed value, as the former will cause a problem if value overflows. For instance, if one were to add 0xffffffff as a code to mean the clock output should be turned off.

Cc Joe Hershberger <[email protected]>
Cc Janine Hagemann <[email protected]>
Cc Grygorii Strashko <[email protected]>
---
 drivers/net/phy/ti.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/net/phy/ti.c +5 -11
index 33f5687e0e..1aee338ec4 100644
@@ -113,7 +113,7 @@ struct dp83867_private {
 	int io_impedance;
 	bool rxctrl_strap_quirk;
 	int port_mirroring;
-	int clk_output_sel;
+	unsigned int clk_output_sel;
 };
 
 /**
@@ -214,21 +214,15 @@ static int dp83867_of_init(struct phy_device *phydev)
 	ofnode node;
 	u16 val;
 
-	/* Optional configuration */
-
-	/*
-	 * Keep the default value if ti,clk-output-sel is not set
-	 * or to high
-	 */
+	node = phy_get_ofnode(phydev);
+	if (!ofnode_valid(node))
+		return -EINVAL;
 
+	/* Keep the default value if ti,clk-output-sel is not set */
 	dp83867->clk_output_sel =
 		ofnode_read_u32_default(node, "ti,clk-output-sel",
 					DP83867_CLK_O_SEL_REF_CLK);
 
-	node = phy_get_ofnode(phydev);
-	if (!ofnode_valid(node))
-		return -EINVAL;
-
 	if (ofnode_read_bool(node, "ti,max-output-impedance"))
 		dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX;
 	else if (ofnode_read_bool(node, "ti,min-output-impedance"))
Signature · 1 line
2.14.5
#1 lore raw

PATCH 1/1 net: phy: ti: Fix clock output DT property

Quoted 9 lines · Trent Piepho

The code block reading the DT property for the clock output control was before the phy's DT node pointer was set, so it could never work. Move it after the node pointer is set.

Also store the unsigned 32-bit property into an unsigned value, not a signed value, as the former will cause a problem if value overflows. For instance, if one were to add 0xffffffff as a code to mean the clock output should be turned off.

Quoted 8 lines
Cc Joe Hershberger <[email protected]>
Cc Janine Hagemann <[email protected]>
Cc Grygorii Strashko <[email protected]>
---
 drivers/net/phy/ti.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
Signature · 2 lines
Best regards,
grygorii
#2 lore raw

PATCH 1/1 net: phy: ti: Fix clock output DT property

In reply to Trent Piepho
Quoted 18 lines

-----Original Message-----
From: Trent Piepho <[email protected]>
Sent: Friday, May 10, 2019 12:49 PM
To: u-boot at lists.denx.de
Cc: Trent Piepho <[email protected]>; Joseph Hershberger <[email protected]>; Janine Hagemann <[email protected]>; Grygorii Strashko <[email protected]>
Subject: [EXTERNAL] [PATCH] net: phy: ti: Fix clock output DT property

The code block reading the DT property for the clock output control was before the phy's DT node pointer was set, so it could never work. Move it after the node pointer is set.

Also store the unsigned 32-bit property into an unsigned value, not a signed value, as the former will cause a problem if value overflows.
For instance, if one were to add 0xffffffff as a code to mean the clock output should be turned off.

Quoted 4 lines
Cc Joe Hershberger <[email protected]>
Cc Janine Hagemann <[email protected]>
Cc Grygorii Strashko <[email protected]>