diff mbox series

[U-Boot,2/4] net: dm: fec: Fix phy-reset-duration clamping and defaults

Message ID 1538675965-4495-3-git-send-email-martin.fuzzey@flowbird.group
State Accepted
Commit 331fcab
Delegated to: Joe Hershberger
Headers show
Series net: dm: fec: Fixes and improvements | expand

Commit Message

Martin Fuzzey Oct. 4, 2018, 5:59 p.m. UTC
The DT binding says:
- phy-reset-duration : Reset duration in milliseconds.  Should present
  only if property "phy-reset-gpios" is available.  Missing the property
  will have the duration be 1 millisecond.  Numbers greater than 1000 are
  invalid and 1 millisecond will be used instead.

However the current code:
 - clamps values greater than 1000ms to 1000ms rather than 1.
 - does not initialize the delay if the property does not exist
   (else clause mismatch)
 - returns an error if phy-reset-gpios is not defined

Fix all this and simplify by using dev_read_u32_default()

Signed-off-by: Martin Fuzzey <martin.fuzzey@flowbird.group>
---
 drivers/net/fec_mxc.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

Comments

Joe Hershberger Oct. 22, 2018, 8:54 p.m. UTC | #1
On Thu, Oct 4, 2018 at 1:02 PM Martin Fuzzey
<martin.fuzzey@flowbird.group> wrote:
>
> The DT binding says:
> - phy-reset-duration : Reset duration in milliseconds.  Should present
>   only if property "phy-reset-gpios" is available.  Missing the property
>   will have the duration be 1 millisecond.  Numbers greater than 1000 are
>   invalid and 1 millisecond will be used instead.
>
> However the current code:
>  - clamps values greater than 1000ms to 1000ms rather than 1.
>  - does not initialize the delay if the property does not exist
>    (else clause mismatch)
>  - returns an error if phy-reset-gpios is not defined
>
> Fix all this and simplify by using dev_read_u32_default()
>
> Signed-off-by: Martin Fuzzey <martin.fuzzey@flowbird.group>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Joe Hershberger Oct. 24, 2018, 7:56 p.m. UTC | #2
Hi Martin,

https://patchwork.ozlabs.org/patch/979101/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git

Thanks!
-Joe
diff mbox series

Patch

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index a1295fc..163ae4c 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1354,20 +1354,17 @@  static int fecmxc_ofdata_to_platdata(struct udevice *dev)
 	ret = gpio_request_by_name(dev, "phy-reset-gpios", 0,
 			     &priv->phy_reset_gpio, GPIOD_IS_OUT);
 	if (ret == 0) {
-		ret = dev_read_u32_array(dev, "phy-reset-duration",
-					 &priv->reset_delay, 1);
-	} else if (ret == -ENOENT) {
-		priv->reset_delay = 1000;
-		ret = 0;
-	}
-
-	if (priv->reset_delay > 1000) {
-		printf("FEX MXC: gpio reset timeout should be less the 1000\n");
-		priv->reset_delay = 1000;
+		priv->reset_delay = dev_read_u32_default(dev,
+							 "phy-reset-duration",
+							 1);
+		if (priv->reset_delay > 1000) {
+			printf("FEC MXC: phy reset duration should be <= 1000ms\n");
+			priv->reset_delay = 1;
+		}
 	}
 #endif
 
-	return ret;
+	return 0;
 }
 
 static const struct udevice_id fecmxc_ids[] = {