All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trent Piepho <tpiepho@impinj.com>
To: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Cc: Trent Piepho <tpiepho@impinj.com>, Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Heiner Kallweit <hkallweit1@gmail.com>
Subject: [PATCH net-next v2 7/8] net: phy: dp83867: Validate FIFO depth property
Date: Wed, 22 May 2019 18:43:26 +0000	[thread overview]
Message-ID: <20190522184255.16323-7-tpiepho@impinj.com> (raw)
In-Reply-To: <20190522184255.16323-1-tpiepho@impinj.com>

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: Trent Piepho <tpiepho@impinj.com>
---

Notes:
    Changes from v1:
      New patch in series v2

 drivers/net/phy/dp83867.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 5ece153aa9c3..ce46ff4cf880 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -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)
-- 
2.14.5


  parent reply	other threads:[~2019-05-22 18:50 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 18:43 [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay Trent Piepho
2019-05-22 18:43 ` [PATCH net-next v2 2/8] dt-bindings: phy: dp83867: Add documentation for disabling clock output Trent Piepho
2019-05-22 19:11   ` Andrew Lunn
2019-05-23  0:44   ` David Miller
2019-05-22 18:43 ` [PATCH net-next v2 3/8] net: phy: dp83867: Add ability to disable output clock Trent Piepho
2019-05-22 18:51   ` Andrew Lunn
2019-05-23  0:44   ` David Miller
2019-05-22 18:43 ` [PATCH net-next v2 4/8] net: phy: dp83867: Rework delay rgmii delay handling Trent Piepho
2019-05-22 18:54   ` Andrew Lunn
2019-05-23  0:44   ` David Miller
2019-05-22 18:43 ` [PATCH net-next v2 5/8] net: phy: dp83867: Use unsigned variables to store unsigned properties Trent Piepho
2019-05-22 18:59   ` Andrew Lunn
2019-05-23  0:44   ` David Miller
2019-05-22 18:43 ` [PATCH net-next v2 6/8] net: phy: dp83867: IO impedance is not dependent on RGMII delay Trent Piepho
2019-05-22 19:03   ` Andrew Lunn
2019-05-23  0:44   ` David Miller
2019-05-22 18:43 ` Trent Piepho [this message]
2019-05-22 19:05   ` [PATCH net-next v2 7/8] net: phy: dp83867: Validate FIFO depth property Andrew Lunn
2019-05-23  0:44   ` David Miller
2019-05-22 18:43 ` [PATCH net-next v2 8/8] net: phy: dp83867: Allocate state struct in probe Trent Piepho
2019-05-22 19:09   ` Andrew Lunn
2019-05-23  0:44   ` David Miller
2019-05-22 19:10 ` [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay Andrew Lunn
2019-05-23  0:43 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190522184255.16323-7-tpiepho@impinj.com \
    --to=tpiepho@impinj.com \
    --cc=andrew@lunn.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.