Skip to content

Commit 97ed20a

Browse files
stemerkanguy11
authored andcommitted
ice: Add ice_get_ctrl_ptp() wrapper to simplify the code
Add ice_get_ctrl_ptp() wrapper to simplify the PTP support code in the functions that do not use ctrl_pf directly. Add the control PF pointer to struct ice_adapter Rearrange fields in struct ice_adapter Signed-off-by: Sergey Temerkhanov <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent 5e07764 commit 97ed20a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

drivers/net/ethernet/intel/ice/ice_adapter.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@
88
#include <linux/refcount_types.h>
99

1010
struct pci_dev;
11+
struct ice_pf;
1112

1213
/**
1314
* struct ice_adapter - PCI adapter resources shared across PFs
1415
* @ptp_gltsyn_time_lock: Spinlock protecting access to the GLTSYN_TIME
1516
* register of the PTP clock.
1617
* @refcount: Reference count. struct ice_pf objects hold the references.
18+
* @ctrl_pf: Control PF of the adapter
1719
*/
1820
struct ice_adapter {
21+
refcount_t refcount;
1922
/* For access to the GLTSYN_TIME register */
2023
spinlock_t ptp_gltsyn_time_lock;
2124

22-
refcount_t refcount;
25+
struct ice_pf *ctrl_pf;
2326
};
2427

2528
struct ice_adapter *ice_adapter_get(const struct pci_dev *pdev);

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ static const struct ice_ptp_pin_desc ice_pin_desc_e810_sma[] = {
5757
{ UFL2, { 3, -1 }},
5858
};
5959

60+
static struct ice_pf *ice_get_ctrl_pf(struct ice_pf *pf)
61+
{
62+
return !pf->adapter ? NULL : pf->adapter->ctrl_pf;
63+
}
64+
65+
static __maybe_unused struct ice_ptp *ice_get_ctrl_ptp(struct ice_pf *pf)
66+
{
67+
struct ice_pf *ctrl_pf = ice_get_ctrl_pf(pf);
68+
69+
return !ctrl_pf ? NULL : &ctrl_pf->ptp;
70+
}
71+
6072
/**
6173
* ice_ptp_find_pin_idx - Find pin index in ptp_pin_desc
6274
* @pf: Board private structure

0 commit comments

Comments
 (0)