Commit 95a46011 authored by Emil Tantilov's avatar Emil Tantilov Committed by Jeff Kirsher

ixgbe: fix sparse warning

warning: symbol 'before' shadows an earlier one

Convert large macros to functions similar to e1000e.
Signed-off-by: default avatarEmil Tantilov <emil.s.tantilov@intel.com>
Acked-by: default avatarDon Skidmore <donald.c.skidmore@intel.com>
Tested-by: default avatarEvan Swanson <evan.swanson@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 2698b208
...@@ -1236,46 +1236,62 @@ static const struct ixgbe_reg_test reg_test_82598[] = { ...@@ -1236,46 +1236,62 @@ static const struct ixgbe_reg_test reg_test_82598[] = {
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
static const u32 register_test_patterns[] = { static bool reg_pattern_test(struct ixgbe_adapter *adapter, u64 *data, int reg,
0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF u32 mask, u32 write)
}; {
u32 pat, val, before;
#define REG_PATTERN_TEST(R, M, W) \ static const u32 test_pattern[] = {
{ \ 0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
u32 pat, val, before; \
for (pat = 0; pat < ARRAY_SIZE(register_test_patterns); pat++) { \ for (pat = 0; pat < ARRAY_SIZE(test_pattern); pat++) {
before = readl(adapter->hw.hw_addr + R); \ before = readl(adapter->hw.hw_addr + reg);
writel((register_test_patterns[pat] & W), \ writel((test_pattern[pat] & write),
(adapter->hw.hw_addr + R)); \ (adapter->hw.hw_addr + reg));
val = readl(adapter->hw.hw_addr + R); \ val = readl(adapter->hw.hw_addr + reg);
if (val != (register_test_patterns[pat] & W & M)) { \ if (val != (test_pattern[pat] & write & mask)) {
e_err(drv, "pattern test reg %04X failed: got " \ e_err(drv, "pattern test reg %04X failed: got "
"0x%08X expected 0x%08X\n", \ "0x%08X expected 0x%08X\n",
R, val, (register_test_patterns[pat] & W & M)); \ reg, val, (test_pattern[pat] & write & mask));
*data = R; \ *data = reg;
writel(before, adapter->hw.hw_addr + R); \ writel(before, adapter->hw.hw_addr + reg);
return 1; \ return 1;
} \ }
writel(before, adapter->hw.hw_addr + R); \ writel(before, adapter->hw.hw_addr + reg);
} \ }
return 0;
} }
#define REG_SET_AND_CHECK(R, M, W) \ static bool reg_set_and_check(struct ixgbe_adapter *adapter, u64 *data, int reg,
{ \ u32 mask, u32 write)
u32 val, before; \ {
before = readl(adapter->hw.hw_addr + R); \ u32 val, before;
writel((W & M), (adapter->hw.hw_addr + R)); \ before = readl(adapter->hw.hw_addr + reg);
val = readl(adapter->hw.hw_addr + R); \ writel((write & mask), (adapter->hw.hw_addr + reg));
if ((W & M) != (val & M)) { \ val = readl(adapter->hw.hw_addr + reg);
e_err(drv, "set/check reg %04X test failed: got 0x%08X " \ if ((write & mask) != (val & mask)) {
"expected 0x%08X\n", R, (val & M), (W & M)); \ e_err(drv, "set/check reg %04X test failed: got 0x%08X "
*data = R; \ "expected 0x%08X\n", reg, (val & mask), (write & mask));
writel(before, (adapter->hw.hw_addr + R)); \ *data = reg;
return 1; \ writel(before, (adapter->hw.hw_addr + reg));
} \ return 1;
writel(before, (adapter->hw.hw_addr + R)); \ }
writel(before, (adapter->hw.hw_addr + reg));
return 0;
} }
#define REG_PATTERN_TEST(reg, mask, write) \
do { \
if (reg_pattern_test(adapter, data, reg, mask, write)) \
return 1; \
} while (0) \
#define REG_SET_AND_CHECK(reg, mask, write) \
do { \
if (reg_set_and_check(adapter, data, reg, mask, write)) \
return 1; \
} while (0) \
static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data) static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data)
{ {
const struct ixgbe_reg_test *test; const struct ixgbe_reg_test *test;
...@@ -1326,13 +1342,13 @@ static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data) ...@@ -1326,13 +1342,13 @@ static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data)
switch (test->test_type) { switch (test->test_type) {
case PATTERN_TEST: case PATTERN_TEST:
REG_PATTERN_TEST(test->reg + (i * 0x40), REG_PATTERN_TEST(test->reg + (i * 0x40),
test->mask, test->mask,
test->write); test->write);
break; break;
case SET_READ_TEST: case SET_READ_TEST:
REG_SET_AND_CHECK(test->reg + (i * 0x40), REG_SET_AND_CHECK(test->reg + (i * 0x40),
test->mask, test->mask,
test->write); test->write);
break; break;
case WRITE_NO_TEST: case WRITE_NO_TEST:
writel(test->write, writel(test->write,
...@@ -1341,18 +1357,18 @@ static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data) ...@@ -1341,18 +1357,18 @@ static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data)
break; break;
case TABLE32_TEST: case TABLE32_TEST:
REG_PATTERN_TEST(test->reg + (i * 4), REG_PATTERN_TEST(test->reg + (i * 4),
test->mask, test->mask,
test->write); test->write);
break; break;
case TABLE64_TEST_LO: case TABLE64_TEST_LO:
REG_PATTERN_TEST(test->reg + (i * 8), REG_PATTERN_TEST(test->reg + (i * 8),
test->mask, test->mask,
test->write); test->write);
break; break;
case TABLE64_TEST_HI: case TABLE64_TEST_HI:
REG_PATTERN_TEST((test->reg + 4) + (i * 8), REG_PATTERN_TEST((test->reg + 4) + (i * 8),
test->mask, test->mask,
test->write); test->write);
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