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,45 +1236,61 @@ static const struct ixgbe_reg_test reg_test_82598[] = { ...@@ -1236,45 +1236,61 @@ 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;
static const u32 test_pattern[] = {
0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
for (pat = 0; pat < ARRAY_SIZE(test_pattern); pat++) {
before = readl(adapter->hw.hw_addr + reg);
writel((test_pattern[pat] & write),
(adapter->hw.hw_addr + reg));
val = readl(adapter->hw.hw_addr + reg);
if (val != (test_pattern[pat] & write & mask)) {
e_err(drv, "pattern test reg %04X failed: got "
"0x%08X expected 0x%08X\n",
reg, val, (test_pattern[pat] & write & mask));
*data = reg;
writel(before, adapter->hw.hw_addr + reg);
return 1;
}
writel(before, adapter->hw.hw_addr + reg);
}
return 0;
}
#define REG_PATTERN_TEST(R, M, W) \ static bool reg_set_and_check(struct ixgbe_adapter *adapter, u64 *data, int reg,
{ \ u32 mask, u32 write)
u32 pat, val, before; \ {
for (pat = 0; pat < ARRAY_SIZE(register_test_patterns); pat++) { \ u32 val, before;
before = readl(adapter->hw.hw_addr + R); \ before = readl(adapter->hw.hw_addr + reg);
writel((register_test_patterns[pat] & W), \ writel((write & mask), (adapter->hw.hw_addr + reg));
(adapter->hw.hw_addr + R)); \ val = readl(adapter->hw.hw_addr + reg);
val = readl(adapter->hw.hw_addr + R); \ if ((write & mask) != (val & mask)) {
if (val != (register_test_patterns[pat] & W & M)) { \ e_err(drv, "set/check reg %04X test failed: got 0x%08X "
e_err(drv, "pattern test reg %04X failed: got " \ "expected 0x%08X\n", reg, (val & mask), (write & mask));
"0x%08X expected 0x%08X\n", \ *data = reg;
R, val, (register_test_patterns[pat] & W & M)); \ writel(before, (adapter->hw.hw_addr + reg));
*data = R; \ return 1;
writel(before, adapter->hw.hw_addr + R); \ }
return 1; \ writel(before, (adapter->hw.hw_addr + reg));
} \ return 0;
writel(before, adapter->hw.hw_addr + R); \
} \
} }
#define REG_SET_AND_CHECK(R, M, W) \ #define REG_PATTERN_TEST(reg, mask, write) \
{ \ do { \
u32 val, before; \ if (reg_pattern_test(adapter, data, reg, mask, write)) \
before = readl(adapter->hw.hw_addr + R); \
writel((W & M), (adapter->hw.hw_addr + R)); \
val = readl(adapter->hw.hw_addr + R); \
if ((W & M) != (val & M)) { \
e_err(drv, "set/check reg %04X test failed: got 0x%08X " \
"expected 0x%08X\n", R, (val & M), (W & M)); \
*data = R; \
writel(before, (adapter->hw.hw_addr + R)); \
return 1; \ return 1; \
} \ } while (0) \
writel(before, (adapter->hw.hw_addr + R)); \
}
#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)
{ {
......
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