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:
parent
db85061b0b
commit
ca22e95577
|
@ -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(¶ms);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
vmdev = kmm_zalloc(sizeof(*vmdev));
|
||||
if (vmdev == NULL)
|
||||
{
|
||||
|
|
|
@ -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(¶ms);
|
||||
if (ret < 0)
|
||||
{
|
||||
vrterr("metal_init failed, ret=%d\n", ret);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DRIVERS_VIRTIO_BLK
|
||||
ret = virtio_register_blk_driver();
|
||||
if (ret < 0)
|
||||
|
|
Loading…
Reference in New Issue