Skip to content

Commit dd84744

Browse files
Karol Kolacinskianguy11
authored andcommitted
ice: PTP: move quad value check inside ice_fill_phy_msg_e822
The callers of ice_fill_phy_msg_e822 check for whether the quad number is within the expected range. Move this check inside the ice_fill_phy_msg_e822 function instead of duplicating it twice. Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 64fd7de commit dd84744

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

drivers/net/ethernet/intel/ice/ice_ptp_hw.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -621,11 +621,14 @@ ice_write_64b_phy_reg_e822(struct ice_hw *hw, u8 port, u16 low_addr, u64 val)
621621
* Fill a message buffer for accessing a register in a quad shared between
622622
* multiple PHYs.
623623
*/
624-
static void
624+
static int
625625
ice_fill_quad_msg_e822(struct ice_sbq_msg_input *msg, u8 quad, u16 offset)
626626
{
627627
u32 addr;
628628

629+
if (quad >= ICE_MAX_QUAD)
630+
return -EINVAL;
631+
629632
msg->dest_dev = rmn_0;
630633

631634
if ((quad % ICE_QUADS_PER_PHY_E822) == 0)
@@ -635,6 +638,8 @@ ice_fill_quad_msg_e822(struct ice_sbq_msg_input *msg, u8 quad, u16 offset)
635638

636639
msg->msg_addr_low = lower_16_bits(addr);
637640
msg->msg_addr_high = upper_16_bits(addr);
641+
642+
return 0;
638643
}
639644

640645
/**
@@ -653,10 +658,10 @@ ice_read_quad_reg_e822(struct ice_hw *hw, u8 quad, u16 offset, u32 *val)
653658
struct ice_sbq_msg_input msg = {0};
654659
int err;
655660

656-
if (quad >= ICE_MAX_QUAD)
657-
return -EINVAL;
661+
err = ice_fill_quad_msg_e822(&msg, quad, offset);
662+
if (err)
663+
return err;
658664

659-
ice_fill_quad_msg_e822(&msg, quad, offset);
660665
msg.opcode = ice_sbq_msg_rd;
661666

662667
err = ice_sbq_rw_reg(hw, &msg);
@@ -687,10 +692,10 @@ ice_write_quad_reg_e822(struct ice_hw *hw, u8 quad, u16 offset, u32 val)
687692
struct ice_sbq_msg_input msg = {0};
688693
int err;
689694

690-
if (quad >= ICE_MAX_QUAD)
691-
return -EINVAL;
695+
err = ice_fill_quad_msg_e822(&msg, quad, offset);
696+
if (err)
697+
return err;
692698

693-
ice_fill_quad_msg_e822(&msg, quad, offset);
694699
msg.opcode = ice_sbq_msg_wr;
695700
msg.data = val;
696701

0 commit comments

Comments
 (0)