ipc: ipc_service: Inline libmetal_{setup,teardown}() for correct ordering
Currently metal_init() is called as part of libmetal_setup() which is
called after libmetal has already started being used (metal_io_init
called before). Same for metal_finish() but in reverse (metal_io_finish
called after). To fix this inline the content of libmetal_{setup,teardown}
into their one call-sites and move the init/finish calls to the correct
spot before/after all uses of the lib.
Signed-off-by: Andrew Davis <afd@ti.com>
This commit is contained in:
parent
be4a4ee324
commit
df64d076d8
1 changed files with 8 additions and 30 deletions
|
|
@ -70,26 +70,6 @@ const static struct virtio_dispatch dispatch = {
|
|||
.notify = ipc_virtio_notify,
|
||||
};
|
||||
|
||||
static int libmetal_setup(struct ipc_static_vrings *vr)
|
||||
{
|
||||
struct metal_init_params metal_params = METAL_INIT_DEFAULTS;
|
||||
int err;
|
||||
|
||||
err = metal_init(&metal_params);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int libmetal_teardown(struct ipc_static_vrings *vr)
|
||||
{
|
||||
metal_finish();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vq_setup(struct ipc_static_vrings *vr, unsigned int role)
|
||||
{
|
||||
vr->vq[RPMSG_VQ_0] = virtqueue_allocate(vr->vring_size);
|
||||
|
|
@ -138,22 +118,23 @@ static int vq_teardown(struct ipc_static_vrings *vr, unsigned int role)
|
|||
|
||||
int ipc_static_vrings_init(struct ipc_static_vrings *vr, unsigned int role)
|
||||
{
|
||||
struct metal_init_params metal_params = METAL_INIT_DEFAULTS;
|
||||
int err = 0;
|
||||
|
||||
if (!vr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = metal_init(&metal_params);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
vr->shm_physmap[0] = vr->shm_addr;
|
||||
|
||||
metal_io_init(&vr->shm_io, (void *)vr->shm_addr,
|
||||
vr->shm_physmap, vr->shm_size, -1, 0, NULL);
|
||||
|
||||
err = libmetal_setup(vr);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return vq_setup(vr, role);
|
||||
}
|
||||
|
||||
|
|
@ -166,12 +147,9 @@ int ipc_static_vrings_deinit(struct ipc_static_vrings *vr, unsigned int role)
|
|||
return err;
|
||||
}
|
||||
|
||||
err = libmetal_teardown(vr);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
metal_io_finish(&vr->shm_io);
|
||||
|
||||
metal_finish();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue