diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index f4103e1521e1c..05470ce6e79ab 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -130,13 +130,13 @@ static void vhost_defered_probe_work(FAR void *arg) { if (item->device->id.device == driver->device) { + item->device->priv = driver; if (driver->probe(item->device) >= 0) { vhosterr("device probe success device=%p\n", item->device); item->driver = driver; + break; } - - break; } } } @@ -207,6 +207,7 @@ int vhost_register_driver(FAR struct vhost_driver *driver) * matched. */ + item->device->priv = driver; if (driver->probe(item->device) >= 0) { item->driver = driver; diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 133c8950d8616..2a77dcbe43d89 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -225,13 +225,14 @@ int virtio_register_driver(FAR struct virtio_driver *driver) FAR struct virtio_device_item_s *item = container_of(node, struct virtio_device_item_s, node); FAR struct virtio_device *device = item->device; - if (driver->device == device->id.device) + if (item->driver == NULL && driver->device == device->id.device) { /* If found the device in the device list, call driver probe, * if probe success, assign item->driver to indicate the device * matched. */ + device->priv = driver; if (driver->probe(device) >= 0) { item->driver = driver; @@ -327,12 +328,12 @@ int virtio_register_device(FAR struct virtio_device *device) * matched. */ + device->priv = driver; if (driver->probe(device) >= 0) { item->driver = driver; + break; } - - break; } }