Skip to content

Commit 13c8adc

Browse files
elkablodavem330
authored andcommitted
net: sfp: Add and use macros for SFP quirks definitions
Add macros SFP_QUIRK(), SFP_QUIRK_M() and SFP_QUIRK_F() for defining SFP quirk table entries. Use them to deduplicate the code a little bit. Signed-off-by: Marek Behún <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 31eb890 commit 13c8adc

File tree

1 file changed

+26
-35
lines changed

1 file changed

+26
-35
lines changed

drivers/net/phy/sfp.c

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -350,42 +350,33 @@ static void sfp_quirk_ubnt_uf_instant(const struct sfp_eeprom_id *id,
350350
linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT, modes);
351351
}
352352

353+
#define SFP_QUIRK(_v, _p, _m, _f) \
354+
{ .vendor = _v, .part = _p, .modes = _m, .fixup = _f, }
355+
#define SFP_QUIRK_M(_v, _p, _m) SFP_QUIRK(_v, _p, _m, NULL)
356+
#define SFP_QUIRK_F(_v, _p, _f) SFP_QUIRK(_v, _p, NULL, _f)
357+
353358
static const struct sfp_quirk sfp_quirks[] = {
354-
{
355-
// Alcatel Lucent G-010S-P can operate at 2500base-X, but
356-
// incorrectly report 2500MBd NRZ in their EEPROM
357-
.vendor = "ALCATELLUCENT",
358-
.part = "G010SP",
359-
.modes = sfp_quirk_2500basex,
360-
}, {
361-
// Alcatel Lucent G-010S-A can operate at 2500base-X, but
362-
// report 3.2GBd NRZ in their EEPROM
363-
.vendor = "ALCATELLUCENT",
364-
.part = "3FE46541AA",
365-
.modes = sfp_quirk_2500basex,
366-
.fixup = sfp_fixup_long_startup,
367-
}, {
368-
.vendor = "HALNy",
369-
.part = "HL-GSFP",
370-
.fixup = sfp_fixup_halny_gsfp,
371-
}, {
372-
// Huawei MA5671A can operate at 2500base-X, but report 1.2GBd
373-
// NRZ in their EEPROM
374-
.vendor = "HUAWEI",
375-
.part = "MA5671A",
376-
.modes = sfp_quirk_2500basex,
377-
.fixup = sfp_fixup_ignore_tx_fault,
378-
}, {
379-
// Lantech 8330-262D-E can operate at 2500base-X, but
380-
// incorrectly report 2500MBd NRZ in their EEPROM
381-
.vendor = "Lantech",
382-
.part = "8330-262D-E",
383-
.modes = sfp_quirk_2500basex,
384-
}, {
385-
.vendor = "UBNT",
386-
.part = "UF-INSTANT",
387-
.modes = sfp_quirk_ubnt_uf_instant,
388-
}
359+
// Alcatel Lucent G-010S-P can operate at 2500base-X, but incorrectly
360+
// report 2500MBd NRZ in their EEPROM
361+
SFP_QUIRK_M("ALCATELLUCENT", "G010SP", sfp_quirk_2500basex),
362+
363+
// Alcatel Lucent G-010S-A can operate at 2500base-X, but report 3.2GBd
364+
// NRZ in their EEPROM
365+
SFP_QUIRK("ALCATELLUCENT", "3FE46541AA", sfp_quirk_2500basex,
366+
sfp_fixup_long_startup),
367+
368+
SFP_QUIRK_F("HALNy", "HL-GSFP", sfp_fixup_halny_gsfp),
369+
370+
// Huawei MA5671A can operate at 2500base-X, but report 1.2GBd NRZ in
371+
// their EEPROM
372+
SFP_QUIRK("HUAWEI", "MA5671A", sfp_quirk_2500basex,
373+
sfp_fixup_ignore_tx_fault),
374+
375+
// Lantech 8330-262D-E can operate at 2500base-X, but incorrectly report
376+
// 2500MBd NRZ in their EEPROM
377+
SFP_QUIRK_M("Lantech", "8330-262D-E", sfp_quirk_2500basex),
378+
379+
SFP_QUIRK_M("UBNT", "UF-INSTANT", sfp_quirk_ubnt_uf_instant),
389380
};
390381

391382
static size_t sfp_strlen(const char *str, size_t maxlen)

0 commit comments

Comments
 (0)