Commit f8bbf417 authored by Trent Piepho's avatar Trent Piepho Committed by David S. Miller

net: phy: dp83867: Validate FIFO depth property

Insure property is in valid range and fail when reading DT if it is not.
Also add error message for existing failure if required property is not
present.

Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarTrent Piepho <tpiepho@impinj.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 27708eb5
......@@ -65,7 +65,8 @@
/* PHY CTRL bits */
#define DP83867_PHYCR_FIFO_DEPTH_SHIFT 14
#define DP83867_PHYCR_FIFO_DEPTH_MASK (3 << 14)
#define DP83867_PHYCR_FIFO_DEPTH_MAX 0x03
#define DP83867_PHYCR_FIFO_DEPTH_MASK GENMASK(15, 14)
#define DP83867_PHYCR_RESERVED_MASK BIT(11)
/* RGMIIDCTL bits */
......@@ -245,8 +246,20 @@ static int dp83867_of_init(struct phy_device *phydev)
if (of_property_read_bool(of_node, "enet-phy-lane-no-swap"))
dp83867->port_mirroring = DP83867_PORT_MIRROING_DIS;
return of_property_read_u32(of_node, "ti,fifo-depth",
ret = of_property_read_u32(of_node, "ti,fifo-depth",
&dp83867->fifo_depth);
if (ret) {
phydev_err(phydev,
"ti,fifo-depth property is required\n");
return ret;
}
if (dp83867->fifo_depth > DP83867_PHYCR_FIFO_DEPTH_MAX) {
phydev_err(phydev,
"ti,fifo-depth value %u out of range\n",
dp83867->fifo_depth);
return -EINVAL;
}
return 0;
}
#else
static int dp83867_of_init(struct phy_device *phydev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment