summaryrefslogtreecommitdiff
path: root/drivers/net/netdevsim
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/netdevsim')
-rw-r--r--drivers/net/netdevsim/bpf.c4
-rw-r--r--drivers/net/netdevsim/bus.c2
-rw-r--r--drivers/net/netdevsim/dev.c21
-rw-r--r--drivers/net/netdevsim/fib.c14
-rw-r--r--drivers/net/netdevsim/hwstats.c2
-rw-r--r--drivers/net/netdevsim/netdev.c5
-rw-r--r--drivers/net/netdevsim/psample.c2
7 files changed, 24 insertions, 26 deletions
diff --git a/drivers/net/netdevsim/bpf.c b/drivers/net/netdevsim/bpf.c
index 5f17f68f3c08..8eebcc933ddb 100644
--- a/drivers/net/netdevsim/bpf.c
+++ b/drivers/net/netdevsim/bpf.c
@@ -222,7 +222,7 @@ static int nsim_bpf_create_prog(struct nsim_dev *nsim_dev,
char name[16];
int ret;
- state = kzalloc(sizeof(*state), GFP_KERNEL);
+ state = kzalloc_obj(*state);
if (!state)
return -ENOMEM;
@@ -501,7 +501,7 @@ nsim_bpf_map_alloc(struct netdevsim *ns, struct bpf_offloaded_map *offmap)
if (offmap->map.map_flags)
return -EINVAL;
- nmap = kzalloc(sizeof(*nmap), GFP_KERNEL_ACCOUNT);
+ nmap = kzalloc_obj(*nmap, GFP_KERNEL_ACCOUNT);
if (!nmap)
return -ENOMEM;
diff --git a/drivers/net/netdevsim/bus.c b/drivers/net/netdevsim/bus.c
index d16b95304aa7..f85b1c261dfb 100644
--- a/drivers/net/netdevsim/bus.c
+++ b/drivers/net/netdevsim/bus.c
@@ -451,7 +451,7 @@ nsim_bus_dev_new(unsigned int id, unsigned int port_count, unsigned int num_queu
struct nsim_bus_dev *nsim_bus_dev;
int err;
- nsim_bus_dev = kzalloc(sizeof(*nsim_bus_dev), GFP_KERNEL);
+ nsim_bus_dev = kzalloc_obj(*nsim_bus_dev);
if (!nsim_bus_dev)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index f7b32446d3b8..e82de0fd3157 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -267,8 +267,8 @@ static ssize_t nsim_bus_dev_max_vfs_write(struct file *file,
if (val > NSIM_DEV_VF_PORT_INDEX_MAX - NSIM_DEV_VF_PORT_INDEX_BASE)
return -ERANGE;
- vfconfigs = kcalloc(val, sizeof(struct nsim_vf_config),
- GFP_KERNEL | __GFP_NOWARN);
+ vfconfigs = kzalloc_objs(struct nsim_vf_config, val,
+ GFP_KERNEL | __GFP_NOWARN);
if (!vfconfigs)
return -ENOMEM;
@@ -935,13 +935,12 @@ static int nsim_dev_traps_init(struct devlink *devlink)
struct nsim_trap_data *nsim_trap_data;
int err;
- nsim_trap_data = kzalloc(sizeof(*nsim_trap_data), GFP_KERNEL);
+ nsim_trap_data = kzalloc_obj(*nsim_trap_data);
if (!nsim_trap_data)
return -ENOMEM;
- nsim_trap_data->trap_items_arr = kcalloc(ARRAY_SIZE(nsim_traps_arr),
- sizeof(struct nsim_trap_item),
- GFP_KERNEL);
+ nsim_trap_data->trap_items_arr = kzalloc_objs(struct nsim_trap_item,
+ ARRAY_SIZE(nsim_traps_arr));
if (!nsim_trap_data->trap_items_arr) {
err = -ENOMEM;
goto err_trap_data_free;
@@ -1348,7 +1347,7 @@ static int nsim_rate_node_new(struct devlink_rate *node, void **priv,
return -EOPNOTSUPP;
}
- nsim_node = kzalloc(sizeof(*nsim_node), GFP_KERNEL);
+ nsim_node = kzalloc_obj(*nsim_node);
if (!nsim_node)
return -ENOMEM;
@@ -1464,7 +1463,7 @@ static int __nsim_dev_port_add(struct nsim_dev *nsim_dev, enum nsim_dev_port_typ
if (type == NSIM_DEV_PORT_TYPE_VF && !nsim_dev_get_vfs(nsim_dev))
return -EINVAL;
- nsim_dev_port = kzalloc(sizeof(*nsim_dev_port), GFP_KERNEL);
+ nsim_dev_port = kzalloc_obj(*nsim_dev_port);
if (!nsim_dev_port)
return -ENOMEM;
nsim_dev_port->port_index = nsim_dev_port_index(type, port_index);
@@ -1652,9 +1651,9 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
dev_set_drvdata(&nsim_bus_dev->dev, nsim_dev);
- nsim_dev->vfconfigs = kcalloc(nsim_bus_dev->max_vfs,
- sizeof(struct nsim_vf_config),
- GFP_KERNEL | __GFP_NOWARN);
+ nsim_dev->vfconfigs = kzalloc_objs(struct nsim_vf_config,
+ nsim_bus_dev->max_vfs,
+ GFP_KERNEL | __GFP_NOWARN);
if (!nsim_dev->vfconfigs) {
err = -ENOMEM;
goto err_devlink_unlock;
diff --git a/drivers/net/netdevsim/fib.c b/drivers/net/netdevsim/fib.c
index 16c382c42227..1a42bdbfaa41 100644
--- a/drivers/net/netdevsim/fib.c
+++ b/drivers/net/netdevsim/fib.c
@@ -277,7 +277,7 @@ nsim_fib4_rt_create(struct nsim_fib_data *data,
{
struct nsim_fib4_rt *fib4_rt;
- fib4_rt = kzalloc(sizeof(*fib4_rt), GFP_KERNEL);
+ fib4_rt = kzalloc_obj(*fib4_rt);
if (!fib4_rt)
return NULL;
@@ -497,7 +497,7 @@ static int nsim_fib6_rt_nh_add(struct nsim_fib6_rt *fib6_rt,
{
struct nsim_fib6_rt_nh *fib6_rt_nh;
- fib6_rt_nh = kzalloc(sizeof(*fib6_rt_nh), GFP_KERNEL);
+ fib6_rt_nh = kzalloc_obj(*fib6_rt_nh);
if (!fib6_rt_nh)
return -ENOMEM;
@@ -544,7 +544,7 @@ nsim_fib6_rt_create(struct nsim_fib_data *data,
int i = 0;
int err;
- fib6_rt = kzalloc(sizeof(*fib6_rt), GFP_KERNEL);
+ fib6_rt = kzalloc_obj(*fib6_rt);
if (!fib6_rt)
return ERR_PTR(-ENOMEM);
@@ -807,7 +807,7 @@ static int nsim_fib6_event_init(struct nsim_fib6_event *fib6_event,
nrt6 = fen6_info->nsiblings + 1;
- rt_arr = kcalloc(nrt6, sizeof(struct fib6_info *), GFP_ATOMIC);
+ rt_arr = kzalloc_objs(struct fib6_info *, nrt6, GFP_ATOMIC);
if (!rt_arr)
return -ENOMEM;
@@ -987,7 +987,7 @@ static int nsim_fib_event_schedule_work(struct nsim_fib_data *data,
*/
return NOTIFY_DONE;
- fib_event = kzalloc(sizeof(*fib_event), GFP_ATOMIC);
+ fib_event = kzalloc_obj(*fib_event, GFP_ATOMIC);
if (!fib_event)
goto err_fib_event_alloc;
@@ -1116,7 +1116,7 @@ static struct nsim_nexthop *nsim_nexthop_create(struct nsim_fib_data *data,
u64 occ = 0;
int i;
- nexthop = kzalloc(sizeof(*nexthop), GFP_KERNEL);
+ nexthop = kzalloc_obj(*nexthop);
if (!nexthop)
return ERR_PTR(-ENOMEM);
@@ -1556,7 +1556,7 @@ struct nsim_fib_data *nsim_fib_create(struct devlink *devlink,
struct nsim_dev *nsim_dev;
int err;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data);
if (!data)
return ERR_PTR(-ENOMEM);
data->devlink = devlink;
diff --git a/drivers/net/netdevsim/hwstats.c b/drivers/net/netdevsim/hwstats.c
index 1abe48e35ca3..14234a4cc244 100644
--- a/drivers/net/netdevsim/hwstats.c
+++ b/drivers/net/netdevsim/hwstats.c
@@ -238,7 +238,7 @@ nsim_dev_hwstats_enable_ifindex(struct nsim_dev_hwstats *hwstats,
goto out_unlock_list;
}
- hwsdev = kzalloc(sizeof(*hwsdev), GFP_KERNEL);
+ hwsdev = kzalloc_obj(*hwsdev);
if (!hwsdev) {
err = -ENOMEM;
goto out_put_netdev;
diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
index 6285fbefe38a..5ec028a00c62 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -723,7 +723,7 @@ static struct nsim_rq *nsim_queue_alloc(void)
{
struct nsim_rq *rq;
- rq = kzalloc(sizeof(*rq), GFP_KERNEL_ACCOUNT);
+ rq = kzalloc_obj(*rq, GFP_KERNEL_ACCOUNT);
if (!rq)
return NULL;
@@ -997,8 +997,7 @@ static int nsim_queue_init(struct netdevsim *ns)
struct net_device *dev = ns->netdev;
int i;
- ns->rq = kcalloc(dev->num_rx_queues, sizeof(*ns->rq),
- GFP_KERNEL_ACCOUNT);
+ ns->rq = kzalloc_objs(*ns->rq, dev->num_rx_queues, GFP_KERNEL_ACCOUNT);
if (!ns->rq)
return -ENOMEM;
diff --git a/drivers/net/netdevsim/psample.c b/drivers/net/netdevsim/psample.c
index f0c6477dd0ae..47d24bc64ee4 100644
--- a/drivers/net/netdevsim/psample.c
+++ b/drivers/net/netdevsim/psample.c
@@ -200,7 +200,7 @@ int nsim_dev_psample_init(struct nsim_dev *nsim_dev)
struct nsim_dev_psample *psample;
int err;
- psample = kzalloc(sizeof(*psample), GFP_KERNEL);
+ psample = kzalloc_obj(*psample);
if (!psample)
return -ENOMEM;
nsim_dev->psample = psample;