virtio: move metal_init to the virtio_register_drivers()

Only call metal_init() once for virtio framework

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
Bowen Wang 2024-01-23 15:21:40 +08:00 committed by Xiang Xiao
parent db85061b0b
commit ca22e95577
2 changed files with 7 additions and 12 deletions

View File

@ -819,23 +819,11 @@ static int virtio_mmio_init_device(FAR struct virtio_mmio_device_s *vmdev,
int virtio_register_mmio_device(FAR void *regs, int irq)
{
struct metal_init_params params = METAL_INIT_DEFAULTS;
FAR struct virtio_mmio_device_s *vmdev;
static bool onceinit;
int ret;
DEBUGASSERT(regs != NULL);
if (onceinit == false)
{
onceinit = true;
ret = metal_init(&params);
if (ret < 0)
{
return ret;
}
}
vmdev = kmm_zalloc(sizeof(*vmdev));
if (vmdev == NULL)
{

View File

@ -119,8 +119,15 @@ void virtio_free_buf(FAR struct virtio_device *vdev, FAR void *buf)
void virtio_register_drivers(void)
{
struct metal_init_params params = METAL_INIT_DEFAULTS;
int ret = OK;
ret = metal_init(&params);
if (ret < 0)
{
vrterr("metal_init failed, ret=%d\n", ret);
}
#ifdef CONFIG_DRIVERS_VIRTIO_BLK
ret = virtio_register_blk_driver();
if (ret < 0)