Commit 2a887191 authored by Joe Perches's avatar Joe Perches Committed by David S. Miller

[E1000E]: convert register test macros to functions

Add functions for reg_pattern_test and reg_set_and check
Changed macros to use these functions

Compiled x86, untested

Size decreased ~2K

old:

$ size drivers/net/e1000e/ethtool.o
   text    data     bss     dec     hex filename
  14461       0       0   14461    387d drivers/net/e1000e/ethtool.o

new:

$ size drivers/net/e1000e/ethtool.o
   text    data     bss     dec     hex filename
  12498       0       0   12498    30d2 drivers/net/e1000e/ethtool.o
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarAuke Kok <auke-jan.h.kok@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7e64300a
...@@ -690,40 +690,62 @@ err_setup: ...@@ -690,40 +690,62 @@ err_setup:
return err; return err;
} }
#define REG_PATTERN_TEST(R, M, W) REG_PATTERN_TEST_ARRAY(R, 0, M, W) bool reg_pattern_test_array(struct e1000_adapter *adapter, u64 *data,
#define REG_PATTERN_TEST_ARRAY(reg, offset, mask, writeable) \ int reg, int offset, u32 mask, u32 write)
{ \ {
u32 _pat; \ int i;
u32 _value; \ u32 read;
u32 _test[] = {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; \ static const u32 test[] =
for (_pat = 0; _pat < ARRAY_SIZE(_test); _pat++) { \ {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
E1000_WRITE_REG_ARRAY(hw, reg, offset, \ for (i = 0; i < ARRAY_SIZE(test); i++) {
(_test[_pat] & writeable)); \ E1000_WRITE_REG_ARRAY(&adapter->hw, reg, offset,
_value = E1000_READ_REG_ARRAY(hw, reg, offset); \ (test[i] & write));
if (_value != (_test[_pat] & writeable & mask)) { \ read = E1000_READ_REG_ARRAY(&adapter->hw, reg, offset);
ndev_err(netdev, "pattern test reg %04X " \ if (read != (test[i] & write & mask)) {
"failed: got 0x%08X expected 0x%08X\n", \ ndev_err(adapter->netdev, "pattern test reg %04X "
reg + offset, \ "failed: got 0x%08X expected 0x%08X\n",
value, (_test[_pat] & writeable & mask)); \ reg + offset,
*data = reg; \ read, (test[i] & write & mask));
return 1; \ *data = reg;
} \ return true;
} \ }
}
return false;
}
static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data,
int reg, u32 mask, u32 write)
{
u32 read;
__ew32(&adapter->hw, reg, write & mask);
read = __er32(&adapter->hw, reg);
if ((write & mask) != (read & mask)) {
ndev_err(adapter->netdev, "set/check reg %04X test failed: "
"got 0x%08X expected 0x%08X\n", reg, (read & mask),
(write & mask));
*data = reg;
return true;
}
return false;
} }
#define REG_PATTERN_TEST(R, M, W) \
do { \
if (reg_pattern_test_array(adapter, data, R, 0, M, W)) \
return 1; \
} while (0)
#define REG_PATTERN_TEST_ARRAY(R, offset, M, W) \
do { \
if (reg_pattern_test_array(adapter, data, R, offset, M, W)) \
return 1; \
} while (0)
#define REG_SET_AND_CHECK(R, M, W) \ #define REG_SET_AND_CHECK(R, M, W) \
{ \ do { \
u32 _value; \ if (reg_set_and_check(adapter, data, R, M, W)) \
__ew32(hw, R, W & M); \
_value = __er32(hw, R); \
if ((W & M) != (_value & M)) { \
ndev_err(netdev, "set/check reg %04X test failed: " \
"got 0x%08X expected 0x%08X\n", R, (_value & M), \
(W & M)); \
*data = R; \
return 1; \ return 1; \
} \ } while (0)
}
static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data) static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
{ {
......
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