Skip to content

Commit 5b246e5

Browse files
Michal Swiatkowskianguy11
authored andcommitted
ice: split probe into smaller functions
Part of code from probe can be reused in reload flow. Move this code to separate function. Create unroll functions for each part of initialization, like: ice_init_dev() and ice_deinit_dev(). It simplifies unrolling and can be used in remove flow. Avoid freeing port info as it could be reused in reload path. Will be freed in remove path since is allocated via devm_kzalloc(). Also clean the remove path to reflect the init steps. Signed-off-by: Michal Swiatkowski <[email protected]> Tested-by: Gurucharan G <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent a696d61 commit 5b246e5

File tree

3 files changed

+559
-388
lines changed

3 files changed

+559
-388
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,8 @@ int ice_open(struct net_device *netdev);
931931
int ice_open_internal(struct net_device *netdev);
932932
int ice_stop(struct net_device *netdev);
933933
void ice_service_task_schedule(struct ice_pf *pf);
934+
int ice_load(struct ice_pf *pf);
935+
void ice_unload(struct ice_pf *pf);
934936

935937
/**
936938
* ice_set_rdma_cap - enable RDMA support

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,8 +1088,10 @@ int ice_init_hw(struct ice_hw *hw)
10881088
if (status)
10891089
goto err_unroll_cqinit;
10901090

1091-
hw->port_info = devm_kzalloc(ice_hw_to_dev(hw),
1092-
sizeof(*hw->port_info), GFP_KERNEL);
1091+
if (!hw->port_info)
1092+
hw->port_info = devm_kzalloc(ice_hw_to_dev(hw),
1093+
sizeof(*hw->port_info),
1094+
GFP_KERNEL);
10931095
if (!hw->port_info) {
10941096
status = -ENOMEM;
10951097
goto err_unroll_cqinit;
@@ -1217,11 +1219,6 @@ void ice_deinit_hw(struct ice_hw *hw)
12171219
ice_free_hw_tbls(hw);
12181220
mutex_destroy(&hw->tnl_lock);
12191221

1220-
if (hw->port_info) {
1221-
devm_kfree(ice_hw_to_dev(hw), hw->port_info);
1222-
hw->port_info = NULL;
1223-
}
1224-
12251222
/* Attempt to disable FW logging before shutting down control queues */
12261223
ice_cfg_fw_log(hw, false);
12271224
ice_destroy_all_ctrlq(hw);

0 commit comments

Comments
 (0)