[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20071108231222.GF15968@electric-eye.fr.zoreil.com>
Date: Fri, 9 Nov 2007 00:12:22 +0100
From: Francois Romieu <romieu@...zoreil.com>
To: jgarzik@...ox.com
Cc: netdev@...r.kernel.org, Andrew Morton <akpm@...ux-foundation.org>,
Mark Lord <mlord@...ox.com>,
Ciaran McCreesh <ciaran.mccreesh@...eyonder.co.uk>,
Josh Logan <joshtlogan@...il.com>,
cecco <f.cecco77@...cali.it>,
Hans-Jurgen Koch <hjk@...utronix.de>,
David Gundersen <gundy@...et.net.au>,
Will Trives <will@...vescon.com.au>,
"Alexander Y. Fomichev" <gluk@...4.ru>,
Rolf Eike Beer <eike-kernel@...tec.de>,
Daniel Drake <dsd@...too.org>,
Lennert Buytenhek <buytenh@...tstofly.org>,
Philip Craig <philipc@...pgear.com>,
Edward Hsu <edward_hsu@...ltek.com.tw>
Subject: [PATCH 05/05] r8169: prevent bit sign expansion error in mdio_write
Oops.
The current code does not like being given an u16 with the highest
bit set as an argument to mdio_write. Let's enforce a correct range of
values for both the register address and value (resp. 5 and 16 bits).
The callers are currently left as-is.
Signed-off-by: Francois Romieu <romieu@...zoreil.com>
Cc: Edward Hsu <edward_hsu@...ltek.com.tw>
---
drivers/net/r8169.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index f9ba2e4..1f647b9 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -470,7 +470,7 @@ static void mdio_write(void __iomem *ioaddr, int reg_addr, int value)
{
int i;
- RTL_W32(PHYAR, 0x80000000 | (reg_addr & 0xFF) << 16 | value);
+ RTL_W32(PHYAR, 0x80000000 | (reg_addr & 0x1f) << 16 | (value & 0xffff));
for (i = 20; i > 0; i--) {
/*
@@ -487,7 +487,7 @@ static int mdio_read(void __iomem *ioaddr, int reg_addr)
{
int i, value = -1;
- RTL_W32(PHYAR, 0x0 | (reg_addr & 0xFF) << 16);
+ RTL_W32(PHYAR, 0x0 | (reg_addr & 0x1f) << 16);
for (i = 20; i > 0; i--) {
/*
@@ -495,7 +495,7 @@ static int mdio_read(void __iomem *ioaddr, int reg_addr)
* the specified MII register.
*/
if (RTL_R32(PHYAR) & 0x80000000) {
- value = (int) (RTL_R32(PHYAR) & 0xFFFF);
+ value = RTL_R32(PHYAR) & 0xffff;
break;
}
udelay(25);
--
1.5.3.3
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists