From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@google.com, netdev@vger.kernel.org
Cc: Karol Kolacinski <karol.kolacinski@intel.com>,
anthony.l.nguyen@intel.com, richardcochran@gmail.com,
Jacob Keller <jacob.e.keller@intel.com>,
Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com>
Subject: [PATCH net-next v2 07/11] ice: PTP: move quad value check inside ice_fill_phy_msg_e822
Date: Mon, 18 Sep 2023 14:28:10 -0700 [thread overview]
Message-ID: <20230918212814.435688-8-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20230918212814.435688-1-anthony.l.nguyen@intel.com>
From: Karol Kolacinski <karol.kolacinski@intel.com>
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>
---
drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
index 7c18dbac49d0..f839f186797d 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
@@ -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)
@@ -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;
}
/**
@@ -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);
@@ -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;
--
2.38.1
next prev parent reply other threads:[~2023-09-18 21:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-18 21:28 [PATCH net-next v2 00/11][pull request] Intel Wired LAN Driver Updates 2023-09-18 (ice) Tony Nguyen
2023-09-18 21:28 ` [PATCH net-next v2 01/11] ice: prefix clock timer command enumeration values with ICE_PTP Tony Nguyen
2023-09-18 21:28 ` [PATCH net-next v2 02/11] ice: retry acquiring hardware semaphore during cross-timestamp request Tony Nguyen
2023-09-18 21:28 ` [PATCH net-next v2 03/11] ice: Support cross-timestamping for E823 devices Tony Nguyen
2023-09-18 21:28 ` [PATCH net-next v2 04/11] ice: introduce hw->phy_model for handling PTP PHY differences Tony Nguyen
2023-09-18 21:28 ` [PATCH net-next v2 05/11] ice: PTP: Clean up timestamp registers correctly Tony Nguyen
2023-09-18 21:28 ` [PATCH net-next v2 06/11] ice: PTP: Rename macros used for PHY/QUAD port definitions Tony Nguyen
2023-09-18 21:28 ` Tony Nguyen [this message]
2023-09-18 21:28 ` [PATCH net-next v2 08/11] ice: remove ICE_F_PTP_EXTTS feature flag Tony Nguyen
2023-09-18 21:28 ` [PATCH net-next v2 09/11] ice: fix pin assignment for E810-T without SMA control Tony Nguyen
2023-09-18 21:28 ` [PATCH net-next v2 10/11] ice: introduce ice_pf_src_tmr_owned Tony Nguyen
2023-09-18 21:28 ` [PATCH net-next v2 11/11] ice: check netlist before enabling ICE_F_GNSS Tony Nguyen
2023-09-20 9:40 ` [PATCH net-next v2 00/11][pull request] Intel Wired LAN Driver Updates 2023-09-18 (ice) patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230918212814.435688-8-anthony.l.nguyen@intel.com \
--to=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=himasekharx.reddy.pucha@intel.com \
--cc=jacob.e.keller@intel.com \
--cc=karol.kolacinski@intel.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).