aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000e/ethtool.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2007-11-13 23:53:51 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:03:51 -0500
commit2a88719197bde746006c18ebe8f3576c87991419 (patch)
treea597d56f8626f3ecfdf74a5fcd6916e208e5b95b /drivers/net/e1000e/ethtool.c
parent7e64300a0f335e443aa39ee477c541e34a69ae52 (diff)
[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: Joe Perches <joe@perches.com> Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/e1000e/ethtool.c')
-rw-r--r--drivers/net/e1000e/ethtool.c84
1 files changed, 53 insertions, 31 deletions
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index e6ff3af8ef0f..6d9c27fd0b53 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -690,41 +690,63 @@ err_setup:
690 return err; 690 return err;
691} 691}
692 692
693#define REG_PATTERN_TEST(R, M, W) REG_PATTERN_TEST_ARRAY(R, 0, M, W) 693bool reg_pattern_test_array(struct e1000_adapter *adapter, u64 *data,
694#define REG_PATTERN_TEST_ARRAY(reg, offset, mask, writeable) \ 694 int reg, int offset, u32 mask, u32 write)
695{ \ 695{
696 u32 _pat; \ 696 int i;
697 u32 _value; \ 697 u32 read;
698 u32 _test[] = {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; \ 698 static const u32 test[] =
699 for (_pat = 0; _pat < ARRAY_SIZE(_test); _pat++) { \ 699 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
700 E1000_WRITE_REG_ARRAY(hw, reg, offset, \ 700 for (i = 0; i < ARRAY_SIZE(test); i++) {
701 (_test[_pat] & writeable)); \ 701 E1000_WRITE_REG_ARRAY(&adapter->hw, reg, offset,
702 _value = E1000_READ_REG_ARRAY(hw, reg, offset); \ 702 (test[i] & write));
703 if (_value != (_test[_pat] & writeable & mask)) { \ 703 read = E1000_READ_REG_ARRAY(&adapter->hw, reg, offset);
704 ndev_err(netdev, "pattern test reg %04X " \ 704 if (read != (test[i] & write & mask)) {
705 "failed: got 0x%08X expected 0x%08X\n", \ 705 ndev_err(adapter->netdev, "pattern test reg %04X "
706 reg + offset, \ 706 "failed: got 0x%08X expected 0x%08X\n",
707 value, (_test[_pat] & writeable & mask)); \ 707 reg + offset,
708 *data = reg; \ 708 read, (test[i] & write & mask));
709 return 1; \ 709 *data = reg;
710 } \ 710 return true;
711 } \ 711 }
712 }
713 return false;
712} 714}
713 715
714#define REG_SET_AND_CHECK(R, M, W) \ 716static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data,
715{ \ 717 int reg, u32 mask, u32 write)
716 u32 _value; \ 718{
717 __ew32(hw, R, W & M); \ 719 u32 read;
718 _value = __er32(hw, R); \ 720 __ew32(&adapter->hw, reg, write & mask);
719 if ((W & M) != (_value & M)) { \ 721 read = __er32(&adapter->hw, reg);
720 ndev_err(netdev, "set/check reg %04X test failed: " \ 722 if ((write & mask) != (read & mask)) {
721 "got 0x%08X expected 0x%08X\n", R, (_value & M), \ 723 ndev_err(adapter->netdev, "set/check reg %04X test failed: "
722 (W & M)); \ 724 "got 0x%08X expected 0x%08X\n", reg, (read & mask),
723 *data = R; \ 725 (write & mask));
724 return 1; \ 726 *data = reg;
725 } \ 727 return true;
728 }
729 return false;
726} 730}
727 731
732#define REG_PATTERN_TEST(R, M, W) \
733 do { \
734 if (reg_pattern_test_array(adapter, data, R, 0, M, W)) \
735 return 1; \
736 } while (0)
737
738#define REG_PATTERN_TEST_ARRAY(R, offset, M, W) \
739 do { \
740 if (reg_pattern_test_array(adapter, data, R, offset, M, W)) \
741 return 1; \
742 } while (0)
743
744#define REG_SET_AND_CHECK(R, M, W) \
745 do { \
746 if (reg_set_and_check(adapter, data, R, M, W)) \
747 return 1; \
748 } while (0)
749
728static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data) 750static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
729{ 751{
730 struct e1000_hw *hw = &adapter->hw; 752 struct e1000_hw *hw = &adapter->hw;