Commit 2956870e authored by Heiner Kallweit's avatar Heiner Kallweit Committed by David S. Miller

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: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0a616b32
...@@ -2451,7 +2451,7 @@ static void rtl_fw_write_firmware(struct rtl8169_private *tp, ...@@ -2451,7 +2451,7 @@ static void rtl_fw_write_firmware(struct rtl8169_private *tp,
int predata = 0, count = 0; int predata = 0, count = 0;
size_t index; 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 action = le32_to_cpu(pa->code[index]);
u32 data = action & 0x0000ffff; u32 data = action & 0x0000ffff;
u32 regno = (action & 0x0fff0000) >> 16; u32 regno = (action & 0x0fff0000) >> 16;
...@@ -2464,18 +2464,15 @@ static void rtl_fw_write_firmware(struct rtl8169_private *tp, ...@@ -2464,18 +2464,15 @@ static void rtl_fw_write_firmware(struct rtl8169_private *tp,
case PHY_READ: case PHY_READ:
predata = fw_read(tp, regno); predata = fw_read(tp, regno);
count++; count++;
index++;
break; break;
case PHY_DATA_OR: case PHY_DATA_OR:
predata |= data; predata |= data;
index++;
break; break;
case PHY_DATA_AND: case PHY_DATA_AND:
predata &= data; predata &= data;
index++;
break; break;
case PHY_BJMPN: case PHY_BJMPN:
index -= regno; index -= (regno + 1);
break; break;
case PHY_MDIO_CHG: case PHY_MDIO_CHG:
if (data == 0) { if (data == 0) {
...@@ -2486,39 +2483,33 @@ static void rtl_fw_write_firmware(struct rtl8169_private *tp, ...@@ -2486,39 +2483,33 @@ static void rtl_fw_write_firmware(struct rtl8169_private *tp,
fw_read = rtl_fw->mac_mcu_read; fw_read = rtl_fw->mac_mcu_read;
} }
index++;
break; break;
case PHY_CLEAR_READCOUNT: case PHY_CLEAR_READCOUNT:
count = 0; count = 0;
index++;
break; break;
case PHY_WRITE: case PHY_WRITE:
fw_write(tp, regno, data); fw_write(tp, regno, data);
index++;
break; break;
case PHY_READCOUNT_EQ_SKIP: case PHY_READCOUNT_EQ_SKIP:
index += (count == data) ? 2 : 1; if (count == data)
index++;
break; break;
case PHY_COMP_EQ_SKIPN: case PHY_COMP_EQ_SKIPN:
if (predata == data) if (predata == data)
index += regno; index += regno;
index++;
break; break;
case PHY_COMP_NEQ_SKIPN: case PHY_COMP_NEQ_SKIPN:
if (predata != data) if (predata != data)
index += regno; index += regno;
index++;
break; break;
case PHY_WRITE_PREVIOUS: case PHY_WRITE_PREVIOUS:
fw_write(tp, regno, predata); fw_write(tp, regno, predata);
index++;
break; break;
case PHY_SKIPN: case PHY_SKIPN:
index += regno + 1; index += regno;
break; break;
case PHY_DELAY_MS: case PHY_DELAY_MS:
mdelay(data); mdelay(data);
index++;
break; break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment