In CMIS, unlike SFF-8636 and SFF-8472, the Tx bias current can be scaled (i.e., multiplied by 1 / 2 / 4). Fix the application of the scaling factor from shift right to shift left. In addition, increase the size of the field that stores the scaled value from 16-bits to 32-bits to avoid truncation. Fixes: 340d88ee1289 ("cmis: Parse and print diagnostic information") Reviewed-by: Danielle Ratson Signed-off-by: Ido Schimmel --- cmis.c | 10 +++++----- sff-common.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmis.c b/cmis.c index f494268ba3b7..a4bf455c2a77 100644 --- a/cmis.c +++ b/cmis.c @@ -517,7 +517,7 @@ cmis_parse_dom_chan_lvl_monitors_bank(const struct cmis_memory_map *map, sd->scd[chan].bias_cur = OFFSET_TO_U16_PTR(page_11h, tx_bias_offset); - sd->scd[chan].bias_cur >>= bias_mul; + sd->scd[chan].bias_cur <<= bias_mul; sd->scd[chan].rx_power = OFFSET_TO_U16_PTR(page_11h, rx_power_offset); sd->scd[chan].tx_power = OFFSET_TO_U16_PTR(page_11h, @@ -544,16 +544,16 @@ static void cmis_parse_dom_chan_lvl_thresh(const struct cmis_memory_map *map, sd->bias_cur[HALRM] = OFFSET_TO_U16_PTR(map->page_02h, CMIS_TX_BIAS_HALRM_OFFSET); - sd->bias_cur[HALRM] >>= bias_mul; + sd->bias_cur[HALRM] <<= bias_mul; sd->bias_cur[LALRM] = OFFSET_TO_U16_PTR(map->page_02h, CMIS_TX_BIAS_LALRM_OFFSET); - sd->bias_cur[LALRM] >>= bias_mul; + sd->bias_cur[LALRM] <<= bias_mul; sd->bias_cur[HWARN] = OFFSET_TO_U16_PTR(map->page_02h, CMIS_TX_BIAS_HWARN_OFFSET); - sd->bias_cur[HWARN] >>= bias_mul; + sd->bias_cur[HWARN] <<= bias_mul; sd->bias_cur[LWARN] = OFFSET_TO_U16_PTR(map->page_02h, CMIS_TX_BIAS_LWARN_OFFSET); - sd->bias_cur[LWARN] >>= bias_mul; + sd->bias_cur[LWARN] <<= bias_mul; sd->tx_power[HALRM] = OFFSET_TO_U16_PTR(map->page_02h, CMIS_TX_PWR_HALRM_OFFSET); diff --git a/sff-common.h b/sff-common.h index 3c02a69ec7f6..59ae21038c9c 100644 --- a/sff-common.h +++ b/sff-common.h @@ -126,7 +126,7 @@ /* Channel Monitoring Fields */ struct sff_channel_diags { - __u16 bias_cur; /* Measured bias current in 2uA units */ + __u32 bias_cur; /* Measured bias current in 2uA units */ __u16 rx_power; /* Measured RX Power */ __u16 tx_power; /* Measured TX Power */ }; @@ -157,7 +157,7 @@ struct sff_diags { /* SFP Temp in 16-bit signed 1/256 Celcius */ __s16 sfp_temp[5]; /* Measured bias current in 2uA units */ - __u16 bias_cur[5]; + __u32 bias_cur[5]; /* Measured TX Power */ __u16 tx_power[5]; /* Measured RX Power */ -- 2.55.0