Skip to content

Commit

Permalink
ice: PTP: move quad value check inside ice_fill_phy_msg_e822
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Karol Kolacinski authored and Tony Nguyen committed Sep 18, 2023
1 parent 64fd7de commit dd84744
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions drivers/net/ethernet/intel/ice/ice_ptp_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,14 @@ ice_write_64b_phy_reg_e822(struct ice_hw *hw, u8 port, u16 low_addr, u64 val)
* Fill a message buffer for accessing a register in a quad shared between
* multiple PHYs.
*/
static void
static int
ice_fill_quad_msg_e822(struct ice_sbq_msg_input *msg, u8 quad, u16 offset)
{
u32 addr;

if (quad >= ICE_MAX_QUAD)
return -EINVAL;

msg->dest_dev = rmn_0;

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

msg->msg_addr_low = lower_16_bits(addr);
msg->msg_addr_high = upper_16_bits(addr);

return 0;
}

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

if (quad >= ICE_MAX_QUAD)
return -EINVAL;
err = ice_fill_quad_msg_e822(&msg, quad, offset);
if (err)
return err;

ice_fill_quad_msg_e822(&msg, quad, offset);
msg.opcode = ice_sbq_msg_rd;

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

if (quad >= ICE_MAX_QUAD)
return -EINVAL;
err = ice_fill_quad_msg_e822(&msg, quad, offset);
if (err)
return err;

ice_fill_quad_msg_e822(&msg, quad, offset);
msg.opcode = ice_sbq_msg_wr;
msg.data = val;

Expand Down

0 comments on commit dd84744

Please sign in to comment.