Patchwork [U-Boot] miiphy: miiphyutil.c: fix compile warning

login
register
mail settings
Submitter Anatolij Gustschin
Date April 30, 2011, 12:17 p.m.
Message ID <1304165864-10499-1-git-send-email-agust@denx.de>
Download mbox | patch
Permalink /patch/93501/
State Accepted
Commit d67d5d529aa3a5c3c063a24585eeaedd5e0728eb
Headers show

Comments

Anatolij Gustschin - April 30, 2011, 12:17 p.m.
Fix warning introduced while recent PHY Lib changes:

miiphyutil.c: In function 'miiphy_read':
miiphyutil.c:304: warning: comparison is always false due to limited range of data type

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Andy Fleming <afleming@freescale.com>
---
 common/miiphyutil.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
Wolfgang Denk - April 30, 2011, 9:09 p.m.
Dear Anatolij Gustschin,

In message <1304165864-10499-1-git-send-email-agust@denx.de> you wrote:
> Fix warning introduced while recent PHY Lib changes:
> 
> miiphyutil.c: In function 'miiphy_read':
> miiphyutil.c:304: warning: comparison is always false due to limited range of data type
> 
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> Cc: Andy Fleming <afleming@freescale.com>
> ---
>  common/miiphyutil.c |   12 ++++++++----
>  1 files changed, 8 insertions(+), 4 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Patch

diff --git a/common/miiphyutil.c b/common/miiphyutil.c
index 243cae9..bcab74e 100644
--- a/common/miiphyutil.c
+++ b/common/miiphyutil.c
@@ -294,14 +294,18 @@  int miiphy_read(const char *devname, unsigned char addr, unsigned char reg,
 		 unsigned short *value)
 {
 	struct mii_dev *bus;
+	int ret;
 
 	bus = miiphy_get_active_dev(devname);
-	if (bus)
-		*value = bus->read(bus, addr, MDIO_DEVAD_NONE, reg);
-	else
+	if (!bus)
 		return 1;
 
-	return (*value < 0) ? 1 : 0;
+	ret = bus->read(bus, addr, MDIO_DEVAD_NONE, reg);
+	if (ret < 0)
+		return 1;
+
+	*value = (unsigned short)ret;
+	return 0;
 }
 
 /*****************************************************************************