aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/rtl8139.c
diff options
context:
space:
mode:
authorMarek Vasut2020-04-12 21:28:30 +0200
committermarex2020-05-01 12:35:21 +0200
commit17dc95e5277cdbad1281b6b5605b1eef74729463 (patch)
treedbf08a45b5ef97fad30e928a731cd06cd721fabf /drivers/net/rtl8139.c
parentf80f4e4d729252eb6124e1afb5dde9f74c35c994 (diff)
net: rtl8139: Minor cleanup of read_eeprom()
Rename the function to rtl8139_read_eeprom() to keep the naming consistent, keep the variables sorted in reverse xmas tree. No functional change. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'drivers/net/rtl8139.c')
-rw-r--r--drivers/net/rtl8139.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c
index ff014ade88b..90e9f1272c3 100644
--- a/drivers/net/rtl8139.c
+++ b/drivers/net/rtl8139.c
@@ -199,7 +199,7 @@ static unsigned char tx_buffer[TX_BUF_SIZE] __attribute__((aligned(4)));
static unsigned char rx_ring[RX_BUF_LEN+16] __attribute__((aligned(4)));
static int rtl8139_probe(struct eth_device *dev, bd_t *bis);
-static int read_eeprom(int location, int addr_len);
+static int rtl8139_read_eeprom(unsigned int location, unsigned int addr_len);
static void rtl_reset(struct eth_device *dev);
static int rtl_transmit(struct eth_device *dev, void *packet, int length);
static int rtl_poll(struct eth_device *dev);
@@ -273,9 +273,9 @@ static int rtl8139_probe(struct eth_device *dev, bd_t *bis)
/* Bring the chip out of low-power mode. */
outb(0x00, ioaddr + RTL_REG_CONFIG1);
- addr_len = read_eeprom(0,8) == 0x8129 ? 8 : 6;
+ addr_len = rtl8139_read_eeprom(0,8) == 0x8129 ? 8 : 6;
for (i = 0; i < 3; i++)
- *ap++ = le16_to_cpu (read_eeprom(i + 7, addr_len));
+ *ap++ = le16_to_cpu (rtl8139_read_eeprom(i + 7, addr_len));
rtl_reset(dev);
@@ -312,12 +312,13 @@ static void rtl8139_eeprom_delay(uintptr_t regbase)
inl(regbase + RTL_REG_CFG9346);
}
-static int read_eeprom(int location, int addr_len)
+static int rtl8139_read_eeprom(unsigned int location, unsigned int addr_len)
{
- int i;
+ unsigned int read_cmd = location | (EE_READ_CMD << addr_len);
+ uintptr_t ee_addr = ioaddr + RTL_REG_CFG9346;
unsigned int retval = 0;
- long ee_addr = ioaddr + RTL_REG_CFG9346;
- int read_cmd = location | (EE_READ_CMD << addr_len);
+ u8 dataval;
+ int i;
outb(EE_ENB & ~EE_CS, ee_addr);
outb(EE_ENB, ee_addr);
@@ -325,19 +326,21 @@ static int read_eeprom(int location, int addr_len)
/* Shift the read command bits out. */
for (i = 4 + addr_len; i >= 0; i--) {
- int dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
+ dataval = (read_cmd & BIT(i)) ? EE_DATA_WRITE : 0;
outb(EE_ENB | dataval, ee_addr);
rtl8139_eeprom_delay(ioaddr);
outb(EE_ENB | dataval | EE_SHIFT_CLK, ee_addr);
rtl8139_eeprom_delay(ioaddr);
}
+
outb(EE_ENB, ee_addr);
rtl8139_eeprom_delay(ioaddr);
for (i = 16; i > 0; i--) {
outb(EE_ENB | EE_SHIFT_CLK, ee_addr);
rtl8139_eeprom_delay(ioaddr);
- retval = (retval << 1) | ((inb(ee_addr) & EE_DATA_READ) ? 1 : 0);
+ retval <<= 1;
+ retval |= inb(ee_addr) & EE_DATA_READ;
outb(EE_ENB, ee_addr);
rtl8139_eeprom_delay(ioaddr);
}
@@ -345,6 +348,7 @@ static int read_eeprom(int location, int addr_len)
/* Terminate the EEPROM access. */
outb(~EE_CS, ee_addr);
rtl8139_eeprom_delay(ioaddr);
+
return retval;
}