Skip to content

Commit 6556ff3

Browse files
TaeheeYookuba-moo
authored andcommitted
netdevsim: use IS_ERR instead of IS_ERR_OR_NULL for debugfs
Debugfs APIs return valid pointer or error pointer. it doesn't return NULL. So, using IS_ERR is enough, not using IS_ERR_OR_NULL. Reviewed-by: Jakub Kicinski <[email protected]> Reported-by: kbuild test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Taehee Yoo <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6fb8852 commit 6556ff3

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

drivers/net/netdevsim/bpf.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ static int nsim_bpf_create_prog(struct nsim_dev *nsim_dev,
218218
{
219219
struct nsim_bpf_bound_prog *state;
220220
char name[16];
221+
int ret;
221222

222223
state = kzalloc(sizeof(*state), GFP_KERNEL);
223224
if (!state)
@@ -230,9 +231,10 @@ static int nsim_bpf_create_prog(struct nsim_dev *nsim_dev,
230231
/* Program id is not populated yet when we create the state. */
231232
sprintf(name, "%u", nsim_dev->prog_id_gen++);
232233
state->ddir = debugfs_create_dir(name, nsim_dev->ddir_bpf_bound_progs);
233-
if (IS_ERR_OR_NULL(state->ddir)) {
234+
if (IS_ERR(state->ddir)) {
235+
ret = PTR_ERR(state->ddir);
234236
kfree(state);
235-
return -ENOMEM;
237+
return ret;
236238
}
237239

238240
debugfs_create_u32("id", 0400, state->ddir, &prog->aux->id);
@@ -587,8 +589,8 @@ int nsim_bpf_dev_init(struct nsim_dev *nsim_dev)
587589

588590
nsim_dev->ddir_bpf_bound_progs = debugfs_create_dir("bpf_bound_progs",
589591
nsim_dev->ddir);
590-
if (IS_ERR_OR_NULL(nsim_dev->ddir_bpf_bound_progs))
591-
return -ENOMEM;
592+
if (IS_ERR(nsim_dev->ddir_bpf_bound_progs))
593+
return PTR_ERR(nsim_dev->ddir_bpf_bound_progs);
592594

593595
nsim_dev->bpf_dev = bpf_offload_dev_create(&nsim_bpf_dev_ops, nsim_dev);
594596
err = PTR_ERR_OR_ZERO(nsim_dev->bpf_dev);

drivers/net/netdevsim/dev.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ static int nsim_dev_debugfs_init(struct nsim_dev *nsim_dev)
7777

7878
sprintf(dev_ddir_name, DRV_NAME "%u", nsim_dev->nsim_bus_dev->dev.id);
7979
nsim_dev->ddir = debugfs_create_dir(dev_ddir_name, nsim_dev_ddir);
80-
if (IS_ERR_OR_NULL(nsim_dev->ddir))
81-
return PTR_ERR_OR_ZERO(nsim_dev->ddir) ?: -EINVAL;
80+
if (IS_ERR(nsim_dev->ddir))
81+
return PTR_ERR(nsim_dev->ddir);
8282
nsim_dev->ports_ddir = debugfs_create_dir("ports", nsim_dev->ddir);
83-
if (IS_ERR_OR_NULL(nsim_dev->ports_ddir))
84-
return PTR_ERR_OR_ZERO(nsim_dev->ports_ddir) ?: -EINVAL;
83+
if (IS_ERR(nsim_dev->ports_ddir))
84+
return PTR_ERR(nsim_dev->ports_ddir);
8585
debugfs_create_bool("fw_update_status", 0600, nsim_dev->ddir,
8686
&nsim_dev->fw_update_status);
8787
debugfs_create_u32("max_macs", 0600, nsim_dev->ddir,
@@ -115,8 +115,8 @@ static int nsim_dev_port_debugfs_init(struct nsim_dev *nsim_dev,
115115
sprintf(port_ddir_name, "%u", nsim_dev_port->port_index);
116116
nsim_dev_port->ddir = debugfs_create_dir(port_ddir_name,
117117
nsim_dev->ports_ddir);
118-
if (IS_ERR_OR_NULL(nsim_dev_port->ddir))
119-
return -ENOMEM;
118+
if (IS_ERR(nsim_dev_port->ddir))
119+
return PTR_ERR(nsim_dev_port->ddir);
120120

121121
sprintf(dev_link_name, "../../../" DRV_NAME "%u",
122122
nsim_dev->nsim_bus_dev->dev.id);
@@ -934,8 +934,8 @@ int nsim_dev_port_del(struct nsim_bus_dev *nsim_bus_dev,
934934
int nsim_dev_init(void)
935935
{
936936
nsim_dev_ddir = debugfs_create_dir(DRV_NAME, NULL);
937-
if (IS_ERR_OR_NULL(nsim_dev_ddir))
938-
return -ENOMEM;
937+
if (IS_ERR(nsim_dev_ddir))
938+
return PTR_ERR(nsim_dev_ddir);
939939
return 0;
940940
}
941941

drivers/net/netdevsim/health.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ int nsim_dev_health_init(struct nsim_dev *nsim_dev, struct devlink *devlink)
285285
}
286286

287287
health->ddir = debugfs_create_dir("health", nsim_dev->ddir);
288-
if (IS_ERR_OR_NULL(health->ddir)) {
289-
err = PTR_ERR_OR_ZERO(health->ddir) ?: -EINVAL;
288+
if (IS_ERR(health->ddir)) {
289+
err = PTR_ERR(health->ddir);
290290
goto err_dummy_reporter_destroy;
291291
}
292292

0 commit comments

Comments
 (0)