Skip to content

Commit

Permalink
rpmsg: Release rpmsg devices in backends
Browse files Browse the repository at this point in the history
The rpmsg devices are allocated in the backends and as such must be
freed there as well.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
  • Loading branch information
Bjorn Andersson committed May 17, 2017
1 parent 2ea659a commit b0b03b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/rpmsg/qcom_smd.c
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,14 @@ static const struct rpmsg_endpoint_ops qcom_smd_endpoint_ops = {
.poll = qcom_smd_poll,
};

static void qcom_smd_release_device(struct device *dev)
{
struct rpmsg_device *rpdev = to_rpmsg_device(dev);
struct qcom_smd_device *qsdev = to_smd_device(rpdev);

kfree(qsdev);
}

/*
* Create a smd client device for channel that is being opened.
*/
Expand Down Expand Up @@ -998,6 +1006,7 @@ static int qcom_smd_create_device(struct qcom_smd_channel *channel)

rpdev->dev.of_node = qcom_smd_match_channel(edge->of_node, channel->name);
rpdev->dev.parent = &edge->dev;
rpdev->dev.release = qcom_smd_release_device;

return rpmsg_register_device(rpdev);
}
Expand All @@ -1013,6 +1022,8 @@ static int qcom_smd_create_chrdev(struct qcom_smd_edge *edge)
qsdev->edge = edge;
qsdev->rpdev.ops = &qcom_smd_device_ops;
qsdev->rpdev.dev.parent = &edge->dev;
qsdev->rpdev.dev.release = qcom_smd_release_device;

return rpmsg_chrdev_register_device(&qsdev->rpdev);
}

Expand Down
9 changes: 9 additions & 0 deletions drivers/rpmsg/virtio_rpmsg_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,14 @@ static const struct rpmsg_device_ops virtio_rpmsg_ops = {
.announce_destroy = virtio_rpmsg_announce_destroy,
};

static void virtio_rpmsg_release_device(struct device *dev)
{
struct rpmsg_device *rpdev = to_rpmsg_device(dev);
struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev);

kfree(vch);
}

/*
* create an rpmsg channel using its name and address info.
* this function will be used to create both static and dynamic
Expand Down Expand Up @@ -408,6 +416,7 @@ static struct rpmsg_device *rpmsg_create_channel(struct virtproc_info *vrp,
strncpy(rpdev->id.name, chinfo->name, RPMSG_NAME_SIZE);

rpdev->dev.parent = &vrp->vdev->dev;
rpdev->dev.release = virtio_rpmsg_release_device;
ret = rpmsg_register_device(rpdev);
if (ret)
return NULL;
Expand Down

0 comments on commit b0b03b8

Please sign in to comment.