diff mbox series

[RFC,iwl-next,v1,2/4] ice: Add ice_get_ctrl_ptp() wrapper to simplify the code

Message ID 20240618131208.6971-3-sergey.temerkhanov@intel.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series Replace auxbus with ice_adapter in the PTP support code | expand

Checks

Context Check Description
netdev/series_format warning Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 845 this patch: 19
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 6 maintainers not CCed: richardcochran@gmail.com jesse.brandeburg@intel.com pabeni@redhat.com anthony.l.nguyen@intel.com kuba@kernel.org edumazet@google.com
netdev/build_clang fail Errors and warnings before: 849 this patch: 19
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 850 this patch: 19
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 63 this patch: 63
netdev/source_inline success Was 0 now: 0

Commit Message

Sergey Temerkhanov June 18, 2024, 1:12 p.m. UTC
Add ice_get_ctrl_ptp() wrapper to simplify the PTP support code
in the functions that do not use ctrl_pf directly

Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Sergey Temerkhanov <sergey.temerkhanov@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_ptp.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Michal Schmidt June 20, 2024, 6:06 a.m. UTC | #1
On Tue, Jun 18, 2024 at 3:53 PM Sergey Temerkhanov
<sergey.temerkhanov@intel.com> wrote:
> Add ice_get_ctrl_ptp() wrapper to simplify the PTP support code
> in the functions that do not use ctrl_pf directly
>
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> Signed-off-by: Sergey Temerkhanov <sergey.temerkhanov@intel.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_ptp.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
> index 57e1e5a5da4a..a2578bc2af54 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> @@ -16,6 +16,18 @@ static const struct ptp_pin_desc ice_pin_desc_e810t[] = {
>         { "U.FL2", UFL2, PTP_PF_NONE, 2, { 0, } },
>  };
>
> +static struct ice_pf *ice_get_ctrl_pf(struct ice_pf *pf)
> +{
> +       return !pf->adapter ? NULL : pf->adapter->ctrl_pf;
> +}
> +
> +static struct ice_ptp *ice_get_ctrl_ptp(struct ice_pf *pf)
> +{
> +       struct ice_pf *ctrl_pf = ice_get_ctrl_pf(pf);
> +
> +       return !ctrl_pf ? NULL : &ctrl_pf->ptp;
> +}
> +
>  /**
>   * ice_get_sma_config_e810t
>   * @hw: pointer to the hw struct
> --
> 2.43.0

The patch order is incorrect. Here you access the ctrl_pf member,
which is added later in the subsequent patch.

But more importantly, it looks unsafe to access another ice_pf this
way. The administrator may unbind a PF from the driver in any order.
Can the shared objects be moved into struct ice_adapter itself so that
cross-ice_pf access becomes unnecessary?

Michal
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
index 57e1e5a5da4a..a2578bc2af54 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
@@ -16,6 +16,18 @@  static const struct ptp_pin_desc ice_pin_desc_e810t[] = {
 	{ "U.FL2", UFL2, PTP_PF_NONE, 2, { 0, } },
 };
 
+static struct ice_pf *ice_get_ctrl_pf(struct ice_pf *pf)
+{
+	return !pf->adapter ? NULL : pf->adapter->ctrl_pf;
+}
+
+static struct ice_ptp *ice_get_ctrl_ptp(struct ice_pf *pf)
+{
+	struct ice_pf *ctrl_pf = ice_get_ctrl_pf(pf);
+
+	return !ctrl_pf ? NULL : &ctrl_pf->ptp;
+}
+
 /**
  * ice_get_sma_config_e810t
  * @hw: pointer to the hw struct