mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
net/mlx5: rsc_dump and hv_vhca return NULL on create error
All callers of these create functions treat NULL and ERR_PTR as equivalent error cases. Align the return convention to NULL-on-failure to simplify the checks at usage sites. Since its return value is never checked and failure is non-fatal, change hv_vhca init function to return void. Signed-off-by: Michael Guralnik <michaelgur@nvidia.com> Reviewed-by: Shay Drori <shayd@nvidia.com> Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260811061637.3195320-1-tariqt@nvidia.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
379122479b
commit
03a105c832
|
|
@ -130,7 +130,7 @@ struct mlx5_rsc_dump_cmd *mlx5_rsc_dump_cmd_create(struct mlx5_core_dev *dev,
|
|||
struct mlx5_rsc_dump_cmd *cmd;
|
||||
int sgmt_type;
|
||||
|
||||
if (IS_ERR_OR_NULL(dev->rsc_dump))
|
||||
if (!dev->rsc_dump)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
sgmt_type = dev->rsc_dump->fw_segment_type[key->rsc];
|
||||
|
|
@ -165,7 +165,7 @@ int mlx5_rsc_dump_next(struct mlx5_core_dev *dev, struct mlx5_rsc_dump_cmd *cmd,
|
|||
bool more_dump;
|
||||
int err;
|
||||
|
||||
if (IS_ERR_OR_NULL(dev->rsc_dump))
|
||||
if (!dev->rsc_dump)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
err = mlx5_rsc_dump_trigger(dev, cmd, page);
|
||||
|
|
@ -257,14 +257,14 @@ struct mlx5_rsc_dump *mlx5_rsc_dump_create(struct mlx5_core_dev *dev)
|
|||
}
|
||||
rsc_dump = kzalloc_obj(*rsc_dump);
|
||||
if (!rsc_dump)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
return NULL;
|
||||
|
||||
return rsc_dump;
|
||||
}
|
||||
|
||||
void mlx5_rsc_dump_destroy(struct mlx5_core_dev *dev)
|
||||
{
|
||||
if (IS_ERR_OR_NULL(dev->rsc_dump))
|
||||
if (!dev->rsc_dump)
|
||||
return;
|
||||
kfree(dev->rsc_dump);
|
||||
}
|
||||
|
|
@ -274,7 +274,7 @@ int mlx5_rsc_dump_init(struct mlx5_core_dev *dev)
|
|||
struct mlx5_rsc_dump *rsc_dump = dev->rsc_dump;
|
||||
int err;
|
||||
|
||||
if (IS_ERR_OR_NULL(dev->rsc_dump))
|
||||
if (!dev->rsc_dump)
|
||||
return 0;
|
||||
|
||||
err = mlx5_core_alloc_pd(dev, &rsc_dump->pdn);
|
||||
|
|
@ -303,7 +303,7 @@ int mlx5_rsc_dump_init(struct mlx5_core_dev *dev)
|
|||
|
||||
void mlx5_rsc_dump_cleanup(struct mlx5_core_dev *dev)
|
||||
{
|
||||
if (IS_ERR_OR_NULL(dev->rsc_dump))
|
||||
if (!dev->rsc_dump)
|
||||
return;
|
||||
|
||||
mlx5_core_destroy_mkey(dev, dev->rsc_dump->mkey);
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ int mlx5e_health_rsc_fmsg_dump(struct mlx5e_priv *priv, struct mlx5_rsc_key *key
|
|||
struct page *page;
|
||||
int size;
|
||||
|
||||
if (IS_ERR_OR_NULL(mdev->rsc_dump))
|
||||
if (!mdev->rsc_dump)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
page = alloc_page(GFP_KERNEL);
|
||||
|
|
|
|||
|
|
@ -44,12 +44,12 @@ struct mlx5_hv_vhca *mlx5_hv_vhca_create(struct mlx5_core_dev *dev)
|
|||
|
||||
hv_vhca = kzalloc_obj(*hv_vhca);
|
||||
if (!hv_vhca)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
return NULL;
|
||||
|
||||
hv_vhca->work_queue = create_singlethread_workqueue("mlx5_hv_vhca");
|
||||
if (!hv_vhca->work_queue) {
|
||||
kfree(hv_vhca);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hv_vhca->dev = dev;
|
||||
|
|
@ -60,7 +60,7 @@ struct mlx5_hv_vhca *mlx5_hv_vhca_create(struct mlx5_core_dev *dev)
|
|||
|
||||
void mlx5_hv_vhca_destroy(struct mlx5_hv_vhca *hv_vhca)
|
||||
{
|
||||
if (IS_ERR_OR_NULL(hv_vhca))
|
||||
if (!hv_vhca)
|
||||
return;
|
||||
|
||||
destroy_workqueue(hv_vhca->work_queue);
|
||||
|
|
@ -198,28 +198,26 @@ static void mlx5_hv_vhca_control_agent_destroy(struct mlx5_hv_vhca_agent *agent)
|
|||
mlx5_hv_vhca_agent_destroy(agent);
|
||||
}
|
||||
|
||||
int mlx5_hv_vhca_init(struct mlx5_hv_vhca *hv_vhca)
|
||||
void mlx5_hv_vhca_init(struct mlx5_hv_vhca *hv_vhca)
|
||||
{
|
||||
struct mlx5_hv_vhca_agent *agent;
|
||||
int err;
|
||||
|
||||
if (IS_ERR_OR_NULL(hv_vhca))
|
||||
return IS_ERR_OR_NULL(hv_vhca);
|
||||
if (!hv_vhca)
|
||||
return;
|
||||
|
||||
err = mlx5_hv_register_invalidate(hv_vhca->dev, hv_vhca,
|
||||
mlx5_hv_vhca_invalidate);
|
||||
if (err)
|
||||
return err;
|
||||
return;
|
||||
|
||||
agent = mlx5_hv_vhca_control_agent_create(hv_vhca);
|
||||
if (IS_ERR_OR_NULL(agent)) {
|
||||
mlx5_hv_unregister_invalidate(hv_vhca->dev);
|
||||
return IS_ERR_OR_NULL(agent);
|
||||
return;
|
||||
}
|
||||
|
||||
hv_vhca->agents[MLX5_HV_VHCA_AGENT_CONTROL] = agent;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mlx5_hv_vhca_cleanup(struct mlx5_hv_vhca *hv_vhca)
|
||||
|
|
@ -227,7 +225,7 @@ void mlx5_hv_vhca_cleanup(struct mlx5_hv_vhca *hv_vhca)
|
|||
struct mlx5_hv_vhca_agent *agent;
|
||||
int i;
|
||||
|
||||
if (IS_ERR_OR_NULL(hv_vhca))
|
||||
if (!hv_vhca)
|
||||
return;
|
||||
|
||||
agent = hv_vhca->agents[MLX5_HV_VHCA_AGENT_CONTROL];
|
||||
|
|
@ -261,7 +259,7 @@ mlx5_hv_vhca_agent_create(struct mlx5_hv_vhca *hv_vhca,
|
|||
{
|
||||
struct mlx5_hv_vhca_agent *agent;
|
||||
|
||||
if (IS_ERR_OR_NULL(hv_vhca))
|
||||
if (!hv_vhca)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
if (type >= MLX5_HV_VHCA_AGENT_MAX)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ struct mlx5_hv_vhca_control_block {
|
|||
|
||||
struct mlx5_hv_vhca *mlx5_hv_vhca_create(struct mlx5_core_dev *dev);
|
||||
void mlx5_hv_vhca_destroy(struct mlx5_hv_vhca *hv_vhca);
|
||||
int mlx5_hv_vhca_init(struct mlx5_hv_vhca *hv_vhca);
|
||||
void mlx5_hv_vhca_init(struct mlx5_hv_vhca *hv_vhca);
|
||||
void mlx5_hv_vhca_cleanup(struct mlx5_hv_vhca *hv_vhca);
|
||||
void mlx5_hv_vhca_invalidate(void *context, u64 block_mask);
|
||||
|
||||
|
|
@ -63,9 +63,8 @@ static inline void mlx5_hv_vhca_destroy(struct mlx5_hv_vhca *hv_vhca)
|
|||
{
|
||||
}
|
||||
|
||||
static inline int mlx5_hv_vhca_init(struct mlx5_hv_vhca *hv_vhca)
|
||||
static inline void mlx5_hv_vhca_init(struct mlx5_hv_vhca *hv_vhca)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void mlx5_hv_vhca_cleanup(struct mlx5_hv_vhca *hv_vhca)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user