rsc->vring[idx].notifyid = -1;
}
+static int rproc_vdev_do_probe(struct rproc_subdev *subdev)
+{
+ struct rproc_vdev *rvdev = container_of(subdev, struct rproc_vdev, subdev);
+
+ return rproc_add_virtio_dev(rvdev, rvdev->id);
+}
+
+static void rproc_vdev_do_remove(struct rproc_subdev *subdev)
+{
+ struct rproc_vdev *rvdev = container_of(subdev, struct rproc_vdev, subdev);
+
+ rproc_remove_virtio_dev(rvdev);
+}
+
/**
* rproc_handle_vdev() - handle a vdev fw resource
* @rproc: the remote processor
kref_init(&rvdev->refcount);
+ rvdev->id = rsc->id;
rvdev->rproc = rproc;
/* parse the vrings */
list_add_tail(&rvdev->node, &rproc->rvdevs);
- /* it is now safe to add the virtio device */
- ret = rproc_add_virtio_dev(rvdev, rsc->id);
- if (ret)
- goto remove_rvdev;
+ rproc_add_subdev(rproc, &rvdev->subdev,
+ rproc_vdev_do_probe, rproc_vdev_do_remove);
return 0;
unwind_vring_allocations:
for (i--; i >= 0; i--)
rproc_free_vring(&rvdev->vring[i]);
-remove_rvdev:
- list_del(&rvdev->node);
free_rvdev:
kfree(rvdev);
return ret;
{
struct rproc_vdev *rvdev = container_of(ref, struct rproc_vdev, refcount);
struct rproc_vring *rvring;
+ struct rproc *rproc = rvdev->rproc;
int id;
for (id = 0; id < ARRAY_SIZE(rvdev->vring); id++) {
rproc_free_vring(rvring);
}
+ rproc_remove_subdev(rproc, &rvdev->subdev);
list_del(&rvdev->node);
kfree(rvdev);
}
}
/* clean up remote vdev entries */
- list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node) {
- rproc_remove_virtio_dev(rvdev);
+ list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node)
kref_put(&rvdev->refcount, rproc_vdev_release);
- }
}
/*
*/
int rproc_del(struct rproc *rproc)
{
- struct rproc_vdev *rvdev, *tmp;
-
if (!rproc)
return -EINVAL;
if (rproc->auto_boot)
rproc_shutdown(rproc);
- /* clean up remote vdev entries */
- list_for_each_entry_safe(rvdev, tmp, &rproc->rvdevs, node)
- rproc_remove_virtio_dev(rvdev);
-
/* the rproc is downref'ed as soon as it's removed from the klist */
mutex_lock(&rproc_list_mutex);
list_del(&rproc->node);