aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2007-11-13 23:52:05 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:03:50 -0500
commit7e64300a0f335e443aa39ee477c541e34a69ae52 (patch)
treecd1c9e593f578da9f1d1082bd17e02d82cbeb211 /drivers/net/e1000
parentef90e4eca9fcade05dd03f853df75cf459a75422 (diff)
[E1000]: Convert regtest macro's to functions
Minimal macro to function conversion in e1000_ethtool.c Adds functions reg_pattern_test and reg_set_and_check Changes REG_PATTERN_TEST and REG_SET_AND_CHECK macros to call these functions. Saves ~2.5KB Compiled x86, untested (no hardware) old: $ size drivers/net/e1000/e1000_ethtool.o text data bss dec hex filename 16778 0 0 16778 418a drivers/net/e1000/e1000_ethtool.o new: $ size drivers/net/e1000/e1000_ethtool.o text data bss dec hex filename 14128 0 0 14128 3730 drivers/net/e1000/e1000_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/e1000')
-rw-r--r--drivers/net/e1000/e1000_ethtool.c84
1 files changed, 55 insertions, 29 deletions
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 2e44191d4b42..2280818476e2 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -728,39 +728,65 @@ err_setup:
728 return err; 728 return err;
729} 729}
730 730
731#define REG_PATTERN_TEST(R, M, W) \ 731static bool reg_pattern_test(struct e1000_adapter *adapter, uint64_t *data,
732{ \ 732 int reg, uint32_t mask, uint32_t write)
733 uint32_t pat, val; \ 733{
734 const uint32_t test[] = \ 734 static const uint32_t test[] =
735 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; \ 735 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
736 for (pat = 0; pat < ARRAY_SIZE(test); pat++) { \ 736 uint8_t __iomem *address = adapter->hw.hw_addr + reg;
737 E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W)); \ 737 uint32_t read;
738 val = E1000_READ_REG(&adapter->hw, R); \ 738 int i;
739 if (val != (test[pat] & W & M)) { \ 739
740 DPRINTK(DRV, ERR, "pattern test reg %04X failed: got " \ 740 for (i = 0; i < ARRAY_SIZE(test); i++) {
741 "0x%08X expected 0x%08X\n", \ 741 writel(write & test[i], address);
742 E1000_##R, val, (test[pat] & W & M)); \ 742 read = readl(address);
743 *data = (adapter->hw.mac_type < e1000_82543) ? \ 743 if (read != (write & test[i] & mask)) {
744 E1000_82542_##R : E1000_##R; \ 744 DPRINTK(DRV, ERR, "pattern test reg %04X failed: "
745 return 1; \ 745 "got 0x%08X expected 0x%08X\n",
746 } \ 746 reg, read, (write & test[i] & mask));
747 } \ 747 *data = reg;
748 return true;
749 }
750 }
751 return false;
748} 752}
749 753
750#define REG_SET_AND_CHECK(R, M, W) \ 754static bool reg_set_and_check(struct e1000_adapter *adapter, uint64_t *data,
751{ \ 755 int reg, uint32_t mask, uint32_t write)
752 uint32_t val; \ 756{
753 E1000_WRITE_REG(&adapter->hw, R, W & M); \ 757 uint8_t __iomem *address = adapter->hw.hw_addr + reg;
754 val = E1000_READ_REG(&adapter->hw, R); \ 758 uint32_t read;
755 if ((W & M) != (val & M)) { \ 759
756 DPRINTK(DRV, ERR, "set/check reg %04X test failed: got 0x%08X "\ 760 writel(write & mask, address);
757 "expected 0x%08X\n", E1000_##R, (val & M), (W & M)); \ 761 read = readl(address);
758 *data = (adapter->hw.mac_type < e1000_82543) ? \ 762 if ((read & mask) != (write & mask)) {
759 E1000_82542_##R : E1000_##R; \ 763 DPRINTK(DRV, ERR, "set/check reg %04X test failed: "
760 return 1; \ 764 "got 0x%08X expected 0x%08X\n",
761 } \ 765 reg, (read & mask), (write & mask));
766 *data = reg;
767 return true;
768 }
769 return false;
762} 770}
763 771
772#define REG_PATTERN_TEST(reg, mask, write) \
773 do { \
774 if (reg_pattern_test(adapter, data, \
775 (adapter->hw.mac_type >= e1000_82543) \
776 ? E1000_##reg : E1000_82542_##reg, \
777 mask, write)) \
778 return 1; \
779 } while (0)
780
781#define REG_SET_AND_CHECK(reg, mask, write) \
782 do { \
783 if (reg_set_and_check(adapter, data, \
784 (adapter->hw.mac_type >= e1000_82543) \
785 ? E1000_##reg : E1000_82542_##reg, \
786 mask, write)) \
787 return 1; \
788 } while (0)
789
764static int 790static int
765e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data) 791e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
766{ 792{