mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-01 19:34:35 +08:00
ixgbe: fix sparse warning
warning: symbol 'before' shadows an earlier one Convert large macros to functions similar to e1000e. Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com> Acked-by: Don Skidmore <donald.c.skidmore@intel.com> Tested-by: Evan Swanson <evan.swanson@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
This commit is contained in:
parent
2698b20842
commit
95a4601184
@ -1236,46 +1236,62 @@ static const struct ixgbe_reg_test reg_test_82598[] = {
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
static const u32 register_test_patterns[] = {
|
||||
0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF
|
||||
};
|
||||
static bool reg_pattern_test(struct ixgbe_adapter *adapter, u64 *data, int reg,
|
||||
u32 mask, u32 write)
|
||||
{
|
||||
u32 pat, val, before;
|
||||
static const u32 test_pattern[] = {
|
||||
0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
|
||||
|
||||
#define REG_PATTERN_TEST(R, M, W) \
|
||||
{ \
|
||||
u32 pat, val, before; \
|
||||
for (pat = 0; pat < ARRAY_SIZE(register_test_patterns); pat++) { \
|
||||
before = readl(adapter->hw.hw_addr + R); \
|
||||
writel((register_test_patterns[pat] & W), \
|
||||
(adapter->hw.hw_addr + R)); \
|
||||
val = readl(adapter->hw.hw_addr + R); \
|
||||
if (val != (register_test_patterns[pat] & W & M)) { \
|
||||
e_err(drv, "pattern test reg %04X failed: got " \
|
||||
"0x%08X expected 0x%08X\n", \
|
||||
R, val, (register_test_patterns[pat] & W & M)); \
|
||||
*data = R; \
|
||||
writel(before, adapter->hw.hw_addr + R); \
|
||||
return 1; \
|
||||
} \
|
||||
writel(before, adapter->hw.hw_addr + R); \
|
||||
} \
|
||||
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_SET_AND_CHECK(R, M, W) \
|
||||
{ \
|
||||
u32 val, before; \
|
||||
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; \
|
||||
} \
|
||||
writel(before, (adapter->hw.hw_addr + R)); \
|
||||
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 + reg);
|
||||
writel((write & mask), (adapter->hw.hw_addr + reg));
|
||||
val = readl(adapter->hw.hw_addr + reg);
|
||||
if ((write & mask) != (val & mask)) {
|
||||
e_err(drv, "set/check reg %04X test failed: got 0x%08X "
|
||||
"expected 0x%08X\n", reg, (val & mask), (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(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)
|
||||
{
|
||||
const struct ixgbe_reg_test *test;
|
||||
@ -1326,13 +1342,13 @@ static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data)
|
||||
switch (test->test_type) {
|
||||
case PATTERN_TEST:
|
||||
REG_PATTERN_TEST(test->reg + (i * 0x40),
|
||||
test->mask,
|
||||
test->write);
|
||||
test->mask,
|
||||
test->write);
|
||||
break;
|
||||
case SET_READ_TEST:
|
||||
REG_SET_AND_CHECK(test->reg + (i * 0x40),
|
||||
test->mask,
|
||||
test->write);
|
||||
test->mask,
|
||||
test->write);
|
||||
break;
|
||||
case WRITE_NO_TEST:
|
||||
writel(test->write,
|
||||
@ -1341,18 +1357,18 @@ static int ixgbe_reg_test(struct ixgbe_adapter *adapter, u64 *data)
|
||||
break;
|
||||
case TABLE32_TEST:
|
||||
REG_PATTERN_TEST(test->reg + (i * 4),
|
||||
test->mask,
|
||||
test->write);
|
||||
test->mask,
|
||||
test->write);
|
||||
break;
|
||||
case TABLE64_TEST_LO:
|
||||
REG_PATTERN_TEST(test->reg + (i * 8),
|
||||
test->mask,
|
||||
test->write);
|
||||
test->mask,
|
||||
test->write);
|
||||
break;
|
||||
case TABLE64_TEST_HI:
|
||||
REG_PATTERN_TEST((test->reg + 4) + (i * 8),
|
||||
test->mask,
|
||||
test->write);
|
||||
test->mask,
|
||||
test->write);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user