[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3a50a637-89fc-25a5-836f-9dbd3c604a74@gmail.com>
Date: Mon, 3 Jun 2019 21:24:38 +0200
From: Heiner Kallweit <hkallweit1@...il.com>
To: Realtek linux nic maintainers <nic_swsd@...ltek.com>,
David Miller <davem@...emloft.net>
Cc: "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: [PATCH net-next 2/4] r8169: simplify rtl_fw_write_firmware
Similar to rtl_fw_data_ok() we can simplify the code by moving
incrementing the index to the for loop initialization.
Signed-off-by: Heiner Kallweit <hkallweit1@...il.com>
---
drivers/net/ethernet/realtek/r8169.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 1a1253237..7ba2107ae 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -2451,7 +2451,7 @@ static void rtl_fw_write_firmware(struct rtl8169_private *tp,
int predata = 0, count = 0;
size_t index;
- for (index = 0; index < pa->size; ) {
+ for (index = 0; index < pa->size; index++) {
u32 action = le32_to_cpu(pa->code[index]);
u32 data = action & 0x0000ffff;
u32 regno = (action & 0x0fff0000) >> 16;
@@ -2464,18 +2464,15 @@ static void rtl_fw_write_firmware(struct rtl8169_private *tp,
case PHY_READ:
predata = fw_read(tp, regno);
count++;
- index++;
break;
case PHY_DATA_OR:
predata |= data;
- index++;
break;
case PHY_DATA_AND:
predata &= data;
- index++;
break;
case PHY_BJMPN:
- index -= regno;
+ index -= (regno + 1);
break;
case PHY_MDIO_CHG:
if (data == 0) {
@@ -2486,39 +2483,33 @@ static void rtl_fw_write_firmware(struct rtl8169_private *tp,
fw_read = rtl_fw->mac_mcu_read;
}
- index++;
break;
case PHY_CLEAR_READCOUNT:
count = 0;
- index++;
break;
case PHY_WRITE:
fw_write(tp, regno, data);
- index++;
break;
case PHY_READCOUNT_EQ_SKIP:
- index += (count == data) ? 2 : 1;
+ if (count == data)
+ index++;
break;
case PHY_COMP_EQ_SKIPN:
if (predata == data)
index += regno;
- index++;
break;
case PHY_COMP_NEQ_SKIPN:
if (predata != data)
index += regno;
- index++;
break;
case PHY_WRITE_PREVIOUS:
fw_write(tp, regno, predata);
- index++;
break;
case PHY_SKIPN:
- index += regno + 1;
+ index += regno;
break;
case PHY_DELAY_MS:
mdelay(data);
- index++;
break;
}
}
--
2.21.0
Powered by blists - more mailing lists