r8169: add enum rtl_fw_opcode

Replace the firmware opcode defines with a proper enum. The BUG()
in rtl_fw_write_firmware() can be removed because the call to
rtl_fw_data_ok() ensures all opcodes are valid.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Heiner Kallweit 2019-06-03 21:23:43 +02:00 committed by David S. Miller
parent 6e36d77c83
commit 0a616b327d

View File

@ -2298,19 +2298,21 @@ static void __rtl_writephy_batch(struct rtl8169_private *tp,
#define rtl_writephy_batch(tp, a) __rtl_writephy_batch(tp, a, ARRAY_SIZE(a)) #define rtl_writephy_batch(tp, a) __rtl_writephy_batch(tp, a, ARRAY_SIZE(a))
#define PHY_READ 0x00000000 enum rtl_fw_opcode {
#define PHY_DATA_OR 0x10000000 PHY_READ = 0x0,
#define PHY_DATA_AND 0x20000000 PHY_DATA_OR = 0x1,
#define PHY_BJMPN 0x30000000 PHY_DATA_AND = 0x2,
#define PHY_MDIO_CHG 0x40000000 PHY_BJMPN = 0x3,
#define PHY_CLEAR_READCOUNT 0x70000000 PHY_MDIO_CHG = 0x4,
#define PHY_WRITE 0x80000000 PHY_CLEAR_READCOUNT = 0x7,
#define PHY_READCOUNT_EQ_SKIP 0x90000000 PHY_WRITE = 0x8,
#define PHY_COMP_EQ_SKIPN 0xa0000000 PHY_READCOUNT_EQ_SKIP = 0x9,
#define PHY_COMP_NEQ_SKIPN 0xb0000000 PHY_COMP_EQ_SKIPN = 0xa,
#define PHY_WRITE_PREVIOUS 0xc0000000 PHY_COMP_NEQ_SKIPN = 0xb,
#define PHY_SKIPN 0xd0000000 PHY_WRITE_PREVIOUS = 0xc,
#define PHY_DELAY_MS 0xe0000000 PHY_SKIPN = 0xd,
PHY_DELAY_MS = 0xe,
};
struct fw_info { struct fw_info {
u32 magic; u32 magic;
@ -2378,7 +2380,7 @@ static bool rtl_fw_data_ok(struct rtl8169_private *tp, struct net_device *dev,
u32 action = le32_to_cpu(pa->code[index]); u32 action = le32_to_cpu(pa->code[index]);
u32 regno = (action & 0x0fff0000) >> 16; u32 regno = (action & 0x0fff0000) >> 16;
switch(action & 0xf0000000) { switch (action >> 28) {
case PHY_READ: case PHY_READ:
case PHY_DATA_OR: case PHY_DATA_OR:
case PHY_DATA_AND: case PHY_DATA_AND:
@ -2453,11 +2455,12 @@ static void rtl_fw_write_firmware(struct rtl8169_private *tp,
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;
enum rtl_fw_opcode opcode = action >> 28;
if (!action) if (!action)
break; break;
switch(action & 0xf0000000) { switch (opcode) {
case PHY_READ: case PHY_READ:
predata = fw_read(tp, regno); predata = fw_read(tp, regno);
count++; count++;
@ -2517,9 +2520,6 @@ static void rtl_fw_write_firmware(struct rtl8169_private *tp,
mdelay(data); mdelay(data);
index++; index++;
break; break;
default:
BUG();
} }
} }
} }