1 From 705b2cfaf7d7703ae4c86fe84a7db0cf2dcbd08e Mon Sep 17 00:00:00 2001 2 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <kabel@kernel.org> 3 Date: Fri, 30 Sep 2022 15:38:27 +0200 4 Subject: [PATCH net-next 09/12] net: sfp: Add and use macros for SFP quirks 5 definitions 6 MIME-Version: 1.0 7 Content-Type: text/plain; charset=UTF-8 8 Content-Transfer-Encoding: 8bit 9 10 Add macros SFP_QUIRK(), SFP_QUIRK_M() and SFP_QUIRK_F() for defining SFP 11 quirk table entries. Use them to deduplicate the code a little bit. 12 13 Signed-off-by: Marek BehĂșn <kabel@kernel.org> 14 --- 15 drivers/net/phy/sfp.c | 61 ++++++++++++++++++------------------------- 16 1 file changed, 26 insertions(+), 35 deletions(-) 17 18 diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c 19 index b150e4765819..3201e2726e61 100644 20 --- a/drivers/net/phy/sfp.c 21 +++ b/drivers/net/phy/sfp.c 22 @@ -350,42 +350,33 @@ static void sfp_quirk_ubnt_uf_instant(const struct sfp_eeprom_id *id, 23 linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT, modes); 24 } 25 26 +#define SFP_QUIRK(_v, _p, _m, _f) \ 27 + { .vendor = _v, .part = _p, .modes = _m, .fixup = _f, } 28 +#define SFP_QUIRK_M(_v, _p, _m) SFP_QUIRK(_v, _p, _m, NULL) 29 +#define SFP_QUIRK_F(_v, _p, _f) SFP_QUIRK(_v, _p, NULL, _f) 30 + 31 static const struct sfp_quirk sfp_quirks[] = { 32 - { 33 - // Alcatel Lucent G-010S-P can operate at 2500base-X, but 34 - // incorrectly report 2500MBd NRZ in their EEPROM 35 - .vendor = "ALCATELLUCENT", 36 - .part = "G010SP", 37 - .modes = sfp_quirk_2500basex, 38 - }, { 39 - // Alcatel Lucent G-010S-A can operate at 2500base-X, but 40 - // report 3.2GBd NRZ in their EEPROM 41 - .vendor = "ALCATELLUCENT", 42 - .part = "3FE46541AA", 43 - .modes = sfp_quirk_2500basex, 44 - .fixup = sfp_fixup_long_startup, 45 - }, { 46 - .vendor = "HALNy", 47 - .part = "HL-GSFP", 48 - .fixup = sfp_fixup_halny_gsfp, 49 - }, { 50 - // Huawei MA5671A can operate at 2500base-X, but report 1.2GBd 51 - // NRZ in their EEPROM 52 - .vendor = "HUAWEI", 53 - .part = "MA5671A", 54 - .modes = sfp_quirk_2500basex, 55 - .fixup = sfp_fixup_ignore_tx_fault, 56 - }, { 57 - // Lantech 8330-262D-E can operate at 2500base-X, but 58 - // incorrectly report 2500MBd NRZ in their EEPROM 59 - .vendor = "Lantech", 60 - .part = "8330-262D-E", 61 - .modes = sfp_quirk_2500basex, 62 - }, { 63 - .vendor = "UBNT", 64 - .part = "UF-INSTANT", 65 - .modes = sfp_quirk_ubnt_uf_instant, 66 - } 67 + // Alcatel Lucent G-010S-P can operate at 2500base-X, but incorrectly 68 + // report 2500MBd NRZ in their EEPROM 69 + SFP_QUIRK_M("ALCATELLUCENT", "G010SP", sfp_quirk_2500basex), 70 + 71 + // Alcatel Lucent G-010S-A can operate at 2500base-X, but report 3.2GBd 72 + // NRZ in their EEPROM 73 + SFP_QUIRK("ALCATELLUCENT", "3FE46541AA", sfp_quirk_2500basex, 74 + sfp_fixup_long_startup), 75 + 76 + SFP_QUIRK_F("HALNy", "HL-GSFP", sfp_fixup_halny_gsfp), 77 + 78 + // Huawei MA5671A can operate at 2500base-X, but report 1.2GBd NRZ in 79 + // their EEPROM 80 + SFP_QUIRK("HUAWEI", "MA5671A", sfp_quirk_2500basex, 81 + sfp_fixup_ignore_tx_fault), 82 + 83 + // Lantech 8330-262D-E can operate at 2500base-X, but incorrectly report 84 + // 2500MBd NRZ in their EEPROM 85 + SFP_QUIRK_M("Lantech", "8330-262D-E", sfp_quirk_2500basex), 86 + 87 + SFP_QUIRK_M("UBNT", "UF-INSTANT", sfp_quirk_ubnt_uf_instant), 88 }; 89 90 static size_t sfp_strlen(const char *str, size_t maxlen) 91 -- 92 2.35.1 93