diff options
author | Jason Wang <jasowang@redhat.com> | 2022-12-23 06:55:45 +0100 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2023-02-21 01:26:57 +0100 |
commit | 0497f23e73ec2211eff3921ed33026dea93482a5 (patch) | |
tree | 628ce82e6f7fcae60976cc7e4bd295511fdb6d05 /drivers/vdpa | |
parent | vdpa_sim: use weak barriers (diff) | |
download | linux-0497f23e73ec2211eff3921ed33026dea93482a5.tar.xz linux-0497f23e73ec2211eff3921ed33026dea93482a5.zip |
vdpa_sim: switch to use __vdpa_alloc_device()
This allows us to control the allocation size of the structure.
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Acked-by: Eugenio PĂ©rez <eperezma@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20221223055548.27810-2-jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/vdpa')
-rw-r--r-- | drivers/vdpa/vdpa_sim/vdpa_sim.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index 88eab8ded751..f41f9fc522ee 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -251,6 +251,7 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr, const struct vdpa_dev_set_config *config) { const struct vdpa_config_ops *ops; + struct vdpa_device *vdpa; struct vdpasim *vdpasim; struct device *dev; int i, ret = -ENOMEM; @@ -268,14 +269,16 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr, else ops = &vdpasim_config_ops; - vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops, - dev_attr->ngroups, dev_attr->nas, - dev_attr->name, false); - if (IS_ERR(vdpasim)) { - ret = PTR_ERR(vdpasim); + vdpa = __vdpa_alloc_device(NULL, ops, + dev_attr->ngroups, dev_attr->nas, + sizeof(struct vdpasim), + dev_attr->name, false); + if (IS_ERR(vdpa)) { + ret = PTR_ERR(vdpa); goto err_alloc; } + vdpasim = vdpa_to_sim(vdpa); vdpasim->dev_attr = *dev_attr; INIT_WORK(&vdpasim->work, dev_attr->work_fn); spin_lock_init(&vdpasim->lock); |