Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

octeontx2-pf: Remove unnecessary bounds check

active_fec is a 2-bit unsigned field, and thus can only have the values
0-3. So checking that it is less than 4 is unnecessary.

Simplify the code by dropping this check.

As it no longer fits well where it is, move FEC_MAX_INDEX to towards the
top of the file. And add the prefix OXT2. I believe this is more
idiomatic.

Flagged by Smatch as:
...//otx2_ethtool.c:1024 otx2_get_fecparam() warn: always true condition '(pfvf->linfo.fec < 4) => (0-3 < 4)'

No functional change intended.
Compile tested only.

Signed-off-by: Simon Horman <horms@kernel.org>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: Hariprasad Kelam <hkelam@marvell.com>
Link: https://patch.msgid.link/20260119-oob-v1-1-a4147e75e770@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Simon Horman and committed by
Jakub Kicinski
2ec113ee cd18e8ac

+5 -4
+5 -4
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
··· 66 66 { "frames", 1 }, 67 67 }; 68 68 69 + #define OTX2_FEC_MAX_INDEX 4 70 + 69 71 static const unsigned int otx2_n_dev_stats = ARRAY_SIZE(otx2_dev_stats); 70 72 static const unsigned int otx2_n_drv_stats = ARRAY_SIZE(otx2_drv_stats); 71 73 static const unsigned int otx2_n_queue_stats = ARRAY_SIZE(otx2_queue_stats); ··· 1033 1031 ETHTOOL_FEC_BASER, 1034 1032 ETHTOOL_FEC_RS, 1035 1033 ETHTOOL_FEC_BASER | ETHTOOL_FEC_RS}; 1036 - #define FEC_MAX_INDEX 4 1037 - if (pfvf->linfo.fec < FEC_MAX_INDEX) 1038 - fecparam->active_fec = fec[pfvf->linfo.fec]; 1034 + 1035 + fecparam->active_fec = fec[pfvf->linfo.fec]; 1039 1036 1040 1037 rsp = otx2_get_fwdata(pfvf); 1041 1038 if (IS_ERR(rsp)) 1042 1039 return PTR_ERR(rsp); 1043 1040 1044 - if (rsp->fwdata.supported_fec < FEC_MAX_INDEX) { 1041 + if (rsp->fwdata.supported_fec < OTX2_FEC_MAX_INDEX) { 1045 1042 if (!rsp->fwdata.supported_fec) 1046 1043 fecparam->fec = ETHTOOL_FEC_NONE; 1047 1044 else